# What is the correct way of integrating in astronomy simulations? [closed]

I'm creating a simple astronomy simulator that should use Newtonian physics to simulate movement of plants in a system (or any objects, for that matter). All the bodies are circles in an Euclidean plane, that have properties such as position, velocity, mass, radius and the resultant force.

I want to update the universe in small time steps, usually a few milliseconds, but I'm not sure how to correctly calculate the changes in position.

The force is simple: fr = sum(G * body.m * bodyi.m / dist(body, bodyi)^2).

But how do I go on from there?

I could do this:

a = Fr/body.m
v += a*dt
position += v*dt


But that would, of course, be false. Maybe if I added 0.5 as a factor in position calculation?

-

## closed as off topic by dmckee♦Oct 27 '12 at 19:50

Questions on Physics Stack Exchange are expected to relate to physics within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

The FAQ says 'Some kinds of questions should not be asked here: [...] Computational questions'. See the scientific computation beta site. But search first as I think this has already been addressed. There are also several such questions on Stack Overflow. – dmckee Oct 27 '12 at 19:50
And don't fret the silly automatic down vote: it will time out in a few days. – dmckee Oct 27 '12 at 19:50
I reposted it on the computation site. Also, if you see those similar questions on SO, please throw me a link. – jcora Oct 27 '12 at 20:02
I don't have any particular questions in mind, but searches like "planet gravity" turn up some possibilities that look promising. – dmckee Oct 27 '12 at 20:26
@dmckee automatic downvote, WTF ...?! Who has implemented such a needless and mean thing into SE? I quite often disagree about how things work or are implemented by the "overlords" into the SE sites against the will or needs of the respective communities, but such a thing is really over the top now ...! So I +1 the question to revert it – Dilaton Oct 27 '12 at 22:18