Euler
Very nice.
Sources?
Where is this going - are you going to continue with Runge-Kutta?
I would point out that the large errors in your first analysis are from my point of view not only because of the truncation error but also because you are using a ridiculously large step of h=0.1. This is not small.
If you set for example h=0.0001 then the error becomes too small to see on plot.
The whole point of these approaches on modern computing systems is that it is relatively fast easy to do a large number of steps. And the first and simplest approach to checking your accuracy is to make the step size smaller to see if your result changes. Comparing h=0.01 to h=0.1 gives different answers; therefore, h=0.1 is not appropriate.
Part of the game here is to decide how much error is acceptable, which will inform how small the step can be.
Fancier numeric techniques - like Runge-Kutta - will give better accuracy for a given step size, at a cost of more analysis and (probably) more intermediate calculations. But they won't change these underlying ideas:
Minor gripe: should be "plt.show()", not "plt.show".
Not quite so minor gripe: your plot of (h vs error) doesn't to my eyes show clearly what you say that it shows. Check out my modified version.
Some of the LaTeX didn't display correctly in your .html file. I don't think it's your LaTeX, since it did display fine in the "jupyter nbconvert" that I did.
last modified | size | ||
eulers_method.html | Sat Nov 23 2024 10:11 pm | 491K | |
eulers_method.ipynb | Sat Nov 23 2024 10:11 pm | 222K | |
eulers_method_jim.html | Sat Nov 23 2024 10:11 pm | 481K | |
eulers_method_jim.ipynb | Sat Nov 23 2024 10:11 pm | 211K |