This note covers finding the gradient of a line from two points, the midpoint of a line segment, and its length using Pythagoras' theorem. These three measures describe how steep, where central and how long a line segment is, and they are used in maps, design and navigation. They also lead into finding equations of lines.
Key ideas
A point on a coordinate grid is written \((x,y)\). A line segment is the part of a line between two points, say \(A(x_1,y_1)\) and \(B(x_2,y_2)\).
Gradient. The gradient measures steepness: how far the line goes up for each unit it goes across.
- Gradient \(=\dfrac{\text{change in }y}{\text{change in }x}=\dfrac{y_2-y_1}{x_2-x_1}\).
- A line sloping up from left to right has a positive gradient. A line sloping down has a negative gradient.
- A horizontal line has gradient 0. A vertical line has an undefined gradient, because the change in \(x\) is zero and you cannot divide by zero.
- The order of the points does not matter, but you must use the same order on the top and the bottom. Subtracting the top the "wrong way round" and the bottom the other way gives the wrong sign.
On a graph, the same idea is "rise over run". Draw a right-angled triangle under the line, measure the vertical side (rise) and the horizontal side (run) using the scale, and divide.
Midpoint. The midpoint is the point halfway along the segment. Its coordinates are the means of the coordinates of the end points: add the two \(x\)-values and halve, then do the same for \(y\). If you know the midpoint and one end, you can work back to the other end by "doubling and subtracting".
Length. Join the points with a line, then make a right-angled triangle with horizontal side \(|x_2-x_1|\) and vertical side \(|y_2-y_1|\). The line segment is the hypotenuse, so by Pythagoras' theorem its length is the square root of the sum of the squares of these two sides. Leave the answer as a surd if the question asks for an exact value, or round it to 3 significant figures.
Using the results. Lengths can be used to show that a triangle is isosceles (two equal sides) or to find a perimeter. An unknown coordinate can be found by writing the gradient or length formula with a letter in it, setting it equal to the known value, and solving the resulting equation.
Definitions and formulae
| Term or formula | Meaning / when to use |
|---|---|
| \(m=\dfrac{y_2-y_1}{x_2-x_1}\) | Gradient of the line through \((x_1,y_1)\) and \((x_2,y_2)\). |
| \(M=\left(\dfrac{x_1+x_2}{2},\dfrac{y_1+y_2}{2}\right)\) | Midpoint of the segment joining the two points. |
| \(d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\) | Length of the segment, from Pythagoras' theorem. |
| Rise and run | The vertical and horizontal changes between two points on a line. |
| Positive, negative, zero gradient | Line goes up, goes down, or is horizontal as you move to the right. |
| Undefined gradient | A vertical line, where \(x_2-x_1=0\). |
Worked examples
Example 1 On a map grid (in kilometres), a cable runs between \(A(-2,1)\) and \(B(6,7)\). Find (a) the gradient of \(AB\), (b) the midpoint of \(AB\), (c) the length of \(AB\).
(a) The change in \(y\) is \(7-1=6\) and the change in \(x\) is \(6-(-2)=8\). Gradient \(=\dfrac{6}{8}=\dfrac34\).
(b) Add the \(x\)-values and halve: \(\dfrac{-2+6}{2}=2\). Add the \(y\)-values and halve: \(\dfrac{1+7}{2}=4\). The midpoint is \((2,4)\).
(c) Horizontal side 8 and vertical side 6. Length \(=\sqrt{8^2+6^2}=\sqrt{64+36}=\sqrt{100}=10\).
Answer: (a) \(\dfrac34\); (b) \((2,4)\); (c) 10 km
Example 2 (a) The line through \(P(2,k)\) and \(Q(6,9)\) has gradient 2. Find \(k\). (b) The midpoint of \(AB\) is \(M(3,-1)\) and \(A\) is \((-2,5)\). Find the coordinates of \(B\).
(a) Write the gradient formula: \(\dfrac{9-k}{6-2}=2\), so \(\dfrac{9-k}{4}=2\).
Multiply by 4: \(9-k=8\), so \(k=1\). Check: \(\dfrac{9-1}{4}=2\). Correct.
(b) Let \(B=(x,y)\). The midpoint formula gives \(\dfrac{-2+x}{2}=3\) and \(\dfrac{5+y}{2}=-1\).
Multiply by 2: \(-2+x=6\), so \(x=8\). And \(5+y=-2\), so \(y=-7\).
Check: the midpoint of \((-2,5)\) and \((8,-7)\) is \((3,-1)\). Correct.
Answer: (a) \(k=1\); (b) \(B=(8,-7)\)
Example 3 A triangle has vertices \(A(1,2)\), \(B(5,6)\) and \(C(9,2)\). Show that it is isosceles, and find the length \(EF\) between \(E(2,-3)\) and \(F(7,1)\) to 3 significant figures.
\(AB=\sqrt{(5-1)^2+(6-2)^2}=\sqrt{16+16}=\sqrt{32}\).
\(BC=\sqrt{(9-5)^2+(2-6)^2}=\sqrt{16+16}=\sqrt{32}\).
\(AB=BC\), so the triangle is isosceles. (For completeness, \(AC=\sqrt{8^2+0^2}=8\).)
\(EF=\sqrt{(7-2)^2+(1-(-3))^2}=\sqrt{25+16}=\sqrt{41}\). Use the square root key: \(\sqrt{41}=6.403\ldots\)
Answer: \(AB=BC=\sqrt{32}\), so isosceles; \(EF=6.40\) (3 s.f.)
Common errors
- Subtracting in different orders on the top and the bottom of the gradient, such as \(\dfrac{y_2-y_1}{x_1-x_2}\). This gives the wrong sign.
- Writing the gradient as change in \(x\) over change in \(y\). It is \(y\) over \(x\), "rise over run".
- Subtracting the coordinates for the midpoint instead of adding them and halving.
- Forgetting to square-root at the end of the length formula, or squaring a negative difference incorrectly. \((-4)^2=16\), not \(-16\).
- Thinking a vertical line has gradient 0. A horizontal line has gradient 0, and a vertical line has no defined gradient.
Exam tip: Sketch the two points quickly before you start. The sketch shows whether the gradient should be positive or negative and whether your length is believable.
Check yourself
- Find the gradient of the line through \((3,-2)\) and \((7,6)\).
Answer
\(\dfrac{6-(-2)}{7-3}=\dfrac{8}{4}=2\). - Find the midpoint of \((-4,3)\) and \((10,-9)\).
Answer
\(\left(\dfrac{-4+10}{2},\dfrac{3+(-9)}{2}\right)=(3,-3)\). - Find the exact length of the line from \((1,1)\) to \((4,-2)\).
Answer
\(\sqrt{3^2+(-3)^2}=\sqrt{18}=3\sqrt2\) (which is 4.24 to 3 s.f.). - The points \((0,5)\) and \((6,k)\) are 10 units apart, and \(k\) is positive. Find \(k\).
Answer
\(\sqrt{6^2+(k-5)^2}=10\), so \(36+(k-5)^2=100\) and \((k-5)^2=64\). Then \(k-5=\pm8\), so \(k=13\) or \(k=-3\). Since \(k\) is positive, \(k=13\).