N-body force calculation and softening
Separate pair-force symmetry, approximation error and the physical bias introduced by gravitational softening.
On this page
The question for today
What you’ll understand
- Differentiate a softened pair potential with the correct attractive sign.
- Check pair momentum balance before dividing forces by unequal masses.
- Distinguish softening bias, force-approximation error and time-integration error.
An N-body calculation combines a physical model, a force evaluator and a time integrator. Errors in these ingredients are different. Reducing the time step does not remove a bias introduced by changing Newton's potential, and evaluating a chosen force very accurately does not establish that its smoothing length is physically appropriate. Softening is often useful when massive numerical particles represent a smooth collisionless distribution. It is a modeling and resolution decision, not merely protection against division by zero or a universal prescription for literal stellar collisions.
Derive a symmetric attractive pair force
Let the displacement from particle i to particle j point toward j. A fixed positive Plummer softening length replaces the inverse separation in the pair potential by the inverse square root of squared separation plus squared softening. Differentiating the potential with respect to the first position gives an attractive force along that displacement. Swapping particle labels reverses the displacement, so the forces are opposite. The accelerations are generally not opposite when the masses differ.
Calculating a pair once and applying equal and opposite momentum increments enforces the pair symmetry up to floating-point accumulation. A central pair force also has zero net torque about a common origin. These statements concern the specified force law, not exact energy conservation by an arbitrary integrator. If the softening changes with particle configuration or time, differentiating the resulting potential may require additional terms; simply substituting changing lengths into a fixed-softening force is not automatically energy consistent.
Balance discreteness against smoothing bias
For a smooth collisionless target, a finite set of particles samples a distribution rather than resolving every microscopic encounter. Too little smoothing can make nearby numerical particles produce large fluctuating forces; too much removes real spatial structure and systematically weakens attraction at resolved separations. The best compromise depends on particle number, density, kernel and the observable. There is no single universal optimal softening length independent of the physical system or desired resolution.
Plummer smoothing is noncompact: its force differs from Newton's at every finite radius, although the relative change becomes small far outside the softening scale. Other kernels can recover Newton's law beyond a finite support. Softening studies should therefore vary the length and particle sampling, rather than interpret the time-step convergence of one softened model as convergence to the unsoftened continuum. Statistical sampling fluctuations also need ensembles or justified estimators; deterministic integrator error is not the same uncertainty.
Keep force approximations separate from time stepping
Direct summation evaluates all unordered pairs, requiring a number of pair interactions proportional to N squared. Tree methods approximate distant groups and fast multipole methods organize higher-order spatial expansions. Their force tolerances are separate from integration time steps. Some approximate evaluations do not preserve exact pair antisymmetry, so total momentum drift can diagnose an implementation choice rather than a defect of Newtonian mechanics. Boundary treatment also matters: isolated and periodic gravitational systems have different long-range force problems.
A practical comparison fixes the target distribution and boundaries, measures force error against a more accurate evaluation, and then studies time integration with that force prescription. Close binary dynamics may demand a collisional method rather than stronger smoothing. The fields lab displays a softened planar source with an optional rotational term. Its radial power and sign convention differ from three-dimensional gravity, and it contains neither particle pairs nor their backreaction. Only its linear response to source strength is the intended comparison.
Work it through
A softened unequal-mass pair
Use dimensionless gravitational units with G = 1. Put masses m1 = 2 and m2 = 3 at (0,0,0) and (3,0,0), and use fixed ε = 4. Find the pair potential, both forces and both accelerations.
The softened distance is , so the potential is −6/5 = −1.2. The force denominator is 125, not 25.
The force on mass one points toward mass two and has x component . The force on mass two is −0.144 along x.
Dividing by the appropriate masses gives a1x = 0.072 and a2x = −0.048. Their mass-weighted sum is 2(0.072) + 3(−0.048) = 0, confirming momentum balance even though their accelerations differ.
U12 = −1.2, F1x = 0.144, F2x = −0.144, a1x = 0.072 and a2x = −0.048 in the declared scaled units.
The living notebook
Explore the model
Interactive lab · fields
Source scaling without a gravity solver
Reset and set BOTH Source strength q = 1 and Rotation Ω = 0; note the numerical Fx, Fy and magnitude readouts at the fixed probe. Reset and set q = 2 and Ω = 0; predict the components and magnitude double to displayed precision. Visible arrow lengths are compressed, so they do not double. This is a softened planar source field, not a gravitational N-body force evaluator or a momentum-balance simulation.
- Fx at (1, 0)
- 0.833
- Fy at (1, 0)
- 0.5
- Field magnitude there
- 0.972
The softened illustration is q·r/(r² + 0.2) + Ω(−y, x). Moving markers indicate local direction, not integrated particle paths or a Maxwell solution. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forCheck numerical field components when testing proportionality; graphical arrow scaling need not be linear.
Pause & reason
Check your understanding
Your turn
Try it yourself
Keep G = 1, masses 2 and 3 and separation 3, but set ε = 0. Find the Newtonian force magnitude and potential, and compare them with the softened values from the worked example. Does softening itself invalidate pair momentum balance?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
For nonzero separation the unsoftened magnitudes are Gm1m2/r² and Gm1m2/r. Compare forces before dividing by masses.
Compare with the solution
The Newtonian force magnitude is and the potential is −6/3 = −2. The softened force 0.144 is only 0.216 of the Newtonian magnitude, while its potential is less negative. This is a deliberate bias at a separation smaller than ε, not a time-integration error. Both force laws retain equal and opposite pair forces for the stated fixed symmetric softening, so each has zero net internal momentum change. More accurate stepping of the softened model cannot restore the missing Newtonian attraction.
Keep the idea
Take it with you
- Fixed symmetric softened pair forces preserve pair momentum balance.
- Softening trades sampling fluctuations for a model-dependent bias.
- Force accuracy, boundary treatment and integration accuracy require separate studies.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.