How to write a line equation from two points

Find the slope first, anchor it to either point, then convert forms only if the problem needs a different presentation.

LaTeX article Updated July 13, 2026

yy1=m(xx1)y-y_1=m(x-x_1)

Check for a vertical line first

If the x-coordinates are equal, the slope denominator is zero and the line is vertical. Its equation is x equal to that shared coordinate.

Otherwise compute the slope with consistent subtraction order and simplify before substituting.

x1=x2x=x1x_1=x_2\quad\Longrightarrow\quad x=x_1

Either point gives the same line

Once the slope is known, substitute either given point into point-slope form. The two resulting equations look different before simplification but describe the same set of points.

Using the point with smaller or simpler coordinates often makes expansion easier.

yy1=m(xx1)y-y_1=m(x-x_1)

Verify with both points

A correct equation must make a true statement for each original point. Testing both catches a wrong slope and a wrong intercept quickly.

If slope-intercept form is requested, isolate y only after the point-slope equation is secure.

y=mx+by=mx+b

Worked example

Common mistakes

  • Dividing y-change by x-change with inconsistent order.
  • Substituting a point as (y, x).
  • Stopping without checking the second point.

Keep these ideas

  • Handle vertical lines separately.
  • Point-slope form is the natural starting form.
  • Both points must satisfy the result.
Vocab
Linear function
Math glossaryLinear function
f(x)=mx+bf(x)=mx+b

A function with constant rate of change.

Learn more
Slope
Math glossarySlope
m=ΔyΔxm=\frac{\Delta y}{\Delta x}

The vertical change divided by horizontal change on a nonvertical line.

Learn more
Rate of change
Math glossaryRate of change
ΔyΔx\frac{\Delta y}{\Delta x}

How much one quantity changes per unit change in another.

Learn more
Slope-intercept form
Math glossarySlope-intercept form
y=mx+by=mx+b

Displays a line's slope and vertical intercept directly.

Learn more
x-intercept
Math glossaryx-intercept
f(x)=0f(x)=0

A point where a graph meets the x-axis.

Learn more
Math glossary