Finite Difference Methods
A computer can't take derivatives, so it swaps them for differences between nearby grid points. For the heat equation that means nudging each point toward its neighbors' average, which works only if each nudge is small enough: . Push past that and the numbers blow up.
What the symbols mean
- Grid spacing
The distance between neighboring points.
What the symbols mean
- Grid value
Temperature at grid point i after n time steps.
- Mesh ratio
Stability requires r ≤ 1/2.
Explanation
A finite difference method is simply a way to make a computer solve a PDE: chop the rod into evenly spaced points, and at each tick of the clock, let every point's temperature drift a little toward its neighbors. It's called "finite" because the gaps and stay a fixed, nonzero size instead of shrinking to zero the way they do inside a derivative. It's good for exactly the problems separation of variables can't handle: odd shapes, materials that vary from place to place, real engineering. The update rule looks busy, but it's just three parts: (the temperature at point right now), (how far the point is from the average of its two neighbors) and (how big a step you take toward that average). The only catch is that can't be too big, or you overshoot. That's the whole method; bear with the subscripts.
The scheme. Where does that update come from? A derivative is a limit of differences, so just don't take the limit. Replace by and by the second difference, the formula above, which is the difference of two first differences. Solve for and you get the explicit scheme. Rearranged, it's : each new value is a weighted average of the point and its neighbors, which is exactly what heat does.
Stability. Think about the worst case: a wiggle that alternates sign from point to point. Each point's neighbors are both on the other side, so the update pulls it hard toward zero. In fact it's multiplied by each step. If that factor is below , so the pull overshoots: the wiggle grows and flips every step until the numbers explode. With , every weight and is nonnegative, so every new value is a true average, and errors stay bounded.
The cost. : halving the grid spacing forces four times as many time steps. Implicit schemes like Crank–Nicolson are stable for any , at the price of solving a linear system each step.
A common mistake. It's tempting to think a finer grid is always safer, since smaller means a more accurate second difference. It isn't, not on its own. Shrinking while keeping the same makes bigger, and can push a perfectly good simulation past into blow-up. Refine the grid and you have to shrink the time step with it.
Other equations. For waves the condition is (the CFL condition: information can't skip a grid cell per step). For Laplace's equation, repeatedly replacing each value by the average of its four neighbors converges to the solution.
See it
Worked examples
, . What is the largest stable time step?
- 1
With and , the mesh ratio is , and stability needs .
Practice
Type your answer and check it. Solve them all to complete the lesson.
, , . Find .
Is that scheme stable?
, . Find the largest stable .
With , a point at temperature 1 has neighbors at 0. Find its value after one step.
Halving forces the stable to be divided by:
You simulate heat in a 1 m rod with m²/s on a grid with m (100 intervals). What's the largest time step the explicit scheme can use and stay stable, in seconds?
Approximate for with the central difference .
The hardest one here. Get it, and you've got this lesson.
Run two steps of on three interior points starting at , with the boundary values held at 0. What is the middle value after two steps with , and with ? Enter both.
Where it's used
Weather prediction, crash simulations, chip design and visual effects all run grid-based PDE solvers; stability limits like these decide how long the simulations take.