Math Calculators

← All calculators

Cubic Spline Interpolation Calculator

Fit natural, clamped or not-a-knot splines to your points, with derivatives and the full coefficient table.

Your points and end condition

Duplicate x values are not allowed and points must be in increasing x order. Invalid input is rejected before any calculation, and your points are never silently reordered or merged.

Everything is calculated in your browser.

Your spline answer first: the value, the first derivative and the second derivative at your point

This cubic spline interpolation calculator fits a cubic spline to your points with the end condition you select, natural, clamped with your two end slopes, or not-a-knot, then evaluates the spline at your chosen x with its first and second derivatives and prints the full per-segment coefficient table.

Enter your points, select natural, clamped or not-a-knot, and enter a value of x, and this calculator returns the spline value there with its first and second derivatives, plus the full coefficient table. On the worked example loaded when the page opens, the points (0,0), (1,1) and (2,0) at x = 0.5 give 0.6875 natural, 0.5 clamped with end slopes 0 and 0, and 0.75 not-a-knot.

Spline value S(x)

-

First derivative S'(x)

-

Second derivative S''(x)

-

Segment used

-

End condition applied

-

Segmentxiabcd

Steps, shown in full

    By Waqar Ghouri, founder of CalcMega

    Cubic spline interpolation is a way of drawing a smooth curve through a set of points by fitting a separate cubic polynomial to each interval between neighbouring points, joined so the value, slope and curvature agree at every interior point.

    For the points (0,0), (1,1) and (2,0) at x = 0.5, the answer depends on the end condition: 0.6875 natural, 0.5 clamped with end slopes 0 and 0, and 0.75 not-a-knot. The table below gives those three answers beside the four-point check and the two-point reduction, so the effect of the end condition is visible in the numbers themselves.

    PointsxEnd conditionS(x)
    (0,0), (1,1), (2,0)0.5Natural0.6875
    (0,0), (1,1), (2,0)0.5Clamped, slopes 0 and 00.5
    (0,0), (1,1), (2,0)0.5Not-a-knot0.75
    (0,0), (1,1), (2,0), (3,1)1.5Natural0.5
    (0,0), (1,1), (2,0), (3,1)1.5Clamped, slopes 1 and -10.416667
    (0,0), (1,1), (2,0), (3,1)1.5Not-a-knot0.5
    (0,0), (1,1), (2,0), (3,1)2.5Natural0.25
    (0,0), (1,1), (2,0), (3,1)2.5Clamped, slopes 1 and -10.666667
    (0,0), (1,1), (2,0), (3,1)2.5Not-a-knot0.0
    (0,0), (2,4)0.5Natural or not-a-knot, straight line1
    (0,0), (2,4)0.5Clamped, slopes 0 and 0, single cubic0.625

    This calculator is the first web calculator in the observed field offering selectable natural, clamped and not-a-knot end conditions with the full segment coefficient table.

    Worked example: one point set gives 0.6875 natural, 0.5 clamped and 0.75 not-a-knot at x = 0.5

    The points loaded when the page opens are (0,0), (1,1) and (2,0): a rise to a peak and a fall back down, symmetric around x = 1. At the halfway point of the first rise, x = 0.5, the three end conditions give three visibly different answers. The natural spline gives 0.6875, with a first derivative of 1.125 and a second derivative of -1.5 at that point. Clamp both end slopes to 0 and the value drops to 0.5, because a curve that must leave the first point flat and arrive at the last point flat bulges less on the way up. Choose not-a-knot and the value rises to 0.75, because with only three points the not-a-knot spline is the single parabola 2x - x squared through all three points. Same points, same evaluation point, three different curves. Any tool that picks one condition for you without saying so is answering a question you did not ask.

    Four point check: natural gives 0.5 and 0.25, clamped gives 0.416667 and 0.666667, not-a-knot gives 0.5 and 0.0

    Add a fourth point, (3,1), and evaluate at the two interior midpoints. At x = 1.5 the natural spline gives 0.5 and at x = 2.5 it gives 0.25. The clamped spline with end slopes 1 and -1 gives 0.416667 at x = 1.5 and 0.666667 at x = 2.5: forcing the curve to leave the first point rising at slope 1 and to arrive at the last point falling at slope -1 reshapes the whole middle, not just the ends. Not-a-knot gives 0.5 at x = 1.5 and exactly 0.0 at x = 2.5. These are the numbers to check by hand if you want to convince yourself the selector is really switching conditions and not just relabelling one curve.

    What is cubic spline interpolation?

    Cubic spline interpolation fits a separate cubic polynomial to each interval between data points, joined so the value, first derivative and second derivative agree at every interior point, with two end conditions closing the system. The same between-the-points reading turns up in concrete work, where an intermediate value is read off a strength–maturity curve built from measured points, the relationship the Concrete Maturity Calculator is based on.

    One single polynomial through many points wiggles badly, swinging above and below the data between the points. A spline avoids that by keeping the degree low on every interval: each stretch between two neighbouring points gets its own cubic, and the cubics are stitched together so smoothly that you cannot see the joins. At every interior point the two neighbouring pieces agree on the height, on the slope and on the curvature. That is the whole trick, and it is why spline curves look like a draughtsman's flexible strip settling through the points, which is where the name came from.

    Counting unknowns shows why the two extra conditions are unavoidable. Each cubic carries four coefficients, and matching values, slopes and curvatures at the interior joins uses up all but two of the free numbers. Something has to decide those last two, and that something is the end condition: a statement about how the curve behaves at the very first and very last point, where it has no neighbour to agree with.

    What do natural, clamped and not-a-knot end conditions mean?

    This calculator computes cubic spline interpolation with selectable end conditions, natural, clamped and not-a-knot, and prints the full per-segment coefficient table.

    A natural spline sets the second derivative to zero at both ends, so the curve straightens out as it leaves the data. It is the common default because it needs no extra information from you, but default is all it is: nothing about your data says the curvature must vanish at the ends. A clamped spline instead fixes the first derivative at each end to a slope you supply, which is the right choice when you know how the curve should leave the first point and arrive at the last one, from a measurement, a physical constraint or a design tangent. A not-a-knot spline asks for no end information at all and instead makes the third derivative continuous at the first and last interior points, which merges the first two segments into one cubic and the last two into one cubic.

    Clamped needs two end slopes: with slopes 0 and 0 the seed spline at x = 0.5 is 0.5, not 0.6875

    The clamped option is the one that changes the seed example most plainly. Slopes of 0 at both ends mean the curve leaves (0,0) horizontally and arrives at (2,0) horizontally. It still has to pass through the peak at (1,1), so it climbs later and more steeply in the middle of the first interval, and at x = 0.5 it has only reached 0.5, with a slope there of 1.5 and no curvature at all at that point. If an assignment or a specification hands you end slopes, a natural-only answer of 0.6875 is simply the wrong number, off by more than a third of the value itself.

    How is a cubic spline calculated?

    The standard construction solves for the second derivative at every point first. Call those values M0 up to the last point. On each interval the second derivative varies linearly between its two end values, and integrating twice gives the segment cubic, with the two integration constants fixed by the requirement that the segment passes through its two end points. Requiring the first derivative to match at every interior point produces one equation per interior point, and those equations link each second derivative only to its two neighbours, so the whole system is tridiagonal and solves in a single sweep of elimination.

    The end conditions supply the first and last equations of that system. Natural contributes the two plain statements that the end second derivatives are zero. Clamped contributes two equations tying the end second derivatives to your two end slopes. Not-a-knot contributes two equations tying the first three and the last three second derivatives together through the interval widths. Swap those two rows and the same machinery returns a different spline, which is exactly what the selector above does.

    Once the second derivatives are known, each segment is written in the form S(x) = a + b(x - xi) + c(x - xi)^2 + d(x - xi)^3, where xi is the left point of the segment, a is the value at that point, c is half the second derivative there, and b and d follow from the interval width and the two end second derivatives. The coefficient table above prints all four numbers for every segment, so you can evaluate the spline by hand anywhere: find the segment containing your x, subtract the left point, and work through the four terms. Evaluating the spline also gives its first derivative, b + 2c(x - xi) + 3d(x - xi)^2, and its second derivative, 2c + 6d(x - xi), at the same point, and the result block prints both beside the value.

    Two input rules are enforced before any of this runs. Every x value must be unique, because a spline needs exactly one y for each x, so duplicate x values are rejected with the reason stated. And the points must be entered in increasing x order, so the page never silently rearranges your data. With only two points the general construction has nothing to join, and the page states which reduction it uses for the condition you picked: a straight line under natural and not-a-knot, and under clamped the single cubic fixed by the two points and the two end slopes.

    What this calculator does not cover

    This calculator does not extrapolate. If you enter an x outside the range of your points, the page rejects it and says why. It does not extend the curve past the ends. Interpolation also settles workshop questions, such as a tap-drill size that falls between two chart entries, which is the sort of lookup the Drill Size Converter covers.

    It offers the three end conditions above and nothing else. There is no Akima mode, no PCHIP mode and no least-squares smoothing mode: every curve here passes exactly through every point you enter, so noisy data will show up as wiggles in the curve. Nothing here smooths the data away.

    With only two points there is a single interval, so the general construction has nothing to join: natural and not-a-knot give the straight line through the points, and clamped gives the single cubic fixed by the two points and the two end slopes. Duplicate x values are rejected, because one x cannot carry two y values on a single curve.

    The page also draws no plot. The coefficient table is the record of the curve, and it is what you use to check any value by hand.

    Cubic Spline Interpolation Calculator FAQs

    What is cubic spline interpolation?

    Cubic spline interpolation fits a separate cubic polynomial to each interval between your data points. The pieces are joined so that the value, the first derivative and the second derivative agree at every interior point, which makes the curve smooth, and two end conditions at the first and last points close the system so the spline is unique.

    What is the difference between natural, clamped and not-a-knot end conditions?

    A natural spline sets the second derivative to zero at both ends. A clamped spline sets the first derivative at each end to a slope you specify. A not-a-knot spline makes the third derivative continuous at the first and last interior points, so the first two segments are a single cubic and the last two segments are a single cubic. The three conditions give different curves through the same points.

    What does the worked example on this page give?

    For the points (0,0), (1,1) and (2,0) at x = 0.5, the natural spline gives 0.6875 with a first derivative of 1.125 and a second derivative of -1.5. The clamped spline with end slopes 0 and 0 gives 0.5, and the not-a-knot spline gives 0.75. Every general calculator returns only the natural value, 0.6875.

    What happens if I enter two points with the same x value?

    The input is rejected before any calculation. A spline needs a unique y for each x, so duplicate x values are not allowed. The rule is stated on the page with the point entry, not after a failed calculation.

    What happens with only two points?

    The answer depends on the end condition, and the page states which reduction it uses. Under not-a-knot, two points give the straight line through them. Under clamped, two points with two end slopes give the single cubic fixed by those four conditions. Neither case falls back silently to the natural spline.

    What does the coefficient table show?

    One row per segment, giving the four coefficients of that segment in the form S(x) = a + b(x - xi) + c(x - xi)^2 + d(x - xi)^3, where xi is the left point of the segment. With the table you can evaluate the spline by hand at any x inside that segment and check the value the tool prints.

    Sources: NIST DLMF section 3.3 and the classical tridiagonal spline construction

    The interpolation framework follows the NIST Digital Library of Mathematical Functions, section 3.3, which sets out piecewise polynomial interpolation and the spline construction used here. The tridiagonal system for the second derivatives, and the natural, clamped and not-a-knot ways of closing it, are the classical textbook construction for cubic splines.

    Every figure in the worked examples on this page was computed from the point sets printed beside it, under the end condition named with it. No search volume, cost per click, keyword difficulty or authority score is stated anywhere on this page, because none was measured.

    Calibration tables are the everyday home of interpolation: a refractometer reading corrected for temperature comes off exactly this kind of curve, and the Brix & Hydrometer Scale Converter applies the table to Brix, Plato, specific gravity and Baumé.

    Sources last verified 15 November 2026. Last verified 15 November 2026.

    Related calculators

    📈
    Breusch-Godfrey and White Test Calculator

    Breusch-Godfrey and White LM tests from pasted residuals and regressors.

    ➗
    GCD & LCM Calculator

    Greatest common divisor and least common multiple — Euclid's steps shown, exact at any size.

    📊
    Statistics Calculator

    Mean, median, mode, variance, standard deviation and quartiles for any data set.

    📊
    Cramér's V and Phi Coefficient Calculator

    Cramer V, phi and Bergsma bias corrected V from a contingency table.

    🔁
    Fixed-Point Iteration Calculator

    Fixed point iteration with Aitken delta squared acceleration beside raw iterates.

    🔢
    Sign Test Calculator

    Exact sign test for a median with a distribution free confidence interval.

    ⭕
    Annulus Calculator

    Area of a ring from any two values, with true unit conversion and ring weight.

    📂
    All Math Calculators

    Browse every calculator in this category.