3.6 Writing the Equation of a Line Given Two Points

Learning Objectives

After completing this section, you should be able to:
  1. Find the slope of a line given two points.
  2. Write the equation of a line in slope-intercept form (y = mx + b).
  3. Use slope-intercept form to find equations of parallel and perpendicular lines.
  4. Recognize and write equations of vertical and horizontal lines.

Two Methods for Writing a Linear Equation

There are two common ways to find the equation of a line:
  • Slope-Intercept Form: Substitute the slope (m) and a known point ((x, y)) into y = mx + b, then solve for b.
  • Point-Slope Form: Use y - y_1 = m(x - x_1), where m is the slope and (x_1, y_1) is a point on the line.
Both methods lead to the same final equation.

Example 3.6.1 — Two methods

Find the equation of the line with slope 3 through (4,1).
Method 1: Using slope-intercept form
When you know one point and the slope, start with y = mx + b. Substitute the slope for m and the point (x,y) to find b.
We know x=4, y=1, and m=3. Substitute into y = mx + b and solve for b.
Solution (Method 1)
y = mx + b
1 = 3(4) + b
1 = 12 + b
b = -11
Equation: y = 3x - 11
Line y = 3x -11
Figure 3.6A
Method 2: Using point-slope form
Substitute (x_1,y_1)=(4,1) and m=3 into y-y_1 = m(x-x_1).
Solution (Method 2)
y - 1 = 3(x - 4)
y - 1 = 3x - 12
y = 3x - 11
This matches the equation from Method 1.
Optional: Where point-slope form comes from
Start with the slope formula using points (x_1,y_1) and (x,y) on the line:
m=\frac{y-y_1}{x-x_1}
Multiply both sides by (x-x_1):
m(x-x_1)=y-y_1
Rewriting gives point-slope form:
y-y_1=m(x-x_1)

Example 3.6.2

Find the equation of the line with slope -2 through (1,4).
Solution
Start with y = mx + b:
y = -2x + b
Substitute (1,4):
4 = -2(1) + b
4 = -2 + bb=6
Equation: y = -2x + 6
graph of y = -2x+6
Figure 3.6B

Try It


Finding the Equation Given Two Points

When two points are given, first find the slope:

m=\frac{y_2-y_1}{x_2-x_1}

Then use one point and the slope to solve for b in y = mx + b.

Example 3.6.3

Find the equation of the line through (2,4) and (3,7).
Solution
Step 1: Find the slope
m=\frac{7-4}{3-2}=\frac{3}{1}=3
Step 2: Solve for b using one point
y=mx+b
4=3(2)+b4=6+bb=-2
Equation: y=3x-2
line y =3x-2
Figure 3.6C

Example 3.6.4

Find the equation of the line through (-3,5) and (2,8).
Solution
Step 1: Find the slope
m=\frac{8-5}{2-(-3)}=\frac{3}{5}
Step 2: Solve for b using (2, 8)
8=\frac{3}{5}(2)+b8=\frac{6}{5}+b
b=8-\frac{6}{5}=\frac{40}{5}-\frac{6}{5}=\frac{34}{5}
Equation: y=\frac{3}{5}x+\frac{34}{5}
line y (3/5)x+34/5
Figure 3.6D

Try It


Writing Equations of Parallel and Perpendicular Lines

Parallel lines have the same slope.
Perpendicular lines have slopes that are negative reciprocals.

Example 3.6.5 — Parallel line

Write the equation of a line parallel to y=4x-7 and passing through (-3,1).
Solution
Parallel lines have the same slope, so m=4.
Graph of line y = 4x-7 and the point (-3,1)
Figure 3.6E
Use y=mx+b with point (-3,1):
1=4(-3)+b1=-12+bb=13
Equation: y=4x+13
Graph of both lines: y = 4x-7 and y = 4x + 13 (showing the line going through the point (-3,1)
Figure 3.6F

Example 3.6.6 — Perpendicular line

Write the equation of a line perpendicular to y=4x-7 and passing through (-3,1).
Graph of line y = 4x-7 and the point (-3,1)
Figure 3.6G
Solution
The perpendicular slope is the negative reciprocal of 4, so m=-\frac{1}{4}.
Use y=mx+b with point (-3,1):
1=\left(-\frac{1}{4}\right)(-3)+b1=\frac{3}{4}+b
b=1-\frac{3}{4}=\frac{1}{4}
Equation: y=-\frac{1}{4}x+\frac{1}{4}
Graph of the original line y = 4x - 7 and the graph of the line perpendicular y = (-1/4)x + 1/4
Figure 3.6H

Try It


Special Cases: Vertical and Horizontal Lines

Table 3.6
Line Type Description Example
Horizontal y = \text{constant} y=2
Vertical x = \text{constant} x=-3

Quick Reminder

Horizontal lines have slope 0. Vertical lines have undefined slope.

Example 3.6.7 — Horizontal and vertical lines

a) Find the equation of the line through (0,2) and (4,2).
Solution
Both points have the same y-value, so the line is horizontal.
Equation: y=2
b) Find the equation of the line through (-1,-3) and (-1,4).
Solution
Both points have the same x-value, so the line is vertical.
Equation: x=-1
Note: You don’t need to plot points for these equations. Just remember that y=\text{number} is a horizontal line and x=\text{number} is a vertical line.
Quick Tip: Horizontal lines: y=\text{number}    Vertical lines: x=\text{number}

Key Takeaways

  • To find slope: m=\frac{y_2-y_1}{x_2-x_1}
  • To find b: substitute one point into y=mx+b
  • Parallel lines → same slope
  • Perpendicular lines → negative reciprocal slopes
  • Horizontal lines → y=\text{constant} (slope 0)
  • Vertical lines → x=\text{constant} (undefined slope)

 

License

Icon for the Creative Commons Attribution-NonCommercial 4.0 International License

Essentials of Mathematics Copyright © 2026 by Scott McDaniel is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License, except where otherwise noted.