CalcWorldHub
Free online calculator · no signup

Cubic spline and shape preserving interpolation calculator

Interpolate tabulated measurements with a local cubic curve and compare smoothness with shape preservation.

4,000 tools
Cubic spline and shape preserving interpolation calculator — Strictly increasing sample x values, Matching sample y values, Query x coordinate and calculation method
Cubic spline and shape preserving interpolation calculator: inputs and calculation method.

How to use this calculator

Interpolate tabulated measurements with a local cubic curve and compare smoothness with shape preservation.

  1. Enter Strictly increasing sample x values, Matching sample y values, Query x coordinate, Local cubic model. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Cubic spline and shape preserving interpolation explained

Enter paired samples with strictly increasing x values, choose natural spline or PCHIP, and request an x coordinate inside the sampled interval. Both methods interpolate through the supplied points, while their endpoint and shape constraints differ.

Interpolated value2.2y units
Interpolated value: 2.2 y units in the worked scenario.

Inputs, symbols, and units

x — Strictly increasing sample x values
Strictly increasing sample x values. Use comma-separated values in the stated order.
y — Matching sample y values
Matching sample y values. Use comma-separated values in the stated order.
z — Query x coordinate
Query x coordinate.
m — Local cubic model
Local cubic model. Choose natural, pchip.

Formula and method

Piecewise cubic interpolation with natural or PCHIP derivatives

Natural mode solves a tridiagonal system for knot second derivatives, with zero curvature at both endpoints. PCHIP instead constructs limited endpoint and weighted harmonic interior slopes, then evaluates a Hermite cubic in the containing interval. Both pass through every supplied sample.

A worked scenario

Strictly increasing sample x values = 0, 1, 2, 3; Matching sample y values = 0, 1, 4, 9; Query x coordinate = 1.5; Local cubic model = natural.

  • Interpolated value: 2.2 y units

Assumptions and edge cases

No extrapolation. Natural splines set endpoint second derivatives to zero; PCHIP preserves monotonicity between monotone data but has only first-derivative continuity.

Frequently asked questions

Which mode avoids overshooting monotone samples?

PCHIP is designed for that purpose.

Is natural spline the same as not-a-knot?

No, their endpoint conditions differ.

Are duplicate x values allowed?

No, each x must be strictly larger than the previous one.

How do I use the Cubic spline and shape preserving interpolation calculator?

Enter Strictly increasing sample x values, Matching sample y values, Query x coordinate, Local cubic model. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Cubic spline and shape preserving interpolation?

Strictly increasing sample x values = 0, 1, 2, 3; Matching sample y values = 0, 1, 4, 9; Query x coordinate = 1.5; Local cubic model = natural. Interpolated value: 2.2 y units