TITLE: How to calculate $\sum_{n \in P}\frac{1}{n^2}, P=\{n \in \mathbb{N}: \exists (a,b) \in\ \mathbb{N^+} \times \mathbb{N^+} \mbox{ with } a^2+b^2=n^2\}$
QUESTION [5 upvotes]: How I can evaluate
$$\sum_{n \in P}\frac{1}{n^2} \quad \quad P=\{n \in \mathbb{N^+}: \exists (a,b) \in\ \mathbb{N^+} \times \mathbb{N^+} \mbox{ with } a^2+b^2=n^2\}$$
It's clearly convergent. I thought about seeing the sum as a sum of complex numbers using $(a+ib)(a-ib)=a^2+b^2$.

REPLY [3 votes]: Let $S(x)$ denote the number of positive integers not exceeding $x$ which can be expressed as a sum of two squares. Then, as proved by Landau in 1908 the following limit holds.
$$
\lim_{x\to\infty} \frac{\sqrt{\ln x}}{x} S(x) = K,
$$
where $K \approx 0.76422365358922$ is a constant. The convergence to the constant $K$, known as the Landau–Ramanujan constant is very slow. The first ten thousand digits of $K$ is here.
The exact value of $K$ can be expressed as
$$
K = \frac{1}{\sqrt{2}} \prod_{\substack{p \text{ prime } \\ \equiv \, 3 \pmod{4}}} \left(1-\frac{1}{p^2}\right)^{-1/2},
$$
so we have that
$$
\prod_{\substack{p \text{ prime } \\ \equiv \, 3 \pmod{4}}} \left(1-\frac{1}{p^2}\right) = \frac{1}{2K^2}.
$$
From the excellent answer of @Jack D'Aurizio we know that
$$
S = \sum_{n\in P}\frac{1}{n^2} = \frac{\pi^2}{6}-\frac{4}{3}\cdot \prod_{\substack{p \text{ prime } \\ \equiv \, 3 \pmod{4}}} \left(1-\frac{1}{p^2}\right)^{-1}. \\
$$
Using the exact value of $K$ we could express your sum in term of the Landau–Ramanujan constant.

$$
S = \sum_{n\in P}\frac{1}{n^2} = \frac{\pi^2}{6}-\frac{8K^2}{3}.
$$

Numerically

$$
\begin{align}
S \approx 
0.08749995296754071824615285056063798739937787259940111394813\\
9987884926591232919611579752270225245544983905801979851301833\\
539947996701320476568130203602037004645936371\dots\phantom{0000000000000}
\end{align}
$$

Note that the numerical evaluation of the product for $K$ is hopeless in this form. You could find an other expression for $K$ here (eq. 11), which has much faster convergence.