TITLE: Does the mean ratio of the perimeter to the hypotenuse of right triangles converge to $1 + \dfrac{4}{\pi}$?
QUESTION [17 upvotes]: Conjecture: Let $\mu_x$ be the arithmetic mean of the ratio of the 
  perimeter to the hypotenuse of all primitive Pythagorean triplets in
  which no side exceeds $x$; then, 
$$ \lim_{x \to \infty}\mu_x = 1 + \frac{4}{\pi}$$

Based on data for $x \le 10^{11}$, the computed value agrees with the conjectured value up to $5$ decimal places.
Primitive Pythagorean triplets $a^2 = b^2 + c^2, \gcd(b,c) = 1$ are given by $a = r^2 + s^2$, $b = r^2 - s^2$ and $c = 2rs$ where $r > s$ are natural numbers. 
Let the $n$-th primitive triplet be the one formed by the $n$-th smallest pair in increasing order of $(r,s)$. It was proved in this post MSE that the arithmetic mean $\mu_n$ of the ratio of the perimeter to the hypotenuse of first $n$ primitive Pythagorean triplets approaches $\dfrac{\pi}{2} + \log 2$ as $n \to \infty$. However the above claim is still open.
Question: I am looking for a proof or disproof of this conjecture.

REPLY [16 votes]: This is right. Primitive Pythagorean triples are parametrized as $(u^2-v^2, 2uv, u^2+v^2)$ with $\mathrm{GCD}(u,v) = 1$ and $u+v \equiv 1 \bmod 2$. To have $0 < a,b < c \leq R^2$, we must have $0 < v < u$ and $u^2+v^2 \leq R^2$. The ratio of perimeter to hypotenuse is $\tfrac{(u^2-v^2)+(2uv)+(u^2+v^2)}{u^2+v^2} = \tfrac{2u(u+v)}{u^2+v^2}$.
Ignoring the $GCD$ and parity conditions, we want to compute
$$\sum_{0<v<u,\ u^2+v^2\leq R^2} \frac{2u(u+v)}{u^2+v^2} \ \mbox{and} \ \sum_{0<v<u,\ u^2+v^2\leq R^2}  1.$$
Replacing these sums with integrals and changing to polar coordinates gives
$$\int_{r=0}^R \int_{\theta=0}^{\pi/4} 2r ( \cos \theta) (\cos \theta+\sin \theta) \, dr \, d\theta = \frac{4+\pi}{8} R^2$$
and
$$\int_{r=0}^R \int_{\theta=0}^{\pi/4} r \, dr \, d\theta = \frac{\pi}{8} R^2$$
so the ratio approaches $1+\tfrac{4}{\pi}$. 
It remains to analyze replacing the sum by an integer, and the effect of the conditions $\operatorname{GCD}(u,v) = 1$ and $u+v \equiv 1 \bmod 2$. I'll sketch the argument. 
The GCD condition can be represented as an inclusion-exclusion sum
$$\sum_{1 \leq k \leq R} \mu(k) \sum_{0<kv<ku,\ (ku)^2+(kv)^2\leq R} \frac{2(ku)(ku+kv)}{(ku)^2+(kv)^2}.$$
The inner sum is exactly the one we discussed above, with $R$ replaces by $R/k$, so the integral approximation gives $\tfrac{4+\pi}{8} (R/k)^2$. Being more precise, the error in replacing the sum by an integral is $O(R/k)$. So the sum with GCD condition imposed is $\tfrac{4+\pi}{8} R^2 \sum_k \tfrac{\mu(k)}{k^2} + O(\sum_{k \leq R} R/k) = \tfrac{4+\pi}{8} \tfrac{6}{\pi^2} R^2 + O(R \log R)$. Likewise, the denominator is $\tfrac{\pi}{8} \tfrac{6}{\pi^2} R^2 + O(R \log R)$. So the limiting ratio is still the same. Imposing that $u+v \equiv 1 \bmod 2$ (once we have already imposed $\mathrm{GCD}(u,v)=1$) multiplies top and bottom by $2/3$.