Sub topic 12
What m and b mean in real situations
This chapter assumes you can compute slope from two points, read m and b in y = mx + b, and solve a one-step or two-step linear equation. Here you use those skills to read a line as a statement about a real situation. You will also learn where that reading breaks down.
The two sentences to memorize
In y = mx + b, each symbol has a meaning that goes beyond its place in the formula.
mis the rate of change. It tells you how many units ofyyou gain (or lose, ifmis negative) for each 1 unit increase inx.bis the starting value. It is the value ofywhenx = 0.
The units carry the meaning. A slope of 25 means nothing by itself. A slope of 25 dollars per month is a fact you can act on. Write m as "y-units per x-unit" every time.
| Situation | x | y | m | b |
|---|---|---|---|---|
| Taxi ride | kilometers | fare in dollars | price per kilometer | flat pickup fee |
| Gym membership | months | total paid in dollars | monthly fee | sign-up fee |
| Draining tank | minutes | liters left | liters lost per minute (negative) | liters at the start |
| Savings account | weeks | balance in dollars | deposit per week | opening balance |
Reading an equation as a story
A taxi fare
A taxi charges a flat $3.50 pickup fee plus $2.00 per kilometer. With x as kilometers and y as the fare in dollars:
y = 2x + 3.5m = 2means each extra kilometer adds $2.00 to the fare.b = 3.5means a ride of 0 kilometers still costs $3.50. That is the pickup fee, charged the moment you get in.
To find the fare for 10 km, substitute x = 10: y = 2(10) + 3.5 = 23.5, so the fare is $23.50. To find how far $15.50 takes you, solve 15.5 = 2x + 3.5. That gives x = 6, so 6 km.
A negative slope
A tank holds 500 liters and drains at 12 liters per minute. With x as minutes and y as liters remaining:
y = -12x + 500The negative sign on m is part of the story. The quantity is falling, and the rate says by how much. The intercept b = 500 is the amount in the tank at time 0.
The line also crosses the x-axis, and that point has a meaning here. Setting y = 0 and solving gives x = -b/m, which is the time at which the tank is empty.
m = -12
b = 500
minutes_to_empty = -b / m
print(round(minutes_to_empty, 1)) # 41.7The tank empties after about 41.7 minutes. This x-intercept is the answer to "when does it run out?", and it is a useful check on whether your model makes sense.
Building the model from data
Usually you do not receive the equation. You receive two measurements and must find m and b yourself. Suppose a gym's records show you had paid a total of $95 after 2 months and $195 after 6 months.
- Compute the slope:
m = (195 - 95) / (6 - 2) = 100 / 4 = 25. - Solve for
busing one point:95 = 25(2) + b, sob = 45. - Write the model:
y = 25x + 45. - Check it against the other point:
25(6) + 45 = 195. It matches. - Interpret it: the gym charges $25 per month after a $45 sign-up fee.
The same procedure works in code. This helper returns the slope and intercept and prints them with their meaning attached.
def describe_line(x1, y1, x2, y2, x_unit, y_unit):
if x1 == x2:
raise ValueError("A vertical line has no slope-intercept form")
m = (y2 - y1) / (x2 - x1)
b = y1 - m * x1
print(f"m = {m:g} {y_unit} per {x_unit}")
print(f"b = {b:g} {y_unit} at x = 0")
return m, b
describe_line(2, 95, 6, 195, "month", "dollars")
# m = 25 dollars per month
# b = 45 dollars at x = 0Printing the units next to the numbers is a habit worth keeping. If the sentence does not make sense in plain English, the model or the setup is wrong.
When b has no real meaning
The rule "b is the starting value" assumes that x = 0 is a real, sensible input. Often it is not.
A town had 12,000 people in 2015 and 13,600 in 2023. If you use the calendar year as x, the slope is 1600 / 8 = 200 people per year. That part is fine. The intercept, though, is b = 12000 - 200(2015) = -391000. This says the town had negative 391,000 people in the year 0. The number is correct algebra and nonsense as a description of the town.
The fix is to change what x measures. Let x be the number of years since 2015.
m, b = describe_line(0, 12000, 8, 13600, "year", "people")
# m = 200 people per year
# b = 12000 people at x = 0Now x = 0 is the year 2015, and b = 12000 is the population at that moment. The slope did not change, because shifting x by a constant does not alter the rate. Only the intercept changed, and it now has a meaning.
Common errors
Dropping the units
Saying "the slope is 25" leaves out the part that matters. Always say what is gained per what. If you cannot name both units, you do not yet know what the slope is measuring.
Swapping x and y
The slope depends on which quantity is on which axis. If a car travels 60 km per hour, then with distance as y and hours as x, m = 60 km per hour. If you swap the axes, the slope becomes 1/60 hours per km. Both are correct, but they answer different questions. Decide which quantity is the input and which is the output before you compute.
Ignoring the sign
A positive slope means y grows as x grows. A negative slope means y shrinks. Reporting a draining tank as "12 liters per minute" is acceptable in speech, but in the equation the sign must be -12. A sign mistake turns a draining tank into a filling one.
Reading b as a total instead of a starting value
In the gym model, b = 45 is a one-time charge, not a monthly charge. The monthly charge is m. When a story has both a one-time part and a repeating part, the one-time part is b and the repeating part is m.
Extrapolating too far
A line fitted to data from months 2 to 6 describes that range. It says nothing reliable about month 60, when prices may have changed. Predicting inside the observed range is called interpolation. Predicting outside it is extrapolation, and the farther you go, the less you should trust the result.
Treating a model as exact
Real data rarely lies exactly on a line. When you build a line from just two points, you assume the relationship is linear. You are not proving it. If you have a third measurement, check whether it fits. A third point that sits off the line tells you the relationship is not linear, or that your measurements are noisy.
Comparing two models
Slopes and intercepts also let you compare options. Suppose plan A costs y = 25x + 45 and plan B costs y = 30x + 10, with x in months.
- Plan B has the lower starting cost (
10against45). - Plan A has the lower monthly cost (
25against30).
The plans cost the same where the two expressions are equal: 25x + 45 = 30x + 10, so 35 = 5x and x = 7. At 7 months both cost $220. Before that, B is cheaper. After that, A is cheaper. This is the usual pattern when one line has the higher intercept and the other has the higher slope.
def cost_a(x):
return 25 * x + 45
def cost_b(x):
return 30 * x + 10
for months in (3, 7, 12):
print(months, cost_a(months), cost_b(months))
# 3 120 100
# 7 220 220
# 12 345 370The table of results confirms the break-even point at 7 months and shows the ordering flipping on either side.
Exercises
Exercise
A candle is 20 cm tall when lit and burns down 2.5 cm per hour. Write the equation for its height y after x hours, say what m and b mean, and find when the candle is gone.
Show answer
y = -2.5x + 20. The slope m = -2.5 means the candle loses 2.5 cm of height per hour. The intercept b = 20 means the candle is 20 cm tall at the moment it is lit (x = 0). The candle is gone when y = 0: 0 = -2.5x + 20, so x = 8 hours.
Exercise
A plumber's records show a 2-hour job cost $190 and a 5-hour job cost $400. Find the linear model for cost y in dollars after x hours, and interpret m and b.
Show answer
m = (400 - 190) / (5 - 2) = 210 / 3 = 70. Then 190 = 70(2) + b gives b = 50. The model is y = 70x + 50. The plumber charges $70 per hour plus a $50 fixed fee (such as a call-out charge). Check: 70(5) + 50 = 400.
Exercise
A savings account had $800 in the year 2020 and $1,100 in the year 2023. A student uses the calendar year as x and gets b = -599,200. Explain why this b is not useful, then give a better model.
Show answer
With x as the calendar year, b is the balance in year 0, which is meaningless for this account. The slope is (1100 - 800) / 3 = 100 dollars per year. Let x be the years since 2020 instead. Then b = 800 is the balance at the start, and the model is y = 100x + 800. Check: 100(3) + 800 = 1100.