Lagrange Interpolation Calculator

Paste your data points, one per line, and choose the x you want. You get the value, the full polynomial and each step.

Enter one data point per line as x, y (2 to 15 points, all x values different), then the x where you want the value.

P(5) = 2.219048

Polynomial (degree 2 or lower): P(x) = −0.004762x2 + 0.261905x + 1.028571

L0(5) = 0.733333, L1(5) = 0.314286, L2(5) = −0.047619. P(5) = 2 × 0.733333 + 3 × 0.314286 + 4 × (−0.047619) = 2.219048.

Lagrange interpolation formula: P(x) = Σ yi·Li(x), where Li(x) is the product of (x − xj) / (xi − xj) over every other point j. Through n points it gives the single polynomial of degree n − 1 or lower that passes through all of them.

How to use the Lagrange interpolation calculator

  1. Enter each known point on its own line as x, y. Commas, spaces or tabs between the two numbers all work, so you can paste two columns from a spreadsheet.
  2. Make sure every x value is different. Two points with the same x cannot lie on one function.
  3. Enter the x where you want the value. The calculator shows P(x), the polynomial in standard form and each basis value Li(x).
  4. Keep the point you want inside the range of your data. Outside it, polynomials can run away quickly.

Worked example: estimating √5 from three square roots

You know √4 = 2, √9 = 3 and √16 = 4. Estimate √5 with the points (4, 2), (9, 3) and (16, 4) at x = 5.

  • L0(5) = (5 − 9)(5 − 16) / ((4 − 9)(4 − 16)) = 44 / 60 = 0.733333
  • L1(5) = (5 − 4)(5 − 16) / ((9 − 4)(9 − 16)) = −11 / −35 = 0.314286
  • L2(5) = (5 − 4)(5 − 9) / ((16 − 4)(16 − 9)) = −4 / 84 = −0.047619
  • P(5) = 2 × 0.733333 + 3 × 0.314286 + 4 × (−0.047619) = 2.219048 (exactly 233/105)

The true value is √5 = 2.236068, so the error is about 0.017. A straight line between (4, 2) and (9, 3) gives 2.2, which is off by 0.036, so the curved polynomial roughly halves the error. The polynomial itself is P(x) = −0.004762x² + 0.261905x + 1.028571. These are the default values in the calculator above.

For the theory and a proof of the formula, read our Lagrange interpolation formula guide. To add points without starting over, use Newton divided differences, which give the same polynomial.

Lagrange Interpolation Calculator: frequently asked questions

What is Lagrange interpolation used for?

It finds a value between known data points when the data follows a curve rather than a straight line, for example table values in physics and engineering, or a smooth path through a few measured points.

How many points do I need for Lagrange interpolation?

At least 2, which gives a straight line. Three points give a quadratic, four a cubic, and so on. Three to five points close to your target usually work best.

Is Lagrange interpolation the same as Newton interpolation?

They give exactly the same polynomial through the same points. Newton’s divided difference form is easier when you add points one at a time, while Lagrange’s form is easier to write down directly.

Why does my polynomial swing wildly between points?

With many evenly spaced points a single high degree polynomial overshoots near the ends. This is the Runge phenomenon. Use fewer points near the target, or a cubic spline instead.

Can I use Lagrange interpolation to extrapolate?

You can, but the error grows fast outside the data range. For trends beyond your data a straight line is usually safer. Try our extrapolation calculator for that.

More interpolation tools and guides

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