Euler Method - Using the Method with Mathematica - Part 4
Numerical Methods for Solving Differential Equations
Euler's Method
Using the Method with Mathematica
(continued from last page...)
The result should have been:
MatrixForm[prelimsol1]
If you compare this with the solution that we got by hand in the introduction, you'll see that the results are identical.
You'll probably recall, however, that these results are extremely inaccurate. The exact solution to the problem, at the same set of points, was:
n | xn | yn |
---|---|---|
0 | 0.00 | 0.000000 |
1 | 0.25 | 0.000000 |
2 | 0.50 | 0.062500 |
3 | 0.75 | 0.218750 |
4 | 1.00 | 0.515625 |
Let's focus for now on the last point in this exact solution—(1.00, 1.097264), which is quite different from its numerical solution counterpart of (1.00, 0.515625). Can we get the numerical solution to come out closer to the correct value?
We said earlier that the probable reason for this inaccuracy was that we used such a small number of steps, a mere 4, in finding the solution. However, we're now in a position to become much more ambitious with the number of steps, since the computer will be doing all of the work. To recalculate the solution using 20 steps, issue the command:
prelimsol2=euler[x+2y,{x,0,1},{y,0},20]
followed immediately by:
MatrixForm[prelimsol2]
Let's go look at what you should have gotten...