Planetary Motion with Different Force Laws
We take a central force proportional to some power of the radius: force F = Grn
For example, for n = 1, the force is directly proportional to distance from the center. This is a two-dimensional harmonic oscillator, the orbits are closed ellipses, the attractive "sun" being at the center of the ellipse.
The inverse square law (our Solar System), n = -2, also gives elliptic orbits, but now the Sun is at one focus of the ellipse, not at the center. (There are also unbound parabolic and hyperbolic orbits.)
These two values, n=1,-2 are the only ones giving closed orbits (except for special initial values, for example circular orbits are always possible, but not necessarily stable).Moving slightly away from n= -2 gives a precessing elliptical orbit (try it!). This is the behaviour of Mercury's orbit. The precession is partially caused by other planetary attractions, but, crucially, there is a significant contribution from general relativity. This was historically very important: it convinced Einstein he was on the right track.
Orbits with n = -3 or less are unstable. You'll find they get pretty wild on getting below -2.7 or so .
What do you expect for n = 0? For n = 10? Check them out, and interpret.
Code by David Bang