Math Explainer.

Finding the equation of a line: two points, or one point and the gradient

Ages 14–16GCSE (A9c, A10, R14)

What you will learn

Exactly one straight line passes through two different points. You learn to find its equation y=mx+cy = mx + c: first the gradient mm, then the yy-intercept cc.

Think first: does a vertical line have a gradient too? Does it fit the form y=mx+cy = mx + c? Then check: drag B straight above A.

The line through two points A and B, with a triangle that shows its gradientA coordinate grid from −7 to 7 on both axes; the numbers from −6 to 6 are at the left and bottom edges of the grid. Drag the points A and B onto grid points from −6 to 6, move them with the arrow keys or type their coordinates into the boxes; they always stay at least 2 units apart. The green line passes through both points, from edge to edge of the grid. Between A and B a right-angled triangle is drawn in dashed lines; its two dashed sides are labelled with their lengths. A small dark dot shows where the line crosses the y-axis, as long as this place lies on the grid. When A and B are at the same height or one directly above the other, there is no triangle. Under the coordinate boxes is the calculation: the gradient m, the y-intercept c and the equation.
A
B
m=4−(−2)2−(−2)=64=32−2=32×(−2)+cc=−2+3=1y=32x+1\begin{aligned} m &= \frac{4 - (-2)}{2 - (-2)} \rule[-0.94em]{0pt}{2.37em} \\ &= \frac{6}{4} = \frac{3}{2} \rule[-0.77em]{0pt}{2.1em} \\ -2 &= \frac{3}{2} \times (-2) + c \rule[-0.77em]{0pt}{2.1em} \\ c &= -2 + 3 = 1 \rule[-0.77em]{0pt}{2.1em} \\ y &= \frac{3}{2}x + 1 \rule[-0.77em]{0pt}{2.1em} \end{aligned}

The line through A(−2, −2) and B(2, 4) has gradient 3/2 and y-intercept 1. Its equation is y = 3/2 × x + 1.

First the gradient

If A and B lie one directly above the other, there is no step to the right, and you cannot divide by 00: the line has no gradient. All its points have the same xx, for example 22; then the equation is x=2x = 2, in general x=ax = a.

Otherwise divide the difference in the yy-coordinates by the difference in the xx-coordinates, both from A to B:

m=yB−yAxB−xAm = \frac{y_B - y_A}{x_B - x_A}

From the lower point to the upper one it is 22 to the right and 44 up: the gradient is the way up divided by the way to the right.

Self-check

A line passes through the points (1,1)(1, 1) and (3,7)(3, 7). What is its gradient mm?

Show the solution

m=7−13−1=62=3m = \frac{7 - 1}{3 - 1} = \frac{6}{2} = 3. For every step to the right the line rises by 33.

Example 1

A line passes through the points A(1,2)A(1, 2) and B(3,8)B(3, 8). What is its equation?

  1. 01

    Work out the gradient: the difference in the yy-coordinates divided by the difference in the xx-coordinates.

    m=8−23−1=62=3m = \frac{8 - 2}{3 - 1} = \frac{6}{2} = 3
  2. 02

    Substitute m=3m = 3 and the coordinates of A into y=mx+cy = mx + c.

    2=3×1+c2 = 3 \times 1 + c
  3. 03

    Solve for cc: subtract 33 from both sides.

    c=2−3=−1c = 2 - 3 = -1
  4. 04

    Substitute mm and cc into the equation.

    y=3x−1y = 3x - 1
Answer

The equation is y=3x−1y = 3x - 1. Check with the point B: 3×3−1=83 \times 3 - 1 = 8, which is right.

A point and the gradient

Sometimes you know one point and the gradient. Then only cc is missing: substitute the gradient and the coordinates of the point into y=mx+cy = mx + c and solve for cc.

In the figure the point lies to the right of the yy-axis: from it you go back along the line to the yy-axis. From a point on the left you would go forwards.

From the point at height 33 you go 22 down and 11 to the left, twice: the line crosses the yy-axis at c=3−2×2=−1c = 3 - 2 \times 2 = -1.

Example 2

A line has gradient m=−2m = -2 and passes through the point P(2,3)P(2, 3). What is its equation?

  1. 01

    Substitute m=−2m = -2 and the coordinates of P into y=mx+cy = mx + c.

    3=−2×2+c3 = -2 \times 2 + c
  2. 02

    Work out the product.

    3=−4+c3 = -4 + c
  3. 03

    Solve for cc: add 44 to both sides.

    c=3+4=7c = 3 + 4 = 7
  4. 04

    Substitute mm and cc into the equation.

    y=−2x+7y = -2x + 7
Answer

The equation is y=−2x+7y = -2x + 7. Check with P: −2×2+7=3-2 \times 2 + 7 = 3, which is right. Because mm is negative, the line falls.

Self-check

A line passes through the point (0,4)(0, 4) and has gradient 22. What is its equation?

Your answer
Show the solution

y=2x+4y = 2x + 4. The point (0,4)(0, 4) lies on the yy-axis, so c=4c = 4, and the gradient is m=2m = 2. In y=4x+2y = 4x + 2 the two numbers are swapped, and y=2x−4y = 2x - 4 crosses the yy-axis at −4-4.

Self-check

A line has gradient 44 and passes through the point (2,5)(2, 5). What is its yy-intercept cc?

Show the solution

5=4×2+c5 = 4 \times 2 + c, so 5=8+c5 = 8 + c and c=5−8=−3c = 5 - 8 = -3. The equation is y=4x−3y = 4x - 3.

For teachers: a lesson plan (45 min)
  1. 5 min

    Starter

    First ask without the simulation: how many lines pass through one point, and how many through two? And does a vertical line have a gradient too? The class makes its guesses. Then open the simulation with ‘Full screen’: someone drags B straight above A.

  2. 10 min

    First the gradient

    The figure with the triangle on the line: what would the gradient be if the upper point were two squares lower? Then the first self-check, each pupil on their own.

  3. 10 min

    From two points

    Reveal Example 1 step by step together. Then the class substitutes B instead of A in the second step: does the same cc come out?

  4. 15 min

    A point and the gradient

    The figure with the arrows back to the yy-axis: where would the line cross the yy-axis if the given point were one square higher? Discuss the ‘Watch out’ box. Let pupils try Example 2 on their own first, then reveal it and compare. The second and third self-checks, alone or in pairs.

  5. 5 min

    Plenary

    Read the ‘Remember’ box together. Ask: why do you get the same gradient when you swap A and B?

Got an exercise on paper?

Take a photo of it and Math Explainer turns it into an explainer video with every step of the solution.

Upload a photo