Re-discover Neptune with Processing

As we saw in the previous post, it’s quite easy to make even not-so-basic physics simulations with Processing and Jeffrey Traer’s library for physics. This time we’ll give a closer look to the discovery of Neptune. We won’t be really accurate here, I just want to give you the gist of it.

Reverse engineering the orbital wobbling

All the planets in the Solar System feel the force of gravity due to the Sun. However, there are also mutual attractions among the planets themselves. Even if this effect is small, such perturbations can be actually observed. In fact, it turns out that the orbits of the planets do not follow exactly an ellipse but show some “wobbling” around the smooth, ideal path. This wobbling helped astronomers to spot the planet Neptune in the mid 1800s. From wikipedia:

In 1821, Alexis Bouvard published astronomical tables of the orbit of Uranus. Subsequent observations revealed substantial deviations from the tables, leading Bouvard to hypothesize that an unknown body was perturbing the orbit through gravitational interaction

This led John Couch Adams and Urbain Le Verrier to target their telescopes towards the position as calculated using Newtonian mechanics and…voilà! A new planet was found: Neptune! Of course, it wasn’t so easy to invert the equations to predict the position of the planet. And those guys had to know how to build and handle their telescopes.

Anything unexpected about Uranus?

In our little simulation, we set up two Uranus (Urani?): one is the standard fellow, the other one does not feel the attraction due to Neptune’s gravity. We shall plot the distance between the two bodies as a function of time. Pay attention to what we’ll get.

jupiter = physics.makeParticle( m_jupiter/m_earth, width/2 + r_0*r_jupiter , height/2, 0 );
 jupiter.velocity().set( 0, sqrt(mu_solar_system_reduced/r_jupiter/r_0), 0. );
saturn = physics.makeParticle( m_saturn/m_earth, width/2 + r_0*r_saturn , height/2, 0 );
 saturn.velocity().set( 0, sqrt(mu_solar_system_reduced/r_saturn/r_0), 0. );
uranus = physics.makeParticle( m_uranus/m_earth, width/2 + r_0*r_uranus , height/2, 0 );
 uranus.velocity().set( 0, sqrt(mu_solar_system_reduced/r_uranus/r_0), 0. );
neptune = physics.makeParticle( m_neptune/m_earth, width/2 + r_0*r_neptune , height/2, 0 );
 neptune.velocity().set( 0, sqrt(mu_solar_system_reduced/r_neptune/r_0), 0. );
uranus_noN = physics.makeParticle( m_uranus/m_earth, width/2 + r_0*r_uranus , height/2, 0 );
 uranus_noN.velocity().set( 0, sqrt(mu_solar_system_reduced/r_uranus/r_0), 0. );
// all planets feel the sun
 physics.makeAttraction( sun, jupiter, G_N, r_0/100 );
 physics.makeAttraction( sun, saturn, G_N, r_0/100 );
 physics.makeAttraction( sun, uranus, G_N, r_0/100 );
 physics.makeAttraction( sun, uranus_noN, G_N, r_0/100 );
 physics.makeAttraction( sun, neptune, G_N, r_0/100 );
physics.makeAttraction( jupiter, saturn, G_N, r_0/100 );
 physics.makeAttraction( jupiter, uranus, G_N, r_0/100 );
 physics.makeAttraction( jupiter, uranus_noN, G_N, r_0/100 );
 physics.makeAttraction( jupiter, neptune, G_N, r_0/100 );
physics.makeAttraction( saturn, uranus, G_N, r_0/100 );
 physics.makeAttraction( saturn, uranus_noN, G_N, r_0/100 );
 physics.makeAttraction( saturn, neptune, G_N, r_0/100 );
physics.makeAttraction( uranus, neptune, G_N, r_0/100 );
 // here no uranus_noN / Neptune

When we run the simulation, we see that the “dark” Uranus is somehow faster than the real one. Yes, you got it: the real Uranus is slowed down by the attraction of another planet, i.e. Neptune. As time ticks, this effect builds up and after some revolutions around the Sun the discrepancy can be clearly seen…by naked eye. In case you don’t know already, Uranus is the pale blue planet after Saturn. Watch it carefully full-screen:

If we calculate the distance between the “dark” and real Uranus, we can see how this distance builds up: not only it increases on average, but it clearly wobbles in a non-periodic fashion.


In fact, this is a classical behavior that you see in a dynamic system. I made this plot with google spreadsheet. You can get the values here.

If you enjoyed the discovery of Neptune as much as me, why don’t you try it out by yourself with Processing/TraerPhysics? Grab the complete code from my google drive space:

Some suggestions for exercises:

  • Plot the angular position of the two planets as a function of time, in a frame of reference fixed with the Sun
  • Plot the difference of these two angles
  • Try to understand if the pattern in the wobbles show some dependence on the distance Uranus-Neptune (make a 2D scatter plot for instance).

One thought on “Re-discover Neptune with Processing

  1. Pingback: The Dark Matter is Out There | Beyond the Standard Model Pub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s