MathemagiciansLibraryExplorationsDeep Dives
← Mathematics · Upper Secondary
MathematicsUpper Secondary

Finding the equation of a straight line

U2 — Algebra Advancing › U2.4 — Linear and Quadratic GraphsLecture 3 of 5~2730 words

A plumber's bill with a hidden number

A plumber charges a fixed call-out fee, plus a rate for each hour of work. You do not know either number. You only have two of her old bills. A 2-hour job cost $85. A 5-hour job cost $145. How much does she charge just to come to your door?

0 1 2 3 4 5 6 0 $30 $60 $90 $120 $150 $180 Hours of work x Bill y in dollars (2, 85) (5, 145) ?
The two bills as points. The call-out fee is where the line meets the vertical axis, but the bills do not show that point. It has to be worked out. (An invented example.)

The call-out fee is the cost for 0 hours of work. On the graph, it is the -intercept, . In the last lecture, we read straight off a graph, because the line was drawn all the way to the -axis. That lecture also promised that this one would find the equation when the intercept is not visible. Here, nobody ever did a 0-hour job, so no bill shows the intercept. We have to work it out from the two points.

Why two points are enough

Through one point, you can draw as many straight lines as you like, at every possible angle. Add a second point, and only one of those lines passes through both. This is true for every pair of different points. So two points fix a straight line completely.

In the language of , the line has two unknown numbers, and . Each point gives us one fact. Two facts can fix two unknowns. We use them in a clear order.

First, the two points give the gradient. The last lecture showed that any two points on a line give the same value of . So the two bills tell us the rate:

The plumber charges $20 per hour.

Second, one point gives the intercept. The point lies on the line. This means that and must make the equation true. Substitute them:

So the equation is , and the call-out fee is $45. Read it as a sentence: $45 to arrive, then $20 for every hour.

Third, check with the other point. We used to find . The point has not been used yet, so it is a fair test: ✓. A check with the point you did not use catches almost every slip in this method.

The second step is the important one. A point lies on a line exactly when its coordinates make the equation true. That one sentence turns a point on a graph into an equation you can solve. Every method in this lecture comes from it.

Stop and think

"Two different points always fix a line of the form ." This sentence is nearly true. Can you find two points for which it fails?

Show the answer

Take and . They have the same -coordinate, so the line through them is vertical. The gradient would be , which is undefined. Two points still fix exactly one line, but that line is , and it cannot be written as . So when two points share an -coordinate, the answer is simply that number.

The same idea in one line: point–gradient form

There is a second way to write the method. Many textbooks use it, and it becomes the standard form at Pre-University level.

Suppose a line has gradient and passes through a known point . Let be any other point on the line. The gradient between these two points must also be , because every pair of points on a straight line gives the same gradient. So:

Multiply both sides by :

Point–gradient form

The line through the point with gradient is

A point is on the line exactly when this equation is true. Expanding and rearranging gives .

For the plumber, and the point is . So . Expand: . Add 85: . This is the same line, by a different route. Both routes use the same idea: the gradient is the same everywhere along the line.

Lines that never meet

Two lines are parallel when they point in exactly the same direction. Lines with the same direction rise by the same amount for each step of 1 across. So parallel lines have equal gradients.

The reason they never meet is worth seeing in algebra. Take and . If they met, there would be an with . Subtract from both sides: . That is impossible, so there is no meeting point. The gap between the lines is always 4 in the -direction, because both lines climb at the same rate.

So a line parallel to has gradient 3. Its intercept can be anything except 1, because with it would be the same line. One point on the new line is enough to find its .

Lines that meet at a right angle

Two lines are perpendicular when they meet at 90°. What is the link between their gradients? Before reading the answer, find it yourself.

Graph builder — turn a line until it makes a right angle

Line 1 (teal) is fixed. Choose its gradient with the buttons. Then change the gradient of Line 2 (dark) until the two lines meet at 90°. For each Line 1, write down the gradient of Line 2 that works, and look at the product of the two gradients.

Gradient of Line 1:

Line 1 has gradient 2. The table shows the angle between Line 1 and lines through the same point with other gradients.

Gradient of Line 2Angle between the linesProduct of the gradients
1≈ 18.4°2
0≈ 63.4°0
−0.25≈ 77.5°−0.5
−0.590°−1
−1≈ 71.6°−2

The right angle comes at exactly one gradient, , and there the product of the two gradients is . The same happens for every other Line 1: gradient needs , gradient needs 1, and gradient needs .

What did you find? For Line 1 with gradient 2, the right angle came at gradient . For , it came at . For , at 1. For , at . In every case, two things happened together. The new gradient was the old one turned upside down, with its sign changed. And the product of the two gradients was exactly .

Perpendicular gradients

If a line has gradient (not zero), every line perpendicular to it has gradient .

Equivalently, two lines with gradients and are perpendicular when .

The is called the negative reciprocal of . A pattern seen in four cases is not yet a reason, though. Here is why it must always happen. This is the hard part of the lecture. Spend time here.

Draw the step triangle of a line with gradient : 1 across and up. Now turn the whole picture through 90°, about the corner where the triangle meets the line. The line turns through 90°, so the turned line is perpendicular to the first. The triangle turns with it. Its "1 across" now points straight up, and its " up" now points to the left. Follow the steps below one at a time.

1 2 1 2 gradient 2 gradient −½
The teal step triangle (1 across, 2 up) turned through 90° about the marked corner. Its "1 across" becomes "1 up", and its "2 up" becomes "2 left". The turned triangle lies along the dark line, so the dark line has gradient . Both axes use the same scale.
Step through — what a quarter-turn does to a gradient

Press Next to add one step. Read the reason before you go on. Keep the figure above in view.

Each step gives one move and the reason it is allowed.

  • Step 1. Line 1 has gradient . Its step triangle goes 1 across and up. This is what gradient means.
  • Step 2. Turn the line and its triangle through 90° about the corner. A turn of 90° makes the new line perpendicular to Line 1.
  • Step 3. The side "1 across" now points up: it becomes "1 up". Turning anticlockwise through 90° takes "right" to "up".
  • Step 4. The side " up" now points left: it becomes " to the left". Turning anticlockwise through 90° takes "up" to "left".
  • Step 5. So Line 2 rises 1 while it moves to the left, which is a change in of . Moving left is a negative change in .
  • Step 6. Gradient of Line 2 . The definition of gradient.

Conclusion: . The product is for every non-zero , not just the four you tried.

That is it. That is the whole idea. A quarter-turn swaps "across" and "up", which turns the gradient upside down. It also reverses one direction, which gives the minus sign.

Two small cases sit outside the rule. A horizontal line has gradient 0, and has no meaning. A line perpendicular to it is vertical, and a vertical line has no gradient at all. So for a horizontal line and a vertical line, the product test cannot be used. They are still perpendicular. You simply recognise them: and meet at a right angle.

Stop and think

Are and perpendicular? Many students say yes, because the gradients have opposite signs.

Show the answer

No. The product of the gradients is , not . One line rises 2 for each 1 across, and the other falls 2 for each 1 across. The angle between them is about 53°. Changing the sign alone reflects the line in a vertical line through the point where they cross. It does not turn it through 90°. For a right angle you need both moves: turn the fraction upside down and change the sign. A line perpendicular to has gradient .

The midpoint and the perpendicular bisector

One more tool is needed for the last worked example. The midpoint of two points is halfway between them. Halfway in the -direction is the average of the two -coordinates. Halfway in the -direction is the average of the two -coordinates. So the midpoint of and is

The perpendicular bisector of a segment AB is the line that crosses AB at its midpoint, at a right angle. It has a beautiful property. Every point on it is the same distance from A as from B. To find its equation, you need two facts you now have: a point (the midpoint) and a gradient (the negative reciprocal of the gradient of AB).

Worked examples

Worked Example 1 — Two points with negative coordinates

Find the equation of the line through and .

Gradient. Keep the same point first on top and underneath. Brackets protect the negatives:

The line falls as increases, from 5 down to . So a negative gradient fits the picture.

Intercept. Substitute into : , so .

Equation. .

Check with the other point. ✓.

Worked Example 2 — Parallel to a line that is not in y = mx + c form

Find the equation of the line through that is parallel to .

Find the gradient first. The gradient is not 3. The number in front of is the gradient only when the equation reads "". So make the subject: , and so . The gradient is .

Parallel means the same gradient. The new line is .

Intercept. Substitute : , so .

Equation. . Multiply by 2 and rearrange to match the given line's style: .

Check. The point: ✓. The two lines and have the same left-hand side and different right-hand sides, so no point can lie on both. They are parallel ✓.

Worked Example 3 — Perpendicular through a point

Find the equation of the line through that is perpendicular to .

Perpendicular gradient. The given gradient is . Turn it upside down to get 3, then change the sign: .

Check the pair. ✓.

Intercept. Substitute into : , so .

Equation. . Check: ✓.

Worked Example 4 — A perpendicular bisector

Find the equation of the perpendicular bisector of A and B.

Step 1: the point. Midpoint M .

Step 2: the gradient of AB. .

Step 3: the perpendicular gradient. .

Step 4: the equation. Substitute M into : , so . The bisector is .

Check with the special property. Take another point on the bisector, such as . Its distance from A is . Its distance from B is . Equal ✓. The line really is the set of points equally far from A and B.

x y 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 O A(2, 1) B(6, 5) M(4, 3) y = −x + 7
The perpendicular bisector of AB passes through the midpoint M and meets AB at a right angle. AB rises 1 for each 1 across, and the bisector falls 1 for each 1 across: .

Three classic mistakes

Trap 1 — Doing only half of "negative reciprocal"

For a line with gradient , the perpendicular gradient is . Changing only the sign gives . Turning only the fraction upside down gives . Both are wrong. Multiply your answer by the original gradient every time. If the product is not , one of the two moves is missing.

Trap 2 — Reading the gradient before y is the subject

In , the gradient is not 3, and in it is not 1. The number in front of is the gradient only in the form . Rearrange first, then read . Worked Example 2 shows how.

Trap 3 — Judging a right angle by eye

The last lecture showed that the look of a line depends on the axis scales. Right angles depend on them too. On graph paper with different scales on the two axes, perpendicular lines do not look perpendicular, and lines that look perpendicular may not be. Trust , not the drawing. When you sketch, use the same scale on both axes if you can.

Try it yourself

Work each one on paper first. Open a hint only when you are stuck.

  1. Find the equation of the line through and . Check it with the point you did not use.

    Hint 1

    Find the gradient first, with the same point first on top and underneath.

    Hint 2

    . Then substitute into .

    Full answer

    . Substitute : , so . The line is . Check with : ✓. The line falls from left to right, which fits the negative gradient.

  2. Find the equation of the line through that is parallel to .

    Hint 1

    The gradient is not 2 and not . Make the subject of first.

    Hint 2

    , so . Parallel lines share the gradient .

    Full answer

    The given line is , with gradient . The new line is . Substitute : , so . The line is , or . Check: ✓. The intercepts 4 and are different, so the lines are parallel and not the same line ✓.

  3. Find the equation of the line through that is perpendicular to .

    Hint 1

    Turn upside down, and change its sign.

    Hint 2

    The perpendicular gradient is . Check: . Then substitute .

    Full answer

    Perpendicular gradient: , because ✓. Substitute into : , so . The line is . Check: ✓.

  4. On a map grid in kilometres, two villages are at A and B. A straight road runs along the line . A new water tank must stand on the road, the same distance from both villages. Where should it go? (An invented situation.)

    Hint 1

    Every point the same distance from A and B lies on the perpendicular bisector of AB. The tank is where that bisector meets the road.

    Hint 2

    The midpoint is , and the gradient of AB is . So the bisector has gradient . Find its equation, then put .

    Full answer

    Midpoint . Gradient of AB , so the bisector has gradient . Substitute : , so , and the bisector is . On the road, : , so and . The tank goes at . Check the distances: from A, ; from B, . Equal ✓, so each village is km from the tank.

The bigger idea

A straight line has two numbers, so it takes two facts to fix it: two points, or a point and a gradient. This counting idea runs through mathematics. A circle needs three facts, its centre's two coordinates and its radius, and three points that are not in a line fix exactly one circle. Its centre is where the perpendicular bisectors of the points meet, the same construction as Worked Example 4.

Real data rarely gives exactly two points. A scientist measuring a spring's stretch for ten different loads gets ten points that almost, but not exactly, lie on a line. No line passes through all ten. So the question changes: which line comes closest to all of them? Answering it is the job of the line of best fit, and later of linear regression, one of the most used tools in science and economics. It still produces one gradient and one intercept, read exactly as you read them here.

And the quarter-turn argument is the first sight of a bigger tool. With vectors, the direction "1 across, up" is written , and two directions are perpendicular exactly when a quantity called the dot product is zero. For and , that is . That is again, reached by a different road.

Key concepts in this lesson