Chapter 2: Gravitation
Problem 2.1
For a homogeneous sphere \(v_c \sim r\)

Figure 2.1: Data from the THINGS survey (de Blok et al., 2008)1 shows that the circular velocity rises approximately linearly with radius for \(r < 6\) kpc. Linear fit shown in dashed line.
with \(R^2 = 0.949\), from this we can estimate the central density of IC 2574 as
Script to generate figure:
Problem 2.2
Numerical solution
The connection between virial radius \(r_{\mathrm{vir}}\), virial mass \(M_{\mathrm{vir}}\), and overdensity \(\Delta_v\) is
or equivalently
The expression \(r_{\mathrm{vir}} = a c(y)\) then gives the virial radius as a function of overdensity \(\Delta_v\). However, there is no closed-form solution for \(c(y)\), so we must solve numerically.

Figure 2.2: Virial mass (top) and virial radius (bottom) as a function of overdensity \(\Delta_v\) for an NFW halo with \(\rho_0 = 3.5 \times 10^6\,M_\odot/\mathrm{kpc}^3\) and scale radius \(a = 16\) kpc. At \(\Delta_v = 200\), this halo has \(r_{\mathrm{vir}} \approx 95\) kpc and \(M_{\mathrm{vir}} \approx 2 \times 10^{11}\,M_\odot\).
Script to generate figure:
That being said, there are reasonable approximations for \(c(y)\) at high and low \(y\):
Small overdensity
In this regime
such that
To leading order
or equivalently
Large overdensity
In this regime
therefore
Up to a logarithmic correction, we have
In summary, we have
Intuition behind the scaling
If \(\rho(r) \sim r^{-\gamma}\) then \(M(<r) \sim r^{3-\gamma}\), and \(\overline{\rho}(<r) \sim r^{-\gamma}\). Setting \(\overline{\rho}(<r) = \Delta_v \rho_{\mathrm{crit}}\) gives the scaling of \(r_{\mathrm{vir}}\) with \(\Delta_v\).
The NFW profile has \(\gamma \approx 1\) at small \(r\) and \(\gamma \approx 3\) at large \(r\), giving the scalings derived above. The reason for the scaling is then the two-power nature of the NFW profile.
Milky Way NFW Parameters
Recent estimates of the Milky Way's virial mass span a wide range. Using Gaia DR3 data, (Wang et al., 2023)2 found \(M_{\mathrm{vir}} = (6.5 \pm 0.3) \times 10^{11}\,M_\odot\) with concentration \(c \approx 14.5\) for an NFW model. Earlier work by (Eilers et al., 2019)3 estimated \(M_{\mathrm{vir}} = (7.25 \pm 0.25) \times 10^{11}\,M_\odot\). Studies using globular clusters (Posti & Helmi, 2019)4 suggest a higher mass of \(M_{\mathrm{vir}} = (1.3 \pm 0.3) \times 10^{12}\,M_\odot\).
Problem 2.3
For a logarithmic potential
The average density within \(r\) is then
Setting this equal to \(\Delta_v \rho_{\mathrm{crit}}\) and solving for \(r\) gives
In the logarithmic potential \(v_c(r) = v_{c,0}\). Taking \(\Delta_v = 200\), we then have
Problem 2.4
\(r_{\mathrm{vir}}\) vs \(M_{\mathrm{vir}}\) Scaling
The relation between virial mass and virial radius is \(M_{\mathrm{vir}} = 4\pi \Delta_v \rho_{\mathrm{crit}} r_{\mathrm{vir}}^3/3\), which is independent of the density profile. In particular, it does not depend on any potential scaling relation between virial mass and concentration.
Problem 2.5
Mass profile
For a density profile of the form
the mass profile is
and the potential (using $\Phi(r) = $)
Circular velocity is then
Circular velocity

Figure 2.5: Normalized circular velocity as a function of \(r/a\) for Jaffe, Hernquist, and NFW profiles. The Jaffe profile has a monotonically decreasing rotation curve, while Hernquist and NFW rise at small radii before declining.
Script to generate figure:
from galactic_dynamics_bovy.chapter02.vcirc_profiles import plot_vcirc_profiles
plot_vcirc_profiles()
Hernquist vs. Jaffe
The total mass of the Jaffe profile is
And the gravitational potential for a Hernquist profile is
Comparing (2.5.3) and (2.5.2) we see that the potential of a Hernquist profile with mass \(M = 4\pi \rho_{0,\mathrm{Hernquist}} a_{\mathrm{Hernquist}}^3\) matches the negative of the circular velocity squared profile of the Jaffe profile with mass \(M = 4\pi \rho_{0,\mathrm{Jaffe}} a_{\mathrm{Jaffe}}^3\).
Problem 2.6
Total mass
There are various ways to approach this problem.
First method
From Poisson's equation
Second method
Since \(\Phi(r) \to 0\) at infinitu, we can write the monopole term of the potential as
from which we again find \(M_{\mathrm{tot}} = 4\pi \rho_0 a^3\).
Power-law behavior
In spherical coordinates
If \(\phi(r) \sim A r^\alpha\) for large \(r\), then
so the density behaves as \(\rho(r) \sim r^{\alpha - 2}\). What we need to do is to find the power-law behavior of the potential, which is just
therefore \(\rho(r) \sim r^{-3}\) at large \(r\).
Problem 2.7
For an exponential disk the enclosed mass profile is
Define the "spherical exponential disk" as the spherical distribution function with the same enclosed mass profile
This corresponds to a density profile
And the potential is
The circular velocity is then
For comparison, the circular velocity of a true exponential disk (Freeman 1970) is
where \(I_n\) and \(K_n\) are modified Bessel functions.

Figure 2.7: Normalized circular velocity as a function of \(R/R_d\) for the spherical exponential disk (solid) and the true exponential disk (dashed). The spherical approximation peaks at smaller radius than the true disk.
Script to generate figure:
from galactic_dynamics_bovy.chapter02.spherical_exponential import plot_exponential_vcirc
plot_exponential_vcirc()
Problem 2.8
Potential
Consider a 1D mass distribution \(\rho(x) = A\delta(x)\),
Constant \(A\) is therefore the total mass of the distribution. The 1D Poisson equation is
Away from \(x=0\) the this equation is homogenous, so the potential is linear in \(x\).
where symmetry and continuity are used to set the coefficients. Now, let's integrate the Poisson equation across \(x=0\):
The potential is therefore
Where I dropped the constant \(b\) since it is physically irrelevant. The force is then
N-body simulation
For an \(N\)-body simulation with \(N\) particles of equal mass \(m\), the force on particle \(i\) is
where \(N_i^+\) and \(N_i^-\) are the number of particles to the right and left of particle \(i\). This can be computed in \(\mathcal{O}(N \log N)\) time by sorting the particles.
flowchart TD
A["Input: positions x₁, x₂, ..., xₙ"] --> B["Sort positions — O(N log N)"]
B --> C["For particle at sorted position k:<br/>N_left = k, N_right = N − 1 − k"]
C --> D["Compute force:<br/>F_k = 2πGm(N_right − N_left)"]
D --> E["Map forces back to original order"]
E --> F["Output: forces F₁, F₂, ..., Fₙ"]
For a uniform distribution on \([-1/2, 1/2]\) with total mass \(M\), the theoretical force is

Figure 2.8: Comparison of numerical vs theoretical gravitational force for \(N = 10000\) particles uniformly distributed on \([-1/2, 1/2]\). The error \((F_{\mathrm{numerical}} - F_{\mathrm{theory}}) / (4 \pi G M)\) stays close to zero across the distribution.
Script to generate figure:
Energy
To calculate the forces we already sorted the particles. The potential energy of particle \(i\) is:
For a particle at sorted position \(k\), this splits into:
This can be rewritten as:
where: - \(S_{\text{left}}(k) = \sum_{j<k} x_j\) (sum of positions to the left) - \(S_{\text{right}}(k) = \sum_{j>k} x_j\) (sum of positions to the right)
The trick: compute a prefix sum array once in \(\mathcal{O}(N)\):
Then:
- \(S_{\text{left}}(k) = \texttt{prefix}[k]\)
- \(S_{\text{right}}(k) = \texttt{totalsum} - \texttt{prefix}[k] - x_k\)
Each particle's potential energy is then computed in \(\mathcal{O}(1)\), giving \(\mathcal{O}(N)\) total.
flowchart TD
A["Input: sorted positions x₁ ≤ x₂ ≤ ... ≤ xₙ"] --> B["Compute prefix sum array — O(N)<br/>prefix[k] = x₀ + x₁ + ... + x_{k-1}"]
B --> C["Compute total sum<br/>S_total = x₀ + x₁ + ... + x_{N-1}"]
C --> D["For each particle k:"]
D --> E["S_left = prefix[k]<br/>S_right = S_total − prefix[k] − x_k"]
E --> F["Φ_k = 2πGm[k·x_k − S_left + S_right − (N−1−k)·x_k]"]
F --> G["Output: potential energies Φ₁, Φ₂, ..., Φₙ"]
Problem 2.9
Mass, potential, and circular velocity
Call the mass-to-light ratio \(\Upsilon = M/L\), the density is
The mass profile is
The gravitational potential is
and the circular velocity is
Limiting behaviors
For \(x \gg 1\) we have
so that
Mass logarithmically diverges, potential falls off as \(1/r\) with a logarithmic correction, and circular velocity falls off as \(\sqrt{\ln r/r}\).
Problem 2.10
For the profile
we have
Mass
Total mass is
Potential
For \(\gamma \neq 2\), the contribution to the potential from the outer-shell integral is (\(x = r/a\))
The potential is then
For \(\gamma = 2\), the outer-shell integral is
And the potential becomes
References
-
de Blok, W. J. G., Walter, F., Brinks, E., Trachternach, C., Oh, S.-H., & Kennicutt, R. C., Jr. (2008). High-resolution rotation curves and galaxy mass models from THINGS. The Astronomical Journal, 136(6), 2648. https://doi.org/10.1088/0004-6256/136/6/2648 ↩
-
Wang, Y. et al. (2023). Mass models of the Milky Way and estimation of its mass from the Gaia DR3 data set. The Astrophysical Journal, 946(2), 73. https://doi.org/10.3847/1538-4357/acb92c ↩
-
Eilers, A.-C., Hogg, D. W., Rix, H.-W., & Ness, M. K. (2019). The circular velocity curve of the Milky Way from 5 to 25 kpc. The Astrophysical Journal, 871(1), 120. https://doi.org/10.3847/1538-4357/aaf648 ↩
-
Posti, L., & Helmi, A. (2019). Mass and shape of the Milky Way's dark matter halo with globular clusters from Gaia and Hubble. Astronomy\ & Astrophysics, 621, A56. https://doi.org/10.1051/0004-6361/201833355 ↩