Numerical ODEs · Definition
Euler's method
Before you start you need to know
Euler proposed a very simple idea for approximating curves: follow the tangent line over a short interval. That geometric intuition leads to a scheme that can be coded in a few lines.
Definition
Euler's method approximates the solution of an initial value problem \(y'=f(t,y)\), \(y(t_0)=y_0\), advancing in steps of size \(h\) using the slope at the current point.
The method follows from the first-order Taylor expansion \(y(t_{n+1})\approx y(t_n)+h\,y'(t_n)\), and since \(y'(t_n)=f(t_n,y_n)\) we obtain the iterative formula. Its local error is of order \(O(h^2)\), and accumulating over \(N\approx (b-a)/h\) steps gives a global error of order \(O(h)\), so it is a first-order method.
For \(y'=y\), \(y(0)=1\) and \(h=0.1\), the first iteration gives \(y_1=1+0.1\cdot 1=1.1\), while the exact solution at \(t=0.1\) is \(e^{0.1}\approx 1.1052\). The approximation is reasonable, but the error grows with \(h\).
A typical mistake is forgetting that the slope is evaluated at the initial point of the interval and using \(f(t_{n+1},y_{n+1})\) instead, which gives a different implicit method. Another frequent error is taking a step \(h\) that is too large, which can produce oscillations or divergence even when the exact solution is stable.
Think about it
Why is Euler's global error of order one when its local error is of order two?
Because accumulating \(N\approx (b-a)/h\) local errors of size \(O(h^2)\) gives a total of \(O(h)\).
Exercises 10
- For the problem \(y'=2t\), \(y(0)=0\), what is the Euler formula for \(y_{n+1}\)?
- What is the global convergence order of Euler's method?
- For \(y'=y\), \(y(0)=1\), what is the value of \(y_1\) with \(h=0.5\)?
- What is the value of \(f(t,y)\) in the problem \(y'=t+y\)?
- How many steps does Euler need to go from \(t=0\) to \(t=1\) with \(h=0.25\)?
- Apply one Euler step to \(y'=t-y\), \(y(0)=2\), with \(h=0.1\). What is \(y_1\)?
- With \(y'=-2y\), \(y(0)=1\) and \(h=0.1\), what is \(y_2\)?
- For \(y'=t^2\), \(y(1)=0\), with \(h=0.5\), what is \(y_1\) at \(t=1.5\)?
- With \(y'=y\), \(y(0)=1\) and \(h=0.2\), what is the approximation \(y_2\) to \(y(0.4)\)?
- For \(y'=-y+t\), \(y(0)=1\), with \(h=0.5\), compute \(y_2\) and compare with the exact solution \(y(t)=t-1+2e^{-t}\). What is the absolute error at \(t=1\)?
What comes next
References
- Richard L. Burden, J. Douglas Faires, Annette M. Burden, Numerical Analysis, 10th edition, Cengage Learning, 2016.
- Lloyd N. Trefethen, David Bau III, Numerical Linear Algebra, 1st edition, SIAM, 1997.