Lagrange Polynomial Calculator – Online Interpolation Tool


Lagrange Polynomial Calculator


Enter at least 2 pairs of (x, y) coordinates. The values are unitless unless defined by your specific problem context.



The calculator will find the value of the interpolated polynomial P(x) at this point.


A plot of the input data points and the resulting Lagrange interpolating polynomial.

What is a Lagrange Polynomial Calculator?

A Lagrange Polynomial Calculator is a powerful mathematical tool used for polynomial interpolation. Given a set of distinct data points (x, y), it finds the unique polynomial of the lowest possible degree that passes through every single one of those points. This process, known as Lagrange interpolation, is fundamental in numerical analysis, data science, and engineering for approximating functions or filling in missing data.

This online calculator simplifies the complex calculations involved. Instead of manually computing the basis polynomials and summing them, you can simply input your data points and an evaluation point ‘x’ to instantly find the interpolated ‘y’ value. This is especially useful for anyone who needs to model data, approximate function values, or understand the behavior of a dataset without knowing the underlying function. The lagrange polynomial calculator is an essential utility for students, engineers, and researchers.

The Lagrange Polynomial Formula and Explanation

The core of the lagrange polynomial calculator is its formula. For a given set of n+1 data points (x0, y0), (x1, y1), …, (xn, yn), the Lagrange interpolating polynomial P(x) is defined as a sum:

P(x) = ∑i=0n yi ⋅ Li(x)

Where each Li(x) is a “basis polynomial.” The genius of this method is in how these basis polynomials are constructed. Each Li(x) is designed to be equal to 1 at x = xi and 0 at all other data points x = xj (where j ≠ i). The formula for each basis polynomial is a product:

Li(x) = ∏j=0, j≠in ( (x – xj) / (xi – xj) )

For more on interpolation theory, see our article on understanding polynomial interpolation.

Variables Table

Variable Meaning Unit Typical Range
(xi, yi) The i-th known data point (coordinate pair). Unitless / Context-Dependent Any real numbers. xi values must be distinct.
P(x) The Lagrange interpolating polynomial function. Same as yi A polynomial function of degree at most n.
Li(x) The i-th Lagrange basis polynomial. Unitless Real numbers.
x The point at which you want to evaluate the polynomial. Same as xi Any real number, often between min(xi) and max(xi).
Description of variables used in the Lagrange polynomial formula.

Practical Examples

Example 1: Simple Quadratic Curve

Suppose we have three points from a parabola: (0, 1), (1, 4), and (2, 9). We want to use the lagrange polynomial calculator to find the value at x = 1.5.

  • Inputs: Points = {(0, 1), (1, 4), (2, 9)}, Evaluation Point x = 1.5
  • Calculation: The calculator constructs the polynomial that passes through these points (which is P(x) = (x+1)2).
  • Result: P(1.5) = (1.5 + 1)2 = 2.52 = 6.25.

Example 2: Approximating a Sine Function

Let’s approximate the value of sin(x) at x = 1 radian using points we know. We’ll use (0, 0), (π/2, 1), and (π, 0). Here π/2 ≈ 1.57 and π ≈ 3.14. We want to find the value at x = 1.

  • Inputs: Points = {(0, 0), (1.57, 1), (3.14, 0)}, Evaluation Point x = 1
  • Calculation: The calculator interpolates a quadratic polynomial through these three points.
  • Result: The result will be an approximation of sin(1). The actual value is ~0.841. The interpolation will yield a close, but not exact, value. This demonstrates how interpolation is used for function approximation, a key topic in numerical analysis tools.

How to Use This Lagrange Polynomial Calculator

  1. Enter Data Points: Start by entering your known data points. The calculator begins with three empty (x, y) pairs. Fill in the x and y values for each point. Your x-values must be unique.
  2. Add/Remove Points: If you have more than three points, click the “Add Point” button to create new input fields. If you need to remove a point, click the ‘X’ button next to it. You need at least two points to perform an interpolation.
  3. Enter Evaluation Point: In the “Evaluation Point (x)” field, type the x-value for which you want to find the corresponding y-value on the interpolated curve.
  4. Calculate and Analyze: Click the “Calculate & Draw” button. The tool will instantly compute the result.
  5. Interpret Results:
    • The Interpolated Value P(x) is the primary result: the y-value on the polynomial at your chosen x.
    • The Intermediate Values section shows the calculated values for each basis polynomial Li(x), helping you understand the underlying math.
    • The Chart provides a visual representation of your data points and the smooth polynomial curve that connects them.

Key Factors That Affect Lagrange Interpolation

While powerful, the results of a lagrange polynomial calculator can be influenced by several factors:

  • Number of Points: The degree of the resulting polynomial is at most one less than the number of points. More points can create a more complex curve.
  • Distribution of Points: If points are clustered or unevenly spaced, the polynomial can exhibit large oscillations between them. This is a common issue when trying to fit many points.
  • Runge’s Phenomenon: When interpolating using a high number of equally spaced points, the polynomial can have wild oscillations near the edges of the interval. This is a classic issue in numerical analysis. You can learn more about this effect in our article on Runge’s phenomenon example.
  • Numerical Stability: For a very large number of points, the Lagrange formula can become numerically unstable due to the product of many small or large numbers, leading to precision errors. For such cases, other methods like Barycentric interpolation or a Newton form interpolation might be more stable.
  • Outliers: A single incorrect or outlier data point can dramatically change the shape of the entire polynomial curve, as it is forced to pass through that point.
  • Extrapolation vs. Interpolation: The calculator is most accurate for “interpolation” (finding values *between* your known x-points). “Extrapolation” (finding values *outside* the range of your x-points) can be highly unreliable as the polynomial may curve in unexpected ways.

Frequently Asked Questions (FAQ)

What is the main purpose of Lagrange interpolation?
The main purpose is to find a function (specifically, a polynomial) that perfectly fits a given set of data points. This is useful for approximating function values at new points, filling in gaps in data, and as a building block for more complex numerical methods like numerical integration.
How many points do I need to use the calculator?
You need a minimum of two points. Two points define a unique straight line (a polynomial of degree 1). Three points define a unique parabola (a polynomial of degree 2), and so on.
What happens if my x-values are not unique?
The Lagrange interpolation formula requires all x-coordinates (xi) to be distinct. If two x-values are the same, the denominator in the basis polynomial formula (xi – xj) would become zero, leading to a division-by-zero error. This calculator will show an error if duplicate x-values are detected.
Is this calculator better than other interpolation methods?
It depends. Lagrange interpolation is conceptually simple and easy to understand. However, for a large number of points, it can be computationally expensive and numerically unstable. Methods like Newton’s divided differences or spline interpolation can be more efficient and stable. Consider our spline interpolation vs lagrange tool for a comparison.
What is the degree of the resulting polynomial?
If you provide n data points, the resulting Lagrange polynomial will have a degree of at most n-1. For example, 5 points will result in a polynomial of degree up to 4.
Can I use this for curve fitting?
Yes and no. Lagrange interpolation is a form of curve fitting where the curve must pass *exactly* through every data point. If your data has noise or measurement errors, a method like polynomial curve fitting (least-squares regression) is often better, as it finds a “best-fit” curve that minimizes error rather than hitting every point.
Are the units important for this calculator?
The calculations themselves are unitless. However, the interpretation of your results depends entirely on the units of your input data. If your x-axis is ‘time (seconds)’ and your y-axis is ‘temperature (Celsius)’, then the interpolated result will also be in ‘temperature (Celsius)’. The lagrange polynomial calculator correctly processes the numbers, but you must manage the context of the units.
What is Runge’s Phenomenon and should I worry about it?
Runge’s Phenomenon is the problem of oscillation at the edges of an interval when interpolating a function with a high-degree polynomial using equally spaced points. You should be aware of it if you are using more than 7-8 points. If you see wild swings in the graph near the first or last point, you may be seeing this effect.

© 2026 Your Website. All Rights Reserved. A powerful lagrange polynomial calculator for all your interpolation needs.


Leave a Reply

Your email address will not be published. Required fields are marked *