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:

- any numerical approach is an approximation
- a smaller step size gives better results at the cost of memory and time
- estimating the error by various means including changing the step is part of the result

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.

https://cs.marlboro.college /cours /spring2018 /jims_tutorials /computational_science /mar26

last modified Mon June 24 2024 12:24 am

last modified Mon June 24 2024 12:24 am

last modified | size | ||

eulers_method.html |
Mon Jun 24 2024 12:24 am | 491K | |

eulers_method.ipynb |
Mon Jun 24 2024 12:24 am | 222K | |

eulers_method_jim.html |
Mon Jun 24 2024 12:24 am | 481K | |

eulers_method_jim.ipynb |
Mon Jun 24 2024 12:24 am | 211K |