Equation of the Line Through Two Points

Finds the slope a and the intercept b of the line y = ax + b through the two points (x₁, y₁) and (x₂, y₂).

Two points determine exactly one line. This finds the slope aa and the intercept bb that describe it as y=ax+by = ax + b.

a=y2y1x2x1,b=y1ax1a = \dfrac{y_2 - y_1}{x_2 - x_1}, \quad b = y_1 - a x_1

Slope is rise over run. Once you have it, substituting either point gives the intercept.

Example

Take the line through (1,2)(1, 2) and (3,8)(3, 8).

a=8231=62=3a = \dfrac{8 - 2}{3 - 1} = \dfrac{6}{2} = 3

The intercept is b=23×1=1b = 2 - 3 \times 1 = -1, so the line is y=3x1y = 3x - 1. Checking against the other point, 3×31=83 \times 3 - 1 = 8, which is indeed (3,8)(3, 8).

Notes