Calculator
Example data table
This sample uses the curve y = x², which the interpolated polynomial matches exactly.
| # | x | y |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 2 | 4 |
| 3 | 3 | 9 |
Formula used
Given n points (xᵢ, yᵢ) with distinct xᵢ, the Lagrange interpolating polynomial is:
This calculator expands the result into the power basis so you can read coefficients for x⁰, x¹, x², and so on.
How to use this calculator
- Enter at least two points by filling x and y values.
- Use “Add point” to include more data pairs.
- Optionally enter an evaluation x to compute P(x).
- Press “Calculate” to show the polynomial and breakdown.
- Use the download buttons to export CSV or PDF.
FAQs
1) What does Lagrange interpolation do?
It builds a single polynomial that passes through every provided data point. With distinct x-values, the polynomial is unique for that dataset.
2) How many points should I use?
Use the smallest set that captures your trend. More points increase degree and can amplify oscillations, especially near the edges.
3) Why must x-values be unique?
The formula divides by (xᵢ − xₖ). If two x-values match, the denominator becomes zero and the polynomial is not defined.
4) Can I interpolate outside the given range?
You can, but it becomes extrapolation and may be inaccurate. Polynomials can grow quickly outside the data interval.
5) What is the “basis breakdown” showing?
It lists each Lᵢ(x) factorization, its denominator product, and the scaling yᵢ/denominator used before summing all terms into P(x).
6) How is P(x) evaluated here?
After expanding into coefficients, the calculator uses Horner’s method to evaluate the polynomial efficiently and with good numeric stability.
7) Will this match my curve exactly?
It matches the given points exactly. Between points, it estimates smoothly, but may not match a true underlying function if data is noisy.
8) What do the CSV and PDF exports include?
They include your input points, the computed polynomial, and the evaluated value (if provided). Use them to share calculations or archive results.