Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

10.1 Forward Euler method

Integrating the ODE

y(t)=y(t0)+∫t0tf(τ,y(τ))dτy(t) = y(t_0) + \int_{t_0}^t f(\tau, y(\tau)) \ud \tau

We cannot find y(t)y(t) for every tt. Let us take small intervals in tt, say of uniform length hh

t0,t0+h,t0+2h,…t0,t1,t2,…\begin{align*} & t_0, t_0+h, t_0+2h, \ldots \\ & t_0, t_1, t_2, \ldots \end{align*}

i.e.,

tn=t0+nh,n=0,1,2,…t_n = t_0 + n h, \qquad n=0,1,2,\ldots

Then

y(t1)=y(t0)+∫t0t1f(τ,y(τ))dτ≈y(t0)+∫t0t1f(τ,y(t0))dτ=y0+hf(t0,y0)\begin{align*} y(t_1) &= y(t_0) + \int_{t_0}^{t_1} f(\tau, y(\tau)) \ud \tau \\ &\approx y(t_0) + \int_{t_0}^{t_1} f(\tau, y(t_0)) \ud \tau \\ &= y_0 + h f (t_0, y_0) \end{align*}

We obtain the approximation

y1=y0+hf(t0,y0)y_1 = y_0 + h f(t_0, y_0)

This procedure can be continued to produce approximations at t2,t2,…t_2, t_2, \ldots by the following recursive scheme

yn+1=yn+hf(tn,yn),n=0,1,2,…y_{n+1} = y_n + h f(t_n, y_n), \qquad n=0,1,2,\ldots

10.1.1Geometric interpretation

Through the point (t0,y(t0))(t_0, y(t_0)), there is the curve of exact solution and we move along the tangent vector to this curve to reach (t1,y1)(t_1, y_1) where y1=y0+hf0y_1 = y_0 + h f_0.

Now through the point (t1,y1)(t_1, y_1) there is an exact solution curve and we move along the tangent at this point to reach (t2,y2)(t_2, y_2).

This process is continued until we reach the final time.

10.1.2Implementation

The following function implements Euler method.

yn=yn−1+hf(tn−1,yn−1)y_n = y_{n-1} + h f(t_{n-1},y_{n-1})

10.1.3Convergence

We expect that

yn≈y(tn)y_n \approx y(t_n)

and as h→0h \to 0, we expect that the numerical solution converges to the exact solution.

Suppose we are interested in the interval [t0,t0+T][t_0, t_0 + T] We have the numerical approximation

yn=yn,h,n=0,1,2,…,⌊T/h⌋y_n = y_{n,h}, \qquad n=0,1,2,\ldots, \lfloor T/h \rfloor