Minimum time to cover distance with variable acceleration

I have a problem to solve and I got stack. The question is: Having a vehicle that weighs $$m$$ that can move at variable speed but with maximum acceleration of $$a_1$$ and minimum deceleration of $$a_2$$ calculate the minimum time to cover distance $$\ell$$. The starting and ending speed should be zero.

• Does it need to stop at the destination? If no, I think you need to accelerate the vehicle as much as you can until the end. If yes, you need to accelerate the vehicle as much as you can until it reaches a prechosen speed V, then at a later time, start to decelerate it as much as you can until it stops exactly at the destination. Since there is only one single variable V to deal with, you can easily optimize time with the best choice of V (apparently V will be the V with which you have to immediately start to decelerate). – verdelite Nov 23 '19 at 22:27
• @verdelite Yes it does need to stop at the end. I updated the post – Dimitris Karagiannis Nov 23 '19 at 22:29

Let's write $$v_M$$ the maximal velocity. Deceleration is from $$v_M$$. Then the time to decelerate with the minimal decelaration $$a_m$$ is $$t_d=v_M/a_m$$ on a distance $$l_d=\int_0^{t_d}(v_M-a_m t)dt=v_M t-a_m t^2/2$$. Now the maximal acceleration is $$a_M$$. Then $$v(t)=\int^t_0 a_M t'dt'=a t$$. And $$x(t)=at^2/2$$. At $$t_M$$ we got to the maximal velocity : $$v_M=a t_a$$ and the distance $$l_a=at_a^2/2$$. We have $$L=l_a+l_d=a_M t_a^2/2+(a_M t_a) (a_M t_a /a_m)-a_m (a_M t_a/a_m)^2/2=t_a^2(a_M/2-a_M^2/a_m/2)$$.
Ok now you can finish. You have $$t_a$$, so you have $$l_a$$. But then you have also $$l_d=L-l_a$$. And from this you get $$t_d$$, and then $$T=t_a+t_d$$.