Numerical Methods for Solving ODEs
Ordinary Differential Equations (ODEs):
- Equations which are composed of an unknown function and its derivatives are called differential equations.
- Differential equations play a fundamental role in engineering because many physical phenomena are best formulated mathematically in terms of their rate of change.
For example: the pendulum
- Analytical:
- Numberical:
Use of Taylor series
This lecture is devoted to solving ordinary differential equations of the form
- Suppose that the solution passes through the point
- we attempt, by a step-by-step method, to calculate successively approximate values of
at the points , where is a suitably chosen spacing along the axis - Use the Taylor series representation in the form of function
at point:
setting
where
Example1
- with the initial condition that
at .
- Choose an interval
, - calculate successively the approximate values of
at , and so on:
- At
, with
- At
, with
Euler’s Methods

The first derivative provides a direct estimate of the slope at
where
A new value of

Error Analysis for Euler’s Method
Numerical solutions of ODEs involves two types of error:
- Truncation error
- Local truncation error
- Propagated truncation error
- The sum of the two is the total or global truncation error
- Round-off errors
Improvements of Euler’s method
A fundamental source of error in Euler’s method is that the derivative at the beginning of the interval is assumed to apply across the entire interval.
Two simple modifications are available to circumvent this shortcoming:
- Heun’s Method
- The Midpoint (or Improved Polygon) Method
Heun’s Method
One method to improve the estimate of the slope involves the determination of two derivatives for the interval:
- At the initial point
- At the end point
The two derivatives are then averaged to obtain an improved estimate of the slope for the entire interval.
- Predictor:
- Corrector:


The Midpoint / Improved Polygon Method
Uses Euler’s method to predict a value of
where

Runge-Kutta (RK) Methods
Runge-Kutta methods achieve the accuracy of a Taylor series approach without requiring the calculation of higher derivatives.
’s are recurrence functions. Because each is a functional evaluation, this recurrence makes RK methods efficient for computer calculations. - Various types of RK methods can be devised by employing different number of terms in the increment function as specified by
. - First order RK method with
is in fact the Euler’s method. - Once
is chosen, values of ’s, ’s, and ’s are evaluated by setting general equation equal to terms in a Taylor series expansion.
2nd-Order RK
For
Values of
While for a general case, the Taylor expansion gives
Since
Therefore
On the other hand
Then
Thus
For
- (Midpoint)
:
- (Heun)
:
- (Raltson)
:
- Because we can choose an infinite number of values for
, there are an infinite number of second-order RK methods. - Every version would yield exactly the same results if the solution to ODE were quadratic, linear, or a constant.
- However, they yield different results if the solution is more complicated (typically the case).
- Three of the most commonly used methods are:
- Huen Method with a Single Corrector (
) - The Midpoint Method (
) - Raltson’s Method (
)
- Huen Method with a Single Corrector (

3rd-Order RK
For
Classical 4th-Order RK
For
Butcher’s 5th-Order RK Method

Example2
Solve the following initial-value problem over the interval from
where
(a) The analytical solution can be derived by separation of variables
Substituting the initial conditions yields
The result can be plotted as

(b) Euler's method with
| 0 | 1 | -1.1 |
| 0.5 | 0.45 | -0.3825 |
| 1 | 0.25875 | -0.02588 |
| 1.5 | 0.245813 | 0.282684 |
| 2 | 0.387155 | 1.122749 |
Euler's method with
| 0 | 1 | -1.1 |
| 0.25 | 0.725 | -0.75219 |
| 0.5 | 0.536953 | -0.45641 |
| 0.75 | 0.422851 | -0.22728 |
| 1 | 0.36603 | -0.0366 |
| 1.25 | 0.356879 | 0.165057 |
| 1.5 | 0.398143 | 0.457865 |
| 1.75 | 0.51261 | 1.005997 |
| 2 | 0.764109 | 2.215916 |
(c) For Heun's method, the value of the slope at
The slope at the end of the interval can be computed as
which can be averaged with the initial slope to predict
This formula can then be iterated to yield
| 0 | 0.45 | |
| 1 | 0.629375 | |
| 2 | 0.5912578 | |
| 3 | 0.5993577 | |
| 4 | 0.5976365 |
The remaining steps can be implemented with the result
| 0 | 1.0000000 |
| 0.5 | 0.5976365 |
| 1 | 0.4590875 |
| 1.5 | 0.6269127 |
| 2 | 2.8784358 |
The results along with the analytical solution are displayed below:

(d) The midpoint method with
| 0 | 1 | -1.1 | 0.725 | -0.75219 |
| 0.5 | 0.623906 | -0.53032 | 0.491326 | -0.26409 |
| 1 | 0.491862 | -0.04919 | 0.479566 | 0.221799 |
| 1.5 | 0.602762 | 0.693176 | 0.776056 | 1.52301 |
| 2 | 1.364267 | 3.956374 | 2.35336 | 9.32519 |
with
| 0 | 1 | -1.1 | 0.8625 | -0.93527 |
| 0.25 | 0.766182 | -0.79491 | 0.666817 | -0.63973 |
| 0.5 | 0.60625 | -0.51531 | 0.541836 | -0.38436 |
| 0.75 | 0.510158 | -0.27421 | 0.475882 | -0.15912 |
| 1 | 0.470378 | -0.04704 | 0.464498 | 0.076932 |
| 1.25 | 0.489611 | 0.226445 | 0.517916 | 0.409478 |
| 1.5 | 0.59198 | 0.680777 | 0.677077 | 1.043122 |
| 1.75 | 0.852761 | 1.673543 | 1.061954 | 2.565282 |
| 2 | 1.494081 | 4.332836 | 2.035686 | 6.953139 |

(d) The
| 0 | 1 | -1.1 | 0.725 | -0.75219 | 0.811953 | -0.8424 | 0.578799 | -0.49198 | -0.79686 |
| 0.5 | 0.60157 | -0.51133 | 0.473737 | -0.25463 | 0.537912 | -0.28913 | 0.457006 | -0.0457 | -0.27409 |
| 1 | 0.464524 | -0.04645 | 0.452911 | 0.209471 | 0.516892 | 0.239062 | 0.584055 | 0.671663 | 0.253713 |
| 1.5 | 0.59138 | 0.680087 | 0.761402 | 1.494252 | 0.964943 | 1.893701 | 1.538231 | 4.460869 | 1.986144 |
| 2 | 1.584452 | 4.594911 | 2.73318 | 10.83023 | 4.292008 | 17.00708 | 10.08799 | 51.95317 | 18.70378 |
