Linear interpolation between two points

Enter two points P1 and P2. Give the x (or the y) of a point lying between them on the straight line: the tool returns the other coordinate.

Point 1
Point 2
I know

Result

y = 20

Point P(40 ; 20)
Liney = 0.5·x + 0
Slope a0.5
Position from P1 to P240 %
0 10 20 30 40 50 0 20 40 60 80 100 x y P1 P2 P

Reference: Analytic geometry — Line through two points: y = y₁ + (y₂ − y₁)·(x − x₁)/(x₂ − x₁). Module math.linear_interpolation, version 1.

The known x must lie between the two points: interpolation only.

Engineering aid only. Results are indicative and must be checked by the user before any design decision.

How it works

The point lies on the straight line through P1(x₁, y₁) and P2(x₂, y₂):

y = y_1 + \frac{y_2 - y_1}{x_2 - x_1}\,(x - x_1)

Knowing y instead, the same relation is solved for x. The tool only interpolates: the known coordinate must lie between those of P1 and P2. Outside that range (extrapolation), nothing guarantees that the quantity still follows a straight line.

Reference: analytic geometry, equation of the line through two points.