Guides / Linear equations

Finding the equation of a line: slope, point-slope, and slope-intercept

Two points, or one point and a slope, are all it takes to pin down a line. The points get lost in the slope formula's subtraction order, in a negative coordinate's sign, and in a distribution that stops halfway.

Short answer

Find the slope from two points with m = (y₂ − y₁) / (x₂ − x₁), subtracting in the same order on top and bottom. Put the slope and either point into point-slope form, y − y₁ = m(x − x₁). To get slope-intercept form y = mx + b, distribute m to both terms and move y₁ across. A horizontal line is y = c (slope 0); a vertical line is x = c (slope undefined). Parallel lines have equal slopes. Perpendicular slopes are negative reciprocals: flip the fraction and change the sign, so the two slopes multiply to −1.

Why it works

A line is the one shape whose steepness never changes: between any two of its points, the rise divided by the run is the same number, the slope m. So if (x₁, y₁) is a known point and (x, y) is any other point on the line, (y − y₁) / (x − x₁) = m. Multiply both sides by (x − x₁) and you have point-slope form. It isn't a formula to memorize so much as the definition of slope with the fraction cleared.

The order rule in the slope formula comes from the same place. Rise and run are both measured from one point to the other. If the top goes from point 1 to point 2, the bottom must too; mixing directions changes the sign of one and not the other.

For perpendicular lines, turning a line a quarter turn swaps its rise and run and reverses one of them. A slope of 23 (up 2, right 3) becomes right 2, down 3, which is −32. That's why you need both the flip and the sign change.

Example 1: two points to y = mx + b

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

  1. m = 9 − 35 − 2 = 63 = 2Point 2 minus point 1 on top and bottom. The y's go on top because slope is rise (change in y) over run (change in x).
  2. y − 3 = 2(x − 2)Point-slope form with the point (2, 3). Either point gives the same line.
  3. y − 3 = 2x − 4Distribute the 2 to both terms in the parentheses.
  4. y = 2x − 1Add 3 to both sides. Now it's in y = mx + b form with b = −1.

Check the other point: 2(5) − 1 = 9. Since the equation was built from (2, 3), testing (5, 9) is the check that actually tells you something.

Example 2: a negative coordinate

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

  1. m = −4 − 41 − (−3) = −84 = −2Same order top and bottom. Put −3 in parentheses so the two minus signs don't blur together: 1 − (−3) = 4.
  2. y − 4 = −2(x − (−3))Point-slope with (−3, 4). Write the formula's minus sign and the coordinate's sign separately.
  3. y − 4 = −2(x + 3)Subtracting −3 is adding 3.
  4. y − 4 = −2x − 6Distribute −2 to both terms: −2 · x and −2 · 3.
  5. y = −2x − 2Add 4 to both sides.

Check: −2(1) − 2 = −4 and −2(−3) − 2 = 4. Both points are on the line.

Example 3: perpendicular and parallel

Find the line through (4, 1) that is perpendicular to y = 23x + 5.

  1. m = −32The given slope is 2/3. Flip it to 3/2 and change the sign. Check: (2/3)(−3/2) = −1.
  2. y − 1 = −32(x − 4)Point-slope with (4, 1).
  3. y − 1 = −32x + 6Distribute: −3/2 times −4 is +6.
  4. y = −32x + 7Add 1 to both sides. Check (4, 1): −6 + 7 = 1.

The parallel line through the same point keeps the slope 2/3: y − 1 = 23(x − 4), which simplifies to y = 23x − 53. The +5 in the original equation plays no part in either answer; only the slope carries over.

Example 4: horizontal and vertical lines

Find the line through (3, −2) and (3, 5), and the line through (−1, 4) and (6, 4).

  1. m = 5 − (−2)3 − 3 = 70Division by zero: the slope is undefined. The x-coordinate never changes, so the line goes straight up and down.
  2. x = 3A vertical line is every point whose x is 3. There's no y in the equation, and it can't be written as y = mx + b.
  3. m = 4 − 46 − (−1) = 07 = 0Zero divided by a nonzero number is 0. The y-coordinate never changes, so the line is flat.
  4. y = 4This is y = 0x + 4: every point whose y is 4.

These two are perpendicular to each other, and they're the one pair the "slopes multiply to −1" test can't handle, because one slope doesn't exist. Vertical and horizontal lines are always perpendicular.

Common mistakes, and the exact line they happen on

1. Building the slope wrong: mismatched order, or run over rise

Line through (2, 3) and (5, 9) (Example 1).

  1. m = 9 − 32 − 5 = −2This is the mistake. The top goes from point 1 to point 2, the bottom from point 2 to point 1, so the sign is wrong. This leads to y = −2x + 7, which misses (5, 9): −2(5) + 7 = −3, not 9.
  1. m = 5 − 29 − 3 = 12This is the mistake. The x's are on top, which is run over rise. This leads to y = (1/2)x + 2, and at x = 5 that gives 4.5, not 9.

Either order of points works, as long as both subtractions use it. A quick sense check also helps: from (2, 3) to (5, 9) the line goes up as you move right, so the slope has to be positive, and it rises 6 over a run of 3, so it's steeper than 1.

2. Losing the sign of a negative coordinate

Point (−3, 4), slope −2 (Example 2).

  1. y − 4 = −2(x − 3)This is the mistake. The formula says x − x₁, and x₁ is −3, so it's x − (−3) = x + 3. Writing x − 3 uses the point (3, 4) instead. This leads to y = −2x + 10, and the original point fails: −2(−3) + 10 = 16, not 4.

Substitute with parentheses every time, x − (−3), and simplify on the next line. The same habit protects the slope formula's denominator.

3. Distributing the slope to only one term

  1. y − 4 = −2(x + 3)Correct so far (Example 2).
  2. y − 4 = −2x + 3This is the mistake. The −2 multiplies the x but not the 3. It should be −2x − 6. This leads to y = −2x + 7, which misses (1, −4): −2(1) + 7 = 5.

The slope multiplies everything inside the parentheses, including the sign. When m is negative, the constant usually changes sign too.

4. Calling a vertical line "slope 0"

Line through (3, −2) and (3, 5) (Example 4).

  1. m = 70 = 0, so y = −2This is the mistake. 7/0 isn't 0; it's undefined, because no number times 0 gives 7. The line y = −2 is horizontal, and it misses (3, 5) completely. The answer is x = 3.

Zero on top means slope 0 and a horizontal line, y = c. Zero on the bottom means no slope and a vertical line, x = c.

5. Doing only half of "negative reciprocal"

Perpendicular to y = 23x + 5 (Example 3).

  1. m = −23This is the mistake. Only the sign changed. (2/3)(−2/3) = −4/9, not −1, so the lines cross at a slant, not at a right angle.
  1. m = 32This is the mistake. Only the fraction flipped. (2/3)(3/2) = 1, not −1. Both lines rise to the right, so they can't meet at a right angle.

Multiply your new slope by the old one. If you don't get exactly −1, one of the two steps is missing.

Practice

  1. Find the equation of the line through (1, 2) and (4, 11) in slope-intercept form.

    Show answer

    m = (11 − 2)/(4 − 1) = 9/3 = 3. Then y − 2 = 3(x − 1), so y = 3x − 1. Check: 3(4) − 1 = 11.

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

    Show answer

    m = (−3 − 5)/(2 − (−2)) = −8/4 = −2. Then y − 5 = −2(x + 2) = −2x − 4, so y = −2x + 1. Check: −2(2) + 1 = −3.

  3. Write the line with slope 34 through (−4, 1) in point-slope form, then in slope-intercept form.

    Show answer

    Point-slope: y − 1 = 34(x + 4). Distribute: y − 1 = 34x + 3, so y = 34x + 4.

  4. Find the line through (2, −1) perpendicular to y = −4x + 3.

    Show answer

    The negative reciprocal of −4 is 14. Then y + 1 = 14(x − 2), so y = 14x − 32. Check: (−4)(1/4) = −1, and 1/2 − 3/2 = −1.

  5. Find the line through (−5, 2) and (−5, −7), and the line through (−5, 2) perpendicular to it.

    Show answer

    Both points have x = −5, so the run is 0 and the line is vertical: x = −5. A line perpendicular to a vertical line is horizontal, so through (−5, 2) it is y = 2.