Blog

Factorials and circles

Jun 30, 2024

#lecture #math

In highschool, I discovered the magic of the Desmos graphing calculator. Being a nerdy tinkerer, I pushed this tool to its limits, making lots of fun graphs, even including a fully-playable version of pong.

So when we learned about factorials in my grade 11 math class, one of the first things I did was plug it into Desmos to see what it looked like.

I was shocked at what I got. I was expecting a pointwise function on every positive integer, but not only did I get rational numbers, the graph went crazy in the negatives! Furthermore, when I plugged it into a calculator I found

0.5!=π2\displaystyle 0.5! = \frac{\sqrt{\pi}}{2}

Woah! Why is pi there? What does this factorial have to do with circles?? I asked my poor substitute teacher what was happening, and they gave a confused attempt at an answer; but a quick Google search pointed me towards the gamma function, defined as follows

n!:=Γ(n+1)=∫0∞tne−tdt\displaystyle n! := \Gamma(n + 1) = \int_0^\infty t^{n}e^{-t}dt

The reason we define n!n! as Γ(n+1)\Gamma(n + 1) instead of Γ(n)\Gamma(n) is, as 19th-century mathematician Cornelius Lanczos puts it “void of any rationality”.

Why the gamma function works

In order for our new definition of the factorial to make any sense, we’d like it to at least satisfy the same properties that our normal factorial function has. That being

  1.  n!=n⋅(n−1)!\:n! = n \cdot (n - 1)!
  2.  0!=1\:0! = 1

From principles, we know the product rule for derivatives is

(uv)′=uv′+u′v\displaystyle (uv)' = uv' + u'v

So, integrating both sides, we get

uv=∫vdu+∫udvu\displaystyle v = \int vdu + \int udv

Giving us the familiar integration by parts formula

∫vdu=uv−∫udv\displaystyle \int vdu = uv - \int udv

We can apply this to our gamma function, to see that

Γ(n+1)=∫0∞tne−tdt=[−tne−t]0∞+n∫0∞tn−1e−tdt=nΓ(n)\displaystyle \Gamma(n + 1) = \displaystyle \int_0^\infty t^n e^{-t}dt = \left[-t^{n}e^{-t}\right]_0^\infty + n\int_0^\infty t^{n-1}e^{-t}dt = n\Gamma(n)

And furthermore

Γ(1)=∫0∞t0e−tdt=1\displaystyle \Gamma(1) = \int_0^\infty t^0e^{-t}dt = 1

So our choice of Gamma function is at least somewhat justified. In fact, if we add constraints that our function must be log convex we get that the gamma function must be unique (not shown).

Lets work through a few values of the gamma function that will help us later

Γ(1.5)=0.5Γ(0.5)=12∫0∞1te−tdt\displaystyle \Gamma(1.5) = 0.5\Gamma(0.5) = \frac{1}{2}\int_{0}^\infty \frac{1}{\sqrt t}e^{-t}dt

u=t\displaystyle u = \sqrt{t}

du=12tdt\displaystyle du = \frac{1}{2\sqrt t}dt

=∫0∞e−u2du\displaystyle = \int_{0}^\infty e^{-u^2}du

=π/2\displaystyle = \sqrt{\pi}/2

Γ(0.5)=π\displaystyle \Gamma(0.5) = \sqrt{\pi}

The volume of an n-sphere

The volume of an nn-ball of radius RR is intuitively porportional to RnR^n (not shown, you can think of it as scaling a ball in each of nn-dimensions), so we’ll write

V=CRn\displaystyle V = CR^n

dV=nCRn−1dR\displaystyle dV = nCR^{n - 1}dR

Here’s the trick, we’ll consider this weird integral

∫−∞∞∫−∞∞⋯∫−∞∞e−(x12+x22+⋯+xn2)dx1dx2⋯dxn=∫0∞e−R2dV\displaystyle \int_{-\infty}^\infty\int_{-\infty}^\infty\cdots\int_{-\infty}^\infty e^{-(x_1^2+x_2^2+\cdots+x_n^2)}dx_1dx_2\cdots dx_n = \int_{0}^\infty e^{-R^2}dV

You can think of it as covering the space by summing over shells of nn-dimensional spheres, instead of by integrating over each point individually. This works because our function e−(x12+x22+⋯+xn2)e^{-(x_1^2 + x_2^2 + \cdots + x_n^2)} has radial symmetry in all axis. For example, in two-dimensions instead of integrating over small rectangles, we cover the space by integrating over the difference in area of all radii of circles.

Now substitute the dVdV,

=nC∫0∞e−R2Rn−1dR\displaystyle = nC\int_{0}^\infty e^{-R^2}R^{n - 1}dR

and use a change-of-variables

t=R2\displaystyle t = R^2

12tdt=dR\displaystyle \frac{1}{2\sqrt{t}}dt = dR

=nC∫0∞e−ttn−1212tdt=nC2∫0∞e−ttn2dt\displaystyle = nC\int_{0}^\infty e^{-t}t^{\frac{n-1}{2}}\frac{1}{2\sqrt{t}}dt = \frac{nC}{2}\int_{0}^\infty e^{-t}t^{\frac{n}{2}}dt

Hey look! The gamma function! So, this is

=n2CΓ(n2)=CΓ(n2+1)\displaystyle = \frac{n}{2}C\Gamma\left(\frac{n}{2}\right) = C\Gamma\left(\frac{n}{2}+1\right)

Now the right side. We can break it up into

∫−∞∞∫−∞∞⋯∫−∞∞e−(x12+x22+⋯+xn2)dx1dx2⋯dxn=∫−∞∞e−x12dx1∫−∞∞e−x22dx2⋯∫−∞∞e−xn2dxn\displaystyle \int_{-\infty}^\infty\int_{-\infty}^\infty\cdots\int_{-\infty}^\infty e^{-(x_1^2+x_2^2+\cdots+x_n^2)}dx_1dx_2\cdots dx_n = \int_{-\infty}^\infty e^{-x_1^2}dx_1\int_{-\infty}^\infty e^{-x_2^2}dx_2\cdots\int_{-\infty}^\infty e^{-x_n^2}dx_n

=(∫−∞∞e−x2dx)n=(π)n=πn/2\displaystyle =\left(\int_{-\infty}^\infty e^{-x^2}dx\right)^n = (\sqrt\pi)^n = \pi^{n/2}

And so, combining these we can derive the formula for the volume of an n-ball

πn/2=CΓ(n2+1)\displaystyle \pi^{n/2} = C\Gamma\left(\frac{n}{2} + 1\right)

C=πn/2Γ(n2+1)\displaystyle C = \frac{\pi^{n/2}}{\Gamma\left(\frac{n}{2} + 1\right)}

Vn=πn/2n2!Rn\displaystyle V_n = \frac{\pi^{n/2}}{\frac{n}{2}!}R^n

Specific examples

Now that we have a closed-form formula for our volume, we can work it out for specific dimensions

V2=π1!R2=πR2\displaystyle V_2 = \frac{\pi}{1!}R^2 = \pi R^2

V3=π3232!R3=4π3R3\displaystyle V_3 = \frac{\pi^{\frac{3}{2}}}{\frac{3}{2}!}R^3 = \frac{4\pi}{3}R^3

V4=π22R4\displaystyle V_4 = \frac{\pi^2}{2}R^4

V−1=1πR\displaystyle V_{-1} = \frac{1}{\sqrt\pi R}

And V−2V_{-2} is undefined, because (−1)!(-1)! is undefined