Numerical Solution of PDEs: Finite Differences Intro
The finite difference method is a numerical technique for solving partial differential equations (PDEs) by replacing derivatives with differences between nearby grid values. PDEs describe how quantities change in both space and time, and most cannot be solved exactly.
This matters because heat flow, fluid motion, electric fields and wave propagation are all governed by PDEs. Finite differences turn these continuous problems into systems of algebraic equations that computers can solve step by step, forming the basis of many engineering simulations.
Key Concepts
- Grid (mesh): the domain is covered with evenly spaced points: xᵢ = i·Δx, tₙ = n·Δt.
- Forward difference: (f(xᵢ₊₁) − f(xᵢ))/Δx, first-order accurate.
- Central difference: (f(xᵢ₊₁) − f(xᵢ−₁))/(2Δx), second-order accurate for first derivatives; the second derivative is (f(xᵢ₊₁) − 2f(xᵢ) + f(xᵢ−₁))/Δx².
- Explicit scheme: future values computed directly from known ones; simple but can become unstable.
- Implicit scheme: future values solved from equations; more stable but needs a linear solver.
How It Works
- Choose the PDE, for example the heat equation ∂u/∂t = α ∂²u/∂x².
- Cover the rod with grid points spaced Δx apart and choose time steps Δt.
- Replace ∂u/∂t with (uᵢⁿ⁺¹ − uᵢⁿ)/Δt and ∂²u/∂x² with the central second-difference stencil.
- This gives the explicit update: uᵢⁿ⁺¹ = uᵢⁿ + r(uᵢ₊₁ⁿ − 2uᵢⁿ + uᵢ−₁ⁿ), where r = αΔt/Δx².
- Start from the initial temperatures and step forward in time.
The explicit heat scheme is stable only if r ≤ 1/2; violating this produces wild, growing oscillations instead of physics.
Worked Example
Heat equation with α = 1, rod of 4 interior points, Δx = 1, Δt = 0.4 (so r = 0.4), initial u = [0, 100, 100, 100, 0] including fixed ends. One step for interior point 1:
- u₁ⁿew = 100 + 0.4·(u₂ − 2u₁ + u₀) = 100 + 0.4·(100 − 200 + 0) = 100 − 40 = 60
- u₂ⁿew = 100 + 0.4·(100 − 200 + 100) = 100
- u₃ⁿew = 100 + 0.4·(0 − 200 + 100) = 100 − 40 = 60
After one step the profile is [0, 60, 100, 60, 0]: heat flows from the hot interior toward the cold ends, exactly as expected.
Common Misconceptions
- "Any Δt works if the equations are right." Explicit schemes blow up unless stability limits like r ≤ 1/2 are respected.
- "Finer grids only change accuracy." Refinement also changes stability requirements and computing cost sharply.
- "Finite differences give exact answers." They give approximations whose error shrinks with the grid spacing.
Real-World Applications
- Semiconductor designers simulate heat dissipation in chips with finite difference heat models.
- Weather models discretise the atmosphere's governing PDEs on giant grids.
- Options pricing (Black–Scholes PDE) is often solved numerically on finite difference grids.
Finite differences convert differential equations into grid arithmetic by approximating derivatives with nearby value differences. The method is simple and powerful, but its accuracy and stability always depend on careful choice of grid spacing and time step.
Related blogs
- Floating Point Arithmetic and Error Analysis: Notes and FAQs
- Truncation and Round-Off Errors: Numerical Error Basics
- Bisection Method: Explained with Examples, Notes and FAQs
- Fixed Point Iteration: Concepts, Formulas and Examples
- Newton-Raphson Method Explained: Root Finding Made Simple
- Secant and Regula Falsi Methods: Root Finding Guide