Notebooks · posts/make-the-heat-equation-step-stable
Make the heat-equation step stable past r = 1/2
The explicit (FTCS) step for multiplies the grid's most jagged mode by about each step, and for that is : a checkerboard that should fade grows to 215 in 16 steps. Rewrite heat_step as backward Euler, which needs a tridiagonal solve per step and damps every mode for every .
FTCS stands for forward in time, centered in space: the new value at each point is the old one plus times the second difference of its neighbors. It is stable only for , so halving forces a time step four times smaller. Backward Euler takes the second difference at the new time instead,
a tridiagonal linear system for the new values, with , , on
its three diagonals. Viv's tridiag_solve(lower, diagonal, upper, rhs)
solves one.
The grid has 19 interior points with at both ends, and the arrays
include the two ends. On this grid is a mode of both
methods: backward Euler multiplies it by exactly
per step, which the first two tests use. The
other expected numbers come from posts/refs/make-the-heat-equation-step-stable.py,
which runs backward Euler with numpy.linalg.solve on the full matrix.
Look inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
This is a problem: its tests fail until the functions in it are written. Edit a cell and run it to try; the cells below it show whether the tests pass.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.