➗ Mathematics

Find the Equation of a Line From Two Points

Work out the gradient (slope), find the y-intercept and write the equation of a line, plus parallel and perpendicular lines and midpoints.

  • ⏱ 3 min read
  • ✏️ 3 worked examples
  • 🎯 5 practice questions
  • 📶 Intermediate
GCSEA-LevelHigh School

Curriculum fit: GCSE Maths Algebra (mainly Higher for perpendicular lines). US: Algebra I and Geometry (Expressing Geometric Properties with Equations).

On this page

What Is It?

If you know two points on a straight line, you can work out its equation. First find the gradient, then use one of the points to find the y-intercept.

Lines that are perpendicular (at right angles) have gradients that multiply to −1. This lets you find the equation of a perpendicular line through a given point.

xyA (1, 3)B (4, 9)run = 3rise = 6gradient m = 6 ÷ 3 = 2y = 2x + cuse A: 3 = 2 × 1 + c, so c = 1y = 2x + 1
Find the gradient with rise ÷ run, then substitute one point into y = mx + c to find c.

Key Formulas and Ideas

  • Gradient m = (y₂ − y₁) ÷ (x₂ − x₁).
  • Then substitute a point into y = mx + c to find c.
  • Perpendicular gradient = −1 ÷ m.
  • Midpoint of (x₁, y₁) and (x₂, y₂) = ((x₁ + x₂)/2, (y₁ + y₂)/2).

Worked Examples

Example 1

Equation From Two Points

Question

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

  1. Gradient: (9 − 5) ÷ (4 − 2) = 4 ÷ 2 = 2.
  2. Substitute (2, 5) into y = 2x + c: 5 = 4 + c, so c = 1.
  3. Write the equation: y = 2x + 1.

✓ Answer y = 2x + 1

Example 2

Perpendicular Line

Question

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

  1. Perpendicular gradient: −1 ÷ 2 = −½.
  2. Substitute (4, 1): 1 = −½ × 4 + c = −2 + c, so c = 3.
  3. Equation: y = −½x + 3.

✓ Answer y = −½x + 3

Example 3

Midpoint

Question

Find the midpoint of (−2, 3) and (6, 9).

  1. x: (−2 + 6) ÷ 2 = 2.
  2. y: (3 + 9) ÷ 2 = 6.

✓ Answer (2, 6)

Common Mistakes to Avoid

  • Subtracting the coordinates in a different order on top and bottom.
  • Finding the gradient but forgetting to find c.
  • Using the reciprocal without changing the sign for a perpendicular line.
  • Substituting the numbers into the wrong place in y = mx + c.

Practice Questions

0 of 5 answered
Q1Find the gradient through (1, 3) and (3, 7).
Q2A line has gradient 3 and passes through (1, 5). What is c?
Q3What is the gradient perpendicular to a line with gradient 4?
Q4Find the midpoint of (0, 0) and (8, 6).
Q5Which is the line through (0, 2) with gradient −1?

Frequently Asked Questions

Does it matter which point I use to find c?

No. Both points lie on the line, so either gives the same value of c.

What is the gradient of a vertical line?

It is undefined. A vertical line has an equation of the form x = k.

Take This Guide With You

Get a free printable PDF with the worked examples and quiz answers. Enter your email and the download starts straight away.

Sources and Review

Reviewed by StudyMorrow editorial review on 5 Nov 2026.