---
title: "Cubic spline and its advantage"
subject: "Numerical Method"
chapter: 4
key: "semester_4/numerical_method:cubic-spline-advantage"
source: https://www.bctengineer.com/q/semester_4/numerical_method/cubic-spline-advantage
site: BCT Engineering
---

# Cubic spline and its advantage

Numerical Method · Chapter 4: Interpolation

- Asked in: 2068 Magh, 8 marks
- Video: [Cubic Spline Interpolation Theory | Numerical Methods](https://www.youtube.com/watch?v=pBtqaK0PzrA) — StudySession
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/numerical_method/cubic-spline-advantage
- Whole chapter: https://www.bctengineer.com/md/semester_4/numerical_method/chapter-4

## Question

What is Cubic Spline Interpolation? What is the advantage of this method over polynomial interpolation?

## 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.

## Answer

#### 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).

```text
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:

1. Interpolation: Sᵢ(xᵢ) = yᵢ and Sᵢ(xᵢ₊₁) = yᵢ₊₁.
2. Continuity of slope at interior knots: Sᵢ′(xᵢ₊₁) = Sᵢ₊₁′(xᵢ₊₁).
3. Continuity of curvature at interior knots: Sᵢ″(xᵢ₊₁) = Sᵢ₊₁″(xᵢ₊₁).
4. Two end conditions. For the **natural spline**: S″(x₀) = S″(xₙ) = 0.

#### Working formula

Let Mᵢ = S″(xᵢ) and hᵢ = xᵢ₊₁ − xᵢ. Then

```text
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:

```text
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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is a cubic spline?
   A. A linear fit
   B. One cubic through all points
   C. A set of cubics, one per interval, joined smoothly at knots
   D. A cubic for the whole table
   Answer: C. Piecewise cubic. (Key point: Definition)

2. Which continuities are required at interior knots?
   A. Value, first and second derivative
   B. Value only
   C. Third derivative
   D. None
   Answer: A. S, S' and S'' are continuous. (Key point: Continuity)

3. What is a key advantage over high-degree polynomials?
   A. Higher degree
   B. Passes outside points
   C. Avoids large oscillations (Runge's phenomenon)
   D. Needs fewer points
   Answer: C. Degree stays 3. (Key point: Advantage)

4. How does changing one data point affect a spline?
   A. Nothing
   B. Whole curve
   C. Only the ends
   D. Mainly nearby intervals
   Answer: D. Local effect, unlike a global polynomial. (Key point: Locality)

## Related in Numerical Method

- [Natural cubic spline: y(6.5)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aspline-5-7-9-11) — Numerical Method, chapter 4, asked 3×
- [Natural cubic spline: y(4.5)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aspline-4-5) — Numerical Method, chapter 4, asked 3×
- [Natural cubic spline: y(0.5)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aspline-y-0-5) — Numerical Method, chapter 4, asked 3×
- [Natural cubic spline: y(8)](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Aspline-find-y-8) — Numerical Method, chapter 4

## Related in other subjects

- [Interpolation versus approximation spline](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Ainterpolation-vs-approximation-spline) — Computer Graphics, chapter 5, asked 2×
- [Uniform cubic B-spline segment points](https://www.bctengineer.com/question.md?key=semester_4%2Fcomputer_aided_design%3Auniform-cubic-bspline-numerical) — Computer Aided Design, chapter 3
- [Advantage of C++ over C](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Acpp-advantage-over-c) — Object Oriented Programming, chapter 2
- [Triaxial advantage over direct shear](https://www.bctengineer.com/question.md?key=semester_4%2Fsoil_mechanics%3Atriaxial-advantages-over-direct-shear) — Soil Mechanics, chapter 10
