Interpolation Formula: Every Method in One Place, With Examples

The basic interpolation formula estimates a value between two known points with a straight line:

y = y1 + (x − x1) × (y2 − y1) / (x2 − x1)

Here (x1, y1) and (x2, y2) are the known points on either side, x is where you want a value, and y is the estimate. This is the formula most textbooks and exams mean. When the data curves, when you have more than two points, or when the value depends on two inputs, other formulas fit better. This page puts them all in one place, each with a small example you can check by hand.

To skip the arithmetic, use the interpolation calculator on our homepage for two points, or the Lagrange interpolation calculator for up to 15.

Interpolation formulas at a glance

MethodFormulaUse it when
Lineary = y1 + (x − x1)(y2 − y1) / (x2 − x1)Two points, data roughly straight between them
LagrangeP(x) = Σ yi × Li(x)A few points and you want one curve through all of them
Newton forward differencey = y0 + pΔy0 + p(p − 1)/2! × Δ²y0 + …Equally spaced x values, worked by hand
Newton divided differenceP(x) = f[x0] + f[x0, x1](x − x0) + …Unequal spacing, or you may add points later
BilinearWeighted average of four corner valuesTwo inputs, such as a two-way table
Inversex = x1 + (y − y1)(x2 − x1) / (y2 − y1)You know y and need the x that gives it

Linear interpolation formula

The formula draws a straight line through the two known points and reads off its height at x. It is easier to remember in two parts. First find how far along the gap you are, as a fraction from 0 to 1:

t = (x − x1) / (x2 − x1)

Then move that fraction of the way from y1 to y2:

y = y1 + t × (y2 − y1)

Example: the known points are (2, 4) and (6, 12). Find y at x = 3.

  • t = (3 − 2) / (6 − 2) = 0.25
  • y = 4 + 0.25 × (12 − 4) = 4 + 2 = 6

For the proof and more examples, see our linear interpolation formula guide.

Lagrange interpolation formula

With n + 1 points you can fit exactly one polynomial of degree n through all of them. The Lagrange form writes it down directly:

P(x) = y0 L0(x) + y1 L1(x) + … + yn Ln(x)

Each basis polynomial is a product over every other point j:

Li(x) = Π (x − xj) / (xi − xj), for all j ≠ i

Li(x) equals 1 at xi and 0 at every other known x, so the sum passes through every point.

Example: the points are (1, 1), (2, 4) and (3, 9). Find P(2.5).

  • L0(2.5) = (2.5 − 2)(2.5 − 3) / ((1 − 2)(1 − 3)) = −0.25 / 2 = −0.125
  • L1(2.5) = (2.5 − 1)(2.5 − 3) / ((2 − 1)(2 − 3)) = −0.75 / −1 = 0.75
  • L2(2.5) = (2.5 − 1)(2.5 − 2) / ((3 − 1)(3 − 2)) = 0.75 / 2 = 0.375
  • P(2.5) = 1 × (−0.125) + 4 × 0.75 + 9 × 0.375 = −0.125 + 3 + 3.375 = 6.25

The three points lie on y = x², and 2.5² = 6.25, so the formula recovers the curve exactly. More in our Lagrange interpolation guide and polynomial interpolation guide.

Newton forward difference formula

When the x values are equally spaced, a step h apart, Newton’s forward difference formula is quicker by hand:

y = y0 + pΔy0 + p(p − 1)/2! × Δ²y0 + p(p − 1)(p − 2)/3! × Δ³y0 + …

Here p = (x − x0) / h, Δy0 = y1 − y0, and each higher difference is the difference of the row below it, so Δ²y0 = Δy1 − Δy0.

Example: the same points (1, 1), (2, 4), (3, 9), so x0 = 1 and h = 1. The differences are Δy0 = 3, Δy1 = 5 and Δ²y0 = 2. For x = 2.5, p = 1.5:

y = 1 + 1.5 × 3 + (1.5 × 0.5 / 2) × 2 = 1 + 4.5 + 0.75 = 6.25

It matches the Lagrange answer, as it must: through the same points there is only one polynomial of that degree. Newton’s backward formula works the same way from the end of the table and suits x values near the last point.

Newton divided difference formula

For unequally spaced x values, use divided differences:

P(x) = f[x0] + f[x0, x1](x − x0) + f[x0, x1, x2](x − x0)(x − x1) + …

The first divided difference is f[x0, x1] = (y1 − y0) / (x1 − x0), and each higher one is built the same way from the level below. A useful property: adding a new data point adds one term and leaves every earlier term as it is.

Example: the points are (1, 1), (2, 4) and (4, 16). Then f[x0, x1] = 3, f[x1, x2] = (16 − 4) / 2 = 6, and f[x0, x1, x2] = (6 − 3) / (4 − 1) = 1. At x = 2.5:

P(2.5) = 1 + 3 × 1.5 + 1 × 1.5 × 0.5 = 6.25

The full table method is in our Newton divided difference guide.

Bilinear interpolation formula

When a value depends on two inputs, such as a table with rows and columns, interpolate in both directions at once. With corner values Q11 at (x1, y1), Q21 at (x2, y1), Q12 at (x1, y2) and Q22 at (x2, y2):

f(x, y) = [Q11(x2 − x)(y2 − y) + Q21(x − x1)(y2 − y) + Q12(x2 − x)(y − y1) + Q22(x − x1)(y − y1)] / ((x2 − x1)(y2 − y1))

Example: a unit square from (0, 0) to (1, 1) with Q11 = 10, Q21 = 20, Q12 = 30 and Q22 = 40. At the point (0.25, 0.75) the denominator is 1, so:

f = 10 × 0.75 × 0.25 + 20 × 0.25 × 0.25 + 30 × 0.75 × 0.75 + 40 × 0.25 × 0.75 = 1.875 + 1.25 + 16.875 + 7.5 = 27.5

See the bilinear interpolation guide, the double interpolation guide, or let the bilinear interpolation calculator do it.

Inverse interpolation formula

Sometimes you know the y value and need the x that produces it. Swap the roles of x and y in the linear formula:

x = x1 + (y − y1) × (x2 − x1) / (y2 − y1)

Example: with the points (2, 4) and (6, 12), which x gives y = 10? x = 2 + (10 − 4) × 4 / 8 = 2 + 3 = 5. More in our inverse interpolation guide.

Interpolation formula for grouped data

Statistics uses the same idea to find the median of grouped data. It assumes the values in the median class are spread evenly across it:

Median = L + ((n/2 − CF) / f) × h

L is the lower boundary of the median class, n the total frequency, CF the cumulative frequency before that class, f the class frequency and h the class width. Example: n = 50, the median class is 20 to 30, CF = 18 and f = 14, so the median = 20 + ((25 − 18) / 14) × 10 = 25. Worked tables are in our median of grouped data guide.

Which interpolation formula should you use?

  • Two points and a roughly straight relationship: linear.
  • A table with two inputs: bilinear, also called double interpolation.
  • Three or more points on a smooth curve: Lagrange or Newton. Keep the degree low, because high-degree polynomials can swing wildly between points. For many points, a cubic spline is safer.
  • Equally spaced data worked by hand: Newton forward or backward difference.
  • You know the output and need the input: inverse interpolation.
  • The x you need is outside your data: that is extrapolation, not interpolation. See interpolation vs extrapolation.

For an overview of how the methods differ, read types of interpolation, and for a step-by-step walkthrough, how to interpolate.

FAQs

What is the general formula for interpolation?

There is no single formula for every case. When people say “the interpolation formula” they usually mean the linear one, y = y1 + (x − x1)(y2 − y1) / (x2 − x1). For curves, the Lagrange and Newton formulas generalise it to any number of points.

Is the interpolation formula the same as the slope formula?

They are closely related. The linear interpolation formula is the point-slope form of a line, y = y1 + m(x − x1), with the slope m = (y2 − y1) / (x2 − x1) taken from the two known points.

Do Lagrange and Newton give different answers?

No. Through the same set of points there is only one polynomial of the lowest degree, so both formulas give the same value. They differ only in how you build it: Newton’s form is easier to extend when you add a point.

Can I use the interpolation formula outside my data?

The arithmetic still works, but then you are extrapolating, and the error grows quickly the further you go past your known points. Use the extrapolation calculator and treat the answer as a projection, not a reading.

Soren Vance
Soren Vance

Soren Vance is the Director of Quantitative Analysis & Algorithms at Interpolation Calculator, where he leads the design and optimization of the company’s core interpolation engines and data processing frameworks.

With a master’s in Computational Mathematics and over 8 years of experience in analytical modeling and numerical computing, Soren oversees the development of high‑performance methods — from spline interpolation and polynomial regressions to multidimensional estimators for real‑world datasets.

Known for his clarity of thought, Soren builds systems that balance mathematical rigor with computational efficiency. He collaborates closely with product, engineering, and UX teams to ensure users get reliable, transparent, and fast results. Outside of work, he contributes to open‑source math libraries and teaches data science workshops at local universities.

Articles: 21

Interpolation Calculator is a mathematical method used to estimate an unknown value between known data points.

Privacy

Disclaimer

Terms

GDPR

Affiliate

Refund

Company

About Us

Contact Us