# Calculate maximum velocity given accel, decel, initial v, final position

I'm trying to calculate the maximum velocity of an object given:

• acceleration
• deceleration
• starting position (0)
• ending position
• initial velocity

but I still can't seem to figure it out.

The closest I've gotten is: $$t = \frac{V_{max} - V_0}{a} + \frac{0 - V_{max}}{d}$$

But even trying to solve that for Vmax leaves an unknown '$t$' in the equation, and doesn't take into account the ending position either.

A sort of real world example for this, if it helps, is of a car. The car starts at p=0, with a rolling start (in either direction). At the finish line (ending position) is a brick wall. The car must stop with the front bumper touching the brick wall. It must accelerate at a for as long as possible, then decelerate at d, ending at that brick wall, with v=0.

(I'm writing an Arduino library for controlling servos, with speed limits, acceleration and deceleration. I need to know whether the max velocity it can reach given the acceleration and deceleration will ever exceed the max velocity the library user specifies, so I can calculate whether there needs to be any time spent "coasting" between acceleration and deceleration.)

• a and d are both constant, and there's a given "ending position" the object must reach, and be at rest, so there must be a maximum velocity, unless I'm missing something. – Derek Lewis Jan 13 '14 at 16:43

We assume the object starts at time $t=0$ at position $x=0$ and ends at position $\ell$. It accelerates constantly with acceleration $a$ and then suddenly at time $t=t_1$ it decelerates constantly with deceleration $d$ (positive) until stopping at the point $\ell$. Let us call $t_2$ the deceleration time.
Then $v_\max=v_0+at_1$. To find $t_1$, note that $$v_0+at_1-dt_2=0;$$ this is the condition that the speed at $x=\ell$ is zero. And the distance has to be $\ell$, so $$v_0t_1+\frac12at_1^2+(v_0t_2+at_1t_2-\frac12dt_2^2)=\ell.$$ The term between brackets comes from the fact that the speed during the deceleration process is $v_\max-dt$, so the distance covered during the deceleration process is $v_\max t_2-\frac12dt_2^2$.
From the first equation, we get $t_2=(v_0+at_1)/d$. Plugging this into the second equation and solving, $$t_1=-\frac{v_0}a+\frac1a\sqrt{\frac{d v_0^2+2a\ell d}{a+d}}.$$ So $$v_\max=v_0+at_1=\sqrt{\frac{d v_0^2+2a\ell d}{a+d}}.$$
• $v_0t_1+at_1$, makes no sense: $v_0t_1$ has units of distance, while $at_1$ has units of speed. When the deceleration starts, the initial speed for this second part of the problem is $v_0+at_1$. The distance covered is the integral of the speed, $-\frac12 dt_2^2$ plus the initial speed times $t_2$; that's precisely the expression in brackets. – Martin Argerami Jan 13 '14 at 19:22