Algebra in the City All articles
Civic Algebra

The Lights Aren't the Whole Story: Rebuilding Your Commute as a Piecewise Graph

Algebra in the City
The Lights Aren't the Whole Story: Rebuilding Your Commute as a Piecewise Graph

You tap your destination into the satnav. It says ten minutes. You arrive in twelve, feeling as if the city has personally edited your diary. The strange part is that nothing dramatic happened: no crash, no road closure, no heroic detour. You simply stopped at two pelican crossings, waited behind a bus at a stop, and crawled along a high street where the limit is 20mph. None of that is unusual. All of it disappears into one cheerful number on the dashboard.

That number is an average, and averages are terrible at telling you what actually happened. A trip is not one speed. It is a string of little speeds and little waits. In algebra, that is a piecewise function: a function with different rules on different intervals. Your commute has been one all along.

A route you have probably driven

Take a 3.1-mile city route with seven stages. First, 0.8 miles along a 20mph high street. Then a 45-second wait at a pelican crossing. Next, 1.2 miles on a 30mph arterial road. After that, 90 seconds stuck behind a bus loading at a stop. Then 0.6 miles at 30mph, a 30-second wait at a second pelican crossing, and a final 0.5 miles at 30mph.

Those stages are not exotic. They are the ordinary furniture of a UK trip: a high street with shops and pedestrians, an arterial road doing the heavy lifting, signalised crossings, and a bus stop that temporarily turns one lane into a queue.

Turn the route into arithmetic

Speed is distance divided by time, so time is distance divided by speed. For each moving segment, multiply by 3,600 to convert hours into seconds.

Stage Distance or wait Speed Time
High street 0.8 miles 20mph 144 s
Pelican crossing wait - 45 s
Arterial road 1.2 miles 30mph 144 s
Bus stop wait - 90 s
Arterial road 0.6 miles 30mph 72 s
Pelican crossing wait - 30 s
Final road 0.5 miles 30mph 60 s

The total distance is 3.1 miles. The total time is 144 + 45 + 144 + 90 + 72 + 30 + 60 = 585 seconds, or 9 minutes 45 seconds. Average speed is total distance divided by total time:

3.1 / (585 / 3,600) = 19.1mph

So the trip averages about 19mph, even though most of the moving time is spent at 30mph. The waits take 165 seconds, nearly three minutes, and those zeros drag the average down hard.

The piecewise function hiding in your dashboard

If we let t be the time in seconds and v(t) the speed in mph, the journey looks like this:

v(t) = 20 for 0 <= t < 144 0 for 144 <= t < 189 30 for 189 <= t < 333 0 for 333 <= t < 423 30 for 423 <= t < 495 0 for 495 <= t < 525 30 for 525 <= t < 585

The function is constant on each interval: 20, then zero, then 30, then zero, and so on. The average speed over the whole trip is the time-weighted average of those values:

(20 x 144 + 0 x 45 + 30 x 144 + 0 x 90 + 30 x 72 + 0 x 30 + 30 x 60) / 585 = 11,160 / 585 = 19.1mph

That is the same answer, just built from the inside out. It also explains why you cannot simply average the moving speeds. The moving speeds are 20, 30, 30 and 30. Their simple mean is 27.5mph, which is far too optimistic because it ignores the waiting. The zeros are part of the function, so they are part of the average.

Why the satnav can still look right-ish

Suppose the satnav predicts 10 minutes. At 3.1 miles, that implies an average of 18.6mph. Our model says 9 minutes 45 seconds, or 19.1mph. The two are close, which is reassuring: the satnav is doing a version of this same sum, with extra data for acceleration, turning penalties and live traffic.

But the single ETA still hides the composition. Remove the three waits and the same 3.1 miles takes 420 seconds, or 7 minutes, for an average of 26.6mph. Add just one more 60-second hold-up and the total becomes 645 seconds, or 10 minutes 45 seconds, for an average of 17.3mph. A minute of waiting changes the story by nearly 2mph. That is why a trip can feel slow even when the satnav insists it is fine.

What to do with this on your street

Pick a route you know well. Use a map to note the distance of each section, then use a stopwatch or your phone to record the waits. Build your own piecewise function. You do not need perfect data; the exercise is the point. Convert speeds to times, add the zeros, and compare your overall average with the average of the moving sections alone.

You will probably find the same thing: the city is not one speed. It is a series of rules, some of which move you and some of which hold you. Algebra does not remove the pelican crossing. It just shows you where the time went.

All Articles

Related Articles

The Extra Ten Miles Per Hour: A School-Gate Quadratic

The Extra Ten Miles Per Hour: A School-Gate Quadratic

The Cut-Off Isn't a Border: Ranking Your Way Into a School Place

The Cut-Off Isn't a Border: Ranking Your Way Into a School Place

The Quota on the Hoarding: Auditing an Affordable Housing Promise

The Quota on the Hoarding: Auditing an Affordable Housing Promise