Lagrange Interpolation Calculator
Enter at least two points as x, y pairs (one point per line), then choose an x-value to evaluate the interpolated polynomial.
x, y, x y, or (x, y)What is Lagrange interpolation?
Lagrange interpolation is a classic numerical method used to construct a polynomial that passes exactly through a set of known data points. If you know several values of a function but do not have its explicit formula, interpolation helps you estimate values between those points.
Given points (x0, y0), (x1, y1), ..., (xn, yn) with distinct x-values, there is one unique polynomial of degree at most n that matches every point. The Lagrange form writes that polynomial directly, without solving a large linear system.
Lagrange interpolation formula
Li(x) = Π [ (x - xj) / (xi - xj) ], for j = 0..n, j ≠ i
Each basis polynomial Li(x) is crafted so that it equals 1 at x = xi and 0 at all other data x-values. That means the sum isolates each known y-value in exactly the right place.
How to use this calculator
Step-by-step
- Enter your known data points in the textbox (one point per line).
- Ensure no two points share the same x-value.
- Type the x-value where you want the estimate.
- Click Calculate to get:
- The interpolated value P(x)
- The expanded polynomial expression
- Term-by-term contributions for transparency
Worked example
Suppose your points are (0,1), (1,3), (2,2), and (4,5). These four points produce a cubic polynomial. If you evaluate at x = 2.5, the calculator computes each Lagrange basis term and combines them into the final interpolated value.
This is especially useful when your data comes from experiments, simulation outputs, lookup tables, or sampled measurements.
Where Lagrange interpolation is useful
- Engineering: estimating values from calibration tables.
- Physics: reconstructing smooth approximations from sampled data.
- Computer graphics: curve fitting between key points.
- Finance and analytics: estimating unknown points in tabulated scenarios.
- Education: understanding polynomial construction and numerical methods.
Accuracy and limitations
Lagrange interpolation is exact at the given sample points, but between and beyond them accuracy depends on how well the underlying function behaves. High-degree polynomials can oscillate, especially near the ends of an interval (often called Runge's phenomenon).
Best practices
- Use interpolation mainly inside the range of your data (not far outside it).
- Avoid very high polynomial degrees when possible.
- For many points, piecewise methods (like splines) are often more stable.
- Make sure x-values are distinct; duplicates make the formula undefined.
Final thoughts
A Lagrange interpolation calculator gives you a practical way to build and evaluate a polynomial from raw point data in seconds. Use it to test hypotheses, fill missing values, and understand how numerical interpolation works under the hood.