Skip to the page
Home Campus
Start free

Gradient of a Line Through Two Points

Find the gradient of a straight line from the coordinates of two of its points with the formula m=y2−y1x2−x1,m = \frac{y_2 - y_1}{x_2 - x_1}\text{,} find an unknown coordinate from a given gradient, and use gradients to tell whether three points lie on one straight line.

Before you start

  • In Secondary 1 you found the gradient of a straight line from a right-angled step between two of its points: gradient=vertical changehorizontal change.\text{gradient} = \frac{\text{vertical change}}{\text{horizontal change}}\text{.} You went from the left-hand point to the right-hand point, so a line that goes up from left to right has a positive gradient, and a line that goes down from left to right has a negative gradient. Any two points on the line give the same gradient.
  • For example, from A(1,2)A(1, 2) to B(4,8)B(4, 8) the horizontal change is 4−1=34 - 1 = 3 and the vertical change is 8−2=68 - 2 = 6, so the gradient is 63=2\frac{6}{3} = 2.
  • In Secondary 2 you met the two special lines: a horizontal line y=ky = k has gradient 00, and a vertical line x=hx = h has no gradient: its gradient is undefined, because its horizontal change is 00.

The Gradient Formula

Two points with whole-number coordinates are easy to sketch. With negative coordinates, fractions or large numbers, a sketch is slow and a slip is easy. So we give the coordinates names and write the two changes as subtractions.

Call the two points A(x1,y1)A(x_1, y_1) and B(x2,y2)B(x_2, y_2). Here x1x_1 is read "xx one": it is the xx-coordinate of the first point. Going from AA to BB, the xx-coordinate changes from x1x_1 to x2x_2, so the horizontal change is x2−x1x_2 - x_1. The yy-coordinate changes from y1y_1 to y2y_2, so the vertical change is y2−y1y_2 - y_1.

The line through A(x₁, y₁) and B(x₂, y₂), with the step from A: the horizontal change x₂ − x₁ across, then the vertical change y₂ − y₁ up to Bxyx₂ − x₁y₂ − y₁−112345678−1123456OA(x₁, y₁)B(x₂, y₂)

The gradient formula

The gradient mm of the line through the points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2), where x1≠x2x_1 \ne x_2, is

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

Either point may be taken as (x1,y1)(x_1, y_1), but the subtraction on the top and the subtraction at the bottom must start from the same point. The point you start from is the one whose coordinates are taken away: going from AA to BB, both subtractions take away AA's coordinates.

If x2−x1=0x_2 - x_1 = 0, the two points are one above the other: the line is vertical and its gradient is undefined. If y2−y1=0y_2 - y_1 = 0, the line is horizontal and its gradient is 00.

Why may we start from either point? If we go from BB to AA instead, the top becomes y1−y2y_1 - y_2 and the bottom becomes x1−x2x_1 - x_2. Both have changed sign, and a fraction whose top and bottom both change sign has the same value: −3−4=34\frac{-3}{-4} = \frac{3}{4}.

The formula also takes care of the sign by itself. When the right-hand point is lower, the top and the bottom have opposite signs and the gradient comes out negative, as it should for a line that goes down from left to right.

Example 1: Using the formula

Find the gradient of the line through A(−1,2)A(-1, 2) and B(3,5)B(3, 5).

Solution

Take A(−1,2)A(-1, 2) as (x1,y1)(x_1, y_1) and B(3,5)B(3, 5) as (x2,y2)(x_2, y_2): x1=−1x_1 = -1, y1=2y_1 = 2, x2=3x_2 = 3, y2=5y_2 = 5.

m=y2−y1x2−x1=5−23−(−1)=34m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{5 - 2}{3 - (-1)} = \frac{3}{4}

Subtracting −1-1 is the same as adding 11, so the bottom is 3+1=43 + 1 = 4.

Check by starting from BB: m=2−5−1−3=−3−4=34,m = \frac{2 - 5}{-1 - 3} = \frac{-3}{-4} = \frac{3}{4}\text{,} the same.

Check with a sketch: from AA the step goes 44 across and 33 up, so the line goes up from left to right and the gradient is positive.

The line through A(−1, 2) and B(3, 5), with the step from A: 4 across, then 3 up to Bxy43−2−11234−1123456OA(−1, 2)B(3, 5)

The gradient of the line through AA and BB is 34\frac{3}{4}.

Example 2: Negative coordinates and a negative gradient

Find the gradient of the line through C(−4,−1)C(-4, -1) and D(2,−5)D(2, -5).

Solution

Take C(−4,−1)C(-4, -1) as (x1,y1)(x_1, y_1) and D(2,−5)D(2, -5) as (x2,y2)(x_2, y_2). Put each negative number in brackets as you substitute it.

m=y2−y1x2−x1=−5−(−1)2−(−4)=−5+12+4=−46=−23m = \frac{y_2 - y_1}{x_2 - x_1} = \frac{-5 - (-1)}{2 - (-4)} = \frac{-5 + 1}{2 + 4} = \frac{-4}{6} = -\frac{2}{3}

Check by starting from DD: m=−1−(−5)−4−2=4−6=−23.m = \frac{-1 - (-5)}{-4 - 2} = \frac{4}{-6} = -\frac{2}{3}\text{.}

Check the sign: CC is the left-hand point (−4<2-4 < 2) and it is higher (−1>−5-1 > -5), so the line goes down from left to right. A negative gradient is right.

The gradient of the line through CC and DD is −23-\frac{2}{3}.

An Unknown Coordinate from a Given Gradient

If the gradient is known and one coordinate of a point is not, substitute everything you know into the formula. This gives an equation with one unknown. Solve it, then check by working out the gradient with the value you found.

Example 3: An unknown y-coordinate

The line through P(1,3)P(1, 3) and Q(5,k)Q(5, k) has gradient 22. Find the value of kk.

Solution

Take P(1,3)P(1, 3) as (x1,y1)(x_1, y_1) and Q(5,k)Q(5, k) as (x2,y2)(x_2, y_2).

k−35−1=2\frac{k - 3}{5 - 1} = 2

k−34=2\frac{k - 3}{4} = 2

Multiply both sides by 44: k−3=8k - 3 = 8.

Add 33 to both sides: k=11k = 11.

Check: the line through (1,3)(1, 3) and (5,11)(5, 11) has gradient 11−35−1=84=2.\frac{11 - 3}{5 - 1} = \frac{8}{4} = 2\text{.}

k=11k = 11

Example 4: An unknown x-coordinate

The line through A(h,4)A(h, 4) and B(3,−2)B(3, -2) has gradient −32-\frac{3}{2}. Find the value of hh.

Solution

Take A(h,4)A(h, 4) as (x1,y1)(x_1, y_1) and B(3,−2)B(3, -2) as (x2,y2)(x_2, y_2).

−2−43−h=−32\frac{-2 - 4}{3 - h} = -\frac{3}{2}

−63−h=−32\frac{-6}{3 - h} = -\frac{3}{2}

The unknown is at the bottom. Multiply both sides by 2(3−h)2(3 - h) to clear both fractions: −6×2=−3(3−h).-6 \times 2 = -3(3 - h)\text{.}

Expand: −12=−9+3h-12 = -9 + 3h.

Add 99 to both sides: −3=3h-3 = 3h, so h=−1h = -1.

Check: the line through (−1,4)(-1, 4) and (3,−2)(3, -2) has gradient −2−43−(−1)=−64=−32.\frac{-2 - 4}{3 - (-1)} = \frac{-6}{4} = -\frac{3}{2}\text{.}

h=−1h = -1

Three Points on One Straight Line

Points that lie on one straight line are called collinear. Gradients give a quick test. Find the gradient of ABAB and the gradient of BCBC. If they are different, the path from AA to BB to CC bends at BB, so the points are not collinear.

If the gradients are equal, the two segments are equally steep and they share the point BB. A line with a given gradient through a given point is fixed, so ABAB and BCBC are parts of one line. The shared point matters: two segments with equal gradients and no point in common may lie on two different parallel lines.

Collinear points

Points AA, BB and CC are collinear (they lie on one straight line) when the gradient of ABAB is equal to the gradient of BCBC. The point BB is on both segments.

If the two gradients are different, the points are not collinear. (If ABAB and BCBC are both vertical, the three points have the same xx-coordinate and lie on one vertical line.)

Example 5: Collinear or not?

The points A(−2,−7)A(-2, -7), B(0,−3)B(0, -3), C(6,9)C(6, 9) and D(6,5)D(6, 5) are given. (a) Show that AA, BB and CC are collinear. (b) Determine whether AA, BB and DD are collinear.

Solution

(a) Gradient of AB=−3−(−7)0−(−2)=42=2.AB = \frac{-3 - (-7)}{0 - (-2)} = \frac{4}{2} = 2\text{.}

Gradient of BC=9−(−3)6−0=126=2.BC = \frac{9 - (-3)}{6 - 0} = \frac{12}{6} = 2\text{.}

The gradients are equal and BB is on both ABAB and BCBC, so AA, BB and CC lie on one straight line.

(b) The gradient of ABAB is 22, as in (a). Gradient of BD=5−(−3)6−0=86=43.BD = \frac{5 - (-3)}{6 - 0} = \frac{8}{6} = \frac{4}{3}\text{.}

Since 43≠2\frac{4}{3} \ne 2, the line bends at BB: DD is not on the line through AA and BB.

The points A(−2, −7), B(0, −3) and C(6, 9) on one straight line; D(6, 5) is below C, and the dashed segment BD is less steep than the linexy−3−2−11234567−8−6−4−2246810OA(−2, −7)B(0, −3)C(6, 9)D(6, 5)

In this drawing one square on the yy-axis is 22 units, but one square on the xx-axis is 11 unit, so the line looks less steep than a gradient of 22. Read the numbers on the axes, not the squares.

(a) The gradients of ABAB and BCBC are both 22, so AA, BB and CC are collinear. (b) The gradients of ABAB and BDBD are 22 and 43\frac{4}{3}, so AA, BB and DD are not collinear.

In lesson 4.6 you will use this test, with the lengths of lesson 4.2, to solve problems about triangles and quadrilaterals drawn from coordinates.

Common Mistakes

  • Subtracting in different orders. −2−4−3−5\frac{-2 - 4}{-3 - 5} for the line through P(−3,4)P(-3, 4) and Q(5,−2)Q(5, -2) goes from PP to QQ on the top but from QQ to PP at the bottom. Start both subtractions from the same point: −2−45−(−3)=−68=−34.\frac{-2 - 4}{5 - (-3)} = \frac{-6}{8} = -\frac{3}{4}\text{.}
  • Putting the xx-coordinates on top. The gradient is the vertical change over the horizontal change: the yy-coordinates go on top.
  • Losing a minus sign. 3−(−1)=43 - (-1) = 4, not 22. Put each negative coordinate in brackets when you substitute it.
  • Writing a division by 00. If x2−x1=0x_2 - x_1 = 0, do not write a fraction: say that the line is vertical and its gradient is undefined.
  • Testing three points with two segments that share no point. Compare the gradients of two segments that share a point, such as ABAB and BCBC: equal gradients alone do not put the points on one line.

Practice Questions

Work each question on paper before you open its solution. The questions get harder as you go.

Question 1

Find the gradient of the line through each pair of points. (a) (2,3)(2, 3) and (5,12)(5, 12) (b) (−1,5)(-1, 5) and (3,−3)(3, -3) (c) (0,0)(0, 0) and (−4,6)(-4, 6)

ShowHide solution

(a) m=12−35−2=93=3m = \frac{12 - 3}{5 - 2} = \frac{9}{3} = 3

(b) m=−3−53−(−1)=−84=−2m = \frac{-3 - 5}{3 - (-1)} = \frac{-8}{4} = -2

(c) m=6−0−4−0=6−4=−32m = \frac{6 - 0}{-4 - 0} = \frac{6}{-4} = -\frac{3}{2}

(a) 33 (b) −2-2 (c) −32-\frac{3}{2}

Question 2

Find the gradient of the line through each pair of points, if it has one. (a) (−5,−2)(-5, -2) and (−1,6)(-1, 6) (b) (3,−4)(3, -4) and (−6,2)(-6, 2) (c) (−2,7)(-2, 7) and (4,7)(4, 7) (d) (3,1)(3, 1) and (3,−5)(3, -5)

ShowHide solution

(a) m=6−(−2)−1−(−5)=84=2m = \frac{6 - (-2)}{-1 - (-5)} = \frac{8}{4} = 2

(b) m=2−(−4)−6−3=6−9=−23m = \frac{2 - (-4)}{-6 - 3} = \frac{6}{-9} = -\frac{2}{3}

(c) m=7−74−(−2)=06=0.m = \frac{7 - 7}{4 - (-2)} = \frac{0}{6} = 0\text{.} Both points have yy-coordinate 77: the line is the horizontal line y=7y = 7.

(d) x2−x1=3−3=0x_2 - x_1 = 3 - 3 = 0, so the gradient is undefined: both points have xx-coordinate 33, and the line is the vertical line x=3x = 3.

(a) 22 (b) −23-\frac{2}{3} (c) 00 (d) undefined: the line x=3x = 3 is vertical.

Question 3

Siti finds the gradient of the line through P(−2,5)P(-2, 5) and Q(4,1)Q(4, 1) like this: m=1−5−2−4=−4−6=23.m = \frac{1 - 5}{-2 - 4} = \frac{-4}{-6} = \frac{2}{3}\text{.} Explain her mistake and find the correct gradient.

ShowHide solution

On the top she went from PP to QQ (1−51 - 5 is QQ's yy-coordinate minus PP's), but at the bottom she went from QQ to PP (−2−4-2 - 4 is PP's xx-coordinate minus QQ's). Both subtractions must start from the same point.

Starting from PP in both: m=1−54−(−2)=−46=−23.m = \frac{1 - 5}{4 - (-2)} = \frac{-4}{6} = -\frac{2}{3}\text{.}

Check the sign: QQ is to the right of PP and lower, so the line goes down from left to right and its gradient is negative.

She subtracted in different orders on the top and at the bottom. The gradient is −23-\frac{2}{3}.

Question 4

The line through A(3,−1)A(3, -1) and B(7,k)B(7, k) has gradient 52\frac{5}{2}. Find the value of kk.

ShowHide solution

k−(−1)7−3=52,\frac{k - (-1)}{7 - 3} = \frac{5}{2}\text{,} so k+14=52\frac{k + 1}{4} = \frac{5}{2}.

Multiply both sides by 44: k+1=10k + 1 = 10, so k=9k = 9.

Check: 9−(−1)7−3=104=52.\frac{9 - (-1)}{7 - 3} = \frac{10}{4} = \frac{5}{2}\text{.}

k=9k = 9

Question 5

The line through C(p,6)C(p, 6) and D(1,−4)D(1, -4) has gradient 22. Find the value of pp.

ShowHide solution

−4−61−p=2\frac{-4 - 6}{1 - p} = 2, so −101−p=2\frac{-10}{1 - p} = 2.

Multiply both sides by (1−p)(1 - p): −10=2(1−p)=2−2p.-10 = 2(1 - p) = 2 - 2p\text{.}

Add 2p2p and add 1010 to both sides: 2p=122p = 12, so p=6p = 6.

Check: −4−61−6=−10−5=2.\frac{-4 - 6}{1 - 6} = \frac{-10}{-5} = 2\text{.}

p=6p = 6

Question 6

Determine whether the points A(−3,8)A(-3, 8), B(1,2)B(1, 2) and C(5,−4)C(5, -4) are collinear.

ShowHide solution

Gradient of AB=2−81−(−3)=−64=−32.AB = \frac{2 - 8}{1 - (-3)} = \frac{-6}{4} = -\frac{3}{2}\text{.}

Gradient of BC=−4−25−1=−64=−32.BC = \frac{-4 - 2}{5 - 1} = \frac{-6}{4} = -\frac{3}{2}\text{.}

The gradients are equal and BB is on both segments.

The points AA, BB and CC are collinear.

Question 7

Determine whether the points P(−4,−3)P(-4, -3), Q(0,−1)Q(0, -1) and R(5,2)R(5, 2) are collinear.

ShowHide solution

Gradient of PQ=−1−(−3)0−(−4)=24=12.PQ = \frac{-1 - (-3)}{0 - (-4)} = \frac{2}{4} = \frac{1}{2}\text{.}

Gradient of QR=2−(−1)5−0=35.QR = \frac{2 - (-1)}{5 - 0} = \frac{3}{5}\text{.}

12≠35\frac{1}{2} \ne \frac{3}{5} (as decimals, 0.50.5 and 0.60.6), so the line bends at QQ.

The points PP, QQ and RR are not collinear.

Question 8

The points P(2,1)P(2, 1), Q(6,3)Q(6, 3) and R(k,6)R(k, 6) lie on one straight line. Find the value of kk.

ShowHide solution

Gradient of PQ=3−16−2=24=12.PQ = \frac{3 - 1}{6 - 2} = \frac{2}{4} = \frac{1}{2}\text{.}

The points are collinear, so the gradient of QRQR is also 12\frac{1}{2}: 6−3k−6=12\frac{6 - 3}{k - 6} = \frac{1}{2}.

Multiply both sides by 2(k−6)2(k - 6): 3×2=k−63 \times 2 = k - 6, so k−6=6k - 6 = 6 and k=12k = 12.

Check: the gradient of QRQR is 6−312−6=36=12.\frac{6 - 3}{12 - 6} = \frac{3}{6} = \frac{1}{2}\text{.}

k=12k = 12

Question 9

A side view of a walkway is drawn with axes in metres. Ramp 1 runs straight from (0,0)(0, 0) to (6,0.45)(6, 0.45). After a flat landing, ramp 2 runs straight from (7.5,0.45)(7.5, 0.45) to (11.5,0.85)(11.5, 0.85). A ramp for wheelchairs should have a gradient of at most 112\frac{1}{12}. Which ramp meets this rule?

ShowHide solution

Gradient of ramp 1 =0.45−06−0=0.456=0.075.= \frac{0.45 - 0}{6 - 0} = \frac{0.45}{6} = 0.075\text{.}

Gradient of ramp 2 =0.85−0.4511.5−7.5=0.44=0.1.= \frac{0.85 - 0.45}{11.5 - 7.5} = \frac{0.4}{4} = 0.1\text{.}

112=0.0833…\frac{1}{12} = 0.0833\ldots Ramp 1: 0.075<0.0833…0.075 < 0.0833\ldots, so it meets the rule. Ramp 2: 0.1>0.0833…0.1 > 0.0833\ldots, so it is too steep.

Ramp 1 meets the rule (gradient 0.0750.075); ramp 2 is too steep (gradient 0.10.1).

Question 10

A plan of a park is drawn with axes in metres. Three lamp posts stand at L(−20,10)L(-20, 10), M(10,25)M(10, 25) and N(70,55)N(70, 55). A gardener wants to hang a string of lights in a straight line from LL through MM to NN. Are the three lamp posts in one straight line?

ShowHide solution

Gradient of LM=25−1010−(−20)=1530=12.LM = \frac{25 - 10}{10 - (-20)} = \frac{15}{30} = \frac{1}{2}\text{.}

Gradient of MN=55−2570−10=3060=12.MN = \frac{55 - 25}{70 - 10} = \frac{30}{60} = \frac{1}{2}\text{.}

The gradients are equal and MM is on both segments, so LL, MM and NN are collinear.

Yes: the gradients of LMLM and MNMN are both 12\frac{1}{2}, so the three lamp posts are in one straight line.

Question 11

The line through A(1,k)A(1, k) and B(k,4)B(k, 4) has gradient 22. Find the value of kk, and write down the coordinates of AA and BB.

ShowHide solution

4−kk−1=2\frac{4 - k}{k - 1} = 2

Multiply both sides by (k−1)(k - 1): 4−k=2(k−1)=2k−2.4 - k = 2(k - 1) = 2k - 2\text{.}

Add kk and add 22 to both sides: 6=3k6 = 3k, so k=2k = 2.

Then AA is (1,2)(1, 2) and BB is (2,4)(2, 4). Check: 4−22−1=21=2.\frac{4 - 2}{2 - 1} = \frac{2}{1} = 2\text{.}

k=2k = 2; A(1,2)A(1, 2) and B(2,4)B(2, 4).

Key Points

  • The gradient of the line through (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is m=y2−y1x2−x1,m = \frac{y_2 - y_1}{x_2 - x_1}\text{,} where x1≠x2x_1 \ne x_2.
  • Either point may be taken as (x1,y1)(x_1, y_1), but the top and the bottom must start from the same point.
  • Put negative coordinates in brackets when you substitute them: 3−(−1)=43 - (-1) = 4.
  • If x2−x1=0x_2 - x_1 = 0, the line is vertical and has no gradient; if y2−y1=0y_2 - y_1 = 0, the line is horizontal and its gradient is 00.
  • An unknown coordinate: substitute into the formula with the given gradient, solve the equation, and check.
  • Points AA, BB and CC are collinear when the gradient of ABAB equals the gradient of BCBC; BB is on both segments.

Previous lesson3.8 Simple and Compound Interest Next lesson4.2 Length of a Line Segment

All Secondary 3 (Grade 9) lessons

Home Campus has lessons for Primary 3 to Secondary 4, and practice questions with worked solutions and worksheets for Primary 3 to Secondary 2. Register free to practise and keep track of progress.

This lesson follows the Singapore Secondary 3 syllabus and was checked question by question before it was published. Spotted a mistake? Tell us.