Cubic Splines for Interpolating Functions
Recall from the Natural Cubic Spline Function Interpolation page that if $(x_1, y_1)$, $(x_2, y_2)$, …, $(x_n, y_n)$ are points in $\mathbb{R}^2$ such that $x_1 < x_2 < ... < x_n$, then we can construct a natural cubic spline for this data set on the interval $[x_1, x_n]$ of piecewise smooth cubic polynomials [$s(x)$. For each subinterval $[x_{j-1}, x_j]$ for $j = 2, 3, ..., n$ we define:
(1)The values of the $M$'s are obtained by solving the following system of equations:
(2)Now instead, suppose that instead the data points $(x_1, y_1)$, $(x_2, y_2)$, …, $(x_n, y_n)$ are obtained in attempting to approximation a function $y = f(x)$. Then we will also want our cubic spline to be an accurate representation of $f$ on the interval $[x_1, x_n]$. Since these data points are on $f$, then we can impose another condition to improve the accuracy of the cubic spline.
Provided that the first and second derivatives of $f$ is known, then we can also require that the endpoints of our cubic spline satisfies:
(3)We can use the same formula for each $s(x)$ on each subinterval $[x_{j-1}, j_n]$, $j = 2, 3, ..., n$ from above, but now, we require that the $M$'s satisfy:
(4)