Contents

How hard should you brake?

Posted on June 23, 2025 by Daniel Vitek.
Tagged: , .
One of my favorite amusements while driving is to try and time my braking when approaching a red light so as to preserve as much speed as possible. Coasting in an open lane past a car waiting at a red light thanks to hitting the light change perfectly is one of those quotidian moments of joy that make life worth living. Pulling off this timing exploit is most possible on short routes that I drive frequently and know well, but it’s also occasionally possible to look at cross-traffic patterns and make an educated guess about green-light timing on roads you aren’t familiar with.
Nothing in this post should be taken as driving advice.

While the conditions for light timing require a lot of metis, the execution is more amenable to techne. In particular, the technical problem I want to think about today (and for several follow-up posts) is as follows:

Suppose that I’m traveling at speed v0v_0 towards a red light a distance dd away. I have some prior waiting-time distribution D\mathcal{D} on R\mathbb{R} for when the light will change. What should my braking profile look like?

I’ve often wondered about this problem while driving, but every time I have wondered I’ve concluded that it’s too difficult to sort out completely (at least while driving). So let’s take some time and actually work it out!
None of this post was written while driving.

For starters, this is a problem in optimal control theory: we’ve got some state functions (the position and velocity of our car as functions of time) that are influenced by a control function (our braking force as a function of time) via a differential equation (Newton’s second law), some constraints (we can’t run the red light), and we want to extremize some objective functional (unspecified in our informal description, but on which more below below).

Because the waiting time is only known as a distribution, this is actually a problem in stochastic optimal control. It’s a pretty unusual setup for a stochastic optimal control problem, however, because there’s no noise or uncertainty in the control system: we observe the state perfectly, and the state responds deterministically to our control input. Instead, the uncertainty is entirely concentrated in the time horizon.

A formal setup

Let’s get started by setting up the problem a little more formally, borrowing the usual language and notation of optimal control theory. We’ll make some simplifying assumptions throughout: no friction
Except for our brakes!
, no drag, no height variation along the road, and no mass loss due to gas consumption.

The non-stochastic problem

For today, I want to start with the non-stochastic version of our problem, which corresponds to D=δT\mathcal{D} = \delta_T being a point mass at time T>0T > 0. We’ll assume no maximum deceleration. In this case there’s a physically-obvious solution, which is to immediately brake to speed d/Td/T and then coast. This solution preserves d2/T2d^2/T^2 expected kinetic energy.

The argument that this solution is optimal is straightforward. Any solution must have x(T)=0Tv(t)  dtdx(T) = \int_0^T v(t)\;dt \le d. Since b(t)0b(t) \le 0, v(t)v(t) is monotone decreasing, so that v(tf)=v(T)=inf0tTv(t)dT,v(t_f) = v(T) = \inf_{0 \le t \le T} v(t) \le \frac{d}{T}, with equality iff v(t)v(t) is constant.

Note that in this no-maximum-deceleration setup, it’s somehow more intuitive to think of the velocity v(t)v(t) as our control. Formally this is difficult, however, because of the requirement that velocity be monotone decreasing.
I don’t know of instances in optimal control theory where path constraints involving derivatives of the control function are imposed. Such a requirement would be hard to reconcile with non-differentiable velocity inputs like those we’ll see below.

The barely-stochastic problem

The second and final problem that we’ll consider today is what happens when we introduce the tiniest-possible amount of stochasticity into the problem. Specifically, we’ll consider the setup where D=pδT1+(1p)δT2;\mathcal{D} = p\delta_{T_1} + (1-p)\delta_{T_2}; i.e., where the light turns green with probability pp at time T1>0T_1 > 0 and with probability 1p1-p at time T2>T1T_2 > T_1. We have a valid solution with v(t)=d/T2v(t) = d/T_2 as in the non-stochastic problem above, with expected kinetic energy d2/T22d^2/T_2^2. Can we do better? As it turns out, yes—but not always!

One trick to develop intuition for this case is to reason from an extreme limiting case, when pp is very close to 1 and when T2T1T_2 \gg T_1. In other words, we have a tiny probability of having to wait a very long time. In this limiting case, we can do better by immediately braking to speed d/T1d/T_1 at time t=0t = 0, then rolling up to the stoplight at time T1T_1 and immediately braking to speed zero if the light does not change. We have kinetic energy d2/T12d^2/T_1^2 if the light changes and kinetic energy zero otherwise, for an expected kinetic energy of pd2/T12d2/T22pd^2/T_1^2 \gg d^2/T_2^2.

Can we do better than this? Let’s consider the approach where we travel at some constant velocity v1d/T1v_1 \le d/T_1 on the time interval [0,T1][0,T_1] and some constant velocity v2v_2 on the time interval [0,T2][0, T_2]. At time T1T_1, we have remaining distance d1=dv1T10d_1 = d - v_1T_1 \ge 0. Hence by the non-stochastic analysis above we know that the optimal v2v_2 (given some choice of v1v_1) is given by v2=d1/(T2T1)v_2 = d_1/(T_2-T_1). So our maximum expected remaining kinetic energy is K=maxdT2v1dT1[pv12+(1p)(dv1T1T2T1)2].K = \max_{\frac{d}{T_2} \le v_1 \le \frac{d}{T_1}} \left[pv_1^2 + (1-p)\left(\frac{d-v_1T_1}{T_2-T_1}\right)^2\right].

The expression to maximize is a quadratic function of v1v_1, and the quadratic coefficient is p+(1p)T12/(T2T1)2>0.p + (1-p)T_1^2/(T_2-T_1)^2 > 0. Hence the kinetic-energy expression is a convex function of v1v_1, so it attains its maximum at one of the endpoints
This is really convenient, because the kinetic-energy expressions at the endpoints are very clean but the kinetic-energy expression at the critical point is quite messy.
v1=d/T1v_1 = d/T_1 or v=d/T2v = d/T_2. A little bit of algebra tells us that the maximum expected kinetic energy is thus K=d2min(T12p,T22),K = \frac{d^2}{\min\left(\frac{T_1^2}{p}, T_2^2\right)}, where we should take v1=d/T1v_1 = d/T_1 if T12/p<T22T_1^2/p < T_2^2 and v1=d/T2v_1 = d/T_2 otherwise.

The constant-velocity argument

To finish the analysis of the barely-stochastic problem, we need to argue why this two-constant-velocities approach is optimal. The argument here is a pretty straightforward generalization of the constant-velocity argument in the non-stochastic problem above.

To start, our velocity should clearly be constant on the interval [T1,T2][T_1, T_2], because at this point we’ve completely reduced to the non-stochastic analysis. Now notice that regardless of whether tf=T1t_f = T_1 or tf=T2t_f = T_2, our kinetic energy functional is an increasing function of dx(T1)d - x(T_1) and hence a decreasing function of x(T1)x(T_1). Because v(t)v(t) is monotone decreasing, x(T1)x(T_1) is minimized for a given v(T1)v(T_1) precisely when v(t)v(t) is constant on the interval [0,T1][0, T_1].

A concrete example

To illustrate this analysis, let’s suppose that we’re driving towards a red light which we know will turn green either one minute from now (with probability pp) or two minutes from now (with probability 1p1-p). Then the breakpoint is at p=1/4p = 1/4, and we should

This is somewhat counterintuitive: the optimal solution for preserving expected kinetic energy might include a pretty good chance (up to 75% as pp approaches 1/41/4 from above) that we’re slamming on our brakes right at the red light!

For next time

Next time we’ll fully solve the no-maximum-deceleration case when D\mathcal{D} is a discrete distribution with finite support, i.e. D=i=1NpiδTi\mathcal{D} = \sum_{i=1}^N p_i \delta_{T_i} with pi>0p_i > 0, ipi=1\sum_i p_i = 1, and TiT_i positive
Note that if T1=0T_1 = 0, then the only feasible solution is to immediately decelerate completely: i.e., v(t)=0v(t) = 0 for all t0t \ge 0.
and increasing. A good motivational exercise for next week is to consider how to use the N=2N=2 solution above in the N=3N=3 analysis.

<!– References: https://mathoverflow.net/questions/33312/what-braking-strategy-is-most-fuel-efficient https://mathoverflow.net/questions/1108/easy-probability-diff-eq-question https://mathoverflow.net/questions/284114/what-is-the-optimal-speed-to-approach-a-red-light https://arxiv.org/pdf/2511.09530 >