PadhaikoAll subjects

Solution of Ordinary Differential Equations (ODE)

Numerical Methods (ENSH 252)

Open in the Padhaiko app

5.1 Initial value problems

An initial value problem (IVP) for a first-order ordinary differential equation specifies the derivative and the state at a single starting point :

Numerical methods advance the solution across discrete mesh points with step size , producing approximations .

5.1.1 Solution of first order equations: Taylor’s series method, Euler’s method, Runge-Kutta methods (Second and fourth order)

Taylor's Series Method

Expanding around (or ) by Taylor's theorem gives:

where , and higher derivatives are obtained by repeatedly differentiating via the chain rule:

Euler's Method

Truncating the Taylor series after the linear term produces Euler's method (the simplest -stage, first-order Runge–Kutta method):

Definition

Euler's Method

Runge–Kutta Methods (Second and Fourth Order)

Runge–Kutta (RK) methods match the accuracy of higher-order Taylor expansions without computing analytical derivatives, by evaluating at carefully weighted intermediate points inside .

Definition

Second-Order (Heun's) and Fourth-Order Runge–Kutta Formulas

  1. Second-Order Runge–Kutta (RK2 / Heun's Method, global error):

(Equivalently, the RK2 midpoint variant uses and .)

  1. Classical Fourth-Order Runge–Kutta (RK4, global error):
Comparison of First-Order IVP Solvers
MethodFunction Evaluations / StepLocal ErrorGlobal ErrorKey Trade-off
EulerSimple, requires very small
RK2 (Heun)Predictor–corrector slope average
RK4Industry standard for smooth non-stiff ODEs
Taylor (-th) (+ derivatives)Needs symbolic partial derivatives

5.1.2 Solution of system of first order ODEs via Runge-Kutta methods

Consider a coupled system of two first-order ODEs:

In vector RK4, both and are advanced simultaneously at each sub-stage ( increments , and increments ):

Definition

RK4 for a System of Two First-Order ODEs

(Crucial rule: compute both and at stage before computing and .)

5.1.3 Solution of second order ODEs via Runge-Kutta methods

Any second-order IVP

is reduced to a system of two first-order ODEs by introducing the auxiliary variable :

with initial conditions and . This system is then solved directly using the coupled RK2 or RK4 formulas above. (Similarly, an -th order ODE converts into a system of first-order ODEs.)


5.2 Two-point boundary value problems

In a two-point boundary value problem (BVP) over , conditions on (or ) are prescribed at both endpoints rather than at a single initial point:

5.2.1 Shooting method

The shooting method converts the BVP into an IVP by guessing the missing initial slope , integrating forward from to with Euler or Runge–Kutta, and adjusting until the computed endpoint value hits the target (i.e., finding a root of ).

Definition

Shooting Method for Linear and Non-Linear BVPs

  1. For a linear BVP (): Choose two trial slopes and , integrate the IVP twice to obtain and . By linearity, one linear interpolation gives the exact required initial slope:

Re-integrate once with to obtain the full solution.

  1. For a non-linear BVP: is non-linear in ; apply a root-finding method such as the Secant method (or Bisection / Newton) iteratively on until .

5.2.2 Finite difference method

The finite difference method discretizes the entire domain simultaneously on a uniform grid (, ), replacing derivatives at each interior node () with central finite differences of accuracy:

Substituting these into a linear ODE with and produces a tridiagonal system of linear algebraic equations for the interior values :

Solving this linear system yields all nodal values at once without guessing initial slopes.

AspectShooting MethodFinite Difference Method
Core IdeaConverts BVP to IVP by guessing and solving Replaces derivatives with difference quotients at interior grid points
Algebraic ProblemRepeated IVP integration + root-finding on Single linear (or non-linear) algebraic system in
Stability / SensitivitySensitive if the IVP has rapidly growing exponential modesGlobally stable and naturally handles stiff linear BVPs

Worked Out Examples

Example 5.1

5.1

Given with , compute using:

  1. Euler's method with step size ( steps)
  2. Fourth-order Runge–Kutta (RK4) method with ( step)

Compare with the exact solution .

Computing by Euler's method (): Using :

  • First step ():
  • Second step ():

Computing by RK4 (): With , :

Combining the four slopes:

Answer:

Compared with the exact value :

  • Euler (): (error )
  • RK4 (): (error )
Example 5.2

5.2

Using the fourth-order Runge–Kutta (RK4) method with , find and for the second-order initial value problem:

Converting to a system of two first-order ODEs: Let . Then:

with , and .

Evaluating the four coupled RK4 stages:

  • Stage 1:
  • Stage 2 (at ):
  • Stage 3 (at ):
  • Stage 4 (at ):

Updating and :

Answer:

By RK4 with , and (exact ).

Example 5.3

5.3

Solve the two-point boundary value problem

using the finite difference method with step size .

Discretizing the domain with : The grid nodes are , with boundary values and . Replacing by the central difference :

Forming the tridiagonal system:

  • For (, ):
  • For ():
  • For (, ):

In matrix form:

Solving by Gauss elimination: Eliminating from row ():

Eliminating from row ():

Back-substituting for and :

Answer:

The finite difference approximations at the interior nodes are , , and (exact values from : ).


Exercises

Exercise — Solution of Ordinary Differential Equations (ODE)

Question 1

Distinguish between an initial value problem (IVP) and a two-point boundary value problem (BVP). Explain how the shooting method solves a non-linear second-order BVP with .

Distinguishing IVPs and BVPs:

  • In an IVP, all auxiliary conditions () are given at a single starting point , so single-step solvers (Euler, Taylor, RK2, RK4) can march forward step by step from .
  • In a BVP, conditions are split across two boundary points and (e.g., and ), so we do not have enough information at alone to start an IVP integrator.

Shooting method for a non-linear BVP:

  1. Rewrite as the first-order system , with and an unknown initial slope .
  2. Pick two initial slope guesses and , integrate the IVP from to using RK4 (or RK2) to obtain endpoint residuals and .
  3. Because the ODE is non-linear, is non-linear in ; update iteratively using the Secant method:

until .

Answer:

An IVP specifies all conditions at one point , whereas a BVP specifies conditions at two endpoints and . For a non-linear BVP, the shooting method guesses the missing slope , integrates the resulting IVP to , and iterates with a root-finder (such as the Secant method) until .

Question 2

Use Taylor's series method (up to the term) to approximate and for the IVP:

Computing derivatives at :

Writing the Taylor polynomial and evaluating at and :

  • At :
  • At :
Answer:

Using the th-degree Taylor series, and .

Question 3

Solve with to find using the second-order Runge–Kutta (Heun's) method with step size .

First step ():

Second step ():

Answer:

Using Heun's RK2 method with , and .

Question 4

Solve the system of coupled first-order ODEs

with to find and using the fourth-order Runge–Kutta (RK4) method with .

Computing the four simultaneous RK4 stages ():

  • Stage 1:
  • Stage 2 (at ):
  • Stage 3 (at ):
  • Stage 4 (at ):

Updating and :

Answer:

By RK4 with , and (exact ).

Question 5

Solve the linear two-point boundary value problem

by the shooting method, using Heun's (RK2) method with and initial slope guesses and . Estimate .

Converting to a first-order system and shooting with : Let , with and . For :

  • First interval ():
  • Second interval ():

Shooting with and interpolating the exact initial slope: Since the equation is linear and homogeneous with , doubling doubles every value:

Integrating one step () with :

(And the second step yields .)

Answer:

The required initial slope is , giving (exact ).

← Numerical Differentiation and IntegrationSolution of Partial Differential Equations →