MTH3007b Lecture 1

Me, in the lecture

zzzzz…

This session opens the module by establishing the core framework for numerically solving ordinary differential equations. We derive the Explicit Euler method from first principles via finite differences, examine its errors, then introduce the Implicit Euler method as a stability-motivated alternative. There is no previous lecture to connect to - this is the starting point.

The Finite Difference Approach

The starting point for all ODE solvers in this module is the Finite differences approach. Rather than working with the derivative as a limit, we approximate it using a discrete grid of time points.

Partition time into steps of size , so . The forward difference approximation to the first derivative at is

This is the foundation of the explicit Euler method.

Explicit Euler Method

Derivation

Starting from and replacing the left-hand side with the forward difference:

Rearranging gives the Explicit Euler method (also called the forward Euler method):

Important

The explicit Euler update rule:

The method is called “explicit” because is expressed directly in terms of known quantities at step - no equation needs to be solved.

Algorithm

The practical implementation stores the full solution array:

Python
Output

Note

int(round(time_end/time_step)) is used rather than bare integer division because floating-point division can produce results like which would truncate incorrectly.

A more general version using a right-hand-side function :

Python
Output

Errors in Explicit Euler

Local Truncation Error

The Local truncation error is the error introduced in a single step, assuming the previous value is exact. Expanding as a Taylor series:

The explicit Euler step uses only the first two terms. The error per step is therefore

Global Truncation Error

The Global truncation error (GTE) accumulates over all steps from to . The number of steps is , so

Important

Explicit Euler is a first-order method: global error . Halving halves the error.

Example: ,

The exact solution is . The explicit Euler step gives , so after steps:

As with fixed, , confirming convergence.

Stability Example: ,

The exact solution decays: . The Euler step gives

The factor is the amplification factor. For stability we need , which requires .

Warning

Explicit Euler applied to is conditionally stable. If the amplification factor exceeds 1 in magnitude and the solution grows without bound - even though the true solution decays.

Implicit Euler Method

Motivation

The instability of explicit Euler for stiff problems motivates using a backward difference instead of a forward difference. Approximating the derivative at :

This is the Implicit Euler method (backward Euler), since appears on both sides and must be solved for.

Example:

Substituting :

The amplification factor is , which is always less than 1 for and any . Backward Euler is therefore unconditionally stable for this equation.

Example: (implicit update)

When , the implicit Euler step rearranges to:

Python
Output

Note that is known before solving - only is the unknown.

Round-Off Errors

Round-off error arises from finite-precision floating-point arithmetic, distinct from the truncation error above.

Warning

Python integers are exact (arbitrary precision), but Python floats follow IEEE 754 double precision: roughly 15-16 significant decimal digits. Accumulating many small floating-point operations introduces round-off that can dominate if is taken too small.

This means there is a practical lower bound on : below some threshold, reducing no longer improves accuracy because round-off error grows faster than truncation error shrinks.


Pre-Lecture Notes from University Notes

  • Finite difference method: replace with (forward difference) to get the explicit Euler update
  • Local truncation error is (one step); global truncation error is (first-order method)
  • Example , : Euler gives - qualitatively correct but first-order convergence
  • Stability of explicit Euler on : amplification factor ; unstable when
  • Implicit (backward) Euler: use backward difference, evaluate at ; requires solving for each step
  • Backward Euler on : , amplification factor always - unconditionally stable
  • Round-off error: floats have ~15 significant digits; taking too small causes round-off to dominate
  • Next session: higher-order Runge-Kutta methods that achieve global error