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?

  • $\begingroup$ 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. $\endgroup$ Apr 6, 2012 at 15:09
  • $\begingroup$ @Manishearth: I'm simulating on a comupter $\endgroup$
    – Daniel
    Apr 6, 2012 at 15:27
  • $\begingroup$ What simulation? And how different re he answers? And how certain are you that the code is doing it right? $\endgroup$ Apr 6, 2012 at 17:10
  • 1
    $\begingroup$ 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. $\endgroup$
    – David Z
    Apr 6, 2012 at 17:35
  • $\begingroup$ $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. $\endgroup$ Apr 6, 2012 at 17:43

1 Answer 1


Assuming there is no friction, you can use energy conservation to get the speed.

$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++?

  • $\begingroup$ the simulation is in box2d. g is not like on earth but its the same in the simulation and calculation $\endgroup$
    – Daniel
    Apr 6, 2012 at 19:36
  • $\begingroup$ 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$. $\endgroup$ Apr 8, 2012 at 16:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.