[Math] How to test if your cubic spline natural boundary interpolate correctly

numerical methodsspline

If I have constructed a cubic spline, how can you tell if your spline did the approximation correctly ? In my thinking, I will use my cubic spline to interpolate a 3rd degree polynomial function f3, because interpolating polynomial is unique , then it the spline and f3 must agree with each other ? Is that correct ?

Best Answer

The spline is correct if it satisfies the given constraints. So, you can check that the spline interpolates the given data points, that it's $C_2$ continuous at each knot, and that it has zero second derivatives at its start and end.

You can also check that the spline reproduces cubic polynomials, as you suggest. Construct any cubic polynomial $f$ with $f''=0$ at its end-points. Calculate some values of this cubic polynomial, and use these values to construct a cubic spline, $s$. The two functions $f$ and $s$ are both solutions to the same spline interpolation problem, whose solution is known to be unique. So $f$ and $s$ must be equal, if $f$ is correct.