Module1: Numerical Solution of Ordinary Differential Equations
Module1: Numerical Solution of Ordinary Differential Equations
Module1: Numerical Solution of Ordinary Differential Equations
Lecture 2
Keywords: Numerical solution, grid points, local truncation error, rounding error
Numerical Solution
Numerical methods for solving ordinary differential equations are more popular due to
several reasons:
More computational efforts are involved in Picard and Taylor series methods for
complex real life applications
The numerical methods can still be applied in cases where the closed form
expression for the function is not available, but the values of function f are known
at finitely many discrete points. The analytical methods are not applicable.
For example, the velocity of a particle is measured at given points and one is interested
to predict the position of particle at some times in future. In such cases the analytical
methods cannot be applied and one has to obtain solution by numerical methods.
In this lecture a very basic method known as Euler method is being discussed. The
method is illustrated with an example.
Euler method:
When initial value problem (1.2) is solved numerically, the numeric values of the
solution y=g(t) are obtained at finitely many (say n) discrete points in the interval of
interest. Let these n points be equi-spaced in the interval [t0, b] as t1,t 2 ,...,t n such that
t 0 kh, k 1,2,...n . These points are known as grid points. Here the step size h is
b t0
computed as h . The numeric value of the solution is known at t=t0. The
n
approximate numeric value yk of the solution at kth grid point t=tk is an approximation to
the exact solution y(tk) of IVP. The Euler method specifies the formula for computing the
solution:
y k 1 y k h f(t k , y k ); k 0,1,2,...n 1 (1.5)
y(t)
y2
y1
y0 t
t1 t2 tn‐1 tn
The Euler formula (1.5) is a one step difference formula. The solution obtained by this
formula is shown on the computational grid in figure 1.1.
Observe that f(t, y 0 ); y(t 0 ) y 0 is the slope of the solution curve at t=t0. The solution is
approximated as a straight line passing through y (t0) = y0 having slope f(t0, y(t0)). The
actual solution y(t) (shown in blue) may not be a straight line and y(t1) may be different
than y1 computed by the formula (1.5). It is only an approximation to the exact solution.
Starting from this approximation y1 at t1, the solution at next grid point t2 can be
approximated as y2 using (1.5). This is further continued for other grid points.
The actual solution curve may be above/ below the approximated solution.
Accordingly, the algorithm for computing solution using Euler method is given below:
Example 1.3: Solve the initial value problem using the above algorithm
3y t y; y(0) 1
The IVP is solved first for step size h=1. The solution is obtained at t=1, 2 and 3.
The computations are performed using MS-Excel diff-euler1.xls [See columns B and C.
The column D gives the truncation error.] Note that the equation can be solved exactly.
Its exact solution is y(t) 4 exp( t / 3) t 3 , y(3.0)=1.471518.
Next, the same problem is solved with step size h=0.5 up to t=3. The solution is
obtained successively at t=0.5, 1.0, 1.5, 2.0, 2.5, 3.0. [See columns E and F of the same
MS-Excel sheet. The column G gives the error.]
Comparing y computed at t=3.0 by two different step sizes, it is observed that solution
with smaller step size is closer to exact solution.
The computations are repeated with step size h=0.25 and 0.125 also. [See the excel
sheet columns H to M. The column O of the sheet gives exact solution at grid points
with h=0.125].
The table 1.1 shows the application of Euler Method for h=0.125. The attached graph
shows that the difference between the exact solution and the solution obtained by Euler
method with h=0.125. The following conclusions can be drawn:
For the derivation of Euler formula, consider the finite difference approximation of the
derivative
dy y yk
k 1
dx t t h
k
f(t,y(t)) f(tk , yk )
y k 1 y k h f(t k , y k )
When k=0, the right side of the formula can be computed from known initial value y0.
Once y1 is computed, other yk, k=2, 3, 4,… can be computed successively in the similar
manner.
Analysis :
h2
y(t k h) y(t k ) h y(t k ) y( ), (t k ,t k h)
2
Substituting the derivative from the differential equation and neglecting second order
terms of the Taylor theorem gives Euler formula which is an approximation of the
solution at next grid point:
Starting from the initial condition at t0, the approximate solution y1 at t1 computed by
Euler method has error due to following reasons:
solution and approximate solution as obtained by the numerical method assuming the
solution is exact at kth step.
Tk 1 y t k h y k 1
h2
Tk 1 y(t k ) h y (t k ) y ( ) [y k h f(t k , y k )]
2
h2
Tk 1 y(t k ) y k h[f(t k , y(t k )) f(t k , y k )] y ( )
2
h2
Tk 1 (1 hL) Tk M
2
For y1, the initial condition y0 is assumed to be the correct solution; hence the local
truncation error is of order h2.
However, the solution at t2 has one more source of error and that is approximate value
of the solution y1 at t1 as computed in earlier step. This error is further accumulated as
solution is advanced to more grid points tk, k=3, 4,… . The accumulation of error is
evident from the fig. 1.1 also. The Final Global Error (F.G.E) in computing the final value
at the end of the interval (a,b); a= t0, b=to+Mh is accumulated error in M steps and is of
order h. This means that the error E(y(b),h) in computing y(b) using step size h is
approximated as
E( y(B), h) Ch
Accordingly, E( y (B), h / 2) Ch / 2
Therefore, halving the step size will half the FGE. FGE gives an estimate of
computational effort required to obtain an approximation to exact solution.
Mh
1 hL 1
k 1
Tk 1
2L
Mh (k 1)hL
Tk 1 e 1
2L
Apart from the Euler method, there are numerous numerical methods for solving IVP. In
the next couple of lectures more methods are discussed. These are not exhaustive. The
selection of methods is based on the fact that these are generally used by scientists and
engineers in solving IVP because of their simplicity. Also, more complex techniques are
the combination of one or more of these and their development is on similar lines.