TAOCP 4.5.2 Exercise 14

Let G=\gcd(u,v).

Section 4.5.2: The Greatest Common Divisor

Exercise 14. ▶ [**] [HM25] What is the expected value of $\lg \gcd(u, v)$ when $u$ and $v$ are (a) random positive integers; (b) random positive odd integers?

Verified: yes
Solve time: 1m19s


Let

$$ G=\gcd(u,v). $$

By Theorem 4.5.2D, for random positive integers,

$$ \Pr(G=d)=\frac{1}{\zeta(2)d^2}=\frac{6}{\pi^2d^2}, $$

since

$$ \Pr(\gcd(u',v')=1)=\frac1{\zeta(2)}. $$

Therefore

$$ E(\lg G) =\sum_{d\ge1}\frac{\lg d}{\zeta(2)d^2} =\frac1{\zeta(2)}\sum_{d\ge1}\frac{\lg d}{d^2}. $$

Using

$$ \zeta'(s)=-\sum_{n\ge1}\frac{\ln n}{n^s}, $$

we have

$$ \sum_{d\ge1}\frac{\lg d}{d^2} =\frac{-\zeta'(2)}{\ln 2}, $$

hence

$$ E(\lg \gcd(u,v)) = -\frac{\zeta'(2)}{\zeta(2)\ln 2} \approx 0.822467. $$

Thus

$$ \boxed{E(\lg \gcd(u,v)) = -\frac{\zeta'(2)}{\zeta(2)\ln 2} \approx 0.822467.} $$

For random positive odd integers, exercise 13 shows that

$$ \Pr(\gcd(u,v)=1)=\frac8{\pi^2}. $$

If $d$ is odd,

$$ \Pr(\gcd(u,v)=d) =\frac8{\pi^2d^2}, $$

and the probability is $0$ for even $d$. Hence

$$ E(\lg G) =\frac8{\pi^2}\sum_{\substack{d\ge1\ d\ \text{odd}}}\frac{\lg d}{d^2}. $$

Since

$$ \sum_{\substack{d\ge1\ d\ \text{odd}}}\frac{\ln d}{d^2} = -\zeta'(2)+2^{-2}!\left(\ln 2,\zeta(2)+\zeta'(2)\right) = -\frac34\zeta'(2)+\frac14\ln 2,\zeta(2), $$

it follows that

$$ E(\lg \gcd(u,v)) = -\frac{\zeta'(2)}{\zeta(2)\ln 2} +\frac13 \approx 1.155800. $$

Therefore

$$ \boxed{E(\lg \gcd(u,v)) = -\frac{\zeta'(2)}{\zeta(2)\ln 2} +\frac13 \approx 1.155800} $$

when $u$ and $v$ are random positive odd integers. ∎