Chapter 6 ยท Proportional relationships, lines, and slope

Equations from Two Points: Write, Derive, and Check

Write the equation of a line from two points and see why slope-intercept form fits every point on a non-vertical line. Then find and fix mistakes in equations.

20 min read

You already know how to write the equation of a line from its graph. You read the slope mm (how much yy changes when xx increases by 1) and the y-intercept bb (the yy-value where the line crosses the yy-axis, which is where x=0x = 0). Then you write y=mx+by = mx + b. This is called a linear equation because its graph is a straight line.

In this lesson you start with less: just two points. That is still enough, because exactly one straight line passes through two different points. You will write the equation from two points, see why y=mx+by = mx + b fits every point on a line that is not vertical, and learn to find and fix mistakes in an equation.

Call the two different points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2). Going from the first point to the second, yy changes by y2โˆ’y1y_2 - y_1 and xx changes by x2โˆ’x1x_2 - x_1. When the two xx-values are different, the slope is the change in yy divided by the change in xx. Written as a fraction, the subtractions must go in the same order on the top and on the bottom. Either point can come first, as long as it comes first in both places.

When the two xx-values are equal, the line is vertical (straight up and down). The change in xx is 00, and you cannot divide by 00, so the slope of a vertical line is undefined. A vertical line also pairs one xx-value with many yy-values, so it is not a function y=f(x)y = f(x), which is a rule that gives exactly one yy for each xx. It has no equation of the form y=mx+by = mx + b, so the rest of this lesson is about lines that are not vertical.

m=y2โˆ’y1x2โˆ’x1(x1โ‰ x2)m = \frac{y_2 - y_1}{x_2 - x_1} \qquad (x_1 \neq x_2)

An equation of a line must be true for the coordinates of every point on that line. That tells you how to finish once you know mm. Only bb is missing from y=mx+by = mx + b, so replace xx and yy with the coordinates of one of your points (this is called substituting) and solve for bb. Then test your equation with the other point. If both points make y=mx+by = mx + b true, its graph is a line through both of them. Only one line passes through two different points, so your equation is right.

Worked example

Two points with whole-number coordinates

Write an equation of the line through (2,7)(2, 7) and (4,11)(4, 11).

  1. The x-values 2 and 4 are different, so the line is not vertical and it has a slope. Find the change in y and the change in x, with the second point first both times.

    y2โˆ’y1=11โˆ’7=4x2โˆ’x1=4โˆ’2=2y_2 - y_1 = 11 - 7 = 4 \qquad x_2 - x_1 = 4 - 2 = 2
  2. Divide the change in y by the change in x to get the slope.

    m=42=2m = \frac{4}{2} = 2
  3. The point (2, 7) is on the line, so its coordinates must make y = mx + b true. Replace m with 2, x with 2 and y with 7, then multiply.

    7=2(2)+bโ‡’7=4+b7 = 2(2) + b \quad\Rightarrow\quad 7 = 4 + b
  4. Subtract 4 from both sides. Doing the same thing to both sides keeps the equation true, and it leaves b by itself.

    7โˆ’4=bโ‡’b=37 - 4 = b \quad\Rightarrow\quad b = 3
  5. Put m = 2 and b = 3 into y = mx + b, the form that every point on the line must fit.

    y=2x+3y = 2x + 3
  6. Test the point you did not use, (4, 11). Replace x with 4. The result is 11, which matches that point's y-value.

    2(4)+3=8+3=112(4) + 3 = 8 + 3 = 11

Answer

An equation of the line through (2,7)(2, 7) and (4,11)(4, 11) is y=2x+3y = 2x + 3.

Coordinate grid from x -2 to 6 and y -2 to 12, with a grid step of 1, showing 4 plotted elements. Details: line 2 x plus -1 y equals -3, named Line A; point at (2, 7), named (2, 7); point at (4, 11), named (4, 11); point at (0, 3), named (0, 3).
From (2,7)(2, 7) to (4,11)(4, 11), Line A goes right 2 and up 4. It crosses the yy-axis at (0,3)(0, 3).

Worked example

Negative coordinates and a fraction slope

Write an equation of the line through (โˆ’3,1)(-3, 1) and (6,โˆ’5)(6, -5).

  1. The x-values -3 and 6 are different, so the slope exists. Subtract in the same order, with the second point first. Subtracting -3 is the same as adding 3.

    m=โˆ’5โˆ’16โˆ’(โˆ’3)=โˆ’66+3=โˆ’69m = \frac{-5 - 1}{6 - (-3)} = \frac{-6}{6 + 3} = \frac{-6}{9}
  2. Divide the top and the bottom by 3 and keep the exact fraction. A rounded decimal such as -0.67 is only an approximation, so the line it gives would not pass exactly through both points.

    m=โˆ’69=โˆ’23m = \frac{-6}{9} = -\frac{2}{3}
  3. Substitute the slope and the point (-3, 1) into y = mx + b. A negative number times a negative number is positive.

    1=โˆ’23(โˆ’3)+bโ‡’1=2+b1 = -\frac{2}{3}(-3) + b \quad\Rightarrow\quad 1 = 2 + b
  4. Subtract 2 from both sides to find b, then write the equation. Adding -1 is written as subtracting 1.

    b=1โˆ’2=โˆ’1y=โˆ’23x+(โˆ’1)=โˆ’23xโˆ’1b = 1 - 2 = -1 \qquad y = -\frac{2}{3}x + (-1) = -\frac{2}{3}x - 1
  5. Test the other point, (6, -5). Replace x with 6. The result is -5, which matches.

    โˆ’23(6)โˆ’1=โˆ’4โˆ’1=โˆ’5-\frac{2}{3}(6) - 1 = -4 - 1 = -5

Answer

An equation of the line through (โˆ’3,1)(-3, 1) and (6,โˆ’5)(6, -5) is y=โˆ’23xโˆ’1y = -\frac{2}{3}x - 1.

Why does one equation fit every point on a line, not just the two you were given? The reason is that on a line that is not vertical, the slope between any two different points is the same number. You have relied on this whenever you read a slope from a graph.

Take a line through the origin, the point (0,0)(0, 0), with slope mm. Pick any other point (x,y)(x, y) on it. A line that is not vertical crosses the yy-axis only once, so this point has xโ‰ 0x \neq 0. The slope from (0,0)(0, 0) to (x,y)(x, y) is yโˆ’0xโˆ’0=yx\frac{y - 0}{x - 0} = \frac{y}{x}, and it must equal mm. Multiply both sides of yx=m\frac{y}{x} = m by xx, which keeps the equation true, to get y=mxy = mx. The origin fits too, because 0=mโ‹…00 = m \cdot 0. So every point on the line makes y=mxy = mx true.

In the figure, the horizontal axis shows xx and the vertical axis shows yy. Line B passes through (0,0)(0, 0) with slope 22: its points (2,4)(2, 4) and (4,8)(4, 8) give 42=2\frac{4}{2} = 2 and 84=2\frac{8}{4} = 2, so Line B is y=2xy = 2x.

Coordinate grid from x -2 to 6 and y -2 to 12, with a grid step of 1, showing 8 plotted elements. Details: line 2 x plus -1 y equals 0, named Line B; line 2 x plus -1 y equals -3, named Line A; point at (0, 0), named (0, 0); point at (2, 4), named (2, 4); point at (4, 8), named (4, 8); point at (0, 3), named (0, 3); point at (2, 7), named (2, 7); point at (4, 11), named (4, 11).
Line B is y=2xy = 2x through (0,0)(0, 0). Line A is y=2x+3y = 2x + 3 through (0,3)(0, 3). Each point shown on Line A is 3 units above the point on Line B with the same xx-value.

Worked example

Why every point on Line A fits its equation

Line A in the figure is the line from the first example. It has slope 22 and crosses the yy-axis at (0,3)(0, 3). Show that every point (x,y)(x, y) on Line A makes y=2x+3y = 2x + 3 true.

  1. Pick any point (x, y) on Line A other than (0, 3). A line that is not vertical crosses the y-axis only once, so this point is off the y-axis and its x-value is not 0.

    xโ‰ 0x \neq 0
  2. Write the slope from (0, 3) to (x, y) as the change in y over the change in x. Dividing by x is allowed because x is not 0.

    yโˆ’3xโˆ’0=yโˆ’3x\frac{y - 3}{x - 0} = \frac{y - 3}{x}
  3. The slope between any two different points of Line A is 2, so this fraction must equal 2. For example, from (0, 3) to (2, 7) the change in y is 4 and the change in x is 2, and 4 divided by 2 is 2.

    yโˆ’3x=2\frac{y - 3}{x} = 2
  4. Multiply both sides by x. Doing the same thing to both sides keeps the equation true, and it clears the fraction.

    yโˆ’3=2xy - 3 = 2x
  5. Add 3 to both sides so that y is by itself.

    y=2x+3y = 2x + 3
  6. Check the one point you set aside, (0, 3). Replace x with 0. The result is 3, so that point fits too.

    2(0)+3=0+3=32(0) + 3 = 0 + 3 = 3

Answer

Every point (x,y)(x, y) on Line A makes y=2x+3y = 2x + 3 true, including the yy-intercept (0,3)(0, 3).

Key concept

One constant slope builds the equation

On a line that is not vertical, the slope between any two different points is the same number mm. Compare any point (x,y)(x, y) on the line where xโ‰ 0x \neq 0 with the yy-intercept (0,b)(0, b): the slope between them must equal mm. Multiply both sides by xx, then add bb to both sides, and you get the equation below. The point (0,b)(0, b) fits it too, because mโ‹…0+b=bm \cdot 0 + b = b.

When b=0b = 0, the line passes through the origin and the equation is y=mxy = mx. That is the form of a proportional relationship, y=kxy = kx with k=mk = m: the ratio yx\frac{y}{x} is the same constant wherever xโ‰ 0x \neq 0. A line with bโ‰ 0b \neq 0 misses the origin, so it is linear but not proportional. On Line A, (2,7)(2, 7) gives 72=3.5\frac{7}{2} = 3.5 but (4,11)(4, 11) gives 114=2.75\frac{11}{4} = 2.75.

yโˆ’bxโˆ’0=m(xโ‰ 0)โŸนy=mx+b\frac{y - b}{x - 0} = m \quad (x \neq 0) \quad\Longrightarrow\quad y = mx + b

An equation of a line must be true for every point on that line, so it must be true for both points you were given. That gives you a reliable way to find a mistake: substitute each given point into the finished equation. If either point makes it false, something went wrong. Then ask:

  • Were the two subtractions for the slope done in the same order?
  • Was subtracting a negative number treated as adding its opposite?
  • Does the sign of the slope match the points? If yy goes down as xx goes up, the slope must be negative.
  • Was bb solved for, or just copied from a point whose xx-value is not 00?

Be careful with a one-point test. If bb was solved correctly from one point, that point fits the equation even when the slope is wrong, so always test the other point too. Mateo's work in the table has a mistake in it. Try to find it before you read the example after the table.

Mateo's work for the line through (-1, 6) and (3, -2)
StepWhat Mateo wrote
1. Slope
m=6โˆ’(โˆ’2)3โˆ’(โˆ’1)=84=2m = \frac{6 - (-2)}{3 - (-1)} = \frac{8}{4} = 2
2. Solve for bb using (โˆ’1,6)(-1, 6)
6=2(โˆ’1)+b6 = 2(-1) + b, so 6=โˆ’2+b6 = -2 + b and b=8b = 8
3. Equation
y=2x+8y = 2x + 8

Worked example

Find and fix the mistake

Mateo wrote y=2x+8y = 2x + 8 for the line through (โˆ’1,6)(-1, 6) and (3,โˆ’2)(3, -2). His steps are in the table before this example. Find his error and write the correct equation.

  1. Test both given points in Mateo's equation. Replacing x with -1 gives 6, so (-1, 6) fits. Replacing x with 3 gives 14, not -2, so (3, -2) does not fit. The equation is wrong somewhere.

    2(โˆ’1)+8=โˆ’2+8=62(3)+8=6+8=14โ‰ โˆ’22(-1) + 8 = -2 + 8 = 6 \qquad 2(3) + 8 = 6 + 8 = 14 \neq -2
  2. Look for the cause. From (-1, 6) to (3, -2), x goes up and y goes down, so the slope must be negative, but Mateo's slope is positive. On the top he subtracted first point minus second point. On the bottom he subtracted second point minus first point. The two orders do not match, and that flips the sign of the slope.

    top:ย y1โˆ’y2=6โˆ’(โˆ’2)bottom:ย x2โˆ’x1=3โˆ’(โˆ’1)\text{top: } y_1 - y_2 = 6 - (-2) \qquad \text{bottom: } x_2 - x_1 = 3 - (-1)
  3. Redo the slope with the second point first on both the top and the bottom. Subtracting -1 is the same as adding 1.

    m=โˆ’2โˆ’63โˆ’(โˆ’1)=โˆ’83+1=โˆ’84=โˆ’2m = \frac{-2 - 6}{3 - (-1)} = \frac{-8}{3 + 1} = \frac{-8}{4} = -2
  4. Mateo's b came from the wrong slope, so solve for b again. Put m = -2 and the point (-1, 6) into y = mx + b, then subtract 2 from both sides.

    6=โˆ’2(โˆ’1)+bโ‡’6=2+bโ‡’b=46 = -2(-1) + b \quad\Rightarrow\quad 6 = 2 + b \quad\Rightarrow\quad b = 4
  5. Write the corrected equation and test both points. Each point gives its own y-value, so the equation is right.

    y=โˆ’2x+4โˆ’2(โˆ’1)+4=2+4=6โˆ’2(3)+4=โˆ’6+4=โˆ’2y = -2x + 4 \qquad -2(-1) + 4 = 2 + 4 = 6 \qquad -2(3) + 4 = -6 + 4 = -2
  6. Compare the two lines in the figure after this example. Its horizontal axis shows x and its vertical axis shows y. Line C is the corrected line and Line D is Mateo's line. Both pass through (-1, 6), because each b was solved from that point. At x = 3, Line C is at (3, -2) but Line D is at (3, 14). The coordinates, not the look of the picture, are the evidence.

Answer

Mateo subtracted in different orders on the top and bottom of the slope, which flipped its sign. The correct equation is y=โˆ’2x+4y = -2x + 4.

Coordinate grid from x -4 to 6 and y -4 to 16, with a grid step of 1, showing 5 plotted elements. Details: line 2 x plus 1 y equals 4, named Line C; line 2 x plus -1 y equals -8, named Line D; point at (-1, 6), named (-1, 6); point at (3, -2), named (3, -2); point at (3, 14), named (3, 14).
Line C is y=โˆ’2x+4y = -2x + 4 and Line D is Mateo's y=2x+8y = 2x + 8. They meet at (โˆ’1,6)(-1, 6), but at x=3x = 3 Line D is at (3,14)(3, 14), not (3,โˆ’2)(3, -2).

The big idea: a line that is not vertical has one constant slope, and everything in this lesson grows from that fact. Two points with different xx-values give you mm, and substituting one of them into y=mx+by = mx + b gives you bb. The same constant slope is why every point on the line fits y=mx+by = mx + b, or y=mxy = mx when the line passes through the origin. To catch a mistake, test both given points in the finished equation: if one fails, recheck the slope first and then bb.