Polynomial Interpolation Explained with a Worked Example

Polynomial interpolation finds the single polynomial that passes exactly through a set of data points. With n + 1 points (all with different x values) there is exactly one polynomial of degree n or less that hits all of them. Two points give a straight line, three give a parabola, four give a cubic, and so on.

To build the polynomial from your own points, try the Lagrange interpolation calculator, which shows the working step by step.

Linear interpolation, the method behind our interpolation calculator, is the degree 1 case. This guide covers what changes when you use more points: how to find the polynomial, how accurate it is, and why adding more points can make things worse.

The idea in one line

Given points (x0, y0), (x1, y1), …, (xn, yn), find coefficients c0, c1, …, cn so that

p(x) = c0 + c1 x + c2 x² + … + cn xⁿ

satisfies p(xi) = yi for every point. Then use p(x) to estimate y at any x in the range.

There are three standard ways to get the same polynomial:

Method How it works Best for
Vandermonde system Solve a linear system for the coefficients Understanding, small hand problems
Lagrange form Weighted sum of basis polynomials Formulas and proofs
Newton divided differences Build the polynomial one point at a time Adding points, hand calculation from tables

All three give the identical polynomial, because it is unique. This article uses the Vandermonde method. The Lagrange and Newton articles show the other two.

Worked example: a parabola through three points

Find the polynomial through (1, 6), (2, 11) and (4, 27), then estimate y at x = 3.

Three points means degree 2: p(x) = c0 + c1 x + c2 x².

Step 1: write one equation per point

  • x = 1: c0 + c1(1) + c2(1) = 6
  • x = 2: c0 + c1(2) + c2(4) = 11
  • x = 4: c0 + c1(4) + c2(16) = 27

In matrix form this is V c = y, where V is the Vandermonde matrix:

c0 c1 c2 = y
x = 1 1 1 1 6
x = 2 1 2 4 11
x = 4 1 4 16 27

Step 2: solve the system

Subtract the first equation from the second: c1 + 3c2 = 5. Subtract the second from the third: 2c1 + 12c2 = 16, so c1 + 6c2 = 8. Subtract those two results: 3c2 = 3, so c2 = 1. Then c1 = 5 − 3(1) = 2, and c0 = 6 − 2 − 1 = 3.

So p(x) = x² + 2x + 3.

Check: p(1) = 6, p(2) = 4 + 4 + 3 = 11, p(4) = 16 + 8 + 3 = 27. All three points match.

Step 3: estimate

p(3) = 9 + 6 + 3 = 18.

A straight line through only the two nearest points, (2, 11) and (4, 27), would give 19. The parabola uses the curvature that all three points show, so it lands lower.

Check it with the calculator The linear value is easy to confirm on the linear interpolation calculator: enter X1 = 2, Y1 = 11, X2 = 4, Y2 = 27, X3 = 3 and leave Y3 empty. It returns 19.00. The 1 unit gap between 19 and 18 is the correction the quadratic term adds.

How accurate is polynomial interpolation?

If the data comes from a smooth function f, the error at x is

f(x) − p(x) = f⁽ⁿ⁺¹⁾(ξ) / (n + 1)! × (x − x0)(x − x1)…(x − xn)

for some ξ somewhere in the range of the points. Two things drive the error:

  1. How wiggly the function is, measured by its (n + 1)th derivative.
  2. Where x sits relative to the points, through the product (x − x0)…(x − xn). That product is small near the middle of the points and large near the ends and beyond them.

Error example: estimating ln 3

Use the points x = 1, 2, 4 with y = ln x (0, 0.693147, 1.386294) and fit a quadratic. Solving the same kind of system gives

p(x) = −0.924196 + 1.039721 x − 0.115525 x²

so p(3) = 1.155245, while the true ln 3 = 1.098612. The actual error is 0.056633.

The error formula predicts this range. For f(x) = ln x, the third derivative is 2/x³, which is between 2/64 and 2 on [1, 4]. The product (3 − 1)(3 − 2)(3 − 4) has absolute value 2. So the error must lie between (2/64)/6 × 2 ≈ 0.0104 and 2/6 × 2 ≈ 0.667. The real error, 0.0566, sits inside that range.

For comparison, a straight line between (2, ln 2) and (4, ln 4) gives 1.039721 at x = 3, which is off by 0.058892 in the other direction. Here the quadratic is only slightly better, because ln x curves hard near x = 1, the extra point the quadratic uses.

The Runge phenomenon: more points is not always better

It seems natural that a higher-degree polynomial through more points would be more accurate. For evenly spaced points, the opposite is often true.

The classic test is f(x) = 1 / (1 + 25x²) on [−1, 1]. Here is the largest error of the interpolating polynomial over the whole interval:

Points Evenly spaced points Chebyshev points
5 (degree 4) 0.438 0.402
11 (degree 10) 1.916 0.109
21 (degree 20) 59.82 0.015

With 11 evenly spaced points, the polynomial gives 1.924 at x = 0.95, where the true value is 0.042. The curve swings wildly between the points near the ends of the interval. Adding points makes the swings bigger, not smaller. Wolfram MathWorld has plots of the effect.

Two fixes:

  • Chebyshev points. Cluster the x values near the ends (xk = cos((2k + 1)π / 2n)). The error then shrinks as you add points, as the right column shows. This only helps if you can choose where to sample.
  • Piecewise methods. Use low-degree pieces between neighbouring points instead of one big polynomial. A cubic spline is the usual choice. Plain piecewise linear interpolation also avoids the problem.

Choosing the degree in practice

  • Tables (steam, finance, statistics). Linear interpolation between the two nearest rows is standard. If the table is coarse and clearly curved, use a quadratic through the three nearest rows, not every row in the table. See how to interpolate steam tables.
  • Smooth measured data. A spline usually beats one global polynomial.
  • Noisy data. Do not interpolate. A polynomial through every noisy point reproduces the noise. Fit a low-degree curve by least squares instead.
  • Numerical work. Avoid solving large Vandermonde systems directly. With 11 evenly spaced points on [−1, 1], the Vandermonde matrix already has a condition number of about 14,000, and it grows fast with more points. Use the Newton or barycentric Lagrange forms. The NIST Digital Library of Mathematical Functions lists the standard formulas.

FAQ

How many points do I need for a polynomial of degree n? n + 1 points with distinct x values. They determine the polynomial uniquely.

Is Lagrange interpolation different from polynomial interpolation? No. Lagrange interpolation is one way of writing the interpolating polynomial. Newton’s form and the Vandermonde solution give the same polynomial.

Can polynomial interpolation extrapolate? It can produce numbers outside the range, but they are unreliable, because the error product grows quickly beyond the data. See linear extrapolation for safer approaches.

When should I use linear instead of polynomial interpolation? When the points are close together, the data is noisy, or you only need a quick table reading. For most tables, linear interpolation between neighbours is accurate enough and our calculator handles it directly.

What is the Runge phenomenon? Large oscillations near the ends of the interval when a high-degree polynomial is fitted through many evenly spaced points.

Every interpolation formula, from linear to Newton and bilinear, is on one page with a worked example each: interpolation formula.

Soren Vance
Soren Vance

Soren Vance is the Director of Quantitative Analysis & Algorithms at Interpolation Calculator, where he leads the design and optimization of the company’s core interpolation engines and data processing frameworks.

With a master’s in Computational Mathematics and over 8 years of experience in analytical modeling and numerical computing, Soren oversees the development of high‑performance methods — from spline interpolation and polynomial regressions to multidimensional estimators for real‑world datasets.

Known for his clarity of thought, Soren builds systems that balance mathematical rigor with computational efficiency. He collaborates closely with product, engineering, and UX teams to ensure users get reliable, transparent, and fast results. Outside of work, he contributes to open‑source math libraries and teaches data science workshops at local universities.

Articles: 21

Interpolation Calculator is a mathematical method used to estimate an unknown value between known data points.

Privacy

Disclaimer

Terms

GDPR

Affiliate

Refund

Company

About Us

Contact Us