How Finite Differences Turn Derivatives and Boundary-Value Problems into Grid Algebra

Published · Updated

3 sources
Save

Finite differences approximate derivatives using function values at nearby grid points. Substituting those approximations into a differential equation gives equations for the unknown grid values. For a linear boundary-value problem, the result is a linear algebra system; the grid spacing, boundary conditions and approximation formula all matter.

What a finite difference is

MathWorld describes the finite difference as the discrete analog of the derivative. The forward difference compares a function value at one point with the value one step ahead, and the backward difference compares it with the value one step behind. When values are tabulated at regular spacing, the notation is built around that spacing, and repeated differencing gives higher-order differences. [2]

The ACME Labs page uses a slightly broader definition: a finite difference for a function f(x) is any expression of the form f(x+s) minus f(x+t). That generality is useful, because different choices of s and t give different approximations to the derivative. [1]

Why centered differences are preferred

The ACME Labs lab sets up a grid of evenly spaced points with spacing h and writes Taylor expansions of u(x+h) and u(x-h) around x. Combining them leads to centered formulas for the first and second derivatives. The lab states that the resulting differences are second-order approximations, so it is reasonable to expect a numerical solution to converge at a rate of about O(h^2). [1]

The Berkeley textbook chapter gives the same two centered formulas explicitly: the first derivative at grid point i is approximated by (y[i+1] - y[i-1]) / (2h), and the second derivative by (y[i-1] - 2y[i] + y[i+1]) / h^2. It notes that centered formulas are commonly used because they yield better accuracy. [3]

y'(x_i) ≈ (y_{i+1} - y_{i-1}) / (2h)</code> and <code>y''(x_i) ≈ (y_{i-1} - 2 y_i + y_{i+1}) / h^2

[3]

From a differential equation to a matrix system

The key move is to enforce the differential equation only at the grid points. ACME Labs frames this as replacing a differential operator defined on an infinite-dimensional function space with finite difference operators on a finite-dimensional space, so that a well-chosen finite algebraic system stands in for the original problem. The Berkeley chapter says the same thing in plainer terms: the derivatives are swapped for finite difference formulas, which yields a system of linear algebraic equations when the differential equation is linear, and nonlinear algebraic equations when it is not. [1], [3]

Boundary conditions become rows of the matrix too. Fixed endpoint values simply appear as equations that pin the first and last unknowns, while each interior row encodes the discretized differential equation at one grid point. [3]

Worked example: the rocket altitude problem

The Berkeley chapter solves the equation d²y/dt² = -g with y(0) = 0 and y(5) = 50, using n = 10 subintervals so that h = 0.5. Each interior grid point gives the equation y[i-1] - 2y[i] + y[i+1] = -g·h². The first and last rows just say y[0] = 0 and y[10] = 50. Together these form an 11-equation system with a tridiagonal-style matrix, solved with standard linear-algebra tools. [3] In this illustrative constant-acceleration model, use g = 9.8 m/s², time in seconds and altitude in metres.

The chapter then recovers the launch velocity y'(0) from the centered first-derivative formula. That formula needs a value at a fictitious point y[-1], which the chapter obtains by applying the second-derivative equation at the first grid point and solving for y[-1]. Its printed result for the launch velocity is 34.5, which the chapter describes as the correct launching velocity. [3]

A harder case: singular perturbation and checking convergence

ACME Labs also considers the boundary-value problem ε u'' - u' = f(x) on (0,1) with fixed endpoint values. It is called singularly perturbed because of where ε sits: at ε = 0 the equation becomes first order and can no longer support two boundary conditions. The lab reports that the solution gets steeper near x = 1 as ε gets small, and suggests a sparse solver for the linear system. [1]

For checking a scheme, the lab explains that an O(h^p) method has error E(h) approximately equal to C·h^p for small h. Computing approximations at a sequence of decreasing step sizes lets you test whether the observed error shrinks at the expected rate. [1]

Beyond derivatives: interpolation and difference equations

MathWorld notes that an n-th power has a constant n-th finite difference, and uses difference tables to fit a polynomial to a short sequence through Newton's forward difference formula. It also notes that finite differences lead to difference equations, the finite analogs of differential equations, and lists named schemes for partial differential equations such as Crank-Nicolson, Du Fort-Frankel and Laasonen. [2]

Check the launch velocity independently

For constant acceleration, y(t) = v₀t − 4.9t² with y(0) = 0. Setting y(5) = 50 gives 5v₀ − 122.5 = 50, hence v₀ = 34.5 m/s. An exact-rational solve of the displayed 11-point difference equations also gives 69/2 m/s with zero algebraic residual. That calculation checks this simplified example; it is not a physical rocket test or evidence that every finite-difference scheme is stable.

Sources

Discuss this answer