Toolstia / Lagrange interpolation calculator
Lagrange interpolation calculator
Give a set of points and the calculator finds the one polynomial that passes exactly through all of them. It shows the polynomial and can estimate y at any x you choose.
Lagrange interpolation finds the one polynomial of degree n - 1 that passes through all n points, then evaluates it anywhere you like. Every x value must be different. With many points the polynomial can swing wildly between them (Runge's phenomenon), so keep the number of points small, use at most 12, and be careful outside the range of your data.
How it works
- Type the points, one per line, as x and y.
- Optionally enter an x to estimate.
- Read the polynomial and the estimated value.
What it finds
For n points with different x values there is exactly one polynomial of degree n - 1 through them. the Lagrange method builds it from the points directly.
Using the estimate
Interpolating inside the range of your points is usually reasonable. Going outside the range (extrapolating) can be very inaccurate.
Runge phenomenon
A high degree polynomial through many evenly spaced points can swing wildly between them. Keep the number of points small, up to 12 here.
Every x must differ
Two points with the same x and different y cannot be on one function.
Questions
Are my points uploaded?
Everything happens in your browser, and nothing you enter is sent anywhere.
How is it different from linear regression?
Regression finds a simple curve that fits near the points. Interpolation passes through every point exactly.
Why are the coefficients not whole numbers?
Many sets of points need fractions. The tool rounds the display but calculates with full precision.