Coordinate geometry · Lesson 2 of 3

Gradient and the equation of a line

The gradient from two points or from an equation, y = mx + c, the equation of a line through a point or through two points, parallel and perpendicular lines (equal gradients; m₁m₂ = −1), and the angle a line makes with the x-axis or with another line.

19 minYou should already know: Linear & simultaneous equations
  1. 1
  2. 2
  3. 3

The gradient of a line measures how steep it is: how far it goes up for every 1 across. Between two points A(x1,y1)A(x_1, y_1) and B(x2,y2)B(x_2, y_2) on it:

m=riserun=y2−y1x2−x1m = \frac{\text{rise}}{\text{run}} = \frac{y_2 - y_1}{x_2 - x_1}

A positive gradient goes up from left to right; a negative one goes down; a horizontal line has gradient 0; a vertical line has no gradient. A line at an angle θ\theta to the positive xx-axis has gradient tan⁡θ\tan\theta.

Every non-vertical straight line has an equation y=mx+cy = mx + c, where mm is the gradient and cc is the yy-intercept, where the line crosses the yy-axis. A point lies on the line exactly when its coordinates fit the equation.

xyABrunrise
Gradientm = rise ÷ run = (y₂ − y₁) ÷ (x₂ − x₁)
xyc1m
y = mx + cm is the rise for 1 across; c is where it crosses the y-axis

Try it

Two pointsDrag the gold points
−6−5−4−3−2−1123456−5−4−3−2−112345xy64A(−3, −2)B(3, 2)
4rise, y₂ − y₁6run, x₂ − x₁2/3gradient, rise ÷ run
Gradient = rise ÷ run = 4 ÷ 6 = 2/3. Positive: the line goes up from left to right. Take both differences in the same order, B minus A.

In “Gradient”, move BB below AA and watch the sign change, then line them up vertically. In “Equation”, the equation updates as you drag, and the green point shows cc.

To read the gradient from an equation like 3x+4y=123x + 4y = 12, make yy the subject first.

Finding the equation of a line

With the gradient mm and one point (x1,y1)(x_1, y_1) on the line:

y−y1=m(x−x1)y - y_1 = m(x - x_1)

With two points, find the gradient first, then use either point. Tidy the answer into the form the question asks for, such as y=mx+cy = mx + c or ax+by+c=0ax + by + c = 0.

Worked example · WAEC 2019

WAEC 2019 · Paper 2 · Q2 (a)

Find the equation of the line which passes through the points A(−2,7)A(-2, 7) and B(2,−3)B(2, -3).

  1. The gradient

    m=−3−72−(−2)=−104=−52m = \frac{-3 - 7}{2 - (-2)} = \frac{-10}{4} = -\frac52.

    Think first. Rise over run from A to B. Watch the signs.

  2. Use a point

    y−7=−52(x+2)y - 7 = -\frac52(x + 2).

    Think first. Which formula gives the line through A with this gradient?

  3. Clear the fraction

    2y−14=−5x−102y - 14 = -5x - 10, so 2y+5x−4=02y + 5x - 4 = 0. Check with B(2,−3)B(2, -3): −6+10−4=0-6 + 10 - 4 = 0 ✓.

    Think first. Multiply every term by 2.

Parallel and perpendicular lines

  • Parallel lines have equal gradients.
  • Perpendicular lines have gradients that multiply to −1-1: m1m2=−1m_1 m_2 = -1. So the perpendicular gradient is −1m-\frac{1}{m}: flip the fraction and change the sign.
xymm
ParallelSame gradient m
xym−1/m
Perpendicularm × (−1/m) = −1

Switch the board to “Parallel & perpendicular” and drag CC: both lines through it keep their gradients wherever CC goes.

Worked example · WAEC 2023

WAEC 2023 · Paper 2 · Q7 (b)

Given the points P(3,5)P(3, 5) and Q(−5,7)Q(-5, 7) on the Cartesian plane such that RR is the midpoint of PQ‾\overline{PQ}, find the equation of the line that passes through RR and is perpendicular to PQ‾\overline{PQ}.

  1. The midpoint R

    R=(3+(−5)2,5+72)=(−1,6)R = \left(\frac{3 + (-5)}{2}, \frac{5 + 7}{2}\right) = (-1, 6).

    Think first. Average the coordinates of P and Q.

  2. The gradient of PQ

    7−5−5−3=2−8=−14\frac{7 - 5}{-5 - 3} = \frac{2}{-8} = -\frac14.

    Think first. Rise over run.

  3. The perpendicular gradient

    m=4m = 4, since 4×(−14)=−14 \times \left(-\frac14\right) = -1.

    Think first. Flip and change the sign.

  4. The line through R

    y−6=4(x+1)y - 6 = 4(x + 1), so y=4x+10y = 4x + 10.

    Think first. Use y − y₁ = m(x − x₁).

The angle between two lines

A line at an angle θ\theta to the positive xx-axis rises tan⁡θ\tan\theta for every 1 across, so its gradient is

m=tan⁡θm = \tan\theta
xyθrunrise
Gradient and anglem = rise ÷ run = tan θ

To find the angle, find the gradient and use tan⁡−1\tan^{-1} (see the tangent ratio). For example, for the line y=3 x+1y = \sqrt3\,x + 1:

  • The gradient is m=3{m = \sqrt3}.
  • So tan⁡θ=3{\tan\theta = \sqrt3}.
  • So θ=60∘{\theta = 60^\circ}.

For two lines with gradients m1m_1 and m2m_2, the acute angle θ\theta between them satisfies

tan⁡θ=∣m1−m21+m1m2∣\tan\theta = \left|\frac{m_1 - m_2}{1 + m_1 m_2}\right|
xyθm₁m₂
The angle between two linestan θ = |(m₁ − m₂) ÷ (1 + m₁m₂)|

The bars (take the value without its sign) make the answer the acute angle. Two special cases fit the rules above:

  • Parallel lines have m1=m2m_1 = m_2: the top is 0, so θ=0∘\theta = 0^\circ.
  • Perpendicular lines have m1m2=−1m_1 m_2 = -1: the bottom is 0, so there is no tan⁡θ\tan\theta and θ=90∘\theta = 90^\circ.

Worked example · NECO 2022

NECO 2022 · Paper 1 · Q38

Find the acute angle between the lines x+4y=12x + 4y = 12 and 2y−x=−62y - x = -6.

  1. The first gradient

    • Take xx from both sides: 4y=−x+12{4y = -x + 12}.
    • Divide by 4: y=−14x+3{y = -\frac14x + 3}, so m1=−14{m_1 = -\frac14}.

    Think first. Make y the subject of x + 4y = 12.

  2. The second gradient

    • Add xx to both sides: 2y=x−6{2y = x - 6}.
    • Divide by 2: y=12x−3{y = \frac12x - 3}, so m2=12{m_2 = \frac12}.

    Think first. Make y the subject of 2y − x = −6.

  3. The top and the bottom

    • Top: −14−12=−34{-\frac14 - \frac12 = -\frac34}.
    • Bottom: 1+(−14)(12)=1−18=78{1 + \left(-\frac14\right)\left(\frac12\right) = 1 - \frac18 = \frac78}.

    Think first. Work out m₁ − m₂ and 1 + m₁m₂ separately.

  4. The angle

    • Divide: tan⁡θ=34÷78=34×87=67{\tan\theta = \frac34 \div \frac78 = \frac34 \times \frac87 = \frac67}.
    • Use tan⁡−1\tan^{-1}: θ≈40.6∘{\theta \approx 40.6^\circ}, option B.

    Think first. Divide, drop the sign, then use tan⁻¹.

More: the angle between two lines

Your turn

WAEC 2020 · Paper 2 · Q11 (b)

  1. (b)

    Find the equation of the line which has the same gradient as 8y+4x=248y + 4x = 24 and passes through the point (−8,12)(-8, 12).

Worked solution (try it first)

(b)

  1. 8y+4x=248y + 4x = 24 gives y=−12x+3y = -\frac12x + 3, so the gradient is −12-\frac12.
  2. Through (−8,12)(-8, 12): y−12=−12(x+8)y - 12 = -\frac12(x + 8), so y=−12x−4+12=−12x+8y = -\frac12x - 4 + 12 = -\frac12x + 8.

Report a problem with this question

More past questions like this