An atmospheric pixelated view of an intersection with a red light.

You are driving down a long stretch of road when suddenly, in a frustrating recalibration of traffic karma, the light in front of you turns red. Maybe, like the law-abiding citizen you are, you roll to a stop and do your time. Maybe you glance around for speed traps and zoom through the intersection -- no cop, no stop! Or maybe, if you're anything like Márton Balázs and his research team, you turn the situation into a math problem: how do I legally pass through this intersection while still getting to my destination as quickly as possible?

In its simplest form, this problem is solvable with some basic physics. If you roll to a stop, you’ll waste time accelerating back to the speed limit once the light changes. But if you don't slow down enough, you may accidentally run the red light. For every situation there’s a single ideal trajectory that leaves your car going as fast as it possibly can the moment the light turns green, and no faster.

But real life isn’t so simple. While red lights usually last between 30 seconds and a few minutes, there's a notorious intersection in New Jersey that regularly lasts over five. Plus, if you turn a corner into a red light, you have no idea how long ago the light changed -- there’s no stopwatch to help drivers do the math behind the wheel. Maybe you just missed the green and you have a five minute wait ahead, or maybe it turns green the instant you come to a stop. How is it possible to plan around all this uncertainty? Balázs and his collaborators came across a clever and unexpected solution: treat the problem like a glass of water!

Let’s return to the simplest case, with no speeding up or slowing down, but this time visualize your trip as an empty cup. The base of the cup represents your car’s maximum speed; a wider glass means you’re moving fast, while a narrow glass means you’re moving slow. Next we pour some water into the cup and say that the height of the water represents the time it takes for your car to reach the intersection. This lets us treat the amount of water in the cup as the distance between you and the light. If the light is far away, you add more water, which increases your travel time. If you're going very fast, the base of the cup is wider, and the same amount of water will lead to a shorter travel time. Considering your car’s responsiveness to throttling and braking simply changes the shape of the glass, limiting potential paths.

Two water glasses, one straight and one at an angle, with their axes labeled as in the main text.

Note: angle in the diagram is not to scale!

What Balázs has discovered is that if we tilt the glass at a very particular angle, the water level can predict the most ideal trajectory for our trip, no matter when the light turns green. Now, the water level corresponds to many different speeds and travel times, as the surface of the water is tilted with respect to the glass; but, because we poured an amount of water that exactly equals the distance we have to travel, we can be sure that we’ll never run the red light. As time passes, we trace our path up the glass, following the surface of the water. The slope of the water with respect to the glass represents exactly how quickly we should decelerate as we near the light. Once the light changes, we accelerate back to the speed limit, safely and legally on our way.

Amazingly enough, we can use similar logic even when we consider that New Jersey’s five-minute red is a lot less common than lights that last a minute or less. The difference is that we imagine the glass “placed in a funny gravitational field” that warps the water’s surface, describing strange new trajectories that give preference to shorter lights.

Beyond potential contributions to traffic modeling and self-driving car algorithms, this problem demonstrates a fundamental truth in mathematics: that a drastic reframing and a careful choice of metaphor can lead to new problem-solving insight. So next time you approach a red light, stop the car and pour yourself a glass of water. By the time you’re done with your calculations, the light will probably be green anyway!