These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

Consider the gravitational attraction between *Saturn* and its *Rings*. In reality, the planet remains centered within the rings, but consider an (over-)simplified model, which treats the *Rings* as a single solid ring with uniform density, and compute the gravitational force experienced by the planet at different positions within the plane of the ring.
## Exercise 1: Gravitational force due to a uniform circular ring
Using ink & paper, set up the integral to calculate the net gravitational force experienced by the planet due to the rings.
- Situate the ring in the xz-plane, centred on the origin.
- Treat the *Rings* as a single, stationary, thin circular ring of mass $M$ and radius $R$, with uniform linear density $\lambda = M/2\pi R$
- Treat *Saturn* as a point mass, $m$, located on the z-axis at distance $z < R$.
- By symmetry, the force, $F(z)$ will point along the z-axis; it is sufficient to express the integrand in terms of the z-component of the force, $dF_z$.
This integral cannot be solved analytically; you will numerically compute the result in the next exercise. However, with computational work, it is often worth recasting the integral into dimensionless quantities, rather than retaining units. Express the position coordinate in terms of a dimensionless distance, $\xi = z/R$, and scale the net force by a representative value for this system, $F^* = \frac{GmM}{R^2}$.
$$f_{ring}(\xi) = \frac{F(\xi)}{F^*} = \frac{1}{\pi} \int_{0}^{\pi} \frac{\cos(\theta)-\xi}{[1 + \xi^2 - 2\xi\cos(\theta)]^{3/2}} d\theta$$
Note: The symmetry of the integrand allows for the simplification of integration limits: $\int_{0}^{2\pi} \rightarrow 2\int_{0}^{\pi}$.
## Exercise 2: Numerical integration of gravitational force
Equation (1) can be numerically integrated using a pre-existing library/package, or using simple numerical methods such as *Trapezoidal Rule* or *Simpson's Rule*.
1. Create a function, *integrand*, which takes inputs $\theta$ and $\xi$, and returns the corresponding value of the integrand.
2. Plot the integrand as a function of $\theta$ for various planet-positions, $\xi$, to get a sense of the gravitational force from different parts of the ring.
3. Numerically integrate equation (1) for a range of planet positions, $\xi \in [0,0.9]$, and plot the gravitational force vs position.
## Exercise 3: Gravitational potential energy and stability
The potential energy can be obtained by integration:
$$U(P) = -\int_\mathcal{O}^P \overrightarrow{f}\cdot \overrightarrow{dr} $$
1. Use the results from the previous exercise to numerically integrate $f_{ring}(\xi)$ to obtain the potential energy at each position, $\xi$.
2. Plot the gravitational potential energy vs position, using the same range for $\xi$ as in the previous exercise.
**Note:** The reference position, $\mathcal{O}$, is typically chosen to be infinitely far away, where the potential energy is assumed to be zero. However, for this exercise the origin is a useful reference position.
## Exercise 4: Gravitational force and energy out of the plane
Exercises 1-3 can be repeated to compute the force and potential energy for planet-positions *out of the plane of the ring*. For simplicity, consider positions along the y-axis (i.e. the axis of the ring).
1. Using ink & paper, set up the integral to calculate the net gravitational force. Work with dimensionless position $\zeta = y/R$ and scale the force by the same value, $F^*$.
2. This integrals to obtain the force, $f_{ring}(\zeta)$, and the gravitational potential energy, $U_{ring}(\zeta)$, can both be solved analytically, or could be done numerically using the methods in Exercises 2 & 3.
3. Add plots of $f_{ring}(\zeta)$ and $U_{ring}(\zeta)$ to your results for the in-plane position of the planet. How does the gravitational stability compare for in- vs out-of-plane positions?
## Exercise 5: Gravitational force due to a uniformly dense spherical shell
Next, consider the planet to be surrounded by a thin spherical shell of mass $M$ and radius $R$, with a uniform density $\sigma = M/4\pi R^2$. Calculate the gravitational force experienced by the planet for positions within the shell. Based on the symmetry, it is enough to consider positions along the z-axis, as in Exercise 1.
While the mass is distributed over a 2D surface, the force can still be calculated using a 1D integral. In equation (1) the infinitesimal mass element is a segment of arc length, $dM = \lambda Rd\theta$, where $\lambda$ is the linear mass density of the ring.
For the spherical shell, which has area mass density $\sigma$, treat the infinitesimal unit as a ring, where
$$dM = \sigma R\sin(\theta) d\theta d\phi = \sigma 2\pi \sin(\theta) R d\theta = \lambda(\theta) R d\theta.$$
1. Modify your function, *integrand*, from Exercise 2 for the case of a spherical shell.
2. Plot the integrand as a function of $\theta$ for various planet-positions, $\xi$. How does the $\theta$-dependence of the force due to the shell compare with that of the ring?
3. Numerically integrate to solve for the force, and add the $f_{shell}(\xi)$ curve to you plot of force vs position.
4. Compute $U_{shell}(\xi)$ by numerically integrating $f_{shell}(\xi)$, and add this to your energy plot.