Cubic Splines

Numerical Methods

Source inspiration: (Mathew 2000-2019).

Animations

The animation below shows a natural cubic spline fitted to equally-spaced data from \(f(x) = \sin(x)\) on \([0, 2\pi]\), with the number of nodes increasing. The natural spline satisfies \(S''(a) = S''(b) = 0\) at the endpoints.

Julia source scripts that generated these animations are linked under each case.

Case 1 — Natural cubic spline convergence for \(\sin(x)\)

Behavior: Adding nodes shrinks the maximum error rapidly. The natural cubic spline converges at \(O(h^4)\) for smooth functions, where \(h\) is the maximum node spacing. Each frame uses a fully recomputed spline (solving the tridiagonal second-derivative system) for the new set of nodes.

Julia source

Natural cubic spline approximating sin(x) on [0, 2pi] with n=3,4,5,6,7,9 nodes; the spline closely tracks the true curve as nodes increase

Derivation Notes (Planned)

Short derivations will be added to explain the core equations and assumptions.

References

Mathew, John H. 2000-2019. Numerical Analysis - Numerical Methods Modules. https://web.archive.org/web/20190808102217/http://mathfaculty.fullerton.edu/mathews/n2003/NumericalUndergradMod.html.