Processed online by Toolvito
Interpolation & Curve Fitting Calculator
Paste data points to interpolate between them (or extrapolate beyond them) by straight lines, the interpolating polynomial in Lagrange or Newton form, or a cubic spline; interpolate in a two-way table such as a steam table; or fit a straight line, a polynomial or another curve by least squares.
How to use it
- Choose a task: Interpolation, Double interpolation (table) or Curve fitting.
- Paste the points, one x, y pair per line (a header row is allowed), or choose a CSV file. For a table, put the x values in the first row and each y value at the start of its row.
- Type the x values to interpolate at, such as 2.5, 3.7, or the values to predict at. Select Calculate.
- Read the formula, the values and the checks; download the worked solution and the graph.
Interpolation methods
- Linear: a straight line between the two neighbouring points, y = y₁ + (x − x₁)(y₂ − y₁)/(x₂ − x₁); outside the data the end line is extended (linear extrapolation, marked as less reliable). Logarithmic: straight lines in ln x.
- Lagrange and Newton’s divided differences give the same polynomial of degree n − 1 through n points, in two forms; the divided-difference table is shown. Newton’s forward differences use the difference table for equally spaced x.
- Cubic splines join cubic pieces so that the curve, its slope and its curvature are continuous: natural (no curvature at the ends), clamped (given end slopes) or not-a-knot. Every piece is written out with exact fractions. A quadratic spline joins parabolas with continuous slopes (the first piece is a straight line, as in the textbook method). PCHIP never overshoots between points (for data that only rises or falls).
- A polynomial through many points can swing widely between them (Runge’s phenomenon); a spline is often the better choice.
Double interpolation and curve fitting
- Bilinear (double) interpolation in a table interpolates along x in the two rows around the point, then along y between them, with every step shown. A bicubic spline is offered for tables of at least 4 × 4.
- Curve fitting finds the curve that makes the sum of squared residuals smallest: a straight line or a polynomial (normal equations solved exactly), an exponential, power, logarithmic, sinusoidal, logistic or Gaussian curve, or your own model with parameters, such as a e^(-b x) + c. R², RMSE and the residuals show how well it fits.
- An exponential or power curve can also be fitted on the logarithms of y (as many calculators do); that line is not the same as the least-squares fit of y itself, and the page says which one it is.
How the answers are checked
An interpolating polynomial is put back at every point with exact fractions and compared with NumPy’s polyfit; splines are compared with SciPy’s CubicSpline at 97 points and their pieces are checked for continuity; bilinear interpolation is repeated in the other order and with SciPy. Fits are compared with NumPy’s lstsq or SciPy’s curve_fit, and the slope of the sum of squares at the answer must be close to 0.