Euler's methods

The slope of the secant through $y(t)$ and $y(t+h)$ can be approximated by $y'(t)$, $y'(t+h)$, or, more accurately, the average of the two: $(y'(t)+y'(t+h))/2$. Correspondingly, we have the following three methods:

In summary, here is how the three methods find the increment of function $y(t)$:

$\displaystyle \Delta y
=h\,f'(t+ch) \approx h\,\left\{\begin{array}{ll}
y'(t) & O(h^2) \\ y'(t+h) & O(h^2) \\
(y'(t)+y'(t+h))/2 & O(h^3)
\end{array}\right.$ (203)

which can be implemented iteratively from the known initial condition $y_0=y(0)$

$\displaystyle y_{n+1}=y_n+h\,\left\{\begin{array}{l}
y'_n \\ y'_{n+1} \\ (y'_n+...
...n)\\ f(t_{n+1},y_{n+1})\\
(f(t_n,y_n)+f(t_{n+1},y_{n+1}))/2
\end{array}\right.$ (204)

Example: Consider a simple first order constant coefficient DE:

$\displaystyle y'(t)+\lambda y(t)=0,\;\;\;\;\;$i.e.$\displaystyle \;\;\;\;\;\;
y'(t)=f(t,\,y(t))=-\lambda y(t)$ (205)

with $\lambda>0$ and initial condition $y(0)=y_0$. The closed form solution of this equation is known to be $y(t)=y_0 e^{-\lambda t}$, which decays exponentially to zero when $t\rightarrow \infty$. This DE can be solved numerically by each of the three methods. The results of all three methods are shown together with the ground truth solution $y(t)=y_0 e^{-\lambda t}$ with $y_0=1$ and $\lambda=1$. The four plots correspond to five different step sizes $h=0.5,\;0.83,\;1.67,\;2.0,\;2.2$.

FirstOrderDecay4.png

We make the following observations:

In general there are two different types of approaches to estimate some value in the future, such as the next function value $y_{n+1}=y(t+h)$:

We further consider the Midpoint method which uses the midpoint $y(t+h/2)$ between the two end point $y(t)$ and $y(t+h)$. Consider the Taylor series expansion of $y(t+h)$:

$\displaystyle y(t+h)=y(t)+y'(t)h+\frac{h^2}{2!}y''(t)+\frac{h^3}{3!}y'''(t)+O(h^4)$ (211)

which can be rewritten as the following:

$\displaystyle \frac{y(t+h)-y(t)}{h}=y'(t)+\frac{h}{2}y''(t)+\frac{h^2}{6}y'''(t)+O(h^3)$ (212)

On the other hand, the Taylor series for $y'(t+h/2)$ is:

$\displaystyle y'\left(t+\frac{h}{2}\right)=y'(t)+\frac{h}{2}y''(t)+\frac{h^2}{8}y'''(t)+O(h^3)$ (213)

The difference between these two equations above is:

$\displaystyle \frac{y(t+h)-y(t)}{h}-y'\left(t+\frac{h}{2}\right)=O(h^2)$ (214)

Solving for $y(t+h)$ we get

$\displaystyle y(t+h)=y(t)+h\, y'\left(t+\frac{h}{2}\right)+h\,O(h^2)
=y(t)+h f\left(t+\frac{h}{2},\,y\left(t+\frac{h}{2}\right)\right) +O(h^3)$ (215)

The third order error term $O(h^3)$ is one order higher than that of either Euler's forwar or backward method. This equation can be expressd iteratively:

$\displaystyle y_{n+1}=y_n+h f\left(t_n+\frac{h}{2},\,y\left(t_n+\frac{h}{2}\right)\right)$ (216)

The second argument $y(t_n+h/2)$ of the function on the right-hand side can be approximated by the first two terms of its Taylor expansion:

$\displaystyle y\left(t_n+\frac{h}{2}\right)\approx y(t_n)+\frac{h}{2}y'(t_n)
=y_n+\frac{h}{2}f(t_n,\,y_n)=y_n+\frac{h}{2}f_n$ (217)

Substituting this back into the iteration above we get:

$\displaystyle y_{n+1}=y_n+h f\left(t_n+\frac{h}{2},y_n+\frac{h}{2}f_n\right)
=y_n+h f\left(t_n+\frac{h}{2},\,y_n+\frac{h}{2}k_1 \right)
=y_n+hk_2$ (218)

where

$\displaystyle \left\{ \begin{array}{l}
k_1=f(t_n,\,y_n)=f_n\\
k_2=f(t_n+\frac{h}{2},y_n+\frac{h}{2}k_1)\end{array}\right.$ (219)