More Pie For You!

David Ding

September 4, 2026

Continuing our journey into the curious world of pi, in this blog post, I will be showing you two other seemingly unexpected places where pi can be found.

The Foundation: Basel Problem Solution

What I am about to show you completely hinges on this fact:

\begin{equation} \boxed{1 + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \frac{1}{5^2} + \dots = \frac{\pi^2}{6}} \end{equation}

Which I have proven using a little bit of signal processing in this post. Please remember it well as this will be the foundation for some truly strange bakings of...well, pi(e)s!

Calculus Land

In the land of calculus, there lived an integral:

\[ I = \int_0^\infty \frac{x}{e^x - 1}\,dx \]

This integral seemed rather peculiar. Let's do some investigation. First of all, even though it is an improper integral, we have confidence that the area under its curve from 0 to infinity will converge as the numerator grows linearly while the denominator grows exponentially. Then, we remember an often overlooked tool: the geometric series formula:

\begin{equation} 1 + r + r^2 + r^3 + \dots + r^n = \frac{r^{n+1} - 1}{r - 1} \end{equation}

Also if \(|r| < 1\), then:

\begin{equation} 1 + r + r^2 + r^3 + \dots = \frac{1}{1 - r} \end{equation}

Usually, we often rely on the above formula to collapse a series into a neat little formula, but don't forget, the other way around is often just as useful, such as what we are about to do. Through some pattern recognition and critical thinking, we notice that the above integrand is very close to the formula for the infinite geometric series. We've got a fraction with a subtraction in the denominator. Therefore, we try to match the integrand to the formula. After some fiddling, we get:

\begin{align} I &= \int_0^\infty \frac{x}{e^x - 1}\,dx \\ \\ &= \int_0^\infty \frac{xe^{-x}}{1 - e^{-x}}\,dx \end{align}

Bingo! This means we can actually expand the integrand into a series, and then divide and conquer!

\begin{align} I &= \int_0^\infty \frac{x}{e^x - 1}\,dx \\ \\ &= \int_0^\infty \frac{xe^{-x}}{1 - e^{-x}}\,dx \\ \\ &= \int_0^\infty xe^{-x}(1 + e^{-x} + e^{-2x} + e^{-3x} + \dots)\,dx \\ \\ &= \int_0^\infty xe^{-x}\,dx + \int_0^\infty xe^{-2x}\,dx + \int_0^\infty xe^{-3x}\,dx + \dots \end{align}

Now let's solve the general case:

\[ \int_0^\infty xe^{-kx}\,dx \]

I know, I know, integration by parts sucks, but sometimes you gotta do what you gotta do here. Now, let \(u = x\), \(du = dx\), \(dv = e^{-kx}\,dx\), and hence \(v = \frac{e^{-kx}}{-k}\), we get:

\begin{align} \int_0^\infty xe^{-kx}\,dx &= uv\Big|_{0}^{\infty} - \int_0^\infty v\,du \\ \\ &= x\frac{e^{-kx}}{-k}\bigg|_{0}^{\infty} + \frac{1}{k} \int_0^\infty e^{-kx}\,dx \end{align}

In the above equation, first term's boundaries are: when \(x = 0\), the product is 0. When \(x \to \infty\), exponential decay overpowers linear growth, so the product is once again 0. So the entire first term is 0, and the integral only consists of the second term, which is:

\begin{align} \int_0^\infty xe^{-kx}\,dx &= \frac{1}{k} \int_0^\infty e^{-kx}\,dx \\ \\ &= -\frac{1}{k^2} e^{-kx}\bigg|_{x = 0}^{x = \infty} \\ \\ &= \frac{1}{k^2} \end{align}

Therefore, coming back to the original integral:

\begin{align} I &= \int_0^\infty \frac{x}{e^x - 1}\,dx \\ \\ &= \int_0^\infty xe^{-x}\,dx + \int_0^\infty xe^{-2x}\,dx + \int_0^\infty xe^{-3x}\,dx + \dots \\ \\ &= 1 + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \frac{1}{5^2} + \dots \\ \\ &= \boxed{\frac{\pi^2}{6}} \end{align}

Second Serving: Prime Number Land

If you are still hungry, but have had enough of integrals, may I interest you in...prime numbers. How to generate prime numbers? Well, for over 2000 years, the Sieve of Eratosthenes [Era-TUH-ste-nes] is the answer. Filter out enough multiples of prime numbers over the positive integers greater than 1, and you will soon find yourself only the prime numbers remaining, as illustrated below:

Sieve of Eratosthenes

What does that have to do with pi? Well, keep reading! For now, consider the following series:

\[ S = 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \dots \]

We are calling this series \(S\). Our goal is to filter out all terms of the above infinite series so that only the lonely number "1" remains. How do we do that? Well, let's play around and first multiply \(S\) by \(\frac{1}{2}\). We get:

\[ \frac{S}{2} = \frac{1}{2} + \frac{1}{4} + \frac{1}{6} + \frac{1}{8} + \dots \]

Wait, that's...all terms whose denominator is a multiple of 2. So indeed, if we subtract the above series from the original one, we get all terms whose denominator is NOT a multiple of two, i.e.

\[ T = 1 + \frac{1}{3} + \frac{1}{5} + \frac{1}{7} + \frac{1}{9} + \dots \]

Let's keep going, and realize that the next prime number is 3. Taking the above series and subtracting from it ALL terms whose denominator is a multiple of 3, which is accomplished by \(T - \frac{T}{3}\), we get:

\begin{align} T - \frac{T}{3} &= \left(1 - \frac{1}{3}\right) T \\ \\ &= \left(1 - \frac{1}{3}\right) \left(1 - \frac{1}{2}\right) S \\ \\ &= 1 + \frac{1}{5} + \frac{1}{7} + \frac{1}{11} + \frac{1}{13} + \dots \end{align}

Lo and behold, our original series is getting "sifted", fast! Now the non-1 terms have denominators that are increasingly exclusively prime, with just two siftings! In fact, the next composite denominator term is, believe it or not, \(\frac{1}{25}\). Now for another sifting of the next prime number, 5, and that term is gone too! Repeat (albeit infinitely), we get:

\[ 1 = \left(1 - \frac{1}{p_1}\right) \left(1 - \frac{1}{p_2}\right) \left(1 - \frac{1}{p_3}\right) \dots S \]

Where \(p_k\) is the \(k\,\)th prime number.

If we isolate for \(S\), we get:

\begin{align} 1 &= \left(1 - \frac{1}{p_1}\right) \left(1 - \frac{1}{p_2}\right) \left(1 - \frac{1}{p_3}\right) \dots S\\ \\ 1 &= \left(\frac{p_1 - 1}{p_1}\right) \left(\frac{p_2 - 1}{p_2}\right) \left(\frac{p_3 - 1}{p_3}\right) \dots S\\ \\ S &= \left(\frac{p_1}{p_1-1}\right) \left(\frac{p_2}{p_2-1}\right) \left(\frac{p_3}{p_3-1}\right) \dots \end{align}

But here's the thing, the above sieve trick doesn't just apply to:

\[ S = 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \dots \]

It also applies to:

\[ S = 1 + \frac{1}{2^s} + \frac{1}{3^s} + \frac{1}{4^s} + \dots \]

For any number \(s\) (even complex ones). And, as a result, using the same sieve process, we get:

\[ 1 + \frac{1}{2^s} + \frac{1}{3^s} + \frac{1}{4^s} + \dots = \left(\frac{p_1^s}{p_1^s-1}\right) \left(\frac{p_2^s}{p_2^s-1}\right) \left(\frac{p_3^s}{p_3^s-1}\right) \dots \]

What happens when \(s = 2\)? Well on one hand we get:

\begin{align} S &= 1 + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \dots \\ \\ &= \frac{\pi^2}{6} \end{align}

And on the other hand:

\[ S = \left(\frac{p_1^2}{p_1^2-1}\right) \left(\frac{p_2^2}{p_2^2-1}\right) \left(\frac{p_3^2}{p_3^2-1}\right) \dots \]

Coming together, we get:

\[ \left(\frac{2^2}{2^2-1}\right) \left(\frac{3^2}{3^2-1}\right) \left(\frac{5^2}{5^2-1}\right) \dots = \boxed{\frac{\pi^2}{6}} \]

Pi, meet prime numbers!