This question already has an answer here:


I am a professional scientist (biologist), statistician and a computer programmer, but an amateur physicist so pardon me if this question appears silly. In order to understand general relativity (a truly inspiring theory, btw), I would like to create a computer simulation of the solar system using gravity as defined by the general relativity theory (not Newtonian gravity). I am thinking about following steps for the process:

  1. Introduce the XYZ locations, masses, and tangential velocities for celestial bodies
  2. Calculate the curvature of spacetime introduced by these celestial bodies at time t0.
  3. Remove the curvature caused by each celestial body for their own path, but include all other curvatures.
  4. Increase time to t1, iterate the new position of celestial bodies based on conditions set in step 1 and 3 (and those in general relativity).
  5. Calculate steps 2 and 3 for the new position. Repeat 4. Etc.


After using half a day online, I am still unsure whether Einstein Field Equations (EFEs) let me derive the new XYZ locations in step 4. Does General relativity let me do calculations outlined above using computational power in a modern laptop?

My background in physics and maths fails me here (this is part of the fun in learning something new). If doing the above is theoretically possible and not too computationally intensive, figuring out how to do each step is just details. I might ask such details in separate questions, but here I am after whether my understanding is completely off (never worked with partial differential equations before).


marked as duplicate by StephenG, Community Mar 27 '18 at 8:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ It would probably be better to use the parametrized post-newtonian formalism for such a thing, since using the EFEs would require you to know not only the initial positions and velocities of the planets, but also the initial metric of spacetime itself, which is a complicated problem especially for that many bodies. $\endgroup$ – Slereah Mar 27 '18 at 8:08
  • $\begingroup$ For most practical purposes, Newtonian gravity suffices. GR corrections are minuscule. What do you need the simulation for? $\endgroup$ – Qmechanic Mar 27 '18 at 8:12
  • $\begingroup$ @Qmechanic To learn and understand the general relativity theory and to play around. I find it easier to learn things through practical problems...and if it was possible, it would make a nice flexible simulation: introducing moons etc. could lead to actual behavior since (in my mind) the bodies would follow geodesics and the conditions defined in step 1 $\endgroup$ – Mikko Mar 27 '18 at 8:17
  • $\begingroup$ In other words, if the simulation would produce "wrong" results due to too large time steps, this would not be a problem for me (maybe that's why using Newtonian gravity is a better option, put the computational challenges aside). I am thinking about making an educational toy rather than a precise tool. $\endgroup$ – Mikko Mar 27 '18 at 8:24
  • 1
    $\begingroup$ Possible duplicate of Is there an algorithm for N body simulations in General Relativity $\endgroup$ – StephenG Mar 27 '18 at 8:38

Yes it can be done, but it is a remarkably difficult computation to do using the full theory. The Einstein equation looks simple as it is usually written, but it is actually a set of ten simultaneous non-linear partial differential equations. Using computers to solve for the motion of bodies in this way is generally referred to as numerical relativity but (a) you'll need a supercomputer and (b) the mathematical sophistication required is if anything even greater than using analytical methods. You aren't going to be doing this without a thorough understanding of general relativity, and you aren't going to be doing it on your home computer at all.

As mentioned in the comments, the Solar system is well described by the weak field approximation to GR, sometimes referred to as linearised gravity, or an equivalent approach such as the post-Newtonian formalism. These are computationally vastly simpler and for planetary systems are accurate to within experimental error. It is only for extreme systems like merging black holes that we would resort to the full theory.

  • $\begingroup$ Thank you for putting me on track! The PPN certainly seems complicated enough to keep me busy for quite some time and at the same time appears promising as an educational tool to understand the most elegant theory in science ever. If something comes out of this project, I will post a link to the code :) $\endgroup$ – Mikko Mar 27 '18 at 8:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.