Lagrange Interpolation Calculator
Construct and evaluate the unique polynomial P(x) passing exactly through any number of coordinate points. Includes explicit basis polynomial terms L_i(x) and complete step-by-step arithmetic.
How the Lagrange Interpolation Calculator Works
While simple piecewise methods connect points with angular line segments, our online lagrange interpolation calculator generates the unique, smooth Lagrange polynomial curve that passes directly through every single sample point in your dataset. When applied to exactly two points, it simplifies into a linear lagrange interpolation calculator identical to standard linear interpolation.
The elegance of Joseph-Louis Lagrange's formulation lies in the construction of basis polynomials $L_i(x)$. Each basis polynomial is engineered to have a value of exactly $1$ at its own coordinate $x_i$, and exactly $0$ at every other sample coordinate $x_j$. Multiplying each basis polynomial by its corresponding $y_i$ value and summing them up guarantees that the resulting lagrange interpolation calculator polynomial matches your data perfectly.
Lagrange Polynomial Formula
- P(x)=Interpolating Polynomial: The unique polynomial of degree ≤ n - 1 passing through all n given coordinates.
- yᵢ=Ordinate value: The dependent y-value for point i.
- Lᵢ(x)=Lagrange basis polynomial: The basis function that equals 1 at x = xᵢ and 0 at all other sample points x_j (j ≠ i).
- x=Evaluation coordinate: The target x-value where the polynomial is evaluated.
- xᵢ, xⱼ=Sample points: Distinct abscissa coordinates of the observed data.
Note: For n given data points, the resulting polynomial has a maximum degree of n - 1 and is mathematically unique.
Step-by-Step Worked Examples
Walk through two complete real-world calculation problems or click any example to load its numbers directly into the calculator.
Quadratic Curve Fitting Through 3 Distinct Points
Determine the value of the quadratic interpolating polynomial at x = 3 given three experimental data points: (1, 3), (2, 7), and (4, 21).
- L₀(3) = ((3 - 2)/(1 - 2)) × ((3 - 4)/(1 - 4)) = (1 / -1) × (-1 / -3) = -1 × (1/3) = -1/3 = -0.333333
- L₁(3) = ((3 - 1)/(2 - 1)) × ((3 - 4)/(2 - 4)) = (2 / 1) × (-1 / -2) = 2 × 0.5 = 1.000000
- L₂(3) = ((3 - 1)/(4 - 1)) × ((3 - 2)/(4 - 2)) = (2 / 3) × (1 / 2) = 2/6 = 1/3 = 0.333333
- Multiply by y-values: y₀·L₀ = 3 × (-1/3) = -1; y₁·L₁ = 7 × 1 = 7; y₂·L₂ = 21 × (1/3) = 7
- Sum components: P(3) = -1 + 7 + 7 = 13.000000
Kinematic Rocket Altitude Trajectory Calibration
A sounding rocket altimeter telemetry registers altitudes at four recorded flight times: 0s (0m), 2s (38m), 4s (152m), and 6s (342m). Estimate the exact altitude of the rocket at t = 3.5 seconds.
- Evaluate basis polynomial L₀(3.5) = ((3.5-2)/-2) × ((3.5-4)/-4) × ((3.5-6)/-6) = -0.019531
- Evaluate basis polynomial L₁(3.5) = ((3.5-0)/2) × ((3.5-4)/-2) × ((3.5-6)/-4) = 0.273438
- Evaluate basis polynomial L₂(3.5) = ((3.5-0)/4) × ((3.5-2)/2) × ((3.5-6)/-2) = 0.820313
- Evaluate basis polynomial L₃(3.5) = ((3.5-0)/6) × ((3.5-2)/4) × ((3.5-4)/2) = -0.074219
- Compute P(3.5) = 0·L₀ + 38·(0.273438) + 152·(0.820313) + 342·(-0.074219) = 0 + 10.3906 + 124.6875 - 25.3828 = 109.6953 m
Lagrange Interpolation FAQs
What is Lagrange polynomial interpolation?
Lagrange interpolation is a classical numerical method that finds the unique polynomial of the smallest possible degree (degree ≤ n - 1) that passes exactly through a given set of n distinct points. Unlike piecewise linear interpolation, it produces a smooth, continuous polynomial curve across the entire data interval.
What is the degree of the Lagrange polynomial?
Given n distinct coordinate points, the maximum degree of the Lagrange interpolating polynomial is n - 1. For example, 2 points produce a degree-1 linear function, 3 points produce a degree-2 parabola (quadratic), and 4 points produce a degree-3 cubic polynomial.
What is Runge's phenomenon and when should I avoid high-degree polynomials?
Runge's phenomenon is the problem of wild oscillations that occur near the edges of an interval when interpolating with high-degree polynomials (usually n > 7 or 8) over equally spaced points. If you have dozens of data points, using cubic splines or piecewise interpolation is usually preferred over a single high-degree Lagrange polynomial.
Can two points have the same x-coordinate?
No. A mathematical function can only have one y-value for each distinct x-value. If two points have identical x-values with different y-values, the denominator (xᵢ - xⱼ) becomes zero, resulting in division by zero. All x-coordinates must be strictly unique.
How does Lagrange interpolation compare to Newton interpolation?
Both methods produce mathematically identical interpolating polynomials. The Lagrange form expresses the polynomial directly as a linear combination of basis polynomials without solving a system of equations, making it elegant and straightforward for evaluating specific points. The Newton form uses divided differences, which is computationally easier when adding new data points incrementally.