# Fastest possible time for Rectilinear Commuter Train

Say one has a train on a track between two stations with four constraints:

$a_a$ = Acceleration of the Train.
$a_b$ = Braking/Deceleration of the Train.
D = Distance between the two stations.
$v_{max}$ = Top Speed of the Train

What is the minimum possible time between two stops? Assuming the engineer accelerates and brakes perfectly? It is non trivial because the train may not have a chance to hit top speed.

I could no doubt come with a Python numeric solution for this, but there must be a solution that Calculus can offer, I just cannot figure it out.

The solution must be some sort of integral optimization, I need to solve for $t$ with the rectilinear motion formulae, but the struggle is that the 3 stages (train acceleration, train traveling at top speed, train braking) cannot be included in one equation, and it is unclear how I would pull that off.

I've spent the past couple hours on this to no avail. This is not a homework problem, just a physics grad who was curious how big of a difference upgrading the local commuter trains would make, and whether higher top speed or better acceleration would be more important.

Update:
Someone has pointed out that there's no single workable equation, because of the case statement of the train hitting top speed, which is a fair point. But it is still unclear how to find the minimum time without a top speed. Also after having reconsidered the question based on the responses, I found this previous answer with new different search terms. -> Determining the peak speed of an accelerating/decelerating body between two point.
This is similar to what I am looking for, except I would like to assume different accelerations and decelerations (which I think leads to very different math).

Accelerate as fast as you can until either you reach top speed or reach the point at which you no longer have enough distance to decelerate. If the former, continue at top speed until you have just enough distance to decelerate.

Since it's a routine calculus exercise to relate time and distance given initial conditions you can find algebraic expressions for the relevant times and distances. You won't end up with a "single equation" for the minimum trip time since there's a case statement to take into account.

• Right, if the train has time to hit stop speed, and then brake, the math is easy, but what equation would I use to find the location to start braking if the train doesn't have time to hit stop speed? That equation doesn't seem very obvious. – 12eward Sep 15 '18 at 2:32
• @12eward [revision to previous comment] Use conservation of energy: under constant acceleration, kinetic energy is a linear function of distance so finding the transition point is a matter of intersecting two lines. – amd Sep 16 '18 at 0:57
• The distance to decelerate from top speed is the same as the distance to accelerate to top speed using the deceleration rate. Compute the acceleration distance and deceleration distance, add them together. If the run is longer you hit top speed. If not, accelerate from the start, decelerate to the end, and find the point where the speed matches. That is the point to change from one to the other. – Ross Millikan Sep 16 '18 at 2:06

Conservation of energy is your friend for problems like this in which distances are known but times are unknown.

The journey, as Ethan Bolker has explained in his answer, consists of two or three segments: accelerate until you either reach top speed or there’s just enough distance remaining to stop the train, possibly cruise for a bit at top speed, then decelerate to a stop. So, we first find the distance required to accelerate the train from a standstill to its top speed: $$\frac12m v_{\text{max}}^2 = ma_a\Delta s_a \implies \Delta s_a = {v_{\text{max}}^2\over2a_a}.$$ (I’ll suppress the mass $m$ from here on since it will factor out of all of the equations.) Similarly, taking $a_b\gt0$, we have $$\Delta s_b = {v_{\text{max}}^2\over 2a_b}$$ for the distance required to stop the train from its maximum speed. The times it takes to traverse these distances are simply $v_{\text{max}}/a_a$ and $v_{\text{max}}/a_b$, respectively.

Now we need to turn to cases. If $\Delta s_a+\Delta s_b\le D$, then the train will hit its top speed before needing to decelerate. Using the above acceleration/deceleration times, the total time for the trip is therefore $${v_{\text{max}}\over a_a} + {D-\Delta s_a-\Delta s_b\over v_{\text{max}}} + {v_{\text{max}}\over a_b}. \tag{*}$$

On the other hand, if $\Delta s_a+\Delta s_b\gt D$, then the train needs to start braking before reaching top speed. We can find the transition point by equating the work done accelerating and decelerating: $$a_a \Delta s = a_b(D-\Delta s) \implies \Delta s = {a_b\over a_a+a_b}D.$$ The top speed that the train reaches is therefore $$v = \sqrt{2a_a\Delta s} = \sqrt{{2a_aa_b\over a_a+a_b}D}$$ and the total time for the trip is $v/a_a+v/a_b$.

If you like, you can hide this case analysis inside of $\min$ and $\max$ expressions in formula (*): instead of $v_{\text{max}}$ you’d use $\min\left(v_{\text{max}},v\right)$ and so on.

Note that none of this required any direct use of calculus. This is largely because all of the accelerations are uniform and come and go instantaneously. If the accelerations aren’t uniform, on the other hand, such as when they ramp up smoothly, you will likely need to bring some calculus to bear. You can still work in the energy/distance domain, and to compute transit times you can integrate the reciprocal of the speed. You’ll have improper integrals for the first and last segments of the trip, but if you’ve done everything correctly, these integrals will converge.