Next: Using nsys.m Up: Using num3plot.m Previous: Using num3plot.m   Contents

### Example

Use Euler's method to approximate a solution to the ODE . By hand, set up the iterating equation and solve for three iterations using the initial condition and step size . Next investigate both Euler's method and the 4th order Runge-Kutta method graphically using num3plot with the four step sizes . Identify each plot with its respective step size. Explain the rather odd behavior for with when all plots are compared. You may need to calculate a few Euler iterations by hand for these step sizes. (Does this suggest more than one way that step size can affect results?)
1. Iterating equation with

2. Change only the following in initn.m

ftx='2*t*x';
eulerfcn='x+h*(2*t*x)';
hvec=[.5,.25,.1,.01];
t0=-2; tf=2; x0=1;

Save, then type initn to initialize the variables (or copy-and-paste at the Emporium).
3. Type num3plot
4. Here one should investigate and show results such as in Item 4, pp , for eulplot.

For , we have

Each subsequent iteration will also be zero.
For , we have

Each subsequent iteration will also be zero.
5. The finished product is on the next page. (Note: your work in the upper left will be neatly hand written, not typed.) Also be sure to identify which approximation goes with which stepsize from hvec for all three graphs.

Next: Using nsys.m Up: Using num3plot.m Previous: Using num3plot.m   Contents
Michael Renardy
2000-05-12