Skip to content
Calcrivo

Spline Interpolation Calculator

Interpolate between data points using natural cubic splines and evaluate at a given x.

Inputs

At least 3 distinct x values in ascending order.

Corresponding y values.

S(x)

6.23214286

Segment used

[2, 3] (segment 3 of 4)

Step by step

  1. Values used

    x values (comma-separated) = 0, 1, 2, 3, 4; y values (comma-separated) = 0, 1, 4, 9, 16; Evaluate at x = 2.50

  2. Cubic spline on segment i

    Sᵢ(x) = aᵢ + bᵢ(x-xᵢ) + cᵢ(x-xᵢ)² + dᵢ(x-xᵢ)³

  3. S(x)

    = 6.23214286

  4. Segment used

    = [2, 3] (segment 3 of 4)

How it works

Natural cubic spline interpolation fits a piecewise cubic polynomial through the data points with continuous first and second derivatives (C² smoothness). The 'natural' boundary condition sets the second derivative to zero at both endpoints. This avoids the oscillation problems of high-degree polynomial interpolation while giving a smooth curve.

Formula

Cubic spline on segment i

Sᵢ(x) = aᵢ + bᵢ(x-xᵢ) + cᵢ(x-xᵢ)² + dᵢ(x-xᵢ)³

aᵢ
yᵢ (interpolation condition)
bᵢ
First derivative coefficient
cᵢ
Second derivative / 2
dᵢ
Third derivative / 6

Frequently Asked Questions

Why use splines instead of a single polynomial?

A single high-degree polynomial can oscillate wildly (Runge's phenomenon). Cubic splines use low-degree pieces that join smoothly, avoiding this problem.

What are natural boundary conditions?

Natural splines set S''(x₀) = S''(xₙ) = 0, meaning the curve is straight (zero curvature) at the endpoints. Other options include clamped (specified slopes) or not-a-knot conditions.

You might also need