## Thursday, February 8, 2018

Published 6:50 PM by with 4 comments

# N-Body Problem And Our Solar System

I was curious how stable our solar system is, so I started playing a bit with the n-body problem and here are some results. I've also included simple source code in MATLAB and Python if you want to play with it yourself.

#### Examples

Here is a gif showing roughly our current situation:

I set it so that each frame has the Sun at the center, and includes the Sun, Earth, Mars, and Jupiter over 36,500 days (~100 years) of orbit. I'll list all initial conditions at the end of the post. This is the track of each of them:

The first thing I wanted to find out is what happens if Jupiter is big. The result depends on exactly how big Jupiter is. My favorite occurs on this time scale when Jupiter's mass is roughly 1/4 of the sun's mass. The Sun and Jupiter trade Mars back and forth for a bit:

If Jupiter is big but not that big, everything is pretty stable on this time scale. For example, here are the results if Jupiter is 10 times as massive as it actually is:

We can do the same with Mars. If we increase the mass of Mars, things stay pretty stable until we get to 1/10 to 1/100 the mass of the Sun. We start seeing Earth's orbit fluctuating in distance from the Sun, and we can see Jupiter's orbit get more eccentric and Earth get thrown out of the solar system. Here are the results if Mars is ~80,000 times as massive as it actually is:

You can do a lot with these, and I've attached code to play with in both MATLAB and Python (I used MATLAB for these visualizations). Switching gears, another interesting phenomenon is Lagrange points. Of particular interest in our solar system are the L4 and L5 points. When you have two masses in orbit where one is <25 times as massive as the other, you get stable orbits for additional small masses at 60 degrees before and after the smaller mass on its same orbit. The most striking example are the Trojan asteroids for the Jupiter/Sun pair. I ran some examples of those also. First, I moved Mars to be in Jupiter's orbit but at a 45 degree angle. That is, Mars is 1/8 of the orbit ahead of Jupiter. Here is a gif of the situation:

You can probably notice that the distance between Mars and Jupiter seems to fluctuate. If we plot the angle vs time, we can see that that's exactly what is happening:

It seems to bounce around 60 degrees or so. If it just starts at 60 degrees (L4), you get the following gif and angle vs time plot:

Little things lead to perturbations in the orbit. Here, there's the Earth that has a tiny effect. I also don't have exactly perfect initial conditions. The problem is also chaotic so the errors can blow up over time. Since this is a stable Lagrange point though, Mars will tend to move around that stable point as long as nothing really big perturbs it. I first encountered this midway through mechanics in college and remember it being really fascinating.

Anyway...that's it. If you want to see other simulations, feel free to edit the code posted below and/or ask me to run something.

code here

#### Background

The gravitational force between two masses is approximately G*m1*m2/r^2 where m1 and m2 are the masses and r is the distance between them. It is an attractive force so it pulls the masses together. When you have more than two objects, there is no general solution so you have to solve it numerically. Wikipedia has a good introduction to the problem.

There are a lot of paths to solve it. A very simple method is:
• setup initial conditions
• step forward a tiny amount of time
• calculate the forces between all pairs of objects
• approximate the solution to the equations of motion for each object using that force
• repeat for the next time interval
I used that simple method here. For reference, the basic equations of motion are final position = initial position + velocity*(change in time) and final velocity = initial velocity + acceleration*(change in time).

#### Initial conditions

mass of sun = 2E30 kg
mass of earth = 6E24 kg
mass of mars = 6E23 kg
mass of jupiter = 2E27 kg
orbital distance of earth = 1 AU
orbital distance of mars = 1.52 AU
orbital distance of jupiter = 5.2 AU
orbital period of earth = 1 year
orbital period of mars = 1.88 years
orbital period of jupiter = 11.86 years

1. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future... Solceller med batteri

2. Thanks so much with this fantastic new web site. I’m very fired up to show it to anyone. It makes me so satisfied your vast understanding and wisdom have a new channel for trying into the world. 10kw solar system

3. Thank you for very usefull information.. בדיקת לחות

4. With the ability to mount over 100m off the ground, HOMMIIEE high mast lighting poles can take your project to new heights. high mast led flood light manfuacturers