The Big Picture
Drop an apple. Why does it fall straight down? Why does the moon stay in orbit instead of flying off into space? Why does light bend around the sun? Three questions, one answer at the Newtonian level: a single scalar field called the gravitational potential encodes the entire effect of every mass in the universe. Just like the electric potential of the previous section, it satisfies a Poisson equation:
Here is the mass density at the point , is Newton's gravitational constant, and is once again the Laplacian. The equation says the same thing in gravity-speak that it said in electrostatic-speak: mass density tells the potential how to curve; the gradient of the potential is the acceleration any test particle feels.
Why this is exhilarating. Newton wrote down for two point masses. That equation, paired with the principle of superposition, is enough to derive everything in the rest of this section — the potential, Gauss's law for gravity, Poisson's equation, the shell theorem, planetary orbits, escape velocity, even (with general-relativistic corrections) the perihelion of Mercury. One inverse-square law unfolds into the entire structure of celestial mechanics.
Compare side-by-side with the electrostatic version you just learned. The equations are almost identical, but the sign and the constant tell a story:
| Quantity | Electrostatics | Gravity |
|---|---|---|
| Source | Charge density \rho_e (signed) | Mass density \rho (always \geq 0) |
| Potential | V (volts) | \Phi (J/kg) |
| Field | \mathbf{E} = -\nabla V | \mathbf{g} = -\nabla \Phi |
| Poisson equation | \nabla^2 V = -\rho_e/\varepsilon_0 | \nabla^2 \Phi = +4\pi G\,\rho |
| Far-field potential of a point | +kq/r (sign depends on q) | -GM/r (always negative) |
| Net effect | Like signs repel | Always attractive |
The key difference: mass has no negatives. Every source pulls. The wells of the gravitational potential never invert — and that is why everything eventually clumps under gravity, while charge distributions can shield each other out. Cosmology, planet formation, structure formation: all consequences of that single sign.
Newton's Inverse-Square Law
In 1687 Newton published the law that started it all: any two point masses and separated by attract each other along the line between them with magnitude
The minus sign and the unit vector (pointing from toward ) make the force attractive: it always pulls back toward . Three things to chew on before we generalize.
The inverse-square shape
Why the exponent 2? Geometrically, a point source "spreads its influence" over the surface of a sphere of radius , and that surface has area . Whatever the total outward-pointing influence is (call it "flux"), it must thin out as to keep the integral conserved. The inverse-square law is, at its heart, a statement about the dimensionality of space.
Analogy — paint on a balloon. Take a fixed amount of paint and spray it uniformly outward from a tiny nozzle. At distance from the nozzle, the paint covers a sphere of area . So the surface density of paint (mass per unit area) is total mass divided by . That is the inverse-square law. Gravity isn't paint, but the geometric reasoning is the same.
Superposition: gravity is linear
If many masses act on a single test particle, the total force is the vector sum of the individual forces:
Linearity is profound: it means we can decompose any extended mass distribution into infinitesimal point masses, compute each pull separately, and add them up. Every continuous distribution becomes an integral. Every numerical galaxy simulation in the last 60 years is built on this.
Mass attracts mass — there is no "anti-gravity"
Unlike electric charge, mass has only one sign. There is no "negative mass" in classical Newtonian gravity. Two consequences:
- You cannot shield gravity. Pile up a wall of lead between you and the Earth and the Earth still pulls just as hard on you.
- Gravitational potential energy is always negative (taking ). A bound system has lower energy than its separated parts — this is why stars and planets form spontaneously out of diffuse gas.
Why a Potential? From Vectors to a Scalar
Newton's law gives you the force. But carrying around a three-component vector for every particle gets tedious — and worse, it hides a beautiful structure. The fix: introduce a scalar potential such that the gravitational acceleration is its (negative) gradient,
The acceleration (also called the gravitational field strength; units m/s²) is just the force per unit mass: . For a point mass at the origin the potential turns out to be
which you can verify by differentiating: — Newton's law recovered. So carries exactly the same information as the force law but as a single number per point.
Three reasons the potential is the right object
- Scalars superpose more cleanly than vectors. For masses, summing potentials is one addition per point; summing force vectors is three additions. More importantly, the potential of a continuous distribution is a single triple integral, while the field is three.
- Energy is potential, not force. The work done against gravity to move a unit mass from to is exactly — a path-independent difference. Try writing that statement using only the force: you need a line integral and a curl-free assumption.
- Boundary-value problems are tractable in the potential. The equation is a single linear PDE with well-developed analytic and numerical machinery — the same machinery we used for the electric potential.
Mental model — the bowl. Picture a bowl whose depth at a point is the local potential. A marble placed anywhere rolls in the direction of steepest descent — that is . The bottom of the bowl is the deepest well; the rim is far from any mass where . Every mass digs a well in the bowl, and wells from many masses superpose to form the cosmic landscape that planets, stars, and galaxies live in.
Interactive: The Gravitational Well
Drag the sliders. The left panel shows the inverse-square force per unit mass ; the right panel shows the corresponding potential well . Notice how the force diverges at much faster than the potential does — that is the singularity all of classical gravitation hides under the rug, and is one of the reasons general relativity was eventually needed.
Force vs. potential for a single point mass
Left: the inverse-square pull (attractive, so negative). Right: the matching potential well . The dot tracks your test radius.
Notice: doubling the mass doubles both and at every radius. Halving the radius quadruples the force but only doubles the depth of the well — that is the signature of vs. .
Things to try. Set to Earth's value (5.97) and slide to 6.371 — you should see and . That potential value is the famous "escape energy per kilogram": to leave Earth's gravitational well from the surface you must supply at least of kinetic energy per kg, giving an escape speed .
Gauss's Law for Gravity
Just as the electric field has a Gauss law, so does gravity. The reasoning is identical because both forces are inverse-square. Pick any closed surface in space; let be the total mass enclosed inside. Then
The minus sign says: the gravity-flux through any closed surface points inward, proportional to the enclosed mass. Compare with the electric version — same form, with replacing and the minus sign reflecting the attractive nature of gravity.
Why this matters: symmetry shortcuts
Gauss's law turns hard volume integrals into easy surface integrals when symmetry permits. Three workhorse examples:
| Symmetry | Surface to use | Result for |g| |
|---|---|---|
| Spherical (planet, star) | Sphere of radius r | |g| = GM_{\text{enc}}(r)/r^2 |
| Cylindrical (infinite line of mass) | Cylinder | |g| = 2G\lambda/r |
| Planar (infinite sheet of mass, density \sigma) | Pillbox | |g| = 2\pi G\sigma (constant!) |
The spherical case alone is responsible for: orbits, escape velocity, planetary masses inferred from satellites, and Newton's elegant proof that a uniform spherical shell exerts no net force on anything inside it (the shell theorem). That theorem is why Earth can be treated as a point mass when computing the moon's orbit, even though Earth is obviously not a point.
From Gauss to Poisson
The Poisson form of gravity is one substitution away. We take Gauss's law in integral form, convert it to a divergence equation, then substitute .
- Apply the divergence theorem to Gauss's integral form. The flux integral on the left becomes a volume integral of the divergence: . On the right, .
- Equate the integrands. Since the volume is arbitrary, the integrands must agree pointwise:
- Use . Then . Substituting into step 2 and flipping the sign:
That is Poisson's equation for gravity. Outside any mass, where , it reduces to Laplace's equation , and the potential is determined entirely by boundary data — just like in electrostatics outside the charged region.
One picture, two physics. The electric and gravitational Poisson equations are mathematically the same problem. Any algorithm that solves one — finite differences, multigrid, fast multipole, neural-network PDE solver — solves the other with one sign flip. That is why graduate courses in plasma physics, geophysics, astrophysics, and electrical engineering all spend a week or two on the same linear PDE.
Worked Example: Earth as a Uniform Sphere
Treat Earth as a ball of radius with uniform density . By spherical symmetry depends only on . The Laplacian in spherical coordinates for a radial-only function is
Two regions, two ODEs. Inside the ball the source is constant ; outside the source is zero. We solve each region, then glue them at so that and are continuous (no infinite-density surface layer). Add the natural boundary condition and the answer is uniquely determined.
Uniform sphere (Earth model): and
Inside the potential is parabolic and grows linearly from zero. Outside, the sphere looks identical to a point mass at the centre — the shell theorem.
The piecewise result is the gravitational mirror of the charged-sphere formula from the previous section:
- Outside the ball, gravity is identical to a point mass at the centre — Newton's shell theorem in one line. Earth's 6,000-km radius is invisible to the moon: only the total mass matters.
- Inside, the field grows linearly: for . So if you fell down a frictionless shaft through the centre of Earth you would oscillate in simple harmonic motion with period ≈ 84 minutes.
- The well is deepest at the centre: , which is exactly the surface value .
Expand: do the integration by hand (try it yourself first!)
Step 1 — write the ODE in each region. Multiplying the spherical Laplacian by gives . Two antiderivatives separated by the boundary at .
Step 2 — inside (), constant .
- Integrate once: . For (no force at centre by symmetry), . So .
- Integrate again: . The constant is fixed by matching at .
Step 3 — outside (), .
- Integrate twice with zero source: . kills . So .
Step 4 — match at .
- Match slopes: and . Setting equal: (using ).
- Match values: . Solve: .
Step 5 — assemble. . Using this rewrites as — exactly the boxed formula above.
Sanity check with Earth numbers. , , :
- Surface gravity: — matches what you feel.
- Surface potential: .
- Centre potential: — exactly deeper than the surface.
- Escape velocity from the surface: .
Interactive: Mass Distributions to Potential Fields
Click anywhere to plant a mass. The 64×64 grid behind the canvas solves by Jacobi relaxation — every cell updates to the average of its neighbours minus a source bump. The colormap goes from white (potential ≈ 0) at the edges to indigo at the bottom of the wells, and the arrows show the gravitational acceleration , which always points toward mass.
Click anywhere to place a mass
The grid solves in real time via Jacobi relaxation. Indigo = deep well, white = surface. Arrows show — they always point into mass, never away.
Notice: there is no "negative mass." All wells go down. The arrows never point outward — gravity is purely attractive. Place a tight ring of masses and look at the centre: the wells partially flatten out (Newton's shell theorem in 2D form).
What to play with. Two masses far apart: each digs its own well and the saddle between them is a Lagrange-like point where vanishes. A tight cluster: wells merge into a single deeper well — exactly how galaxies look in gravitational potentials. Place a ring of masses: at the centre, the radial arrows from each mass cancel out by symmetry (the shell theorem in flat-land form). Crank up the iterations to converge tightly; drop them low to watch Jacobi propagate information one cell per sweep.
Computing It: Direct N-Body in Python
Before reaching for a grid-based PDE solver, you should know the most direct way to compute the gravitational potential: sum it. For a set of point masses, Newton's law gives as a literal arithmetic sum. The implementation below evaluates this at a single field point. The trick: every step is direct addition — no PDE, no iteration. It is the rawest possible expression of the law.
Why direct summation matters. The Poisson PDE and the direct sum agree because the kernel is literally the Green's function of the 3D Laplacian (up to a constant) — that is the content of Green's functions you saw in Section 3. So for free-space problems with no boundary conductors, direct sum and grid-based Poisson solve are two equivalent computations of the same . Use direct sum when you have many point particles and few field points; use grid Poisson when you have a continuous and want everywhere.
Scaling Up: PyTorch on the GPU
Direct summation is — one term per particle per field point. With a million particles and a million field points the Python version above would take days. PyTorch lets us trade nested for-loops for tensor broadcasting and run the whole computation as one parallel kernel on a GPU. Below we build a toy "galaxy" of 200 stars and evaluate along a line slicing through the galactic plane.
With a softening length the potential is bounded everywhere — no infinities even when a probe lands on a star. The minimum value of along the slice gives the depth of the cluster's gravitational well, and the rate at which at large tells you the total mass (because at large distances the cluster looks like a single point of mass , and ).
From toy to real. Real cosmological simulations (Millennium, IllustrisTNG, FIRE) follow billions of particles through cosmic time. Direct summation at would be impossible — those codes use tree codes (Barnes-Hut, ) or particle-mesh hybrids that solve Poisson on a grid for the long-range force and sum directly only for nearby pairs. Every one of those algorithms is a smart approximation of the inner loop you just wrote.
From Tides to Cosmology to ML
The gravitational potential is doing more work in modern science and engineering than you might guess. A few highlights to anchor the idea.
Tides — the second derivative of
Standing on Earth, you don't feel the moon's pull as a uniform shift — you feel its gradient. The tidal force on a body of size at distance from a mass is — the second derivative of . The reason ocean tides exist at all is that isn't flat across Earth: the near side is pulled more strongly than the far side. The same falloff is why a planet too close to a black hole gets shredded (spaghettification).
Orbits as motion in a 1D effective potential
For a body in orbit around a point mass, conservation of angular momentum lets you eliminate the angular variable and write the energy as if the body lived in a 1D potential
The two terms compete: the gravitational well pulls inward, the centrifugal barrier pushes outward. The minimum of sits at the circular-orbit radius; energies above the minimum give elliptic orbits, exactly at zero give parabolic escape, above zero give hyperbolic flybys. Every Kepler problem in the universe lives on this one curve.
Cosmology and dark matter
Galaxy rotation curves measure for stars orbiting a galactic centre. From Newton's law , so . Observed curves stay flat far out, implying well beyond the luminous matter. The Poisson equation for the inferred mass distribution doesn't add up unless there is invisible matter — that is the observational origin of dark matter. Everything here uses nothing more advanced than .
Machine learning connections
- Score-based generative models & Poisson flow networks. The 2022/2023 PFGM family (Xu, Jiang, Karras, et al.) explicitly trains a neural network to learn the gradient of a 3D Poisson potential whose source is the training data distribution. Sampling = following back toward the wells (the data). Same equation as gravity, with images as "masses."
- Graph neural networks via the Laplacian. Replace the continuous Laplacian by the graph Laplacian . Smoothing signals over a graph by is exactly one Jacobi sweep of on the discrete graph. Many GNN message-passing schemes can be read as "solve Laplace on the data graph."
- Physics-informed neural networks (PINNs). Same idea as in the electrostatic section: train a net by minimizing over sampled points plus boundary loss. The Laplacian inside the loss is computed by autograd. PINNs for Newton-gravity reproduce planetary potentials with parameters trained from a handful of orbit samples.
- N-body emulators. Modern cosmology uses convolutional neural networks trained on small high-resolution simulations to predict the density-to-potential map for huge volumes, replacing FFT-based Poisson solvers. The training target is exactly the inverse Laplacian.
Summary
| Idea | What you should remember |
|---|---|
| Newton's law | F = -GMm/r^2 \,\hat{r}. Inverse-square, attractive, linear (superposes). |
| Potential definition | \Phi(r) = -GM/r for a point mass; field is \mathbf{g} = -\nabla \Phi. |
| Why a potential | Scalar (one number per point), encodes energy directly, makes superposition trivial. |
| Gauss's law | \oint \mathbf{g}\cdot d\mathbf{A} = -4\pi G\, M_{\text{enc}}. Symmetry shortcut for spheres, cylinders, sheets. |
| Poisson form | \nabla^2 \Phi = 4\pi G \rho. Same PDE as electrostatics with opposite-sign coefficient. |
| Worked example | Uniform sphere: parabolic potential inside, -GM/r outside, shell theorem. \Phi(0) = 1.5 \, \Phi(R). |
| Numerical workhorse | Direct N-body sum (small N), Jacobi/FFT/multigrid (continuous \rho on a grid). |
| Modern reach | Tides, orbits, dark-matter inference, PFGM generative models, Laplacian-based GNNs, cosmological emulators. |
The takeaway in one sentence. Newton's inverse-square law, repackaged as , lets the whole celestial sphere — planet, star, galaxy, dark matter halo — be solved by the same averaging-plus-source idea that solved electrostatics, with one difference: mass has no negatives, so every well goes only one way, and the universe (eventually) wants to clump.