Monocurl Essays
Series Download

What slope means, and why y = mx + b is a line

A phone bill that grows by the same amount per gigabyte plots as a straight line. Similar triangles explain why, and give slope and y = mx + b their meaning.

23 min·Middle and high school·

The cost of a phone plan that charges 4 dollars plus 3 dollars per gigabyte, drawn as a staircase. The steps are cut to half and then a quarter of a gigabyte, and every corner of every staircase lies on one straight line, because rise divided by run is 3 for all of them.
Monocurl source
let Step = |run, places| [
    center{[2.75, 1.45, 0]} Note("run (gigabytes)", 0.72),
    center{[2.75, 0.98, 0]} Math(to_string(run, places), 1.0),
    center{[2.75, 0.35, 0]} Note("rise (dollars)", 0.72),
    center{[2.75, -0.12, 0]} Math(to_string(plan(run) - plan(0), places), 1.0, EMBER),
    center{[2.75, -0.75, 0]} Note("rise / run", 0.72),
    center{[2.75, -1.25, 0]} Math(to_string((plan(run) - plan(0)) / run, 0), 1.2, LEAF)
]
mesh plot = PlanPlot
mesh ramp = []
mesh stairs = Stairs(fp, plan, 0, 5, 1)
mesh readout = Step(1, 0)

slide "refine"
    play Wait(1.4)
    readout = []
    play Fade(0.3, [&readout])
    stairs = Stairs(fp, plan, 0, 5, 0.5, EMBER, 0.06)
    readout = Step(0.5, 1)
    play Fade(0.8)
    play Wait(1.2)
    readout = []
    play Fade(0.3, [&readout])
    stairs = Stairs(fp, plan, 0, 5, 0.25, EMBER, 0.05)
    readout = Step(0.25, 2)
    play Fade(0.8)
    play Wait(1)
    ramp = Seg(at(fp, 0, plan(0)), at(fp, 5.2, plan(5.2)), AZURE, 4)
    play Write(1.2, [&ramp])
    play Wait(2)

Uses the shared definitions for this lesson's figures.

A phone plan costs $4 a month plus $3 for every gigabyte of data you use. Work out the bill for 0, 1, 2, 3, 4 and 5 gigabytes, plot the six points, and they appear to sit along the edge of a ruler. There is no obvious reason why they should. The rule “add 3 for each gigabyte” is a statement about arithmetic and says nothing about straightness. A staircase also climbs by the same amount at every step, and a staircase is about as far from straight as a path can be.

Yet the corners of the staircase in the figure do line up, and they keep lining up when the steps are cut in half and in half again. The reason involves a number called the slope, an old fact about triangles, and a proof that the graph of every equation of the form $y = mx + b$ is a straight line.

The same ratio from every pair of points

Write $x$ for the number of gigabytes and $y$ for the bill in dollars. The plan says

$$ y = 3x + 4. $$

Here is the table for whole numbers of gigabytes.

gigabytes $x$012345
cost $y$ (dollars)4710131619

Each step to the right adds 3 to the cost. That much is visible in the rule. What happens between two points that are not neighbors? From 1 gigabyte to 4 gigabytes the cost goes from 7 to 16, so it climbs 9 dollars while the usage moves 3 gigabytes. The vertical change is called the rise and the horizontal change is called the run, and their quotient is

$$ \frac{\text{rise}}{\text{run}} = \frac{16 - 7}{4 - 1} = \frac{9}{3} = 3 \text{ dollars per gigabyte}. $$

Pause and try

Compute rise divided by run for three more pairs of points on the plan: from $x = 0$ to $x = 5$, from $x = 2$ to $x = 3$, and from $x = 2.5$ to $x = 3$. (At 2.5 gigabytes the bill is $3 \times 2.5 + 4 = 11.5$ dollars.)

Show answerHide answer

From 0 to 5: $\frac{19 - 4}{5 - 0} = \frac{15}{5} = 3$. From 2 to 3: $\frac{13 - 10}{3 - 2} = \frac{3}{1} = 3$. From 2.5 to 3: $\frac{13 - 11.5}{3 - 2.5} = \frac{1.5}{0.5} = 3$. Long stretch or short, whole numbers or not, the quotient is 3.

  1. From 1 to 2 gigabytes the cost rises 3 dollars over a run of 1.
  2. From 1 to 4 gigabytes it rises 9 dollars over a run of 3. The triangle is three times as large, and 9 / 3 is again 3.
  3. From 2.5 to 3 gigabytes it rises 1.5 dollars over a run of 0.5. A small triangle somewhere else, and still 3.
Three right triangles drawn under the graph of the phone plan $y = 3x + 4$, with horizontal leg the run and vertical leg the rise. The triangles have different sizes and sit in different places, and rise over run is 3 for each.
Monocurl source
let Reading = |x1, x2, places| {
    let rise = plan(x2) - plan(x1)
    let run = x2 - x1
    let a = at(fp, x1, plan(x1))
    let b = at(fp, x2, plan(x2))
    return [
        center{[(a[0] + b[0]) / 2, a[1] - 0.27, 0]} Math(to_string(run, places), 0.8, SLATE),
        center{[b[0] + 0.34, (a[1] + b[1]) / 2, 0]} Math(to_string(rise, places), 0.8, EMBER),
        center{[2.75, 1.15, 0]} Note("rise over run", 0.74),
        center{[2.75, 0.3, 0]} Math(str_join(["\frac{", to_string(rise, places), "}{", to_string(run, places), "}"]), 1.2, EMBER),
        center{[2.75, -0.65, 0]} Math(str_join(["= ", to_string(rise / run, 0)]), 1.2, LEAF)
    ]
}
let Ends = |x1, x2| [Pt(at(fp, x1, plan(x1)), INK, 0.08), Pt(at(fp, x2, plan(x2)), INK, 0.08)]
mesh plot = PlanPlot
mesh tri = []
mesh line = Seg(at(fp, 0, plan(0)), at(fp, 5.2, plan(5.2)), AZURE, 4)
mesh ends = []
mesh reading = []

slide "From 1 to 2 gigabytes the cost rises 3 dollars over a run of 1."
    tri = SlopeTri(fp, plan, 1, 2)
    ends = Ends(1, 2)
    reading = Reading(1, 2, 0)
    play Fade(0.7)

slide "From 1 to 4 gigabytes it rises 9 dollars over a run of 3. The triangle is three times as large, and 9 / 3 is again 3."
    reading = []
    ends = []
    play Fade(0.3, [&reading, &ends])
    tri = SlopeTri(fp, plan, 1, 4)
    ends = Ends(1, 4)
    reading = Reading(1, 4, 0)
    play Fade(0.7)

slide "From 2.5 to 3 gigabytes it rises 1.5 dollars over a run of 0.5. A small triangle somewhere else, and still 3."
    reading = []
    ends = []
    play Fade(0.3, [&reading, &ends])
    tri = SlopeTri(fp, plan, 2.5, 3)
    ends = Ends(2.5, 3)
    reading = Reading(2.5, 3, 1)
    play Fade(0.7)

Uses the shared definitions for this lesson's figures.

One line of algebra settles the matter for every pair at once. Take any two different amounts of data, $x_1$ and $x_2$. The bills are $3x_1 + 4$ and $3x_2 + 4$, so

$$ \frac{\text{rise}}{\text{run}} = \frac{(3x_2 + 4) - (3x_1 + 4)}{x_2 - x_1} = \frac{3x_2 - 3x_1}{x_2 - x_1} = \frac{3(x_2 - x_1)}{x_2 - x_1} = 3. $$

The 4 cancels, the 3 factors out by the distributive law, and the two copies of $x_2 - x_1$ divide to 1 (they are not zero, because the two amounts are different). Nothing in this used the particular numbers 3 and 4. For any equation $y = mx + b$, the same three steps show that rise over run between any two points of the graph is $m$.

A curve fails the same test

Would any formula do the same? Try the simplest one that is not of this kind, $y = x^2$.

Pause and try

For $y = x^2$, compute rise over run between the points with $x = 0$ and $1$, then $1$ and $2$, then $2$ and $3$. Then compute it between $x = 0$ and $x = 3$, and between $x = 1$ and $x = 3$.

Show answerHide answer

The heights are $0, 1, 4, 9$. The first three quotients are $\frac{1}{1} = 1$, $\frac{3}{1} = 3$ and $\frac{5}{1} = 5$. From 0 to 3 it is $\frac{9}{3} = 3$, and from 1 to 3 it is $\frac{8}{2} = 4$. Five pairs of points give four different answers.

Two staircases with treads one unit wide. For y = 3x + 4 every riser has height 3 and the corners lie on the straight segment joining the first corner to the last. For y = x^2 the risers have heights 1, 3 and 5, and the middle corners sag below that segment.
Two staircases with treads one unit wide. For $y = 3x + 4$ every riser has height 3 and the corners lie on the straight segment joining the first corner to the last. For $y = x^2$ the risers have heights 1, 3 and 5, and the middle corners sag below that segment.
Monocurl source
let fa = Frame(0, 3.5, 0, 14.5, [-1.8, -0.1, 0], 2.9, 3.3)
let fb = Frame(0, 3.5, 0, 9.7, [2.25, -0.1, 0], 2.9, 3.3)
let sq = |x| x * x
let Panel = |fr, f, ys, name, col| block {
    . GridLines(fr, [1, 2, 3], ys)
    . Axes(fr)
    . XTicks(fr, [1, 2, 3])
    . YTicks(fr, ys)
    . Seg(at(fr, 0, f(0)), at(fr, 3, f(3)), col, 3)
    . Stairs(fr, f, 0, 3, 1, EMBER, 0.085)
    for (k in range(0, 3)) {
        . center{[fx(fr, k + 1) + 0.22, fy(fr, (f(k) + f(k + 1)) / 2), 0]} Math(to_string(f(k + 1) - f(k)), 0.78, EMBER)
    }
    . center{[fx(fr, 2.1), fy(fr, fr[3]) + 0.42, 0]} Math(name, 0.85, col)
}
mesh left = Panel(fa, plan, [4, 8, 12], "y = 3x + 4", LEAF)
mesh right = Panel(fb, sq, [3, 6, 9], "y = x^2", ROSE)

Uses the shared definitions for this lesson's figures.

On the left every riser is 3 tall and the corners of the staircase fall on the straight segment from the first corner to the last. On the right the risers grow, 1, 3, 5, and the path through the corners bends upward, away from the straight segment.

So constant rise over run and straightness seem to go together. The algebra above proved that $y = 3x + 4$ has a constant ratio. It did not prove that its graph is straight, because “straight” is a word from geometry and we have not yet connected it to the ratio. That connection is the real content of this lesson.

Why every triangle on a straight line has the same ratio

Start from the geometric side. Suppose someone hands you a straight line drawn on a grid, not vertical, with no equation attached. Pick two points on it and draw the run and the rise between them. Then pick two other points anywhere else on the line and do it again. Why should the two quotients agree?

  1. Pick any two points on a straight line. Draw the horizontal run and the vertical rise between them.
  2. Pick any other two points on the same line and draw their run and rise.
  3. The two runs are horizontal, so they are parallel. One straight line crosses both, and it crosses parallel lines at equal angles.
  4. Each triangle also has a right angle. Two equal angles force the same shape, so the sides are in proportion.
Two right triangles of different sizes drawn on the same straight line. Their horizontal legs are parallel, so the line crosses both at the same angle. With a right angle in each, the triangles have the same shape, and so rise over run is the same for both.
Monocurl source
let La = [-3.6, -1.9, 0]
let Lb = [3.4, 1.6, 0]
let A1 = [-3.0, -1.6, 0]
let P1 = [-1.2, -1.6, 0]
let B1 = [-1.2, -0.7, 0]
let A2 = [-0.4, -0.3, 0]
let P2 = [2.9, -0.3, 0]
let B2 = [2.9, 1.35, 0]
let TriOne = [
    Region([A1, P1, B1], tint(AZURE, 0.22)),
    Path([A1, P1, B1], AZURE, 3),
    center{[-2.1, -1.88, 0]} Math("\text{run}_1", 0.78, AZURE),
    center{[-0.62, -1.15, 0]} Math("\text{rise}_1", 0.78, AZURE)
]
let TriTwo = [
    Region([A2, P2, B2], tint(EMBER, 0.22)),
    Path([A2, P2, B2], EMBER, 3),
    center{[1.25, -0.6, 0]} Math("\text{run}_2", 0.78, EMBER),
    center{[3.45, 0.5, 0]} Math("\text{rise}_2", 0.78, EMBER)
]
mesh t1 = []
mesh t2 = []
mesh line = Seg(La, Lb, INK, 4)
mesh marks = []
mesh dots = []
mesh frac1 = []
mesh frac2 = []
mesh claim = []

slide "Pick any two points on a straight line. Draw the horizontal run and the vertical rise between them."
    t1 = TriOne
    dots = [Pt(A1), Pt(B1)]
    frac1 = center{[-2.3, 1.4, 0]} Math("\frac{\text{rise}_1}{\text{run}_1}", 1.05, AZURE)
    play Fade(0.7)

slide "Pick any other two points on the same line and draw their run and rise."
    t2 = TriTwo
    dots = [Pt(A1), Pt(B1), Pt(A2), Pt(B2)]
    frac2 = center{[1.5, -1.35, 0]} Math("\frac{\text{rise}_2}{\text{run}_2}", 1.05, EMBER)
    play Fade(0.7)

slide "The two runs are horizontal, so they are parallel. One straight line crosses both, and it crosses parallel lines at equal angles."
    marks = [
        stroke{LEAF, 4} Angle(A1, P1, B1, 0.75),
        stroke{LEAF, 4} Angle(A2, P2, B2, 0.75),
        center{[-2.3, 0.6, 0]} Cap("equal angles", 0.85, LEAF)
    ]
    play Fade(0.8, [&marks])

slide "Each triangle also has a right angle. Two equal angles force the same shape, so the sides are in proportion."
    marks = [
        stroke{LEAF, 4} Angle(A1, P1, B1, 0.75),
        stroke{LEAF, 4} Angle(A2, P2, B2, 0.75),
        center{[-2.3, 0.6, 0]} Cap("equal angles", 0.85, LEAF),
        center{[-2.3, 0.1, 0]} Cap("right angles", 0.85, SLATE),
        stroke{SLATE, 2.5} RightAngle(P1, A1, B1, 0.2),
        stroke{SLATE, 2.5} RightAngle(P2, A2, B2, 0.2)
    ]
    frac1 = []
    frac2 = []
    play Fade(0.3, [&frac1, &frac2])
    claim = center{[1.5, -1.35, 0]} Math("\frac{\text{rise}_1}{\text{run}_1} = \frac{\text{rise}_2}{\text{run}_2}", 1.05)
    play Fade(0.7)

Uses the shared definitions for this lesson's figures.

The argument rests on two facts from Euclid’s geometry, and they are exactly where straightness enters. The first: when one straight line crosses two parallel lines, it makes the same angle with each of them (these are called corresponding angles). All horizontal lines are parallel, so our line meets both runs at the same angle. The second: if two angles of one triangle equal two angles of another, the triangles are similar, meaning one is a scaled copy of the other, and the ratio of any two sides of the first equals the ratio of the matching sides of the second. Each of our triangles has a right angle where the run meets the rise, so the ratio of the vertical leg to the horizontal leg is the same in both.

That shared ratio belongs to the line itself, not to any particular pair of points, and so it deserves a name.

The second sentence of the definition makes a promise: that it does not matter which two points are used. A definition is not allowed to promise that without proof.

The two borrowed facts are theorems of Euclid’s Elements (Book I, Proposition 29, and Book VI, Proposition 4), used here without proof. Beyond them the argument used only that two points lie on exactly one straight line.

Why y = mx + b is a straight line

Now come back from the other side. Algebra says the graph of $y = mx + b$ has rise over run equal to $m$ between any two of its points, and geometry says a straight line has one fixed rise over run. That makes it plausible that the graph is a straight line, but no more than plausible: perhaps some bent curve also manages a constant ratio. The following theorem rules that out.

For the phone plan this answers the opening question. The corners of the staircase line up because the equation $y = 3x + 4$ forces rise over run to be 3 between any two of them, and the points with that property, starting from $(0, 4)$, are the points of one straight line. Cutting the steps finer only adds more points of the same line.

What m and b measure

The slope $m$ is a rate. It answers “how much does $y$ change for each unit that $x$ increases?”, and it carries units: the units of $y$ divided by the units of $x$. For the plan, $m = 3$ dollars per gigabyte. Two more gigabytes cost $3 \times 2 = 6$ more dollars whether you were at 1 gigabyte or at 40.

The number $b$ is the value of $y$ when $x = 0$. On the graph it is the height at which the line crosses the vertical axis, which is why it is called the $y$-intercept. For the plan, $b = 4$ dollars, the bill in a month with no data used. The form $y = mx + b$ is called slope-intercept form because the two numbers in it are the slope and the intercept.

Pause and try

Without plotting anything, describe the line $y = -2x + 3$: where does it cross the vertical axis, and what happens to $y$ each time $x$ increases by 1? Give two points on it besides the intercept.

Show answerHide answer

It crosses the vertical axis at height 3. The slope is $-2$, so each step of 1 to the right lowers $y$ by 2. Starting from $(0, 3)$: $(1, 1)$, $(2, -1)$, and going left, $(-1, 5)$.

The line $y = mx + b$ on a square grid. First $m$ changes while $b = 1$ is held fixed: the line pivots about the point $(0, 1)$, and the rise over a run of 1 is always $m$. Then $b$ changes while $m$ is held at $0.5$: the line slides up and down without turning.
Monocurl source
let fm = Frame(-3.5, 3.5, -3, 3, [-1.2, 0.2, 0], 3.85, 3.3)
let Lin = |m, b| {
    var lo = -3.5
    var hi = 3.5
    if (abs(m) > 0.0001) {
        let xa = (-3 - b) / m
        let xb = (3 - b) / m
        lo = max(lo, min(xa, xb))
        hi = min(hi, max(xa, xb))
    }
    var parts = [
        Seg(at(fm, lo, m * lo + b), at(fm, hi, m * hi + b), INK, 4),
        Seg(at(fm, 0, b), at(fm, 1, b), SLATE, 3.5)
    ]
    if (abs(m) > 0.03) {
        parts .= Seg(at(fm, 1, b), at(fm, 1, b + m), AZURE, 4.5)
    }
    parts .= Pt(at(fm, 0, b), EMBER, 0.11)
    var ms = m
    if (abs(m) < 0.05) {
        ms = 0
    }
    var bs = b
    if (abs(b) < 0.05) {
        bs = 0
    }
    parts .= center{[3.05, 0.45, 0]} scale{1.3} color{AZURE} Number(ms, 1)
    parts .= center{[3.05, -0.75, 0]} scale{1.3} color{EMBER} Number(bs, 1)
    return parts
}
mesh grid = GridLines(fm, [-3, -2, -1, 1, 2, 3], [-3, -2, -1, 1, 2, 3])
mesh axes = [
    Axes(fm, "x"),
    map([-3, -2, -1, 0, 1, 2, 3], |v| center{[fx(fm, v), fy(fm, -3) - 0.3, 0]} Math(to_string(v), 0.8, SLATE)),
    map([-2, -1, 0, 1, 2], |v| center{[fx(fm, -3.5) - 0.32, fy(fm, v), 0]} Math(to_string(v), 0.8, SLATE)),
    center{[fx(fm, 0) + 0.3, fy(fm, 3) + 0.22, 0]} Math("y", 0.8, SLATE)
]
mesh names = [
    center{[2.55, 1.6, 0]} color{AZURE, |tags| 1 in tags} color{EMBER, |tags| 2 in tags} color{INK} Tex(["y = ", text_tag{1} "m", "x + ", text_tag{2} "b"], 1.15),
    center{[2.1, 0.45, 0]} Math("m", 1.1, AZURE),
    center{[2.1, -0.75, 0]} Math("b", 1.1, EMBER)
]
mesh line = Lin(m: 1, b: 1)

slide "vary"
    play Wait(0.8)
    line.m = 2
    play Lerp(1.4, [&line])
    line.m = -1
    play Lerp(2.4, [&line])
    line.m = 0.5
    play Lerp(1.6, [&line])
    play Wait(0.7)
    line.b = -1.5
    play Lerp(1.8, [&line])
    line.b = 2
    play Lerp(2, [&line])
    line.b = 1
    play Lerp(1.2, [&line])
    play Wait(1)

Uses the shared definitions for this lesson's figures.

Changing $m$ turns the line about its intercept, and changing $b$ lifts or lowers it without turning. Two lines with the same $m$ and different $b$ therefore never meet: they are parallel.

Negative, zero and missing slopes

The video passed through three kinds of slope, and a fourth kind was excluded from both theorems.

Four lines through one point of a square grid. The line with slope 2 rises two squares for each square to the right, the line with slope 0 is horizontal, the line with slope -\frac{1}{2} falls one square for every two to the right, and the vertical line has a run of zero, so no slope is defined for it.
Four lines through one point of a square grid. The line with slope 2 rises two squares for each square to the right, the line with slope 0 is horizontal, the line with slope $-\frac{1}{2}$ falls one square for every two to the right, and the vertical line has a run of zero, so no slope is defined for it.
Monocurl source
let U = 0.9
let Q = |i, j| [i * U, j * U, 0]
mesh grid = block {
    for (i in range(-4, 5)) {
        . Seg(Q(i, -2), Q(i, 2), MIST, 1.5)
    }
    for (j in range(-2, 3)) {
        . Seg(Q(-4, j), Q(4, j), MIST, 1.5)
    }
}
mesh lines = [
    Seg(Q(-4, 0), Q(4, 0), PLUM, 4),
    Seg(Q(-4, 2), Q(4, -2), EMBER, 4),
    Seg(Q(-1, -2), Q(1, 2), AZURE, 4),
    Seg(Q(0, -2.15), Q(0, 2.15), ROSE, 4),
    Pt(Q(0, 0), INK, 0.1)
]
mesh labels = [
    center{[1.95, 1.5, 0]} Math("m = 2", 0.9, AZURE),
    center{[2.95, 0.33, 0]} Math("m = 0", 0.9, PLUM),
    center{[2.75, -0.7, 0]} Math("m = -\frac{1}{2}", 0.9, EMBER),
    center{[-1.2, 1.5, 0]} Cap("no slope", 0.8, ROSE)
]

Uses the shared definitions for this lesson's figures.

A positive slope means $y$ increases as $x$ increases, so the line climbs to the right. A negative slope means $y$ decreases as $x$ increases.

A slope of zero means the rise is always 0: the line is horizontal and its equation is $y = b$. A plan with unlimited data for $30 a month is the line $y = 30$.

A vertical line is the case the theorems left out. Take the points $(2, 1)$ and $(2, 5)$. The rise is 4 and the run is $2 - 2 = 0$, so the slope would be $\frac{4}{0}$, and division by zero has no value. We say the slope of a vertical line is undefined. Calling it “infinite” does not help: lines leaning slightly right of vertical have huge positive slopes and lines leaning slightly left have huge negative ones, so no single value fits. A vertical line also cannot be written as $y = mx + b$, because that equation gives one $y$ for each $x$ and a vertical line has every $y$ at a single $x$. Its equation is $x = c$; the line in this example is $x = 2$.

Worked examples

Two points are enough to write down the equation of a line. The steps are always the same: compute $m$ from the two points, then find $b$ by requiring one of the points to satisfy $y = mx + b$.

Plan B recovered from two bills. The points (2, 16) and (6, 24) give a run of 4 and a rise of 8, so the slope is 2 dollars per gigabyte. Following the line back to zero gigabytes gives the monthly fee, 12 dollars.
Plan B recovered from two bills. The points $(2, 16)$ and $(6, 24)$ give a run of 4 and a rise of 8, so the slope is 2 dollars per gigabyte. Following the line back to zero gigabytes gives the monthly fee, 12 dollars.
Monocurl source
let m = (plan_b(6) - plan_b(2)) / (6 - 2)
mesh plot = WidePlot
mesh tri = SlopeTri(fw, plan_b, 2, 6)
mesh line = Seg(at(fw, 0, plan_b(0)), at(fw, 10.3, plan_b(10.3)), AZURE, 4)
mesh marks = [
    Pt(at(fw, 2, 16), INK, 0.09),
    Pt(at(fw, 6, 24), INK, 0.09),
    Pt(at(fw, 0, plan_b(0)), LEAF, 0.11),
    center{[fx(fw, 2) - 0.25, fy(fw, 16) + 0.4, 0]} Math("(2, 16)", 0.8),
    center{[fx(fw, 6) - 0.3, fy(fw, 24) + 0.42, 0]} Math("(6, 24)", 0.8),
    center{[fx(fw, 4), fy(fw, 16) - 0.27, 0]} Math("4", 0.8, SLATE),
    center{[fx(fw, 6) + 0.25, fy(fw, 20), 0]} Math("8", 0.8, EMBER),
    center{[fx(fw, 0) + 0.85, fy(fw, 12) - 0.4, 0]} Math(str_join(["b = ", to_string(plan_b(0))]), 0.85, LEAF),
    center{[fx(fw, 7.9), fy(fw, 8.5), 0]} Math(str_join(["m = \frac{8}{4} = ", to_string(m, 0)]), 0.9, EMBER)
]

Uses the shared definitions for this lesson's figures.

When two lines cross

Two lines on the same axes answer a comparison. Plan A, the one we started with, is $y = 3x + 4$. Plan B is $y = 2x + 12$.

Pause and try

At what usage do the two plans cost the same, and what is the bill there? Which plan is cheaper at 5 gigabytes, and which at 10?

Show answerHide answer

The costs are equal when $3x + 4 = 2x + 12$. Subtracting $2x$ and then 4 from both sides gives $x = 8$, and the bill is $3 \times 8 + 4 = 28$ dollars (check with plan B: $2 \times 8 + 12 = 28$). At 5 gigabytes plan A costs 19 and plan B costs 22, so A is cheaper. At 10 gigabytes A costs 34 and B costs 32, so B is cheaper.

Plan A, y = 3x + 4, and plan B, y = 2x + 12, on the same axes. Plan A starts lower and climbs faster. The lines cross at 8 gigabytes, where both plans cost 28 dollars; to the left of the crossing plan A is cheaper and to the right plan B is.
Plan A, $y = 3x + 4$, and plan B, $y = 2x + 12$, on the same axes. Plan A starts lower and climbs faster. The lines cross at 8 gigabytes, where both plans cost 28 dollars; to the left of the crossing plan A is cheaper and to the right plan B is.
Monocurl source
mesh plot = WidePlot
mesh lines = [
    Seg(at(fw, 0, plan_b(0)), at(fw, 10.3, plan_b(10.3)), EMBER, 4),
    Seg(at(fw, 0, plan(0)), at(fw, 10.3, plan(10.3)), AZURE, 4)
]
mesh marks = [
    Seg(at(fw, 8, 0), at(fw, 8, 28), LEAF, 2.5),
    Pt(at(fw, 8, 28), LEAF, 0.12),
    center{[fx(fw, 6.7), fy(fw, 32.5), 0]} Math("(8, 28)", 0.85, LEAF),
    center{[fx(fw, 3.9), fy(fw, 6.5), 0]} Math("\text{A: } y = 3x + 4", 0.85, AZURE),
    center{[fx(fw, 2.3), fy(fw, 24), 0]} Math("\text{B: } y = 2x + 12", 0.85, EMBER)
]

Uses the shared definitions for this lesson's figures.

Finding the point where two lines cross is the subject of the next lesson, solving two equations at once.

Common mistakes

One more caution concerns pictures. The slope is a number with units, and how steep a line looks depends on how the axes are scaled. The graph of plan A above climbs at a gentle angle on the page even though its slope is 3, because one grid square is 1 gigabyte wide and 4 dollars tall.

Stepping back

The hard part was noticing that there was something to prove. Algebra shows that $y = 3x + 4$ grows steadily, and a ruler shows that a drawn object is straight. That these are the same property is a theorem, and its proof needed a fact about shapes: all the right triangles that hang from a straight line are similar. Slope is the ratio those triangles share.

The reusable idea is that a line is a constant rate of change, which is why linear equations describe steady processes such as a fixed price per unit or a fixed speed. It is also the starting point of calculus: a curve such as $y = x^2$ has a different rise over run between different points, and the derivative is what the slope becomes when the two points are brought together.

Check yourself

What is the equation of the line through $(0, 5)$ and $(2, 1)$?

Problems

Problem 1

Find the slope between each pair of points: (a) $(2, 3)$ and $(6, 11)$; (b) $(-1, 4)$ and $(5, 1)$; (c) $(3, 7)$ and $(-2, 7)$.

Show solutionHide solution

(a) $\frac{11 - 3}{6 - 2} = \frac{8}{4} = 2$.

(b) $\frac{1 - 4}{5 - (-1)} = \frac{-3}{6} = -\frac12$. The line falls, as it should: moving right from $x = -1$ to $x = 5$ the height goes from 4 down to 1.

(c) $\frac{7 - 7}{-2 - 3} = \frac{0}{-5} = 0$. Both points have height 7, so the line through them is the horizontal line $y = 7$.

Problem 2

A line has slope 4 and passes through $(1, -2)$. Find its equation in the form $y = mx + b$, and find the points where it crosses the two axes.

Show solutionHide solution

The equation is $y = 4x + b$, and $(1, -2)$ must satisfy it: $-2 = 4 \times 1 + b$, so $b = -6$. The line is $y = 4x - 6$.

It crosses the vertical axis where $x = 0$, at $(0, -6)$. It crosses the horizontal axis where $y = 0$: $0 = 4x - 6$ gives $x = \frac{6}{4} = \frac32$, the point $\left(\frac32, 0\right)$.

Problem 3

A candle is 20 cm tall when lit and burns down 2.5 cm every hour. (a) Write its height $y$ in centimeters after $x$ hours as an equation. (b) State the slope and the intercept with their units and say what each means. (c) When does the candle burn out, and for which values of $x$ does the equation describe the candle?

Show solutionHide solution

(a) The height starts at 20 and drops 2.5 for each hour: $y = -2.5x + 20$.

(b) The slope is $-2.5$ cm per hour, the rate at which the height changes. It is negative because the height decreases. The intercept is 20 cm, the height at time 0.

(c) The candle is gone when $y = 0$: $0 = -2.5x + 20$ gives $x = \frac{20}{2.5} = 8$ hours. The equation describes the candle only for $0 \le x \le 8$. After 8 hours the formula gives negative heights, which mean nothing for a candle. The line continues; the situation it models does not.

Problem 4

A taxi fare is a fixed charge plus a fixed price per kilometer. A 3 km ride costs $9.50 and an 8 km ride costs $19.50. Find the price per kilometer and the fixed charge, and predict the fare for a 12 km ride.

Show solutionHide solution

Let $x$ be the distance in kilometers and $y$ the fare in dollars, so $y = mx + b$. The two rides are the points $(3, 9.5)$ and $(8, 19.5)$.

Slope: $m = \frac{19.5 - 9.5}{8 - 3} = \frac{10}{5} = 2$ dollars per kilometer.

Intercept: $9.5 = 2 \times 3 + b$, so $b = 3.5$ dollars. The fare is $y = 2x + 3.5$. Check with the second ride: $2 \times 8 + 3.5 = 19.5$.

A 12 km ride costs $2 \times 12 + 3.5 = 27.5$, that is, $27.50.

Problem 5

(a) Show that the points $(0, -1)$, $(2, 5)$ and $(5, 14)$ lie on one straight line, and find its equation. (b) Is $(-3, -10)$ on that line?

Show solutionHide solution

(a) The slope from the first point to the second is $\frac{5 - (-1)}{2 - 0} = \frac{6}{2} = 3$. The line through those two points is $y = 3x - 1$ (the first point gives the intercept directly). The third point satisfies this equation, since $3 \times 5 - 1 = 14$, so it is on the same line. Equivalently, the slope from the second point to the third is $\frac{14 - 5}{5 - 2} = \frac{9}{3} = 3$, the same as before.

(b) At $x = -3$ the line has height $3 \times (-3) - 1 = -10$. Yes, the point is on the line.

Problem 6

(a) Let $y = mx + b$. Show that increasing $x$ by any amount $d$ changes $y$ by exactly $md$, no matter what $x$ was to begin with. (b) Conversely, suppose a function $f$ has the property that for some fixed number $m$, $f(x + d) - f(x) = md$ for all real $x$ and $d$. Show that $f(x) = mx + b$ for some number $b$, and say what $b$ is.

Show solutionHide solution

(a) At $x$ the height is $mx + b$, and at $x + d$ it is $m(x + d) + b = mx + md + b$. The difference is $(mx + md + b) - (mx + b) = md$. The starting value $x$ has cancelled, so the change depends only on $d$.

(b) The property holds for all $x$, so use it with $x = 0$: $f(0 + d) - f(0) = md$, that is, $f(d) = md + f(0)$ for every real $d$. Renaming $d$ as $x$, this says $f(x) = mx + f(0)$. So $f$ has the required form with $b = f(0)$, its value at zero.

Problem 7

Let $m \ne 0$. The point $A = (1, m)$ is on the line $y = mx$ and the point $B = \left(1, -\frac1m\right)$ is on the line $y = -\frac{1}{m}x$. Compute the squares of the three side lengths of triangle $OAB$, where $O$ is the origin, and use the converse of the Pythagorean theorem (if the squares of two sides of a triangle add up to the square of the third, the triangle has a right angle between those two sides) to show that the two lines meet at a right angle.

Show solutionHide solution

By the Pythagorean theorem, the square of the distance between two points is the square of the run plus the square of the rise between them. So $|OA|^2 = 1 + m^2$ and $|OB|^2 = 1 + \frac{1}{m^2}$. From $A$ to $B$ the run is 0 and the rise is $-\frac1m - m$, so

$$ |AB|^2 = \left(m + \frac1m\right)^2 = m^2 + 2 \cdot m \cdot \frac1m + \frac{1}{m^2} = m^2 + 2 + \frac{1}{m^2}. $$

The sum $|OA|^2 + |OB|^2 = 2 + m^2 + \frac{1}{m^2}$ is the same expression, so the angle at $O$ is a right angle. The sides $OA$ and $OB$ lie along the two lines, so a line of slope $m$ is perpendicular to a line of slope $-\frac1m$: the slopes of perpendicular lines multiply to $-1$. For $m = 2$ the numbers are $5 + 1.25 = 6.25$.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

# the running example: a phone plan that costs 4 dollars a month plus 3 dollars per gigabyte
let plan = |x| 3 * x + 4
let fp = Frame(0, 5.4, 0, 21, [-1.0, 0.15, 0], 4.4, 3.1)
let PlanPlot = [
    GridLines(fp, [1, 2, 3, 4, 5], [4, 8, 12, 16, 20]),
    Axes(fp),
    XTicks(fp, [1, 2, 3, 4, 5]),
    YTicks(fp, [4, 8, 12, 16, 20]),
    center{[fx(fp, 5.4) - 0.75, fy(fp, 0) - 0.66, 0]} Note("gigabytes used", 0.72),
    center{[fx(fp, 0) + 0.95, fy(fp, 21) + 0.27, 0]} Note("cost (dollars)", 0.72)
]
# a staircase under the graph of f from x = a to x = b with treads of width run
let Stairs = |fr, f, a, b, run, col = EMBER, r = 0.07| block {
    let n = to_int((b - a) / run + 0.5)
    var pts = [at(fr, a, f(a))]
    for (k in range(0, n)) {
        pts .= at(fr, a + (k + 1) * run, f(a + k * run))
        pts .= at(fr, a + (k + 1) * run, f(a + (k + 1) * run))
    }
    . Path(pts, col, 3)
    for (k in range(0, n + 1)) {
        . Pt(at(fr, a + k * run, f(a + k * run)), AZURE, r)
    }
}
# the right triangle with a horizontal leg from x1 to x2 and a vertical leg up to the graph
let SlopeTri = |fr, f, x1, x2, col = EMBER| {
    let a = at(fr, x1, f(x1))
    let p = at(fr, x2, f(x1))
    let b = at(fr, x2, f(x2))
    return [Region([a, p, b], tint(col, 0.25)), Path([a, p, b], col, 3)]
}
# the second example: plan B costs 12 dollars a month plus 2 dollars per gigabyte
let plan_b = |x| 2 * x + 12
let fw = Frame(0, 10.5, 0, 38, [0.05, 0.15, 0], 6.2, 3.1)
let WidePlot = [
    GridLines(fw, [2, 4, 6, 8, 10], [10, 20, 30]),
    Axes(fw),
    XTicks(fw, [2, 4, 6, 8, 10]),
    YTicks(fw, [10, 20, 30]),
    center{[fx(fw, 10.5) - 0.75, fy(fw, 0) - 0.66, 0]} Note("gigabytes used", 0.72),
    center{[fx(fw, 0) + 0.95, fy(fw, 38) + 0.27, 0]} Note("cost (dollars)", 0.72)
]