# 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?

-

## closed as not a real question by Qmechanic♦, Manishearth♦, David Z♦Apr 7 '12 at 19:33

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

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. –  Manishearth Apr 6 '12 at 15:09
@Manishearth: I'm simulating on a comupter –  Dani Apr 6 '12 at 15:27
What simulation? And how different re he answers? And how certain are you that the code is doing it right? –  dmckee Apr 6 '12 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. –  David Z Apr 6 '12 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. –  John Rennie Apr 6 '12 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$. –  Antillar Maximus Apr 8 '12 at 16:08