Algebra 1 · Grades 8, 9

How to Write the Equation of a Line from Two Points

Quick answer

To find the equation of a line through two points, first compute the slope with the slope formula, then substitute that slope and either point into point-slope form, then simplify. Through (1, 3) and (3, 7) the slope is 2, giving y - 3 = 2(x - 1), which simplifies to y = 2x + 1.

What you'll learn

  • Find the equation of a line through two given points
  • Combine the slope formula with point-slope form
  • Handle the special cases of horizontal and vertical lines

The whole method in one line

Two points determine a line, so they must determine its equation. Getting there is two tools you already have, used in order:

two points   slope formula   m   point-slope   equation\text{two points} \;\xrightarrow{\text{ slope formula }}\; m \;\xrightarrow{\text{ point-slope }}\; \text{equation}
  1. Compute the slope: m=y2y1x2x1m = \tfrac{y_2 - y_1}{x_2 - x_1}.
  2. Substitute mm and either point into yy1=m(xx1)y - y_1 = m(x - x_1).
  3. Simplify to slope-intercept form if you want the intercept.

Why you need the slope first

Point-slope form needs a slope, and you are not given one — you are given two points. So the slope formula comes first, and its answer feeds the second step.

It is worth seeing that this always works. Two distinct points with different xx-values give exactly one slope, and a slope plus a point gives exactly one line. So the answer exists and is unique — there is never a choice to agonise over, only arithmetic to do carefully.

Worked examples

Common mistakes

Practice problems

  1. Find the equation of the line through (0,2)(0, 2) and (4,10)(4, 10).

    Hint

    Compute the slope first. One of these points is already the yy-intercept.

    Answer

    y=2x+2y = 2x + 2

    Full solution

    m=10240=84=2m = \tfrac{10 - 2}{4 - 0} = \tfrac{8}{4} = 2.

    Since (0,2)(0, 2) is the yy-intercept, b=2b = 2 and y=2x+2y = 2x + 2 directly.

    Check at x=4x = 4: y=10y = 10

  2. Find the equation of the line through (1,5)(1, 5) and (3,11)(3, 11).

    Answer

    y=3x+2y = 3x + 2

    Full solution

    m=11531=3m = \tfrac{11 - 5}{3 - 1} = 3. Using (1,5)(1, 5): y5=3(x1)=3x3y - 5 = 3(x - 1) = 3x - 3, so y=3x+2y = 3x + 2.

    Check at x=3x = 3: y=11y = 11

  3. Find the equation of the line through (1,4)(-1, 4) and (2,2)(2, -2).

    Answer

    y=2x+2y = -2x + 2

    Full solution

    m=242(1)=63=2m = \tfrac{-2 - 4}{2 - (-1)} = \tfrac{-6}{3} = -2.

    Using (2,2)(2, -2): y+2=2(x2)=2x+4y + 2 = -2(x - 2) = -2x + 4, so y=2x+2y = -2x + 2.

    Check at x=1x = -1: y=2+2=4y = 2 + 2 = 4

  4. Find the equation of the line through (3,1)(3, -1) and (8,1)(8, -1).

    Hint

    Compute the slope before reaching for point-slope form.

    Answer

    y=1y = -1

    Full solution

    m=1(1)83=05=0m = \tfrac{-1 - (-1)}{8 - 3} = \tfrac{0}{5} = 0, so the line is horizontal at the shared height: y=1y = -1.

  5. Find the equation of the line through (2,3)(-2, 3) and (2,9)(-2, 9).

    Answer

    x=2x = -2

    Full solution

    The xx-values match, so the denominator is 00 and the slope is undefined. The line is vertical: x=2x = -2.

  6. Find the equation of the line through (0,3)(0, -3) and (6,1)(6, 1).

    Hint

    Expect a fractional slope. Keep it as a fraction.

    Answer

    y=23x3y = \tfrac{2}{3}x - 3

    Full solution

    m=1(3)60=46=23m = \tfrac{1 - (-3)}{6 - 0} = \tfrac{4}{6} = \tfrac{2}{3}.

    (0,3)(0, -3) is the intercept, so y=23x3y = \tfrac{2}{3}x - 3.

    Check at x=6x = 6: y=43=1y = 4 - 3 = 1

  7. Two students find the line through (2,1)(2, 1) and (5,7)(5, 7). One writes y1=2(x2)y - 1 = 2(x - 2), the other writes y7=2(x5)y - 7 = 2(x - 5). Who is right?

    Hint

    Simplify both.

    Answer

    Both.

    Full solution

    First: y1=2x4y - 1 = 2x - 4, so y=2x3y = 2x - 3.

    Second: y7=2x10y - 7 = 2x - 10, so y=2x3y = 2x - 3.

    They used different points, which is allowed, and reached the same line.

  8. A plant is measured at 1212 cm on day 33 and 2727 cm on day 88. Assuming steady growth, write an equation for its height and predict its height on day 1212.

    Hint

    Days are xx, height is yy. Find the growth rate first.

    Answer

    y=3x+3y = 3x + 3; on day 1212 it is 3939 cm.

    Full solution

    m=271283=155=3m = \tfrac{27 - 12}{8 - 3} = \tfrac{15}{5} = 3 cm per day.

    Using (3,12)(3, 12): y12=3(x3)=3x9y - 12 = 3(x - 3) = 3x - 9, so y=3x+3y = 3x + 3.

    On day 1212: y=36+3=39y = 36 + 3 = 39 cm.

    The intercept 33 predicts a height of 33 cm on day 00, which is a reasonable seedling — but predicting far outside the measured range assumes growth stays steady, and real plants eventually stop.

Frequently asked questions

Which of the two points should I substitute?

Either. Both give equations that simplify to the same line. Pick the one with smaller or positive numbers, since it makes the arithmetic cleaner.

What if the two points give a slope of zero?

Then the line is horizontal and its equation is y = the shared y-value. There is no need for point-slope form; the answer is already in front of you.

What if the x-values are the same?

Then the slope is undefined and the line is vertical. Its equation is x = the shared x-value. A vertical line cannot be written as y = mx + b at all.

What to learn next

Standards alignment

This lesson covers the following Common Core State Standards for Mathematics.

  • CCSS.MATH.CONTENT.HSA.CED.A.2Creating EquationsCreate equations in two or more variables to represent relationships between quantities; graph equations on coordinate axes with labels and scales.
  • CCSS.MATH.CONTENT.8.EE.B.6Expressions and EquationsUse similar triangles to explain why the slope m is the same between any two distinct points on a non-vertical line in the coordinate plane; derive the equation y = mx for a line through the origin and the equation y = mx + b for a line intercepting the vertical axis at b.