- 2068 Magh · 8 marks
Cubic spline and its advantage
Short answer
Cubic spline interpolation fits a piecewise cubic polynomial between each pair of data points, ensuring continuity of the function, slope, and curvature at the joints. Its advantages over polynomial interpolation include avoiding oscillations with many points, local influence of data changes, and suitability for any spacing.
What is Cubic Spline Interpolation? What is the advantage of this method over polynomial interpolation?
Cubic spline interpolation
A cubic spline interpolates n+1 data points (x₀, y₀) … (xₙ, yₙ) by a set of n cubic polynomials Sᵢ(x), one on each sub-interval [xᵢ, xᵢ₊₁], joined smoothly at the knots (the data points).
y
│ ●─── S1 ───●
│ ●╱ ╲● ─ S2 ─ ●
│ S0 ╱
│ ●──╱
└────────────────────────────────── x
x0 x1 x2 x3
one cubic per interval, smoothly joined
Conditions
For i = 0 … n−1, Sᵢ(x) = aᵢ + bᵢ(x − xᵢ) + cᵢ(x − xᵢ)² + dᵢ(x − xᵢ)³ (4n unknowns) must satisfy:
- Interpolation: Sᵢ(xᵢ) = yᵢ and Sᵢ(xᵢ₊₁) = yᵢ₊₁.
- Continuity of slope at interior knots: Sᵢ′(xᵢ₊₁) = Sᵢ₊₁′(xᵢ₊₁).
- Continuity of curvature at interior knots: Sᵢ″(xᵢ₊₁) = Sᵢ₊₁″(xᵢ₊₁).
- Two end conditions. For the natural spline: S″(x₀) = S″(xₙ) = 0.
Working formula
Let Mᵢ = S″(xᵢ) and hᵢ = xᵢ₊₁ − xᵢ. Then
Sᵢ(x) = Mᵢ(xᵢ₊₁ − x)³/(6hᵢ) + Mᵢ₊₁(x − xᵢ)³/(6hᵢ)
+ (yᵢ/hᵢ − Mᵢhᵢ/6)(xᵢ₊₁ − x) + (yᵢ₊₁/hᵢ − Mᵢ₊₁hᵢ/6)(x − xᵢ)
and the Mᵢ come from the tridiagonal system (i = 1 … n−1), with M₀ = Mₙ = 0 for the natural spline:
hᵢ₋₁Mᵢ₋₁ + 2(hᵢ₋₁ + hᵢ)Mᵢ + hᵢMᵢ₊₁ = 6[(yᵢ₊₁ − yᵢ)/hᵢ − (yᵢ − yᵢ₋₁)/hᵢ₋₁]
Steps: find hᵢ, form the system, solve for the Mᵢ, then evaluate the Sᵢ for the interval containing the required x.
Advantages over polynomial interpolation
| Polynomial interpolation | Cubic spline |
|---|---|
| One polynomial of degree n for n+1 points; degree rises with the number of points | Always degree 3, however many points |
| Large oscillations between points for high degree (Runge's phenomenon) | Smooth, stable curve without wild swings |
| Changing one data point changes the whole curve | Local effect: a change mainly affects nearby intervals |
| Error can grow near the ends of the interval | Error is small and uniform, of order h⁴ |
| Only the function values are matched | Slope and curvature are also continuous, so the curve looks smooth |
| Newton's difference formulas need equal spacing (Lagrange's formula does not) | Works directly with unequal spacing |
| Solving a large system or building high-degree terms is ill-conditioned | Tridiagonal system, solved easily and stably |
Hence splines are widely used in curve design, computer graphics and data smoothing.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Natural cubic spline: y(6.5) · Numerical Method, chapter 4 · asked 3×
- Natural cubic spline: y(4.5) · Numerical Method, chapter 4 · asked 3×
- Natural cubic spline: y(0.5) · Numerical Method, chapter 4 · asked 3×
- Natural cubic spline: y(8) · Numerical Method, chapter 4
- Interpolation versus approximation spline · Computer Graphics, chapter 5 · asked 2×
- Uniform cubic B-spline segment points · Computer Aided Design, chapter 3
- Advantage of C++ over C · Object Oriented Programming, chapter 2
- Triaxial advantage over direct shear · Soil Mechanics, chapter 10