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]
³¢±ð³Ù'²õÌýgo lookÌýat what you should have gotten...