A rudimentary simulation of the three-body problem
github.com
github.com
If you're curious what would happen to the Solar System if you made Jupiter 10 times more massive you can pip import the library and find out for yourself in about five minutes.
An integrator is an algorithm which allows the numerical approximation of the solution to an ODE, given that the ODE is written in a specific form where it is equivalent to calculating the integral of multiple functions.
Integrators are much better behaved pets and they don't shit on the carpet. So everybody uses integrators. Integrators have lots of issues too but those can be sufficiently mitigated for many classes of problems. Differentiators are mostly hopeless, feral beasts.
Now let's talk about infinities that can happen instantly: What's the derivative at the upward edge of a square wave?
Since it's so rough on the edges (especially on mobile, initially I was surprised it works at all), here's the steps for the mentioned example of making Jupiter 10x heavier:
1. Open the scenarios on the left and click play on the inner solar system to load that up
2. Click the plus on the outer planets to add them in (if it looks like nothing happened: zoom out. Space is big and this is to scale)
3. Fold out the "bodies" section and alter the mass for "J"upiter. The change is applied live.
4. Optionally press Restart to restart with the current settings but back at their initial positions and speeds
Making Jupiter 1000× heavier (and fast-forwarding the time in the Simulator controls by 10×) makes it eject Mars from the solar system within one minute, but interestingly Mercury and Venus seem pretty stable around the sun in that configurationThe help/about page (https://lucgommans.nl/p/badgravity/about.html) contains links to all other orbit projects I could find. Seeing Rebound as well as the OP, I should probably add a "libraries" section! Or do you think that should just go with "Software to download" alongside Stellarium and such?
[0] https://scholar.archive.org/work/wnwgyliq5fgtba45k535t5lb5e/...
[1] https://www.semanticscholar.org/paper/Crash-test-for-the-res...
[2] https://www.semanticscholar.org/paper/Crash-test-for-the-res...
“An attractor is called strange if it has a fractal structure.”
The best textbook I've ever read: Nonlinear Dynamics and Chaos by Steven Strogatz.
The main thing is that something like Euler's method (naive iterative approximation) doesn't guarantee conservation of energy. I believe that this is why planetary dynamics are usually handled with Lagrangian equations rather than the naive approximation approach.
Edit: It would be nice to see what the author's system does for two bodies as a sanity check. Three body system was indeed chaotic but still conserve energy - would this system do that?
It's not a particularly helpful worldview and can often be harmful if you're working with complex systems, or systems that require more than o(n(log(n)) per step, or any number of other real-world problems scientists face.
Many years later I was impressed at how well astronomy packages work (IE, "it's time T at local L, what is the angle of the sun in the sky?") and stumbled across this paper by Sussman: https://web.mit.edu/wisdom/www/ss-chaos.pdf which shows some pretty serious work on future prediction of solar system objects.
You also assumed that chaos is a measurement problem. You could simulate entire universe if you knew the initial conditions sufficiently enough. There were two nice recent papers[1][2] that showed in order to predict some orbits you'll need an accuracy less of Planck length or else some systems are fundamentally unpredictable.
[1]: https://arxiv.org/abs/2002.04029 [2]: https://arxiv.org/abs/2311.07651
In reality, we're having a hard time precisely simulating even two atoms interacting, with all the quantum effects, diffraction, gravity (however minuscule), etc.
Our universe is surprisingly detailed.
64-bit floats aren't even close enough to precisely simulate real world. What's the precision of the mass of an electron? What's the precision of its coordinates or motion vectors? Maybe plank length for coordinates, maybe not. What about acceleration? Can it be arbitrarily low? An electron's gravitational field from a billion light years away should theoretically affect us (in time).
If you simulate a universe with cube blocks from Minecraft, it doesn't matter as long as your users think the simulation is real.
And since you are simulating their consciousness, you can easily short circuit the train of thought that would cause doubt, or that would attempt logic, etc., so they truly believe their Minecraft cube world is incomprehensibly detailed down to the atoms and galaxies in the sky.
They'd happily go on the whiteboard, and prove their theories with math like 2+2=5 and everyone would agree because they literally couldn't disagree - they would feel in their hearts and minds that this is perfectly correct. There's nothing to say that's not happening now.
In fact, this is how I see most advanced civilizations performing simulations. The compute savings would be immense if you could just alter user consciousness as opposed to simulating an actual universe.
I work around people who do "Computational Chemistry", which is basically running quantum physics calculations. These tend to be done in order to either understand the properties of materials, or to understand the reasons why reactions happen. The results are more advanced materials and better performing reactions. An early and famous example of such technology is the laser. A more typical modern example would be searching for Zeolite catalysts which have particular properties, or trying to create surface coatings which protect implants from being eaten by the immune system, or on which ice cannot freeze.
Basically, I believe the advanced calculations to be correct because they lead to things which are (eventually) used in daily life.
In the example I gave of searching for zeolite catalysts, the simulations were just used to identify candidates for labs to study. I don't remember the exact numbers, but I think it brought the list of candidates down from hundreds to less than 10. The majority of these candidates were at least somewhat effective. Unless we believe that pretty much all of those hundred candidates would have been effective, then the advanced calculations were doing some work.
The question is, is all that work actually just done because of parameter twiddling? I don't think so. Consider that neural networks are often used lately in order to provide computationally simpler models of various physical phenomena. They can do a somewhat better job if fed with a lot of real data, but they use at least thousands of times more parameters than the simple quantum physics calcs with fudge factors. Thus I think it is safe to say that the structure of the quantum physics calcs does meaningfully model some part of reality. (Unless, as xvector points out, our memories are being continuously overwritten to make reality seem consistent)
It's also good to note that the fudge factors (read: parameters) and quantization are done because it would be too computationally difficult to model the parts of the system modeled by fudge factors for systems with a useful amount of atoms in them, and we just don't know how to compute ODEs for complex systems in continuous time and space. In simple systems, (e.g. 2 photons interacting) analytical solutions for ODEs can be found, no fudge factors are needed for computation, and the computed results match the experimental results to within measurement error.
I think you are missing my point - if you can short circuit logic, you will never be able to know whether your calculations are correct (but you will believe it)
Whether the outputs are used in daily life or not is irrelevant. You don't truly know if that is happening because you do not know what the fuzz factor is in the simulation.
Is the night sky the same as it was yesterday, or is it generated on the spot and your memory edited? The latter is more compute efficient.
Does your coworker look the same, or is the fuzz factor in the sim very high and they have a new face/body generated every day, with your memory edited to match?
Etc. that the outputs of the equations you described are used or not is irrelevant because it would be far more compute efficient to just not have them mean anything and to fuzz their existence/workability
Reason being, if reality is consistent, than acting as though it does achieves my goals. If reality isn't consistent, or is consistent in a way that differs from what I am capable of comprehending, then I am unable to compute any pattern of behavior that would be helpful to achieving my goals.
Thus it only makes sense to me to act like reality is consistent. I think that if I am acting this way, then it makes sense for me to say that I "believe" reality is consistent in a non thought overriding way.
EDIT: Looking at your comment again, I think that you think it is likely that reality should be simple because computing that would be easier. If we are stuck in a simulation by more advanced beings, then it is possible that compute power is a limiting factor, or they may just have computers so powerful that simulating us could be a cinch.
The simulation scenario is easy to imagine. However, just because I can't imagine scenarios besides "it just is this way", "God did it", and "We are in a simulation" doesn't mean such scenarios don't exist.
But if it's a proper simulation, base reality must be even more detailed. Like, a lot more.
Not necessarily. You could create the feeling or impression of detail on-demand - consider a 2D fractal in software that you can zoom into infinitely. It's not more detailed than our base reality, it's actually quite a simple construct.
So yeah, you're 33 decimal orders of magnitude off from the Planck length. And that's assuming that Plank length is the smallest possible length.
So you'd need at least 117 extra bits to get your representations precise. And that's just for our solar system.
For the observable universe (~93 billion light years across) you'd need 206 bits of precision.
I.e. do a simple method but calculate the total energy at the beginning, and at each step adjust the speeds (e.g. proportionally) so that the total energy matches the initial value - you'll still always get some difference due to numerical accuracy issues, but that difference won't be growing over time.
Basically, there will be error in the positions and velocities due to the integrator used and you don't know how to patch it up. You have 1 constraint; the total energy should be constant. There are 2(3N-6) degrees of freedom for the positions and velocities (if more than 2 bodies). The extra constraint doesn't help much!
Edit: Also, the only reason thermostats work is because the assumption is that the system is in equilibrium with a heat bath (i.e. bunch of atoms at constant temperature). So there is an entire distribution of velocities that is statistically valid and as long as the velocities of the atoms in the system reflect that, you will on average model the kinetics of the system properly (e.g. things like reaction rates will be right). In gravitational problems there is no heat bath.
Edit: semantics
So, even having a closed form solution isn’t helpful when computing real world situations.
In solutions to ODEs converge very often exponentially from the true result. That the 3 Body problem for this makes it characteristic, not special.
>So, even having a closed form solution isn’t helpful when computing real world situations.
Simply not true. It is helpful or not depending on your problem. Often you are interested in short term behavior, which can be studied by numerical methods or, if existing, analytic solutions.
https://www.aanda.org/articles/aa/full_html/2022/06/aa43327-...
Orbital mechanics is a tough case for perturbation theory because each planet has three degrees of freedom (around, in and out, up and down) and the periods are the same for all of these motions and don’t vary with the orbital eccentricity or inclination. Contrast that to the generic case where the periods are all different and vary with the amplitude so with weak perturbations away from a resonance the system behaves mostly like an integrable system but if the ratio between two periods is close to rational all hell breaks loose, see
https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Arnold%E2%8...
the harmonic oscillator has a similar problem because the period doesn’t change as a function of the amplitude. Either way these two pedagogically important systems will lead you completely wrong in terms of understanding nonlinear dynamic, if you add, say, an εx^3 term to the force in one of two coupled harmonic oscillators it is meaningless that ε is small, you have to realize that the N=2 case of this integrable system
https://en.wikipedia.org/wiki/Toda_lattice
is the right place to start your perturbation from which ends up explaining why the symmetry of the harmonic oscillator breaks the way that it does. Funny though, the harmonic oscillator is not weird at all in quantum mechanics and is just fine to do perturbation theory from.
But that never made sense to me, since plenty of things with closed form solutions also do this.
> A riddled basin implies a kind of unpredictability, since exact initial data are required in order to determine whether the state of a system lies in such a basin, and hence to determine the system’s qualitative behavior as time increases without bound. (Note this is different from “chaos,” where very precise initial data are required to determine finite-time behavior.) What is more, any computation that determines the long-term behavior of a system with riddled basins must use the complete exact initial data, which generally cannot be finitely expressed. Hence such computations are intuitively impossible, even if the data are somehow available.
http://philsci-archive.pitt.edu/13175/1/parker2003.pdf
The above post is a good 'example' of sensitivity to initial conditions, and riddled basins do have a positive Lyapunov exponent which is often the only criteria in popular mathematics related to chaos. But while a positive Lyapunov exponent is required for a system to be chaotic, it is not sufficient to prove a system is chaotic.
If you look at the topologically transitive requirement, where you work with the non-empty open sets U,V ⊂ X....riddled basins have no open sets...only closed sets.
With riddled basins, no matter how small your ε, it will always contain the boundary set.
If you have 3 exit basins you can run into the Wada property, which is also dependent on initial conditions but may have a zero or even negative Lyapunov exponent and is where 3 or more basins share the same boundary set...which is hard to visualize, non-chaotic, and nondeterministic.
Add in strange non-chaotic attractors, which may be easier or harder than strange chaotic attractors, and the story gets more complicated.
Sensitivity to initial conditions is simply not sufficient to show a system is chaotic in the formal meaning.
But the 3 body problem's issues do directly relate to decidability and thus computability.
As far as I understand, extreme sensitivity to parameters/ICs is all that is required for a system to be chaotic.
Here is a paper that is fairly accessible that may help.
https://home.csulb.edu/~scrass/teaching/math456/articles/sen...
It becomes important when you have a need to make useful models, or to know when you probably won't be able to find a practical approximation.
It is similar to the erroneous explanation of entropy as disorder, which is fundamentally false, yet popular.
It has real implications, like frustrating the efforts to make ANNs that are closer to biological neurons:
https://arxiv.org/abs/2303.13921
Or even model realistic population dynamics.
> It has been shown how simple ecosystem models can generate qualitative unpredictability above and beyond simple chaos or alternate basin structures.
https://www.researchgate.net/publication/241757794_Wada_basi...
Chaotic, riddled, and wada can be viewed as deterministic, practically indeterminate, and strongly indeterminate respectfully.
If you want to hold on to the flawed popular understanding of the butterfly effect that is fine, you just won't be able to solve some problems that are open to approximation and please don't design any encryption algorithms.
I think realizing it is simply a popular didactic half truth, is helpful.
This seems a bit off, it seems like[1] an implicit assertion ("only(!) demonstrates") that it is not possible for a system that lacks a closed form solution in fact (beyond our ability to discern) to be demonstrated.
To be clear I'm in no way implying this was your intent (I see it as an interesting "quirk" of our culture)...I'm mainly interesting if you can see what I'm getting at.
As a thought experiment, stand up two instances: one is our current situation (inability to discern, indeterminate), the other where we have (somehow) proven out (or, come to believe we have, reality being Indirect but experienced as Direct, thus: "is "proven", thus: "is") that a closed form solution is not possible: would the second instance "be(!) a demonstration that the system has no closed form solution"? (Thinking more....I think maybe the choice of the word "demonstrate" may very well make a path to seeking the truth of the matter ~impossible to achieve in these sorts of cases, especially if one takes cultural forces[2] into consideration).
[1] Using "pedantry", which few people understand the technical meaning of, and tend to flip flop on depending on what is being considered (precision & accuracy in science/physics is good, precision & accuracy in philosophy/metaphysics is bad - no explanation or justification needed: a Cultural Fact).
[2] Which make the 3 body problem in the known to be deterministic physical realm seem like child's play.
>As a thought experiment, stand up two instances: one is our current situation ..., the other where we have (somehow) proven out ... that a closed form solution is not possible
As far as I understand, this has in fact been proved. Quite a long time ago, too, by Poincare I believe.
GP has edited his comment to reflect my feedback, but originally said that his experiment "demonstrates that there is no solution." All I was trying to point out is that the two concepts are not necessarily related.
You could imagine some system x' = f(x), where f(x) is some transcendental function. There is no analytic solution to this system, but it's obviously not chaotic.
Could you imagine a system that is chaotic but does have an analytical solution? I'm not sure. Closest I could find to answering this was: https://sprott.physics.wisc.edu/pubs/paper496.pdf
I'm sure he understood this. I only commented to try and minimize the confusion of others.
edit - This article suggests that the logistic map (a system famously used to introduce the concept of chaos) has an analytical solution: https://www.sciencedirect.com/science/article/pii/0378437195...
That the three body problem is unstable and that no analytic solution exists are completely independent statements.
The upright pendulum is also an unstable ODE, yet it has an analytical solution.
One interesting detail is that the source code makes extensive use of non-ASCII identifiers, for mathematical symbols and for the names of mathematicians. One of the two primary contributors is also an active contributor to Unicode
I've never gotten very far but the one thing it did manage to impress extremely thoroughly on me is "space is hard". And it's like 5x easier in KSP than on earth lol.
Also it showed me that that ever recurring thought of "why don't they just..." is usually pretty misguided.
I really respect how they managed to make this fun and so incredibly educational at the same time.
Surprisingly enough the jar still runs without issue. Something which probably would not be the case for linux binaries, but maybe for windows.
I jest. Tbh, I didn’t know this was an actual problem. Thanks for sharing.
In college, a long time ago, I wrote something like this, for n bodies, but in c++ and OpenGL
More recently I’ve built something similar in python
For anyone interested in this, I recommend this Wired article that goes from the 2 body problem to n, with simulations and code that run on the browser: https://www.wired.com/2016/06/way-solve-three-body-problem/
In the case of the solar system, yes, it helps that the Sun is much more massive than everything else (and then Jupiter is 4 times more massive than Saturn, the next biggest) - you can go a long way to a "reasonable" solution by starting with the 2-body solution if only the Sun affected each planet, and then adding in the perturbation caused by Jupiter and Saturn. (In fact, that's how we predicted the existence of Neptune, by noticing that there were extra perturbations on Uranus beyond those, and hence another massive planet must exist, far enough away from the sun to only significantly affect Uranus).
One such case where a solution is known is the Lagrange point of the Earth-Moon-Sun system (and similiarly for other points) https://en.wikipedia.org/wiki/Lagrange_point But in reality, they exist only as an approximation. They aren't truly stable.
My understanding the way to calculate spacecraft, asteroid, etc. trajectories is just through a discrete simulation.
Like f you don't know how to solve the antiderivative of a given function, you can still calculate the integral since you know the value of the function.
Computers can easily solve initial value problems for most ordinary differential equations. They integrate them, calculating an approximate solution after every small, but finite step.
Getting an approximate solution to the 3-Body problem can be achieved in around 20 lines of python, without having to use any libraries. It is a remarkable simple and effective technique.
Note that n-body problems are not particularly complex or hard to solve compared to other chaotic systems. In many ways, the existence or nonexistence of closed-form solutions is mostly a distraction: it merely reflects our choice of primitive functions and there is no sets of primitive functions that is stable for addition, multiplication, composition, inversion and integration. Typically, even the simple integral ∫ eˣ/x dx cannot be decomposed into more elementary functions.
But that doesn't matter in practice, because we are already using numerical approximation to compute primitive functions that are not implemented in hardware. Using numerical solvers to compute solutions to ODE is not so different. A good illustration of that point is that there is an analytic solution for the 3-body problem (in the form of an infinite series in t^{1/3}). But this solution is useless for computing orbits because it has bad convergence properties. In other words, it is better to use a numerical solver rather than stick to the analytical solution. And a similar phenomenon exists for polynomial equation of degrees 3 and 4: the exact formula is numerically unstable, and its better to use a numerical solver when one wants a numerical solution.
This reminds me of Langtons Ant, that has very simple rules, but at first still seems very chaotic. Then after some number of iterations it just shoots away in a regular endlessly regular repeating pattern. "Order came from chaos." So it makes me think, maybe there is not a way to tell, whether the orbits "stabilize" at some point, but maybe they will, and we simply don't know when or how to tell?
Source at https://github.com/zkhr/blog/blob/main/static/js/three.js
you can play around with the code. Clicking generate a new solar system. There are a few constants you can adjust at the top of the file.
Not a "solution" of course, but certainly an optimization if you're just generally doing gravitational simulations.
It contains a numerics tutorial [2] that I found very useful for my use case.
[0] https://github.com/kirklong/ThreeBodyBot
[1] https://botsin.space/@ThreeBodyBot/112200106103679713
[2] https://github.com/kirklong/ThreeBodyBot/blob/master/Numeric... (ipynb)
You can see this in the very beginning of the simulation, with the blue and green dot.
Can anyone say if this is actually accurate? It seems like an unintuitive motion to me, but I'm often surprised by how these things work.
example from wikipedia: https://en.wikipedia.org/wiki/Three-body_problem#/media/File...
The solar system is strictly speaking a 20+ body system. That said, the behavior of the solar system is fairly predictable because the the sun has almost all of the mass, and jupiter has almost all of what remains, everything else is a small correction term. We can to a good approximation calculate the other satellites' orbits around either the sun or the center of mass of the sun-jupiter system.
The simulation doesn't get easier with 4 tho, so 3 body problem is still a good name. Also the planets mass is "almost" negligible compared to that of the suns, so I assume simulating (+ occasional correcting) 3 bodies is already a good approximation.
Think about how bad we are at analytically solving “simple looking” diff-eqs and the above statement starts to sound too true.