2 Answers
2

I will assume that the mass of the mass you are concerned with is very small as compared to Earth's mass, hence, the gravitational potential is only due to Earth's mass.

Furthermore, you said that the mass is initially at rest, I will assume that the same goes for Earth (no orbiting around the sun). The motion of the mass $m$ in Earth's gravitational field $\Phi$ is then governed by the following Hamiltonian:

$$ H = \frac{p^2}{2m} - G \frac{M m}{q} $$

where I defined the impulse $p$ of the particle, it's position relative to Earth's core $q$ and the gravitational constant $G$. $M$ is the mass of Earth.

You can solve these equations, but this is a rather cumbersome business. A nicer approach is the conservation of energy: As the $m$ falls in the gravitationa potential, it loses potential energy. This energy has to go somewhere: the velocity of the particle. We hence have (by setting the overall energy to $0$):

with some integration constant $C$ equal to the initial position of $m$ to the power of $\frac{2}{3}$ (note that I already set $\dot q(0) = 0$). Furthermore, note that the first equation also gives you a relation between the velocity and position of a particle.

This also solves Hamilton’s equations somewhere up there.

If you want to include rotations (that is, either Earth moves orthe mass moves initially), things get slightly more difficult.

$F=ma$ so if you know the force due to gravity, you need to divide it by the mass $m$ of the object to get the acceleration.

You'll probably be doing discrete timeslices, so it makes sense to use an approximation known as Euler's step-by-step method:

At any point in time, you'll be storing the position and the current velocity of the object. As you say you're aware how to calculate the gravitational force I'll skip that, but then divide by $m$ to get $a$. You need to divide $a$ by number of time intervals per second (for example 100ms is 10 frames per second, so divide $a$ by 10) to get the change in velocity for that time chunk, and add this to your velocity. Similarly, divide your velocity by the frames per second, and add that to the position.