Coordinate geometry

Line Through Two Points

Build the equation of the unique straight line through two points, including vertical-line cases.

Back to topic

Formula

y - y1 = ((y2 - y1) / (x2 - x1))(x - x1)

Result

Worked substitution


          

Two distinct points determine exactly one straight line.

Read the result

The tool first finds the gradient, then anchors that gradient at one of the points. The final equation is just that movement rule written in algebra.

Where it helps

Use it for modelling a straight trend, setting up simultaneous equations, or turning measured points into a line you can substitute into.

Common slip

If both points are identical, there is no unique line. You need a second distinct point or a gradient.

Try it

Enter two points with the same y value. The answer should become a horizontal line; check that the gradient is 0.