Cubic Spline — Definition, Formula & Examples
A cubic spline is a piecewise function made of cubic polynomials that passes through a set of data points, with the pieces joined so that the overall curve is smooth (continuous first and second derivatives) at every junction.
Given data points with , a cubic spline consists of cubic polynomials on each subinterval , satisfying interpolation conditions , continuity of , , and at each interior knot, plus two boundary conditions (commonly for a natural spline).
Key Formula
Where:
- = Value of the spline at knot $x_i$, so $a_i = y_i$
- = First-derivative coefficient on interval $[x_i, x_{i+1}]$
- = Second-derivative coefficient (related to $S''(x_i)/2$)
- = Third-derivative coefficient on the interval
How It Works
You start with a table of data points (called knots). On each interval between consecutive knots, you define a separate cubic polynomial. Then you enforce that adjacent polynomials agree in value, first derivative, and second derivative at shared knots. This gives you a system of linear equations. Solving the system (typically for the second-derivative coefficients first) yields all the polynomial coefficients. The result is a single smooth curve that passes exactly through every data point without the wild oscillations that a single high-degree polynomial can produce.
Worked Example
Problem: Construct the natural cubic spline through the three points , , .
Set up: There are two subintervals: and , so two cubic pieces and . Each interval has width . The natural boundary conditions give and .
Solve for interior second derivative: The standard tridiagonal equation for the single interior knot () is . Substituting , , :
Compute remaining coefficients: For on : , , and . For on : , , and .
Answer: The natural cubic spline is on and on .
Why It Matters
Cubic splines are the standard interpolation tool in computer-aided design (CAD), computer graphics, and data fitting because they produce visually smooth curves without oscillation. In numerical analysis and engineering courses, understanding splines prepares you for finite element methods and signal processing.
Common Mistakes
Mistake: Forgetting that you need boundary conditions to determine a unique spline.
Correction: With data points there are unknown coefficients but only equations from interpolation and smoothness. The two extra boundary conditions (e.g., natural: at endpoints) close the system.
