14.4: Celestial Mechanics
( \newcommand{\kernel}{\mathrm{null}\,}\)
Celestial mechanics describes how objects move in outer space. If you did Section 11.2, you simulated the Earth being pulled toward the Sun in one dimension. Now we’ll simulate the Earth orbiting the Sun in two dimensions.
To keep things simple, we’ll consider only the effect of the Sun on the Earth and ignore the effect of the Earth on the Sun. So we’ll place the Sun at the origin and use a spatial vector, P, to represent the position of the Earth relative to the Sun.
Given the mass of the Sun, m1, and the mass of the Earth, m2, the gravitational force between them is
Fg=−Gm1m2r2ˆP
Write a simulation of the Earth orbiting the Sun. You can look up the orbital velocity of the Earth or manually search for the initial velocity that causes the Earth to make one complete orbit in one year. Optionally, use fminsearch
to find the velocity that gets the Earth as close as possible to the starting place after one year.