Hello, I would like to write a function that has a loop in it which preforms the operations necessary for Euler's method. Below it my poor attempt.
In[15]:= Euler[icx_,icy_,h_,b_,diffeq_] :=
curx;
cury;
n=0;
curx = icx;
cury = icy;
While
[curx != b,
Print["" + n + " | " + curx + cury];
n++;
dq = StringReplace[diffeq, "y[x]" -> curx];
dq = StringReplace[dq, "x" -> cury];
curx+=h;
cury=cury+h*dq;
]
In[21]:= Euler[0, 0, .1, 1, e^-y[x]]
Out[21]= icx