M07 · Mathematics alongside
Numerical computation
How a finite update changes an image and why numerical settings need checks. Start with one exact small calculation, then inspect grid smoothing.
Mathematical support for the textbook chapters: start with a small calculation, then an interactive example and precise definitions.
Work through a small example
One diffusion step: both neighbors are 0 and the center is 1. Which weights avoid overshoot?
- Step τ = ¼
- Excessive step τ = ¾
The negative center weight pushed the result outside the neighbors' range. This one-dimensional explicit scheme needs 0≤τ≤½. A two-dimensional unit grid with four neighbors needs 0≤τ≤¼. Stability depends on the scheme and dimension.
Discretization and rounding are different errors
One checkable update: the second difference at the center of [0, 1, 0] is . Smoothing with Δt=0.2 gives a new center value . This is the exact result of one declared discrete operation. It does not prove that the whole grid exactly follows the continuous heat equation.
Discretization replaces a continuous problem with a finite grid; truncation error measures a chosen formula's error under exact arithmetic. Rounding arises from finite numerical representation. A finer grid does not reduce every error: subtracting close values and dividing by a small step can amplify rounding.
A pixel sum approximates an integral only with correct cell-area weights. Rectangle and trapezoid rules have their own smoothness conditions. Pixel values can represent sensor-area integration rather than point samples; follow the declared measurement model.
Problem conditioning and algorithm stability
Conditioning describes how data changes affect the exact solution. Algorithm stability describes whether finite-precision computation corresponds to an appropriately nearby problem or controls errors. A good algorithm cannot make an ill-conditioned inverse problem trustworthy without additional information.
For an invertible matrix, . A tiny smallest singular value lets small noise in a weak direction produce a large solution change. Regularization changes the problem itself by adding a controlled preference.
Diffusion step size is stability-limited
For , an explicit five-point scheme on a square grid is . In two dimensions, gives the usual stability condition for this linear scheme with compatible standard boundaries. Do not transfer it unchecked to other stencils, dimensions or nonlinear diffusion.
An implicit step solves a linear system and can remove this stability restriction, but a large step still gives a coarse time approximation. Stability is not accuracy. Show time or step count and the scheme beside the result.
Each finite update moves a value toward its neighbors. Hold update count fixed and change allowed Δt, then hold Δt fixed and add updates. These are two causes of smoothing, not an exact-versus-approximate solution comparison. The allowed range belongs to this example's stable scheme.
One diffusion step
Neighbor exchange smooths small differences. Compare zero and one iteration before increasing the count.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
At steps no greater than 1/4, the new value is a nonnegative weighted sum of the center and four neighbors. Smoothing cannot distinguish noise from a useful thin line.
- MSE
- 0.001
- RMSE
- 0.0324
- PSNR (range 0–1)
- 29.8018 dB
Parameters and details
Heat: explicit four-neighbor scheme, dt≤0.24, repeated boundaries. TV: ½||u−f||² + λΣ(√(dx²+dy²+ε²)−ε); backtracking enforces nonincreasing energy. This is smoothed convex TV, not Perona–Malik or exact nonsmooth ROF.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
The solver and stopping rule belong to the result
Definitions and details
CG targets symmetric positive-definite systems; a different matrix needs different analysis or a solver. Residual helps monitor the linear solve but does not replace solution-error assessment, especially when conditioning is poor.
For filters, test a constant field, an impulse and a boundary; for iterations, a known minimum and a small reference solve. Comparisons require identical boundaries and value domains. Budget-limited stopping must be labeled as such, not as proven convergence.