Skip to content

Instantly share code, notes, and snippets.

@nschloe
Created May 9, 2023 18:55
Show Gist options
  • Save nschloe/d0c906b11f1fdd173a8c58e3308e603c to your computer and use it in GitHub Desktop.
Save nschloe/d0c906b11f1fdd173a8c58e3308e603c to your computer and use it in GitHub Desktop.
Volumes of spheres of radius 1 in higher dimensions
from math import tau
import matplotlib.pyplot as plt
n_max = 20
sphere_vols = [2, tau]
for n in range(3, n_max + 1):
sphere_vols.append(sphere_vols[n-2] * tau / (n-2))
plt.plot(range(1, n_max + 1), sphere_vols, "o")
plt.title("Volumes of spheres of radius 1 in higher dimensions")
plt.xlabel("n")
plt.show()
@nschloe
Copy link
Author

nschloe commented May 9, 2023

Figure_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment