MTH3007b Lecture 5

Me, in the lecture

zzzzz…

Lecture 4 formalised stability and convergence, analysed the Richardson method, and extended explicit RK methods to systems of ODEs. This session covers three further topics: computing definite integrals by recasting them as ODEs, reducing higher-order ODEs to first-order systems, and an introduction to partial differential equations including the derivation and implementation of the FTCS scheme for the diffusion equation.

Numerical Integration via ODE

The Core Idea

A definite integral satisfies the ODE

This is an initial value problem: (the right-hand side does not depend on ). Any ODE solver from previous sessions can therefore compute .

Important

This converts numerical integration into a special case of ODE solving. Higher-order ODE methods give higher-order quadrature rules.

Example

Integrate from to . Set , , and apply any ODE solver to obtain .

Higher-Order ODEs

Reduction to First-Order System

A second-order ODE cannot be solved directly by the methods above. The standard technique is to introduce auxiliary variables to reduce it to a first-order system.

Set and . Then:

This is a system of two first-order ODEs in , of exactly the form treated in Lecture 4. See Reducing a Second-Order ODE for the general pattern.

General n-th Order Case

An -th order ODE reduces to a first-order system of equations by introducing for :

All initial conditions become initial conditions for the components .

Introduction to PDEs

Classification

An ordinary differential equation involves derivatives with respect to a single independent variable. A partial differential equation (PDE) involves partial derivatives with respect to two or more independent variables (typically space and time, or multiple spatial coordinates).

The order of a PDE is the order of the highest partial derivative appearing in it.

Side Conditions

Solutions to PDEs require side conditions to be uniquely specified. These fall into two categories:

  • Initial conditions: specify the solution at a starting time (for time-dependent problems)
  • Boundary conditions: specify the solution (or its derivatives) on the spatial boundary of the domain for all time

A problem with both initial and boundary conditions is an initial-boundary value problem.

Types of Boundary Conditions

Important

Three standard types of boundary condition:

  • Dirichlet BC: specifies the value of on the boundary, e.g.
  • Neumann BC: specifies the normal derivative of on the boundary, e.g.
  • Mixed BC: a linear combination of and its normal derivative

The Diffusion (Heat) Equation

Formulation

The Heat equation (diffusion equation) in one spatial dimension is

where is the diffusion coefficient. This is a second-order PDE in and first-order in .

  • Laplace equation: - the steady-state () limit of the diffusion equation; no time dependence
  • Poisson equation: - Laplace equation with a source term

Finite Difference Discretisation

Spatial Grid

Discretise the spatial domain with grid spacing , so for . Similarly discretise time with step .

Second-Derivative Stencil

The centred second-derivative approximation to at interior point (see Finite differences):

FTCS Scheme

FTCS stands for Forward-Time Central-Space. Applying a forward difference in time and the central stencil in space to the diffusion equation:

Defining :

This is explicit in time: the solution at the new time level is computed directly from the current level.

Note

Index convention here: superscript is the time level, subscript is the spatial index. The boundary nodes and are fixed by the Dirichlet BCs and are not updated by the interior formula.

FTCS Python Implementation

Python
Output

Note

The line u_profile = 1.0 * u_next copies u_next into u_profile (multiplying by 1.0 forces a copy rather than a reference assignment). The boundary values are set once on u_profile before the loop and then copied into u_next[0] and u_next[Nx-1] each iteration.


Pre-Lecture Notes from University Notes

  • Integration via ODE: satisfies , - any ODE solver gives the integral
  • Higher-order ODEs: introduce to reduce -th order ODE to first-order system of size
  • PDEs: involve partial derivatives in variables; classified by order of highest derivative
  • Side conditions: initial conditions (time) + boundary conditions (space); Dirichlet (value), Neumann (derivative), or mixed
  • Diffusion equation: ; Laplace = steady state (); Poisson = Laplace + source
  • Second-derivative stencil: (three-point central difference)
  • FTCS scheme: where ; explicit, second-order in space, first-order in time
  • Boundary values fixed by Dirichlet BCs; interior nodes updated by FTCS formula