Taylor Series → Finite Difference Methods → Error Analysis

Prepared for Numerical Methods / CFD lecture — contains derivations, finite-difference stencils, and truncation/discretization error analysis.


Overview

  • Taylor series expansion is the foundation for finite-difference approximations of derivatives.
  • Replace derivatives in a PDE by finite-difference formulas (FDE) to compute approximate solutions.
  • Truncation error arises from neglected higher-order Taylor terms; discretization error is the overall numerical error.

1. Taylor Series (one-dimensional)

Expand \( f(x) \) about \( x_0 \):

Forward:

\( f(x_0+h) = f(x_0) + h f'(x_0) + \dfrac{h^2}{2!} f''(x_0) + \dfrac{h^3}{3!} f^{(3)}(x_0) + \cdots \)

Backward:

\( f(x_0-h) = f(x_0) - h f'(x_0) + \dfrac{h^2}{2!} f''(x_0) - \dfrac{h^3}{3!} f^{(3)}(x_0) + \cdots \)

2. Finite-Difference Approximations (derived from Taylor)

First derivatives

Forward: \( f'(x) \approx \dfrac{f(x+h)-f(x)}{h} \) (error \(O(h)\)).

Backward: \( f'(x) \approx \dfrac{f(x)-f(x-h)}{h} \) (error \(O(h)\)).

Central: \( f'(x) \approx \dfrac{f(x+h)-f(x-h)}{2h} \) (error \(O(h^2)\)).

Second derivatives

Central 3-point:

\( f''(x) \approx \dfrac{f(x+h) - 2f(x) + f(x-h)}{h^2} \) (error \(O(h^2)\)).

3. Extension to Partial Derivatives (2D index notation)

First derivatives (central):

\( \dfrac{\partial u}{\partial x}\bigg|_{i,j} \approx \dfrac{u_{i+1,j} - u_{i-1,j}}{2\Delta x} \)

\( \dfrac{\partial u}{\partial y}\bigg|_{i,j} \approx \dfrac{u_{i,j+1} - u_{i,j-1}}{2\Delta y} \)

Second derivatives:

\( \dfrac{\partial^2 u}{\partial x^2}\bigg|_{i,j} \approx \dfrac{u_{i+1,j} - 2u_{i,j} + u_{i-1,j}}{(\Delta x)^2} \)

\( \dfrac{\partial^2 u}{\partial y^2}\bigg|_{i,j} \approx \dfrac{u_{i,j+1} - 2u_{i,j} + u_{i,j-1}}{(\Delta y)^2} \)

Mixed derivative (central):

\( \dfrac{\partial^2 u}{\partial x\partial y}\bigg|_{i,j} \approx \dfrac{u_{i+1,j+1} - u_{i+1,j-1} - u_{i-1,j+1} + u_{i-1,j-1}}{4\Delta x \Delta y} \)

4. Example: 1D Heat Equation → Explicit FTCS Scheme

PDE (heat equation):

\( \displaystyle \frac{\partial U}{\partial t} = \alpha \frac{\partial^2 U}{\partial x^2} \)

Discretize: use \(t_n, t_{n+1}\) and spatial nodes \(x_i = i\Delta x\).

Time derivative (forward):

\( \dfrac{\partial U}{\partial t}\Big|_{i}^{n} \approx \dfrac{U_i^{\,n+1} - U_i^{\,n}}{\Delta t} \)

Spatial second derivative (central):

\( \dfrac{\partial^2 U}{\partial x^2}\Big|_{i}^{n} \approx \dfrac{U_{i+1}^{\,n} - 2U_{i}^{\,n} + U_{i-1}^{\,n}}{(\Delta x)^2} \)

Substitute into PDE → FTCS form:

\( \dfrac{U_i^{\,n+1} - U_i^{\,n}}{\Delta t} = \alpha \dfrac{U_{i+1}^{\,n} - 2U_{i}^{\,n} + U_{i-1}^{\,n}}{(\Delta x)^2} \)

Solve for future time:

Let \( r = \dfrac{\alpha \Delta t}{(\Delta x)^2} \). Then

\( \displaystyle U_i^{\,n+1} = U_i^{\,n} + r\left(U_{i+1}^{\,n} - 2U_i^{\,n} + U_{i-1}^{\,n}\right) \)

Or equivalently

\( \displaystyle U_i^{\,n+1} = (1-2r)U_i^{\,n} + rU_{i+1}^{\,n} + rU_{i-1}^{\,n} \)

Stability note: Explicit FTCS is conditionally stable. Require \( r \le \dfrac{1}{2} \) to avoid blow-up (i.e. \( \dfrac{\alpha \Delta t}{\Delta x^2} \le \tfrac{1}{2} \)).

5. Truncation Error & Order of Accuracy (FTCS)

Strategy: expand each term in the FDE with Taylor series about \((x_i,t_n)\), substitute and cancel the PDE terms; remaining terms form the truncation error (T.E.).

Taylor expansions (brief):

\( U_i^{\,n+1} = U + \Delta t\, U_t + \dfrac{(\Delta t)^2}{2} U_{tt} + O(\Delta t^3) \)

\( U_{i\pm1}^{\,n} = U \pm \Delta x\, U_x + \dfrac{(\Delta x)^2}{2} U_{xx} \pm \dfrac{(\Delta x)^3}{6} U_{xxx} + \dfrac{(\Delta x)^4}{24} U_{xxxx} + O(\Delta x^5) \)

Compute LHS and RHS expansions and equate:

LHS: \( \dfrac{U_i^{n+1}-U_i^n}{\Delta t} = U_t + \dfrac{\Delta t}{2} U_{tt} + O(\Delta t^2) \)

RHS: \( \alpha\left[ U_{xx} + \dfrac{(\Delta x)^2}{12} U_{xxxx} + O(\Delta x^4)\right] \)

Use PDE relation: \( U_t = \alpha U_{xx} \) and \( U_{tt} = \alpha^2 U_{xxxx} \).

Truncation error (leading terms):

\( \mathrm{T.E.} = -\dfrac{\Delta t}{2} U_{tt} + \alpha \dfrac{(\Delta x)^2}{12} U_{xxxx} + \cdots \)

Using \( U_{tt} = \alpha^2 U_{xxxx} \),

\( \mathrm{T.E.} = \alpha\left(\dfrac{(\Delta x)^2}{12} - \dfrac{\alpha \Delta t}{2}\right) U_{xxxx} + O(\Delta t^2, \Delta x^4) \)

Conclusion (order):

FTCS is first-order in time (O(Δt)) and second-order in space (O(Δx²)). Usually written \(O(\Delta t) + O(\Delta x^2)\).

Because the leading T.E. involves a fourth derivative (even), the scheme mainly introduces dissipative (amplitude-damping) error rather than dispersive (phase) error.

6. Stencils & Visuals

Grid points
Grid points (replace src)
Central stencil
Central difference stencil

7. Quick Reference Table

Derivative FD formula (centered unless noted) Order
\(f'(x)\) forward \( \dfrac{f(x+h)-f(x)}{h} \) \(O(h)\)
\(f'(x)\) central \( \dfrac{f(x+h)-f(x-h)}{2h} \) \(O(h^2)\)
\(f''(x)\) central \( \dfrac{f(x+h)-2f(x)+f(x-h)}{h^2} \) \(O(h^2)\)