Cubic spline interpolation is a refined mathematical tool frequently used within numerical analysis. It's an approximation technique that employs piecewise cubic polynomials, collectively forming a cubic spline. These cubic polynomials are specifically engineered to pass through a defined set of data points, hence striking a balance between overly simple (like linear) and overly intricate (like high-degree polynomial) interpolations.
Conceptual Illustration:
Imagine you have a set of points on a 2D plane. A cubic spline will "thread" through these points, forming a smooth curve that does not exhibit sudden bends or wiggles:
The spline is constructed from piecewise cubic segments that meet at the data points with continuous first and second derivatives, ensuring a visually natural and mathematically smooth interpolation.
We start with a set of
with
A cubic spline is a function
where
Key Requirements:
I. Interpolation Condition:
Each segment must pass through the given data points:
II. Continuity of the Spline:
The function
III. Continuity of First Derivative:
The first derivatives of adjacent segments must match:
IV. Continuity of Second Derivative:
Similarly, the second derivatives must also be continuous:
V. Boundary Conditions:
For a natural cubic spline, the second derivatives at the boundaries are set to zero:
These conditions lead to a system of linear equations that determine the coefficients
I. Divided Differences and Step Sizes:
Let the spacing between consecutive points be:
II. Formulation in Terms of Second Derivatives:
Let
$$S_i(x) = M_{i}\frac{(x_{i+1}-x)^3}{6h_i} + M_{i+1}\frac{(x - x_i)^3}{6h_i}
-
\left(y_i - \frac{M_i h_i^2}{6}\right)\frac{x_{i+1}-x}{h_i}
-
\left(y_{i+1} - \frac{M_{i+1}h_i^2}{6}\right)\frac{x - x_i}{h_i}.$$
This form ensures the correct boundary conditions and continuity of derivatives once
III. System of Equations for
Using the conditions for continuity of first and second derivatives, one obtains a tridiagonal system of equations in terms of the unknown second derivatives
The remaining
IV. Once
can be computed directly:
I. Data Preparation:
- Sort the data points
$(x_i,y_i)$ in ascending order by$x_i$ . - Compute
$h_i = x_{i+1}-x_i$ for$i=0,\ldots,n-1$ .
II. Form the Equations:
Set up the linear system to solve for the second derivatives
For
III. Solve the Tridiagonal System:
Use an efficient method (like the Thomas algorithm) to solve for
IV. Calculate the Coefficients:
With
as described above.
V. Interpolation:
For a given
Consider three points:
-
$h_0 = 1, h_1=1$ . - Boundary conditions:
$M_0=M_2=0$ .
We form the equation for
Since
Then:
And similarly for
This gives piecewise polynomials smoothly interpolating the given points.
- Splines ensure smoothness by producing curves with continuous first and second derivatives, leading to a natural and visually appealing fit.
- The method provides controlled behavior, avoiding the large oscillations often observed in high-degree polynomial interpolation.
- Local control means that changing a single data point only impacts the neighboring spline segments, rather than the entire curve.
- The method involves complexity, as it requires setting up and solving a linear system of equations, making it more complicated than simpler interpolation techniques.
- Computational cost is higher than methods like linear interpolation, particularly for large datasets with many control points.
- Boundary conditions must be specified (e.g., natural, clamped) to define the behavior at the endpoints, which can influence the overall fit of the spline.