Skip to main content
← Back to all tools
📏

Equation of a Line Through 2 Points

y = mx + c automatically, from (x₁,y₁) to (x₂,y₂).

(1, 3)  →  (2, 5)
Equation of the line:
y = 2x + 1
Gradient
m = 2
y-intercept
c = 1
Step-by-step solution
Step 1 — Find the gradient m:
m = (y₂ − y₁) / (x₂ − x₁) = (53) / (21) = 2 / 1 = 2
Step 2 — Find c by substituting the point (x₁, y₁):
y = mx + c → c = y₁ − m·x₁ = 32 · 1 = 1
Step 3 — Result:
y = 2x + 1
Other forms of the same line
Gradient-intercept form (slope-intercept)
y = 2x + 1
Standard form
2x − y = −1
Point-gradient form (point-slope)
y − 3 = 2·(x − 1)
Graph
-2-11234-2-112345670(1, 3)(2, 5)
Examples

How do you find the equation of a line through 2 points?

Every line in the plane has a unique equation, and two different points are enough to pin it down completely. The most common form is y = mx + c, where m is the gradient (also called the slope — how much y rises for every unit of x) and c is the y-value where the line crosses the y-axis.

y = mx + c — the standard gradient-intercept form of a line's equation. To find it from two points you do two steps: first work out the gradient m = (y₂ − y₁) / (x₂ − x₁), then substitute one of the points into the equation and solve for c: c = y − m·x.

Three worked examples

Example 1: the points (1, 3) and (2, 5).
m = (5 − 3) / (2 − 1) = 2 / 1 = 2; c = 3 − 2·1 = 1; y = 2x + 1.
Example 2: the points (0, 4) and (3, −2).
m = (−2 − 4) / (3 − 0) = −6 / 3 = −2; c = 4 − (−2)·0 = 4; y = −2x + 4.
Example 3: the points (−2, 5) and (2, −3).
m = (−3 − 5) / (2 − (−2)) = −8 / 4 = −2; c = 5 − (−2)·(−2) = 5 − 4 = 1; y = −2x + 1.

Common mistake

Guessing c incorrectly— many students try to read off c just by eye. Always substitute one of the points after you've found m: once you know the gradient, take (x₁, y₁) or (x₂, y₂) and substitute it into y = mx + c. Both points must give the same c — a great way to check you haven't made a mistake.

💼 Where it's used:physics (uniform motion — position as a function of time), economics (price-quantity graphs, supply and demand), unit conversion (Celsius ⇄ Fahrenheit), and any situation where two quantities are in a linear relationship. This is the most fundamental equation in linear algebra — without it you can't understand regression, graphs, or higher-order functions.

How to use it

  • Enter the two coordinates (x₁, y₁) and (x₂, y₂).
  • The tool works out m = (y₂−y₁)/(x₂−x₁) and then c = y₁ − m·x₁.
  • When x₁ = x₂ the line is vertical, so the gradient is undefined — it shows x = c.
  • Forms shown: gradient-intercept, standard, and point-gradient.

Related tools

✍️ Written by the MathsUK teamChecked against the National Curriculum and GCSE specifications

We keep your progress and preferences in your browser only (local storage), and use analytics cookies to improve the site. Read the privacy notice.

More information