un

guest
1 / ?
back to lessons

Why Factorials Matter

Hamming begins Chapter 9 by noting that all engineering design problems live in n-dimensional space, where n counts the independent parameters. Understanding that space requires understanding factorials — they appear inside the volume formula for every n-dimensional sphere.

Stirling's Approximation

Computing n! directly becomes impossible for large n. Stirling's formula gives an accurate approximation:

n! ≈ √(2πn) · (n/e)^n

Taking logarithms (which Hamming does to convert the product into a sum):

ln(n!) ≈ n·ln(n) − n + 0.5·ln(2πn)

The approximation improves as n grows: the ratio Stirling(n)/n! → 1 as n → ∞. Yet the absolute difference grows without bound. Both facts hold simultaneously.

Hamming's derivation route: approximate the sum Σ ln(k) for k=1..n by the integral ∫ ln(x) dx from 1 to n via the trapezoid rule, then take the exponential. The constant √(2π) arises from the limiting behavior of the trapezoid error.

| n | Stirling | True n! | Ratio | |---|---|---|---| | 5 | 118.02 | 120 | 0.9835 | | 10 | 3,598,696 | 3,628,800 | 0.9917 | | 20 | ~2.423×10^18 | ~2.432×10^18 | 0.9958 |

Using Stirling's Formula

Stirling's log form proves most useful for ratio calculations where absolute scale cancels:

ln(n!) ≈ n·ln(n) − n + 0.5·ln(2πn)

Use the log form of Stirling's approximation to estimate ln(10!). Then compare to the true value ln(3,628,800) ≈ 15.104. Show your substitution.

The Gamma Function

The factorial n! only makes sense for non-negative integers. Hamming needs the sphere volume formula for all positive real n, so he introduces the Gamma function:

Γ(n) = ∫₀^∞ x^(n−1) · e^(−x) dx (converges for n > 0)

Integration by parts yields the reduction formula: Γ(n) = (n−1) · Γ(n−1).

At positive integers: Γ(n) = (n−1)! so Γ(5) = 4! = 24.

At the half-integers: Γ(1/2) = √π ≈ 1.772. This arises from the Gaussian integral ∫₋∞^∞ e^(−x²) dx = √π.

The values we need for sphere volumes: Γ(n/2 + 1) at half-integer arguments.

| n | n/2 + 1 | Γ(n/2 + 1) | |---|---|---| | 1 | 3/2 | √π/2 ≈ 0.886 | | 2 | 2 | 1! = 1 | | 3 | 5/2 | 3√π/4 ≈ 1.329 | | 4 | 3 | 2! = 2 | | 5 | 7/2 | 15√π/8 ≈ 3.323 |

Using the reduction formula Γ(n) = (n−1)·Γ(n−1) and Γ(1/2) = √π, compute Γ(5/2). Show each step.

The Formula & the Paradox

With Stirling and Gamma in hand, Hamming derives the volume of an n-dimensional sphere of radius r:

V_n(r) = C_n · r^n where C_n = π^(n/2) / Γ(n/2 + 1)

The constant C_n depends only on n, not r. The first values:

| n | C_n | |---|---| | 1 | 2 | | 2 | π ≈ 3.142 | | 3 | 4π/3 ≈ 4.189 | | 4 | π²/2 ≈ 4.935 | | 5 | 8π²/15 ≈ 5.264 | | 6 | π³/6 ≈ 5.168 | | 8 | π⁴/24 ≈ 4.059 | | 10 | π⁵/120 ≈ 2.550 |

Volume of n-Dimensional Unit Sphere

The paradox: C_n rises to a maximum near n=5 (C_5 ≈ 5.264), then falls back toward zero. The unit sphere in very high dimensions has essentially no volume — even though intuitively adding more dimensions should add more space.

Why Does Volume Collapse?

The key: volume = C_n · r^n. When r < 1, r^n → 0 exponentially. The radius constraint kills the volume faster than the dimensionality grows. Almost all of the n-dimensional unit hypercube's volume lies in its corners, outside the inscribed sphere.

The Corner Paradox

In 2D: a unit square [−1,1]^2 has area 4. The inscribed circle has area π ≈ 3.14. The circle fills 78% of the square.

In 3D: the unit cube [−1,1]^3 has volume 8. The inscribed sphere has volume 4π/3 ≈ 4.19. The sphere fills 52%.

In n dimensions: the unit hypercube [−1,1]^n has volume 2^n. The inscribed sphere has volume C_n. The fraction inside the sphere:

f(n) = C_n / 2^n

As n grows: C_n → 0 while 2^n → ∞. So f(n) → 0 rapidly. In 10D, the sphere fills less than 0.3% of the cube.

Corner Paradox: Volume in High Dimensions

Engineering implication: in high-dimensional design space, you cannot sample by picking random points. Nearly all random points will land in corners, far from the center. Your intuition built in 3D fails completely.

Compute f(n) = C_n / 2^n for n=2 and n=4. Use C_2 = π ≈ 3.14159 and C_4 = π²/2 ≈ 4.935. What does the trend say about searching high-dimensional design spaces by random sampling?

Why 3D Intuition Fails

Hamming's core message in Chapter 9: every engineering system with n independent parameters lives in n-dimensional space. Aerodynamics, control systems, chip design, drug molecules — all involve parameter spaces with n >> 3.

Three specific failures of 3D intuition in high dimensions:

1. Diagonal distances. In 3D, the diagonal of a unit cube has length √3 ≈ 1.73. In n-dimensional unit hypercube, the diagonal has length √n. For n=100, the diagonal length is 10 — yet every coordinate still runs from 0 to 1. Points that look 'nearby' in any single dimension are far apart in n-dimensional space.

2. Volume concentration. As shown above: volume concentrates in corners, not in the central sphere. Your intuition that the center of a space is typical collapses.

3. Neighbor counting. In 2D, a point has roughly πr² neighbors within radius r. In nD, the neighbor count scales as C_n·r^n, which for large n is effectively zero for small r. Neighborhoods collapse.

Hamming's conclusion: 'You simply cannot visualize what is going on in n-space.' You must rely on mathematics — on the formulas for volume, distance, and probability — not on imagination.

Applying the Geometry

The sphere-volume collapse has concrete consequences for modern practice:

Optimization: gradient descent in high-dimensional parameter spaces works better than random search precisely because it exploits local gradient information to navigate the corners-and-voids structure.

Machine learning: neural network weight spaces have millions of dimensions. The geometry predicts that random initialization rarely lands near a good solution — yet the training process navigates toward one through structured gradient steps.

Design of experiments: covering a high-dimensional parameter space with samples requires exponentially many points. This motivates structured experimental designs (Latin hypercubes, space-filling designs) over random sampling.

Hamming says you cannot explore n-dimensional design space by sampling. Name one specific field where this constraint appears and explain how practitioners cope with it. Your answer should reference the geometry: either the sphere-volume collapse, the diagonal-distance effect, or both.