1Newton's law of gravitation
Every pair of bodies attracts along the line between them with a force proportional to both masses and falling off with the square of the distance. Add up the pulls from everyone else and divide by your own mass to get your acceleration.
A tiny softening length ε stops the force blowing up when two bodies pass through each other. With … bodies there are … pairs to add up on every force evaluation, which is why direct summation costs n².
F = G m₁ m₂ / r²G = 1 here; masses and distances in page unitsfirst planet: r = …, G M / r² = …
aᵢ = Σⱼ G mⱼ (rⱼ − rᵢ) / (|rⱼ − rᵢ|² + ε²)3/2sum over every other body j|a| = … (sun alone gives …)