Skip to content

Interpolation Calculator — Step-by-Step Solutions

The Interpolation Calculator estimates values between known data points using several methods. Choose from linear interpolation between two points, bilinear interpolation on a 2D grid, piecewise linear interpolation from a data table, or Lagrange polynomial interpolation.

Enter your data points and target x value to get the interpolated result with detailed step-by-step working. The data table and Lagrange modes include an SVG scatter plot showing your data points and the interpolated value.

Your calculations will appear here

How to Use the Interpolation Calculator

  1. Linear Interpolation: enter two known points (x0, y0) and (x1, y1) and the target x. The calculator gives the interpolated y and the slope.
  2. Bilinear Interpolation: enter the grid corners x1, x2, y1, y2, the four corner values Q11, Q12, Q21, Q22 (Qij is at xi and yj, so Q12 is at x1, y2), and the target point (x, y).
  3. From Data Table: enter points, one per line as x, y. The calculator finds the two points on either side of your x and interpolates between them. If x is outside the data it extrapolates and shows a warning.
  4. Lagrange Polynomial: enter at least two points with distinct x values to fit the unique polynomial through all of them and evaluate it at your x.

Formula and Theory

Interpolation estimates a value between known data points. Linear interpolation assumes a straight line between two neighbours: y = y0 + (x - x0) x (y1 - y0) / (x1 - x0). It is the method behind reading intermediate values from a printed table, such as steam tables or tax tables.

Bilinear interpolation extends this to two variables on a rectangular grid. It interpolates along x on both the lower and upper edges, then interpolates those two results along y. It is widely used for image resizing and for looking up values in two-way tables.

The Lagrange polynomial passes exactly through every given point. With n points it has degree at most n - 1. It can capture curvature that linear interpolation misses, but with many points or unevenly spaced ones it may oscillate between them, so use it with a few well-spaced points.

Extrapolation, estimating outside the known range, is far less reliable than interpolation, because there is nothing to anchor the estimate on the far side. The calculator marks such results with a warning.

Worked Examples

Example 1: Linear interpolation between two points

Problem: Find y at x = 2 given (1, 2) and (3, 8).

Solution: Slope = (8 - 2) / (3 - 1) = 3. y = 2 + (2 - 1) x 3 = 5.

Answer: y = 5

Example 2: Reading between table values

Problem: A table gives 100 at x = 10 and 250 at x = 20. Estimate the value at x = 14.

Solution: Slope = (250 - 100) / (20 - 10) = 15 per unit. y = 100 + (14 - 10) x 15 = 100 + 60 = 160.

Answer: 160

Example 3: Bilinear interpolation

Problem: Corners: x from 10 to 20, y from 100 to 200, Q11 = 1, Q12 = 3, Q21 = 5, Q22 = 9. Find the value at (12, 120).

Solution: Weights: (x2 - x) = 8, (x - x1) = 2, (y2 - y) = 80, (y - y1) = 20, and the cell area is 10 x 100 = 1,000. Sum = Q11 x 8 x 80 + Q21 x 2 x 80 + Q12 x 8 x 20 + Q22 x 2 x 20 = 640 + 800 + 480 + 360 = 2,280. Divide by 1,000: 2.28.

Answer: 2.28

Example 4: Data table and extrapolation

Problem: Points (1, 2), (2, 4), (3, 5), (4, 4), (5, 5). Find y at x = 2.5 and at x = 7.

Solution: For x = 2.5 the neighbours are (2, 4) and (3, 5), slope 1, so y = 4 + 1 x 0.5 = 4.5. For x = 7 the data end at 5, so the calculator uses the last two points (4, 4) and (5, 5), slope 1, and extends: y = 4 + 1 x 3 = 7, with an extrapolation warning.

Answer: y = 4.5 inside the data; y = 7 by extrapolation (unreliable)

Example 5: Lagrange polynomial through three points

Problem: Points (0, 1), (1, 3), (2, 11). Estimate y at x = 1.5 with a polynomial and compare with linear interpolation.

Solution: The polynomial through the points is y = 3x^2 - x + 1 (check: 1, 3, 11). At x = 1.5: 3 x 2.25 - 1.5 + 1 = 6.25. Linear interpolation between (1, 3) and (2, 11) gives 3 + 0.5 x 8 = 7, which overshoots because the data are curved.

Answer: Polynomial 6.25; straight-line estimate 7

Frequently Asked Questions

What is interpolation?
It is estimating a value that lies between known data points. The simplest version draws a straight line between the two nearest known points and reads the value off that line.
What is the difference between interpolation and extrapolation?
Interpolation estimates inside the range of the known data; extrapolation goes outside it. Extrapolated values are much less reliable, and the calculator warns you when you do it.
When should I use bilinear interpolation?
Use it when a value depends on two variables and you know it at the four corners of a rectangle, for example a two-way table of rates by age and term.
Is the Lagrange polynomial better than linear interpolation?
It follows curvature through all points, which can be more accurate for smooth data. With many points it can swing wildly between them, so for large tables linear interpolation between neighbours is often safer.
Can two points have the same x value?
No. Linear interpolation needs two different x values and the Lagrange mode needs all x values distinct, because a function cannot take two values at the same x.
How accurate is linear interpolation?
It is exact when the true relationship is a straight line, and its error grows with the curvature of the data and the spacing of the points. Closer points give a better estimate.

Related General Calculators

Related Articles