# Three-Body Problem Visualization Using Julia

The three-body problem is the problem of taking the initial positions and velocities of three-point masses and solving for their subsequent motion according to Newton’s laws of motion and Newton’s law of universal gravitation (Wikipedia).

I just knew about three-body problem recently.

About two days ago, accidentally I found a Twitter account @ThreeBodyBot that produces a daily video of beautiful three-body problem visualization.

Here is the example video:

Watching all of those beautiful motion, I eager to know how to make it.

And fortunately, the creator, Kirk Long, open-sourced the code on GitHub.

## The code is written in Julia Language

The first time I saw the codes, I confused because I didn’t quite familiar with the syntax.

The syntax of the code is quite simple like Python, but it is not. And the extension of the file is .jl.

After searching on the Google, I realized that it is another programming language called Julia.

## Transcript the code to Python

Because I don’t familiar with Julia, and I didn’t know how to modify the code.

And because of that, I tried to transcript those lines of code from Julia to Python manually.

I can finish almost all of the code, except the plotting function that have different look because of different library.

Because the visualization graph looks like crap, I decided to move back to original code and modified it.

## Reading the documantion is important!

I read the source-code documentation again (and again) to get deeper understanding about what does the code do.

And it turns out that the code is not really that complicated. It is just simple.

So I can tweak the code to modify the mass, location, and velocity of the bodies. I also modified the size of the graph so it have 16:9 ratio to make it look better on Youtube.

Here is my result:

And you know what?

Kirk Long (the creator) gave comments on my video. Whoahh!

## Author: Fajrul

Amateur physicist and science writer