BRAGA

02 Writing02-02 Notes02-02-185

Sphere

Published 16 Apr 20268 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples
V=43πR3V = \frac{4}{3} \pi R^3
(1)

, S=4πR2S = 4\pi R^2

Deep Breakdown

What it tells me (Situation Awareness): The sphere has volume V=43πR3V = \frac{4}{3}\pi R^3 and surface area S=4πR2S = 4\pi R^2. The sphere is the 3D analogue of the circle: the set of all points in R3\mathbb{R}^3 at distance RR from the center, defined by (x−a)2+(y−b)2+(z−c)2=R2(x-a)^2 + (y-b)^2 + (z-c)^2 = R^2. In DA/DS, the sphere appears as the unit ball of the L2L_2 norm in 3D, in the "curse of dimensionality" (hypersphere volumes collapse relative to hypercube volumes as dimension increases), in 3D geospatial modeling (delivery radii in 3D logistics, satellite coverage footprints approximated by spherical caps), and in understanding why kk-NN and other distance-based algorithms degrade in high dimensions.

Flowchart

Curse of dimensionality3D geospatialL2 unit ballSphere: center(a,b,c), radius REquation:(x-a)^2 + (y-b)^2+ (z-c)^2 = R^2Volume V = (4/3)* pi * R^3Surface area S= 4 * pi * R^2DA/DSapplicationsVolume of d-ball:V_d(R) =pi^(d/2) /Gamma(d/2+1) *R^dCoverage zonein 3D space(satellite,warehouse)All vectors x with||x||_2 <= 1 forma sphere in 3DSurface arearatio: S/V = 3/R -large R meansless surface perunit volume

Real-world use

Where it is used

Used in 3D spatial analytics (defining spherical catchment zones for facility location in 3D), in understanding the curse of dimensionality (the dd-dimensional unit ball has volume that goes to 0 as d→∞d \to \infty), in satellite footprint estimation, in physics-based ML simulations (particle collisions, fluid dynamics), and in understanding why cosine similarity is preferred over Euclidean distance in high-dimensional embedding spaces.

Problem it solves

The sphere formula quantifies how much 3D space is enclosed within a given radius, and how much surface is exposed. The surface-to-volume ratio 3/R3/R tells you that as RR increases, volume grows faster than surface — relevant for understanding how coverage zones scale. For the curse of dimensionality argument, the key is that hypersphere volume shrinks relative to the enclosing hypercube.

How it solves the problem

Volume V=43πR3V = \frac{4}{3}\pi R^3 comes from integrating circular cross-sections: V=∫−RRπ(R2−z2)dz=π[R2z−z3/3]−RR=43πR3V = \int_{-R}^{R} \pi(R^2 - z^2) dz = \pi[R^2 z - z^3/3]_{-R}^{R} = \frac{4}{3}\pi R^3. Surface area S=4πR2S = 4\pi R^2 is the derivative of volume with respect to RR: dV/dR=4πR2=SdV/dR = 4\pi R^2 = S, which makes geometric sense (adding a thin shell of thickness dRdR to a sphere adds volume S⋅dRS \cdot dR).

Example in a business

A data scientist studying the curse of dimensionality computes the fraction of the dd-dimensional unit hypercube occupied by the inscribed dd-ball for d=1,2,3,10,100d = 1, 2, 3, 10, 100. For d=3d = 3: V3=43π(0.5)3≈0.524V_3 = \frac{4}{3}\pi(0.5)^3 \approx 0.524 out of a unit cube volume of 1 — about 52%. For d=10d = 10: the fraction drops below 0.3%. This demonstrates why distance-based classifiers lose discriminatory power in high dimensions: almost all data volume is near the cube's corners, not near the center.

The formula, piece by piece

  • V=43πR3V = \frac{4}{3}\pi R^3: the volume of the sphere; the 43\frac{4}{3} prefactor is exact, not an approximation
  • 43\frac{4}{3}: the exact prefactor from integrating circular cross-sections; 43≈1.333\frac{4}{3} \approx 1.333
  • πR3\pi R^3: π\pi is the ratio of circumference to diameter; R3R^3 reflects 3D scaling
  • S=4πR2S = 4\pi R^2: the surface area; exactly 4 times the area of a great circle (πR2\pi R^2)
  • RR: the radius; the only parameter needed to fully specify a sphere (given the center) Full formulas: V=43πR3V = \dfrac{4}{3}\pi R^3, S=4πR2S = 4\pi R^2

The formula in words

"The sphere encloses a volume that grows as the cube of the radius, and exposes a surface that grows as its square. The surface area is exactly four times the area of the equatorial circle — equivalently, you could wrap the sphere with four copies of its circular cross-section." Tiny numeric example: R=3R = 3. V=43π(27)=36π≈113.10V = \frac{4}{3}\pi(27) = 36\pi \approx 113.10. S=4π(9)=36π≈113.10S = 4\pi(9) = 36\pi \approx 113.10. (Coincidence at R=3R = 3: V=SV = S only when R=3R = 3, since 43πR3=4πR2  ⟹  R=3\frac{4}{3}\pi R^3 = 4\pi R^2 \implies R = 3.)

Critical Concepts

  • Surface-to-volume ratio: S/V=3/RS/V = 3/R. Larger sphere = proportionally less surface per unit volume. Relevant in physics-based simulations (heat dissipation, cell biology) and in normalizing features.
  • Curse of dimensionality: for a dd-dimensional ball of radius RR, Vd(R)=πd/2Γ(d/2+1)RdV_d(R) = \frac{\pi^{d/2}}{\Gamma(d/2+1)} R^d. For d=2d = 2: πR2\pi R^2; for d=3d = 3: 43πR3\frac{4}{3}\pi R^3; for large dd: Vd→0V_d \to 0 relative to the enclosing hypercube. This is why kk-NN and RBF kernels degrade in high dimensions.
  • Most volume near the surface: in high dimensions, most of the volume of a ball is concentrated in a thin shell near the surface. In d=100d = 100, 99.99% of the volume is within 1% of the radius from the surface.
  • L2L_2 unit ball: {x∈R3:∥x∥2≤1}\{x \in \mathbb{R}^3 : \|x\|_2 \leq 1\} is a unit sphere.
  • Equation of sphere: (x−a)2+(y−b)2+(z−c)2=R2(x-a)^2 + (y-b)^2 + (z-c)^2 = R^2; the 3D extension of the circle equation.

Step-by-step calculation (tiny example)

Step 1: Identify the radius and compute volume R=6R = 6. V=43π(6)3=43π(216)=288π≈904.78V = \frac{4}{3}\pi(6)^3 = \frac{4}{3}\pi(216) = 288\pi \approx 904.78.

Step 2: Compute the surface area S=4π(6)2=4π(36)=144π≈452.39S = 4\pi(6)^2 = 4\pi(36) = 144\pi \approx 452.39.

Step 3: Compute the surface-to-volume ratio and verify S/V=144π/(288π)=1/2=3/R=3/6=0.5S/V = 144\pi / (288\pi) = 1/2 = 3/R = 3/6 = 0.5.

Code examples

Beginner example (Python)

python
import numpy as np

# -- Sphere: volume, surface area, and curse of dimensionality demo ----


def sphere_volume(radius: float) -> float:
    """Volume of a 3D sphere."""
    return (4.0 / 3.0) * np.pi * radius**3

def sphere_surface(radius: float) -> float:
    """Surface area of a 3D sphere."""
    return 4.0 * np.pi * radius**2


for r in [1.0, 3.0, 5.0, 10.0]:
    v = sphere_volume(r)
    s = sphere_surface(r)
    print(f" R={r:.0f}: V={v:.4f}, S={s:.4f}, S/V={s/v:.4f} (= 3/R = {3/r:.4f})")

# Curse of dimensionality: hypersphere volume fraction in hypercube
from math import gamma, pi as PI


def ball_volume_fraction(d: int) -> float:
    """Fraction of d-dimensional unit hypercube occupied by inscribed d-ball (R=0.5)."""
    r = 0.5
    v_ball = (PI**(d / 2) / gamma(d / 2 + 1)) * r**d
    v_cube = 1.0
    return v_ball / v_cube


print("\nCurse of dimensionality: fraction of unit hypercube in inscribed ball:")
for d in [1, 2, 3, 5, 10, 20, 50]:
    frac = ball_volume_fraction(d)
    print(f" d={d:2d}: fraction = {frac:.6f}")

Beginner example (R)

r
# -- Sphere: volume, surface area, and S/V ratio -----------------------
sphere_volume <- function(r) (4/3) * pi * r^3
sphere_surface <- function(r) 4 * pi * r^2
for (r in c(1, 3, 5, 10)) {
  v <- sphere_volume(r)
  s <- sphere_surface(r)
  cat(sprintf(" R=%2.0f: V=%.4f, S=%.4f, S/V=%.4f\n", r, v, s, s/v))
}

# Curse of dimensionality
ball_fraction <- function(d) {
  r <- 0.5
  v_ball <- (pi^(d/2) / gamma(d/2 + 1)) * r^d
  return(v_ball)  # v_cube = 1
}
cat("\nCurse of dimensionality: ball fraction in unit hypercube:\n")
for (d in c(1, 2, 3, 5, 10, 20, 50)) {
  cat(sprintf(" d=%2d: fraction = %.6f\n", d, ball_fraction(d)))
}

Professional example (Python)

python
import numpy as np
import pandas as pd
from math import gamma   # -- Business scenario: curse of dimensionality impact on k-NN classifier
# Demonstrate how the volume of a sphere relative to the enclosing hypercube
# collapses as dimension increases, explaining k-NN degradation.
MAX_DIM = 30
RADIUS = 0.5   # unit hypercube has side 1; ball has radius 0.5

def hypersphere_volume(d: int, r: float) -> float:
    """Volume of d-dimensional ball with radius r."""
    return (np.pi ** (d / 2) / gamma(d / 2 + 1)) * r ** d
dims = list(range(1, MAX_DIM + 1))
rows = []
for d in dims:
    v_ball = hypersphere_volume(d, RADIUS)
    v_cube = 1.0  # unit hypercube
    frac = v_ball / v_cube
    # Expected fraction of nearest neighbors within radius R in a uniform hypercube
    rows.append({
        "dimension": d,
        "ball_volume": float(v_ball),
        "cube_volume": v_cube,
        "fraction_in_ball": float(frac),
        "pct_volume_in_ball": float(frac * 100),
    })
df = pd.DataFrame(rows)
print("Hypersphere volume fraction by dimension (R=0.5, unit hypercube):")
key_dims = df[df["dimension"].isin([1, 2, 3, 5, 10, 15, 20, 25, 30])]
print(key_dims[["dimension", "ball_volume", "fraction_in_ball", "pct_volume_in_ball"]].to_string(index=False))   # Minimum pct before essentially 0
threshold_dim = int(df[df["pct_volume_in_ball"] < 0.01]["dimension"].min())
print(f"\nDimension where ball fraction drops below 0.01%: d >= {threshold_dim}")
print("\nInterpretation: In d=3, ~52% of the unit cube's volume is within R=0.5 of the center (inside the sphere). By d=10, that drops to ~0.25%. In d=20, it's essentially 0. This is the curse of dimensionality: k-NN queries that search within a fixed radius capture less and less of the data space as dimension grows, forcing larger search radii and degrading classification quality.")

Source: domain knowledge

#linear-algebra#spatial-distance-norms-and-analytic-geometry#analytic-geometry-shapes-perimeter-area-volume

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close