Consider the Sun-Earth system and a small asteroid orbiting with the system. Lagrange points points in the center of mass frame where the centrifugal force of the asteroid balances with the gravitational forces from the Sun and Earth. These five colored points are plotted below are our Lagrange points plotted on an effective potential plot.
To simulate Lagrange points in orbit, we should first simulate the Earth-Sun system. We can do this using a simple Euler-Cromer algorithm. Alongside the orbit of the Earth we have also plotted the how the gravitational potential of the Earth changes as it orbits.
It may also be fun to look at how Earth would revolve around the Sun if the eccentricity of orbit was larger...
...or if the mass of the sun was closer to that of the Earth. Notice with this orbit that the Sun has noticible and not insignificant motion relative to the center of mass located at the origin.
From here, we can easily add a third body to our simulated orbit of the Earth and Sun...
...and even a fourth body!
Now, let us compute the five Lagrange points. In a system where the mass of the largest body is 25 times larger than the second-largest body, two of the Lagrange points are stable (in green) and three are unstable (in red). The stable are L4, L5 while the unstable are L1, L2, L3.
When the mass of the largest body is less than 24.96 larger than the second largest (in the below example, it is only 2.4 times larger), then all five Lagrange points are unstable, demonstrated below.
- Including the effective potentials on the orbit diagrams
- Using more accurate simulation methods
- Creating a toggle between the center of mass and coordinate systems
- Treating the masses as non-point masses -- include collisions