Euler Method - Using the Method with Mathematica
Numerical Methods for Solving Differential Equations
Euler's Method
Using the Method with Mathematica
(continued from last page...)
Reminder: the euler program that we've taken so long to analyze looks like this:
euler[f_,{x_,x0_,xn_},{y_,y0_},steps_]:=
Block[{ xold=x0,
yold=y0,
sollist={{x0,y0}},
x,y,h
},
h=N[(xn-x0)/steps];
Do[ xnew=xold+h;
ynew=yold+h*(f/.{x->xold,y->yold});
sollist=Append[sollist,{xnew,ynew}];
xold=xnew;
yold=ynew,
steps
];
Return[sollist]
]
Copy the program from here and then switch to Mathematica and Paste and execute it. Return here once you have done this. . .
Your output from this command should have been nothing at all! After all, we didn't actually run the euler program, we simply told Mathematica how it works. Let's now move on and try using it.