Euler’s totient function to estimate $\pi$

elementary-number-theorypiprobabilitytotient-function

Euler's totient function $\varphi(n)$ to estimate $\pi$

$$\pi = \sqrt{6 \times \left( \lim_{n \to \infty} \left( \frac{1}{n} \sum_{i=1}^{n} \frac{\varphi(i)}{i} \right)^{-1} \right)}$$

The Idea

Started looking at Euler's totient function a few days ago and noticed that on the line $x + y = n$, the number of points visible from the origin equals $\varphi(n)$. Being aware that $\frac{6}{\pi^2}$ represents the probability that two randomly chosen integers are coprime, I wondered if there's a connection between $\frac{6}{\pi^2}$ and Euler's totient function? Anyhow, after a few hours of thinking, the above formula popped out. To verify it, wrote a demo C program and it outputs $\pi \approx 3.141592$.

Question

As a programmer (not a maths guy), the program computes $\pi \approx 3.141592$ which looks promising but is the maths behind it legitimate?

Best Answer

Well, $\lim_{n\to \infty}\frac 1n\sum_{i=1}\frac{\varphi(i)}{i}$, if it exists, certainly isn't negative. Therefore, your conjecture is equivalent to $$ \lim_{x\to \infty}\frac1x\sum_{n\le x}\frac{\varphi(n)}{n}=\frac{6}{\pi^2}. $$ Proving such identities using complex analysis is the purview of analytic number theory. A detailed proof requires a lot of theory I'm guessing you don't know yet, but the short version is: there is a theorem, which says $$ \lim_{x\to \infty}\frac1x\sum_{n\le x}\frac{\varphi(n)}{n}=\lim_{s\to 1}(s-1)L_{\varphi}(s+1), $$ where $L_{\varphi}(s)$ is the meromorphic continuation of $s\mapsto \sum_{n\ge 1}\frac{\varphi(n)}{n^s}$ to the entire complex plane.

Next, note that for all integers $n\ge 1$, we have $\varphi(n)=\sum_{d\mid n}\mu(d)\frac nd$, where $\mu$ is the Möbius function. Let $I:\mathbb{Z}_{n\ge 1}\to \mathbb{C}^\times$ be given by $I(n)=1$ for all $n\ge 1$, then we have $\varphi=\mu *I$, where '$*$' denotes Dirichlet convolution. Now, subject to some easily checked convergence conditions, we know that $L_{\varphi}(s)=L_\mu(s)L_I(s)=\frac{\zeta(s-1)}{\zeta(s)}$ for $\operatorname{Re}(s)>2$, where $\zeta(s)$ is the Riemann zeta function.

Hence, $$ \lim_{x\to \infty}\frac1x\sum_{n\le x}\frac{\varphi(n)}{n}=\lim_{s\to 1}(s-1)\frac{\zeta(s)}{\zeta(s+1)}=\frac1{\zeta(2)}\lim_{s\to 1}(s-1) \zeta(s)=\frac{6}{\pi^2}\cdot 1 = \frac{6}{\pi^2}, $$ as desired. Your identity is correct!

If you want to understand how identities like these can be proven, study complex analysis, geared towards Dirichlet series and $L$-functions. Among various interesting results, the famous Prime Number Theorem is also proved using these techniques.

Related Question