Numerical approaches to Hamiltonian systems in Matlab

Project members: 2

This project aimed to solve the Kepler Problem by implementing different numerical methods in Matlab. We used forward Euler, backward Euler, symplectic Euler (semi-implicit Euler) and the midpoint method. 

The Kepler problem is a Hamiltonian system, which we can show with the Hamiltonian:

For this system, the energy is constant for the exact solution

In the first image to the right we can see the trajectories for the planets, using the four different methods mentioned above. In the second image we plotted the energy against the time and could see the connection between energy conservation for the methods.

Lastly we implemented the Matlab ode45 that we could see had a higher accuracy but for longer times, this method will not be as energy preserving as the midpoint method and symplectic Euler.

Full report (Swedish)