# How do I know an initial speed of a thrown object using the max height [closed]

The simulation being referred to is in box2d

An object is thrown to the max height of $h$ with gravity of $g$, what is it initial speed?
I tried the following:
$v = v_0 - g t$
$0 = v_0 - g t$
$t = \frac{v_0}{g}$

$h = v_0 * t - \frac{1}{2}g * t^2$
$v_0 = \sqrt{2 * g * h}$

But putting it into physical simulation gives different max height, is the equation wrong or its a simulation artifact?

• How are you exactly simulating it? On a computer? Or by actually chucking the ball? In the latter case, are you throwing it straight up? Is your velocity measurement accurate? More details please. Apr 6, 2012 at 15:09
• @Manishearth: I'm simulating on a comupter Apr 6, 2012 at 15:27
• What simulation? And how different re he answers? And how certain are you that the code is doing it right? Apr 6, 2012 at 17:10
• This seems likely to be a computational issue, which means it's off topic here - but if you improve the question with more detail, it might fit on Computational Science. Apr 6, 2012 at 17:35
• $v^2 = 2as$ is the correct formula. More precisely it's $v^2 = u^2 + 2as$ where $u$ is the initial velocity and $v$ the final velocity, but if you reverse time so the ball starts stationary and falls to the ground, $u$ is zero and $v$ is the launch velocity. If this equation doesn't give the same result as the simulation it's your simulation that's wrong. Apr 6, 2012 at 17:43

$mgh=\frac{1}{2}mv_0^2 \implies v_0=\sqrt{2gh}$
As for your simulation, there is not much you can do wrong. Hope that your units are consistent, i.e $g=9.81 m/s^2$ and $h$ is also in meters. Is your simulation in C/C++?
• Regardless of the syntax, the logic is very simple. Declare $g$ as a double precision constant, $h$ and $v_0$ as double precision arrays, implement a loop within which you read values of $h$, compute $v_0$ and push the computed value back into the array you declared for $v_0$. Apr 8, 2012 at 16:08