Mathwords logoMathwords

Equation of a Line Through Two Points — Definition, Formula & Examples

The equation of a line through two points is a linear equation determined by substituting two known coordinate pairs into the slope formula, then using that slope with either point to write the line's equation. Given any two distinct points, this process produces the unique line passing through both.

Given two distinct points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) where x1x2x_1 \neq x_2, the equation of the line through them is yy1=m(xx1)y - y_1 = m(x - x_1), where m=y2y1x2x1m = \dfrac{y_2 - y_1}{x_2 - x_1}. If x1=x2x_1 = x_2, the line is vertical with equation x=x1x = x_1.

Key Formula

m=y2y1x2x1,yy1=m(xx1)m = \frac{y_2 - y_1}{x_2 - x_1}, \quad y - y_1 = m(x - x_1)
Where:
  • mm = Slope of the line
  • (x1,y1)(x_1, y_1) = First given point
  • (x2,y2)(x_2, y_2) = Second given point

How It Works

To find the equation, start by computing the slope from the two points using the slope formula. Then plug that slope and either point into point-slope form. Finally, simplify into slope-intercept form y=mx+by = mx + b if needed. You can verify your result by checking that both original points satisfy the final equation.

Worked Example

Problem: Find the equation of the line through the points (1, 2) and (4, 8).
Step 1: Find the slope: Use the slope formula with the two points.
m=8241=63=2m = \frac{8 - 2}{4 - 1} = \frac{6}{3} = 2
Step 2: Write in point-slope form: Substitute the slope and one of the points—here (1, 2)—into point-slope form.
y2=2(x1)y - 2 = 2(x - 1)
Step 3: Simplify to slope-intercept form: Distribute and solve for y.
y=2x2+2=2xy = 2x - 2 + 2 = 2x
Step 4: Verify: Check the second point (4, 8): y = 2(4) = 8. It checks out.
Answer: The equation of the line is y=2xy = 2x.

Another Example

Problem: Find the equation of the line through (-3, 7) and (5, 1).
Step 1: Find the slope: Compute the change in y over the change in x.
m=175(3)=68=34m = \frac{1 - 7}{5 - (-3)} = \frac{-6}{8} = -\frac{3}{4}
Step 2: Use point-slope form: Substitute the slope and the point (5, 1).
y1=34(x5)y - 1 = -\tfrac{3}{4}(x - 5)
Step 3: Convert to slope-intercept form: Distribute and isolate y.
y=34x+154+1=34x+194y = -\tfrac{3}{4}x + \tfrac{15}{4} + 1 = -\tfrac{3}{4}x + \tfrac{19}{4}
Answer: The equation is y=34x+194y = -\dfrac{3}{4}x + \dfrac{19}{4}.

Visualization

Why It Matters

This technique appears constantly in Algebra 1, Algebra 2, and on the SAT/ACT. In science and statistics, you often have two data points and need to model a trend between them—for instance, predicting future values from two known measurements. It also forms the foundation for more advanced topics like linear interpolation and constructing the line of best fit.

Common Mistakes

Mistake: Subtracting coordinates in different orders, such as computing (y₂ − y₁) in the numerator but (x₁ − x₂) in the denominator.
Correction: Always subtract in the same order. If you do y₂ − y₁ on top, you must do x₂ − x₁ on the bottom. Mixing the order flips the sign of the slope.
Mistake: Forgetting to distribute the slope to both terms inside the parentheses in point-slope form.
Correction: In yy1=m(xx1)y - y_1 = m(x - x_1), multiply m by both xx and x1-x_1. For example, y2=3(x4)y - 2 = 3(x - 4) becomes y2=3x12y - 2 = 3x - 12, not y2=3x4y - 2 = 3x - 4.

Check Your Understanding

Find the equation of the line through (0, 5) and (3, -1).
Hint: Start by finding the slope using the slope formula.
Answer: y=2x+5y = -2x + 5
Find the equation of the line through (-2, -4) and (6, 12).
Hint: The slope is 12(4)6(2)\frac{12 - (-4)}{6 - (-2)}.
Answer: y=2xy = 2x
Two points on a line are (10, 3) and (10, 9). What is the equation of the line?
Hint: What happens when both x-coordinates are the same?
Answer: x=10x = 10 (a vertical line — slope is undefined)

Related Terms