Reconstructed boundary
Best-fitting curve in each cell. Click a cell to inspect it.
- Marker points
- Best fit per cell
Cell
Zoomed to the cell's points, with x and y scaled separately. Hover a point to see its residuals.
| Model | Fitted equation | Squared error | cond(A) | cond(AᵀA) |
|---|
⚠ marks a fit where cond(AᵀA) is beyond what double precision can resolve (about 4.5 × 10¹⁵), so its coefficients are unreliable.
How it works
Each model is written as an overdetermined system A·x = b, where every column of
A is a basis function evaluated at the cell's points, and solved with the normal
equations x = (AᵀA)⁻¹Aᵀb.
- Line:
y = mx + q - Parabola:
y = ax² + bx + c - Cubic:
y = ax³ + bx² + cx + d - Rotated parabola:
x = ay² + by + c, the parabola with x and y swapped, which can follow nearly vertical stretches of the boundary
The squared error is the sum of the squared residuals, Σ(b − A·x)². Because
cond(AᵀA) = cond(A)², forming AᵀA squares the conditioning of the
problem. Inside one small cell the x values are close together, so the cubic's columns
1, x, x², x³ are nearly parallel and cond(AᵀA) reaches about
10¹⁷. In cells 48 and 55, the original MATLAB script's inv(AᵀA) produced cubic
errors larger than the parabola's, which is impossible in exact arithmetic since every
parabola is also a cubic. This page solves the normal equations with Gaussian elimination
and partial pivoting, which stays within 0.05% of a stable QR solution for those cells.
The original MATLAB implementation is in the matlab folder of this repository.