Mapping Chaotic Gravitational Basins
Restricted -body basins in dimensions
Nirav Ramdhanie · September 2026 · source

My misconceptions
I thought that gravitational basins look like Figure 2. The three white dots are “planets” not affected by each other’s gravity, and each coloured section is their respective gravitational basin. If we place an “asteroid” anywhere within the green section (with initial velocity of 0), it will fall into the green planet… is what I thought would happen. But I took a good pondering session...

I completely negated the fact that all planets are influencing the gravitational field which the asteroids are placed in. Meaning there is a very plausible chance where asteroids could completely miss the closest planet and orbit the system and could possibly end up colliding with any of the planets. The closest planet doesn’t necessarily guarantee the asteroid colliding with it.
So I decided to build a GPU simulation of the restricted n-body problem: a system of bodies where are fixed masses, and the last is a particle of negligible mass influenced by the gravitational fields of the fixed masses. I will refer to the fixed masses as planets and the negligible mass as asteroids. The asteroid moves in Euclidean -space under Newtonian inverse-square gravity until it collides with a planet of a finite radius, or until the maximum allowed time by the simulation has passed (cutoff time). I will send an asteroid for each pixel or lattice point and it will be coloured by which planet it hits, or optionally by how long that takes. This will ultimately return an image of the gravitational basins for this system.
The physical model
Since the planets do not move, they do not define a self-consistent gravitational -body spacetime, and they do not define a circular restricted three-body problem either. They are fixed “wells”. Each asteroid at position feels
with default (inverse square), even when the ambient dimension is greater than 3. This was a modelling choice. Gravity as in three-dimensional space, embedded in a higher-dimensional Euclidean space, not Gauss’s law in dimensions (which would fall as ).
All asteroids start at rest. A collision is counted through a true geometric collision with an -sphere of radius . There is a line segment created from the previous position of an asteroid to the current position of the asteroid between each time-step. If this line collides with a planet, then the first planet intersected will be counted as a collision. Motion is integrated with per-particle RK4 on the GPU; near a surface the step is CFL-limited so it cannot jump over the sphere. The initial position is coloured the same colour of the planet. If an asteroid reaches the maximum time it colours the initial position black. This ultimately colours the image with the gravitational basins.
An optional map colours by collision time over . I basically added this just to see how it looks, and it’s pretty cool.

An optional first-post-Newtonian geodesic flag exists since I was also curious. It is geodesic motion in a prescribed static multi-mass potential. I am not using general-relativistic three-body physics here.


Why rotations don’t increase linearly
I had a problem, or really just a question. What is the most efficient way to describe a cube in -dimensional space? The reason why I needed this is because I wanted to visualise higher dimensions of gravitational basins. The cube is the 3-dimensional window that you can view. A 3-dimensional cross section. I originally thought that the set of rotations increases linearly as the dimensions increase. I soon found out that I was very wrong once again.
Translations in have degrees of freedom: one per axis. Rotations don’t act the same way. The group of orientation-preserving rotations of is the special orthogonal group : real matrices with
The constraint is equivalent to the columns being an orthonormal basis. Infinitesimally, with skew-symmetric (). A skew-symmetric matrix is fixed by its strictly upper-triangular entries: one independent number for each unordered pair of axes. There are such pairs, so
That is quadratic in . Each pair of coordinates spans a plane and each plane carries its own rotation angle. In 2D there is one plane and one angle. In 3D there are three planes (yaw, pitch, roll). In 4D there are already six independent rotations. 10D has forty-five of them, and so on.
That is why a 2D image of this system is a 2-flat (an affine 2-plane) in , simulated with one asteroid per pixel, after which the motion is still -dimensional. A 3D view is a 3-flat through an -dimensional cube of initial conditions. Extra axes are chosen with sliders. An -sphere of radius meets a 3-flat in a ball of apparent radius , or not at all if the centre is farther than from that flat. It is also possible to do mixed-dimension planets: a 3D mass in 4D sits at by padding.

What the basins actually look like
See Figures 1 and 5. I pretty much did simulations for just one system: three equal masses on the vertices of an equilateral triangle. As I figured out, the collision map is not a Voronoi diagram. If you zoom in, each planet has a compact capture region analogous to a Roche lobe. Far away the combined field is nearly that of a point mass, so a particle that starts at rest falls almost radially. Which planet the asteroid eventually hits is decided by tiny deflections as it threads the triangle. The far-field therefore looks like radial stripes. Between those two effects, the boundary is very chaotic.
That structure is a basin of attraction in configuration space (here the space of initial positions at zero velocity). The images show the hallmarks of Wada basins: the boundary of each colour appears to be a boundary of all colours. A set is a Wada boundary if every open neighbourhood of a point of intersects every basin. Then there is no “edge between only red and blue”. Any neighbourhood of the edge contains all red, blue, and green.
I never proved the Wada property to . I just observed this pattern by zooming in on a boundary in which the basins appear to continuously keep appearing in between the boundaries. The images I obtained from this appear to follow Wada properties. The boundary is fractal in the practical sense that its apparent length grows under refinement and figuring out which planet an asteroid will hit if its initial position is on a boundary is unstable under arbitrarily small shifts of the initial point. Therefore there is a sensitive dependence. See Figures 1 and 4.
Colouring by time-to-hit makes the slow layer very obvious. The interiors of the lobes collide quickly (red). The filamentary sea takes much longer (green/blue). See Figure 3.
How I built the simulation
I used Python, NumPy, and CuPy. Each asteroid is an independent initial-value problem, so the natural parallelism is one asteroid per GPU block of work, compacting finished particles off the work set. Two-dimensional stills are rendered with Manim (pixel count is asteroid count). The n-D lattice is visualised with VisPy: a white 3-cube for the first three sampling axes, sliders are used for the rest, and a union of coordinate-plane slices. Each simulated run can be saved as an .npz file (initial lattice, hit index, collision time) and reopened without the need to re-simulate the system.

A first look at relativistic motion
See Figure 4. The relativistic flag was not the point of the programme, but it was the hardest piece of physics I had to get straight. What if the system was affected by relativistic motion? This was just another curious question I had and I wanted to see what it would change. I tried my best to implement this, I am not entirely sure if it is implemented properly but things look different, so it did something.
Exact multi-planet general relativity is not a closed-form metric. Einstein’s equations are nonlinear, so you cannot add Schwarzschild solutions for each mass and call the sum a spacetime. I wanted the asteroid to feel all of the frozen planets at once. The consistent choice, given planets held fixed by hand, is geodesic motion of a test particle in a prescribed static multi-mass field. The planets are boundary conditions, not a self-consistent 3-body geometry.
I took the Newtonian potential
put into the weak-field isotropic metric seen by a static observer at infinity,
and the 3-acceleration in coordinate time is then the standard 1PN geodesic form
Two consequences are immediate and were new to me in practice. First, depends on velocity, so the integrator’s RK4 stages must evaluate at each stage. Acceleration as a function of position alone is the Newtonian special case. Second, the expansion is only a controlled correction to Newton when and . In these units (, sizes ) Newtonian speeds are order one, so cannot be huge or the flag is invisible. If instead is comparable to a planet’s radius, the same formula is being used outside its derivation. That is what the “weak-field geodesic is a toy” warning means. The picture is still coloured in coordinate time: there is no lensing, no time-dilated photograph.
I learnt that you do not “turn on relativity” by adding extra terms at random, and you do not get a 3-body spacetime by superposing black holes. You pick a metric, write the geodesic equation in a definite time coordinate, and stay honest about the regime of the approximation. Implementing it meant accepting an approximate geodesic law and stating clearly where that approximation stops being a small correction.

What the programme is made for
This is quite a poor model of orbital mechanics. The planets do not orbit each other, the asteroids start at rest, there is no radiation pressure, no oblateness, no third-body ephemeris, and the quantity of interest is the endpoint of a collision, not its trajectory. Thus it is very unrealistic in that sense.
I built this programme for the chaotic scattering of masses and the visualisation of the gravitational basin boundaries. A deterministic Newtonian system whose long-term fate, as a function of initial position, is fractal and (in the three-colour case) Wada-like. That is the same mathematical species as other open Hamiltonian exit problems.
It is also a data-visualisation problem. The object of interest is a function from a region of to a discrete label (or to a time). For you cannot see it at once since we live in 3-dimensional space. I decided to use 2-flats, 3-flats, extra-coordinate sliders so that you can effectively slide through the 4th dimension and see how the basin changes. There are also two different colourings of the same samples. Visualising -spheres by their intersection with the current flat is the same idea applied to the planets themselves.
What I learnt
Rotations in dimensions are , with degrees of freedom. The most important part is that it is quadratic, not linear. Big misconception I believed.
I learnt that these systems aren’t as simple as Voronoi diagrams. They are fractals where the boundary appears to behave like a Wada boundary. The chaos here is not random either. It is deterministic motion whose endpoint, as a map from initial data, is unstable at every scale.
The 1PN geodesic made it clear that relativistic motion is motion in a metric. The Newtonian limit is a controlled expansion in and , and that a spacetime with multiple masses is not as simple as the sum of one-body solutions. Implementing required me to use an approximate geodesic law and stating clearly where that approximation stops being a small correction.
On the engineering side I learnt that a visualisation of high-dimensional data is only as honest as the cross section you chose, and that it all pretty much depends on your frame of reference. You can't just choose a random cross section and expect the results to be meaningful.


References
These pages helped a lot with researching for this project. Also fun to read.
- History Topics: Mathematical Physics Index — MacTutor History of Mathematics, University of St Andrews
- Relativity: The Special and General Theory — Albert Einstein
- Testing Chern-Simons modified gravity with orbiting superconductive gravity gradiometers — Li-E Qiang and Peng Xu, arXiv:1502.04632, 2015
- Post-Newtonian N-body dynamics in Extended Theories of Gravity — Antonio Tedesco, The European Physical Journal C, 2026
- Theory of Continuous Set of Points — Kunizô Yoneyama, Tohoku Mathematical Journal, 1917
- On the creation of Wada basins in interval maps through fixed point tangent bifurcation — Romulus Breban and Helena E. Nusse, Physica D, 2005
- Special orthogonal group — Wolfram MathWorld
- Chaos — Wolfram MathWorld