The Equation of a Line Through Two Points

Gradient first, then anchor it.

Two points fix a line

Through a single point there are lines of every steepness. Through two points there is only one straight line. So the two points (1, 3) and (3, 7) are enough to find its equation, y = mx + c: the gradient m first, then the y-intercept c.

The gradient first

From (1, 3) to (3, 7), the rise is 7 − 3 = 4 and the run is 3 − 1 = 2. The gradient is the rise divided by the run: m = 4 / 2 = 2.

xyrun 2rise 4

The one line through (1, 3) and (3, 7). The run between them is 2 and the rise is 4, so the gradient is 2. The line crosses the y-axis at 1.

Then either point fixes c

Now the line is y = 2x + c, and c is the only unknown. Every point on the line makes the equation true, so put in the coordinates of (1, 3): 3 = 2 × 1 + c, so 3 = 2 + c and c = 1. The equation is y = 2x + 1.

Either point gives the same c. With (3, 7): 7 = 2 × 3 + c = 6 + c, so again c = 1.

Point-slope form reaches the same line. Through (1, 3) with gradient 2, it is y − 3 = 2(x − 1). Expand the bracket: y − 3 = 2x − 2. Add 3 to both sides: y = 2x + 1.

Check with the other point

If (1, 3) was used to find c, then (3, 7) has not been used yet, and it makes a check. Put x = 3 into y = 2x + 1: 2 × 3 + 1 = 7, which is the y-coordinate of (3, 7). The line passes through both points, so the equation is right.

A check that fails means a slip somewhere: most often a sign in the gradient, or c found by adding where it should have been subtracted.

A line that slopes down

Find the line through (−2, 5) and (4, 2). The rise is 2 − 5 = −3 and the run is 4 − (−2) = 6, so m = −3 / 6 = −1/2.

So y = −x/2 + c. Put in (−2, 5): 5 = −(−2)/2 + c = 1 + c, so c = 4, and the line is y = −x/2 + 4. Check with (4, 2): −4/2 + 4 = −2 + 4 = 2.

To clear the fraction, multiply every term by 2: 2y = −x + 8. Add x to both sides: x + 2y = 8, the same line in the form Ax + By = C.

xyrun 6rise −3

The line through (−2, 5) and (4, 2): a run of 6 with a rise of −3, so the gradient is −1/2. It crosses the y-axis at 4 and the x-axis at 8, where x + 2y = 8 with y = 0.

Same x, or same y

Through (−1, 4) and (5, 4) the rise is 0, so m = 0 and y = 0x + c. Every point on the line has y = 4, so the equation is y = 4, a level line.

Through (3, 1) and (3, 6) the run is 0, and 5 ÷ 0 has no answer: the line is vertical and has no gradient. Every point on it has x = 3, so its equation is x = 3. It cannot be written as y = mx + c, but it is Ax + By = C with A = 1, B = 0 and C = 3.

Is a third point on the line?

The check works for any point. Is (6, 1) on y = −x/2 + 4? At x = 6 the line has y = −6/2 + 4 = −3 + 4 = 1, which is the y-coordinate of the point, so yes.

Is (2, 4) on it? At x = 2 the line has y = −2/2 + 4 = −1 + 4 = 3, but the point has y = 4. So (2, 4) is not on the line: it is 4 − 3 = 1 unit directly above it.

The usual mistakes

Taking the point’s y-coordinate as c. For (1, 3), c is not 3: at x = 1 the 2x term is 2, and it has to be taken away, so c = 3 − 2 = 1. A point’s y-coordinate is c only when its x-coordinate is 0.

Getting the sign of c wrong. From 3 = 2 + c, c = 3 − 2 = 1, and the equation is y = 2x + 1, not y = 2x − 1.

Looking for another point. Once m is known, one point is enough to find c; a third point, such as the midpoint, only gives the same c again.

Worked example: A Straight Pipeline Through Two Wells, and Whether Two Other Wells Lie on It

Question On a map with a grid in kilometers, a straight water pipeline passes through well A at (2, 3) and well B at (8, 6). (a) Find the equation of the pipeline. (b) Two more wells are at C(12, 9) and D(14, 9). Which of them lies on the pipeline, and how far due north or due south of the pipeline is the other one?

  1. 1.Find the gradient from A(2, 3) and B(8, 6): m = 6 − 38 − 2 = 36 = 12.

    48120481216km east, xkm north, yrun 6rise 3A(2, 3)B(8, 6)gradient = rise over runm = (6 − 3)/(8 − 2) = 3/6 = 1/2
    48120481216km east, xkm north, yrun 6rise 3A(2, 3)B(8, 6)gradient = rise over runm = (6 − 3)/(8 − 2) = 3/6 = 1/2
    Find the gradient from the two wells: m = 6 − 38 − 2 = 36 = 12.
  2. 2.Use the point A(2, 3): y − 3 = 12(x − 2). Expand the bracket: y − 3 = 12x − 1, so y = 12x + 2.

    48120481216km east, xkm north, yrun 6rise 3A(2, 3)B(8, 6)y − 3 = 1/2 (x − 2)y = 1/2 x − 1 + 3, so y = 1/2 x + 2
    48120481216km east, xkm north, yrun 6rise 3A(2, 3)B(8, 6)y − 3 = 1/2 (x − 2)y = 1/2 x − 1 + 3, so y = 1/2 x + 2
    Use the point A(2, 3): y − 3 = 12(x − 2), which simplifies to y = 12x + 2.
  3. 3.(a) The equation of the pipeline is y = 12x + 2. Check with B: 12 × 8 + 2 = 6.

    48120481216km east, xkm north, yc = 2A(2, 3)B(8, 6)the pipeline is y = 1/2 x + 2check with B: 1/2 × 8 + 2 = 6
    48120481216km east, xkm north, yc = 2A(2, 3)B(8, 6)the pipeline is y = 1/2 x + 2check with B: 1/2 × 8 + 2 = 6
    (a) The equation of the pipeline is y = 12x + 2. It meets the y-axis at 2, and B(8, 6) satisfies it.
  4. 4.Test C(12, 9). At x = 12 the pipeline is at y = 12 × 12 + 2 = 8, but the well is at y = 9. The well C is not on the pipeline. It is 9 − 8 = 1 km due north of it.

    48120481216km east, xkm north, yc = 2C(12, 9)A(2, 3)B(8, 6)x = 12: the pipeline is at y = 1/2 × 12 + 2 = 8C is at y = 9, which is 1 km north of the pipeline
    48120481216km east, xkm north, yc = 2C(12, 9)A(2, 3)B(8, 6)x = 12: the pipeline is at y = 1/2 × 12 + 2 = 8C is at y = 9, which is 1 km north of the pipeline
    At x = 12 the pipeline is at y = 8, but the well C is at y = 9. It is 1 km due north of the pipeline.
  5. 5.Test D(14, 9). At x = 14 the pipeline is at y = 12 × 14 + 2 = 9, which is the y-coordinate of D.

    48120481216km east, xkm north, yc = 2C(12, 9)D(14, 9)A(2, 3)B(8, 6)x = 14: the pipeline is at y = 1/2 × 14 + 2 = 9D is at y = 9, so D is on the pipeline
    48120481216km east, xkm north, yc = 2C(12, 9)D(14, 9)A(2, 3)B(8, 6)x = 14: the pipeline is at y = 1/2 × 14 + 2 = 9D is at y = 9, so D is on the pipeline
    At x = 14 the pipeline is at y = 9, which is the y-coordinate of D.
  6. 6.(b) The well D lies on the pipeline. The well C is 1 km due north of the pipeline.

    48120481216km east, xkm north, yc = 2C(12, 9)D(14, 9)A(2, 3)B(8, 6)D lies on the pipelineC is 1 km due north of the pipeline
    48120481216km east, xkm north, yc = 2C(12, 9)D(14, 9)A(2, 3)B(8, 6)D lies on the pipelineC is 1 km due north of the pipeline
    (b) The well D lies on the pipeline, and the well C is 1 km due north of it.

Answer: (a) y = 12x + 2; (b) D lies on the pipeline, and C is 1 km due north of it

Common mistakes

  • Deciding that C is on the pipeline because A, B and C look as if they are in a line on the map. From B to C the gradient is 9 − 612 − 8 = 34, which is not 12, so the three wells are not in a straight line.
  • Writing the equation as y = 12x + 3, with the y-coordinate of A as the intercept. The intercept is the value of y at x = 0, and A is at x = 2, so the point has to be substituted to find c.

More quadratic graphs and coordinate geometry problems, worked step by step →

Practice The Equation of a Line Through Two Points in the app