Scholarly Expositions • Substack • Bigganblog

Research Blog, Essays & Science Writing

Technical tutorials on quantum algorithms and open quantum systems, philosophical essays on epistemology and logic on Substack, and popular mathematics & physics articles in Bengali on Bigganblog.

← Back to All Articles

π in Probability: From Coprime Integers to ζ(−1) = −1/12

π in Probability: From Coprime Integers to ζ(−1) = −1/12

Let us begin with a deceptively simple question from number theory and probability:

Suppose two natural numbers $a, b \in \mathbb{N}^+$ are chosen at random. What is the probability that they are coprime (relatively prime), meaning $\gcd(a, b) = 1$?

At first glance, this question belongs purely to discrete arithmetic: prime factorizations, remainders, and greatest common divisors. There isn't a circle or angle anywhere in sight. Yet the exact answer is:

$$P(\gcd(a, b) = 1) = \frac{6}{\pi^2} \approx 0.607927\dots$$

Somehow, $\pi$ emerges right at the heart of prime divisibility! In this post, expanding on an earlier Bengali article of mine ("সম্ভাবনায় পাই", published in Ganit Ishkul), we will:

  1. Derive $P(\gcd(a, b) = 1) = 6/\pi^2$ using Euler's prime sieve on the Riemann zeta function $\zeta(2) = \sum_{n=1}^{\infty} \frac{1}{n^2}$.
  2. Prove $\zeta(2) = \frac{\pi^2}{6}$ in a few lines via Parseval's Identity from Fourier analysis.
  3. Demystify $\zeta(-1) = -\frac{1}{12}$: Give an intuitive explanation of analytic continuation and show how Riemann's functional equation uses $\zeta(2) = \pi^2/6$ to yield $\zeta(-1) = -1/12$.

Part I: Coprime Integers and Euler's Sieve for $6/\pi^2$

1. Prime Divisibility and Independence

To make "choosing two natural numbers $a, b$ at random" rigorous, we pick $(a, b)$ uniformly from $\{1, 2, \dots, N\}^2$ and take the limit as $N \to \infty$.

When is $\gcd(a, b) = 1$? By the Fundamental Theorem of Arithmetic, $\gcd(a, b) = 1$ if and only if no prime number $p \in \{2, 3, 5, 7, \dots\}$ divides both $a$ and $b$ simultaneously.

Fix a prime $p$. When an integer is divided by $p$, its remainder is equally likely to be any of $0, 1, 2, \dots, p - 1$:

  • The probability that $p$ divides $a$ is $\frac{1}{p}$.
  • Since $a$ and $b$ are chosen independently, the probability that $p$ divides both $a$ and $b$ is $\frac{1}{p} \cdot \frac{1}{p} = \frac{1}{p^2}$.
  • Therefore, the probability that $p$ is not a common prime factor of $a$ and $b$ is:

$$P(p \nmid \gcd(a, b)) = 1 - \frac{1}{p^2}$$

Because divisibility by distinct primes $p_1, p_2, \dots$ is independent (by the Chinese Remainder Theorem), the probability that no prime divides both $a$ and $b$ is the product over all primes:

$$P(\gcd(a, b) = 1) = \prod_{p \text{ prime}} \left(1 - \frac{1}{p^2}\right) = \left(1 - \frac{1}{2^2}\right)\left(1 - \frac{1}{3^2}\right)\left(1 - \frac{1}{5^2}\right)\left(1 - \frac{1}{7^2}\right)\cdots$$

Grid of coprime integer pairs gcd(a, b) = 1 approaching density 6/pi^2

2. Euler's Sieve on $\zeta(2)$

To evaluate this infinite product, we start with the Riemann zeta function at $s = 2$:

$$\zeta(2) = \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{1}{1^2} + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \cdots = \frac{\pi^2}{6} \qquad (1)$$

Because this series converges absolutely (by the integral or comparison test), we can sieve out prime multiples step by step:

Step 1 (Sieving out multiples of $2$): Multiply $(1)$ by $\frac{1}{2^2}$:

$$\frac{1}{2^2}\,\zeta(2) = \frac{1}{2^2} + \frac{1}{4^2} + \frac{1}{6^2} + \frac{1}{8^2} + \cdots \qquad (2)$$

Subtracting $(2)$ from $(1)$ eliminates every even denominator:

$$\left(1 - \frac{1}{2^2}\right)\zeta(2) = \frac{1}{1^2} + \frac{1}{3^2} + \frac{1}{5^2} + \frac{1}{7^2} + \frac{1}{9^2} + \cdots \qquad (3)$$

Step 2 (Sieving out multiples of $3$): Multiply $(3)$ by $\frac{1}{3^2}$ and subtract from $(3)$ to eliminate all remaining multiples of $3$:

$$\left(1 - \frac{1}{2^2}\right)\left(1 - \frac{1}{3^2}\right)\zeta(2) = \frac{1}{1^2} + \frac{1}{5^2} + \frac{1}{7^2} + \frac{1}{11^2} + \frac{1}{13^2} + \cdots$$

Each factor of $\left(1 - \frac{1}{p^2}\right)$ wipes out every denominator divisible by the prime $p$. Repeating this across all primes $p = 2, 3, 5, 7, \dots$, every integer $n \ge 2$ is eliminated, leaving only $\frac{1}{1^2} = 1$ on the right-hand side:

$$\left[\left(1 - \frac{1}{2^2}\right)\left(1 - \frac{1}{3^2}\right)\left(1 - \frac{1}{5^2}\right)\cdots\right] \zeta(2) = 1$$

Dividing by $\zeta(2) = \frac{\pi^2}{6}$ gives our result:

$$P(\gcd(a, b) = 1) = \prod_{p \text{ prime}} \left(1 - \frac{1}{p^2}\right) = \frac{1}{\zeta(2)} = \frac{6}{\pi^2}$$

(More generally, the probability that $k$ random natural numbers share no common factor is $\prod_{p} (1 - p^{-k}) = \frac{1}{\zeta(k)}$.)

Part II: Short Proof of $\zeta(2) = \frac{\pi^2}{6}$ via Parseval's Identity

Why does $\sum_{n=1}^{\infty} \frac{1}{n^2}$ equal $\frac{\pi^2}{6}$ in the first place? The quickest proof comes from Parseval's Identity in Fourier analysis, which states that the total energy of a wave equals the sum of the squared amplitudes of its harmonics.

Consider the simple odd function $g(x) = x$ on $(-\pi, \pi)$. Its Fourier sine series is $x = \sum_{n=1}^{\infty} b_n \sin(nx)$, where a single integration by parts gives the sine coefficients:

$$b_n = \frac{2}{\pi} \int_0^\pi x \sin(nx)\,dx = \frac{2}{\pi} \left[-\frac{x \cos(nx)}{n}\right]_0^\pi = \frac{2(-1)^{n-1}}{n}$$

Now apply Parseval's Identity to $g(x) = x$:

$$\frac{1}{\pi} \int_{-\pi}^{\pi} x^2\,dx = \sum_{n=1}^{\infty} b_n^2 = \sum_{n=1}^{\infty} \frac{4}{n^2}$$

Since $\frac{1}{\pi} \int_{-\pi}^{\pi} x^2\,dx = \frac{1}{\pi} \left[\frac{x^3}{3}\right]_{-\pi}^{\pi} = \frac{2\pi^2}{3}$, dividing both sides by $4$ immediately gives Basel's identity:

$$\zeta(2) = \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$$

Part III: An Intuitive Guide to $\zeta(-1) = -\frac{1}{12}$

Whenever the Riemann zeta function $\zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^s}$ comes up, people inevitably ask about the viral equation:

$$1 + 2 + 3 + 4 + \cdots = -\frac{1}{12} \qquad \text{(?!)}$$

How can adding positive integers produce $-\frac{1}{12}$? Here is a clear, non-intimidating way to understand what is actually going on.

1. The Geometric Series Analogy (Why Formula $\neq$ Infinite Sum)

Think of the familiar geometric series from high school algebra:

$$1 + x + x^2 + x^3 + \cdots = \frac{1}{1 - x}$$

This infinite sum only converges when $|x| < 1$. If you plug $x = 2$ into the left-hand side, you get $1 + 2 + 4 + 8 + \cdots = +\infty$. However, the closed-form formula on the right-hand side, $f(x) = \frac{1}{1 - x}$, makes perfect sense for any number $x \neq 1$! If you plug $x = 2$ into $f(x)$, you get:

$$f(2) = \frac{1}{1 - 2} = -1$$

Writing $f(2) = -1$ does not mean that $1 + 2 + 4 + 8 + \cdots$ adds up to $-1$ in the ordinary sense; it means that $f(x) = \frac{1}{1 - x}$ is the unique smooth formula (analytic continuation) that matches the infinite sum where the sum works ($|x| < 1$) and extends it to where the sum blows up ($x = 2$).

2. Why Analytic Continuation Is Unique: The Miracle of Holomorphy ($C^1 \iff C^\infty \iff C^\omega$)

A natural question arises here: why can't we just extend the function to the left of $x = 1$ in whatever smooth way we like, making the value at $-1$ anything we want?

If we worked only on the real line $\mathbb{R}$, that objection would be completely valid! For real functions $f: \mathbb{R} \to \mathbb{R}$:

  • Being once continuously differentiable ($C^1$) does not imply being infinitely differentiable ($C^\infty$).
  • Even being infinitely differentiable ($C^\infty$) does not imply being analytic ($C^\omega$, locally equal to a convergent Taylor series). For example, Cauchy's flat bump function $\psi(x) = e^{-1/x^2}$ (for $x > 0$) and $0$ (for $x \le 0$) is $C^\infty$ everywhere on $\mathbb{R}$, yet all of its derivatives vanish at $x = 0$. Using such bump functions, a real function defined on $(1, \infty)$ can be smoothly extended to $x < 1$ in infinitely many different ways.

In the complex plane $\mathbb{C}$, however, differentiability is dramatically more rigid:

The Miracle of Holomorphy: C^1 is equivalent to C^infinity and C^omega for complex functions

Because a complex derivative $\lim_{\Delta z \to 0} \frac{f(z + \Delta z) - f(z)}{\Delta z}$ must yield the exact same limit whether $\Delta z$ approaches $0$ horizontally, vertically, or along a spiral, $f$ must satisfy the Cauchy–Riemann equations. By Cauchy's Integral Formula, any function $f: \Omega \subseteq \mathbb{C} \to \mathbb{C}$ that is complex-differentiable even once ($C^1$) on an open domain $\Omega$ is automatically infinitely differentiable ($C^\infty$) and locally equal to its convergent Taylor series ($C^\omega$):

$$C^1(\Omega) \iff C^\infty(\Omega) \iff C^\omega(\Omega) \qquad (\text{holomorphy in }\mathbb{C})$$

This rigidity gives rise to the Identity Theorem of complex analysis: if two holomorphic functions on a connected open domain $\Omega \subseteq \mathbb{C}$ agree on the half-plane $\operatorname{Re}(s) > 1$ (or even on any sequence of points with an accumulation point in $\Omega$), they must be identically equal everywhere on $\Omega$. Consequently, once we view $s \in \mathbb{C}$ as a complex variable, there is at most one complex-differentiable extension of $\zeta(s)$ beyond $\operatorname{Re}(s) > 1$. We have zero freedom to "fudge" its value at $s = -1$!

3. Extending $\zeta(s)$ and Calculating $\zeta(-1) = -\frac{1}{12}$

The exact same thing happens with the Riemann zeta function! The infinite sum

$$\zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^s} = 1 + \frac{1}{2^s} + \frac{1}{3^s} + \cdots$$

only converges when $s > 1$. If you plug $s = -1$ into the raw sum, you get $1 + 2 + 3 + 4 + \cdots = +\infty$.

However, just like $\frac{1}{1 - x}$ extends the geometric series past $x = 1$, Bernhard Riemann discovered in 1859 that $\zeta(s)$ has a unique smooth extension to all $s \neq 1$, governed by Riemann's Functional Equation:

$$\zeta(s) = 2^s \pi^{s-1} \sin\!\left(\frac{\pi s}{2}\right) \Gamma(1 - s)\,\zeta(1 - s)$$

This remarkable formula acts like a mirror: it lets us compute $\zeta(s)$ for negative numbers ($s < 0$) by plugging $1 - s > 1$ into the region where the series does converge!

Let us plug $s = -1$ into Riemann's functional equation:

$$\zeta(-1) = 2^{-1} \pi^{-2} \sin\!\left(-\frac{\pi}{2}\right) \Gamma(2)\,\zeta(2)$$

Every piece on the right-hand side is elementary:

  • $2^{-1} \pi^{-2} = \frac{1}{2\pi^2}$
  • $\sin\!\left(-\frac{\pi}{2}\right) = -1$
  • $\Gamma(2) = 1! = 1$
  • $\zeta(2) = \frac{\pi^2}{6}$ (from Parseval's identity in Part II!)

Multiplying them together, the factors of $\pi^2$ cancel right out:

$$\zeta(-1) = \frac{1}{2\pi^2} \cdot (-1) \cdot 1 \cdot \frac{\pi^2}{6} = -\frac{1}{12}$$

So $\zeta(-1) = -\frac{1}{12}$ is the exact value of the analytically continued zeta function at $s = -1$, directly powered by the very same $\zeta(2) = \frac{\pi^2}{6}$ that governs the probability of coprime integers!

Archival Note: Original Bengali Publication in Ganit Ishkul

Original Bengali column 'Shombhabonay Pi' in Ganit Ishkul (Bangladesh Mathematical Olympiad Committee)

Originally published in Bengali as "সম্ভাবনায় পাই" (Pi in Probability) in Ganit Ishkul (Bangladesh Mathematical Olympiad Committee). Long live mathematics, long live the zeta function, and long live $\pi$!