<s>[INST] 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\}$ 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$.
 [/INST] We just have to understand which numbers $n\in\mathbb{N}^+$ are such that $n^2$ cannot be written as $a^2+b^2$ with $a,b\in\mathbb{N}^+$. If there is some prime $p\equiv 1\pmod{4}$ that divides $n$, such prime splits in $\mathbb{Z}[i]$ (the ring of gaussian integers), hence $n^2$ can be represented for sure as $a^2+b^2$ with $a,b\neq 0$. If $n$ is even then $n^2\equiv 0\pmod{4}$, hence $n^2=a^2+b^2$ gives that both $a$ and $b$ are even and the problem boils down to representing $(n/2)^2$. At last we have that the only numbers whose square cannot be represented as $a^2+b^2$ with $a,b\neq 0$ are the ones whose prime factors lie in the set made by $2$ and the primes $\equiv 3\pmod{4}$. That gives:
$$ \sum_{n\in P}\frac{1}{n^2} = \frac{\pi^2}{6}-\!\!\!\!\prod_{p\in\{2,3,7,\ldots\}}\left(1-\frac{1}{p^2}\right)^{-1}=\frac{\pi^2}{6}-\frac{4}{3}\cdot\!\!\!\prod_{p\equiv 3\!\!\pmod{4}}\left(1-\frac{1}{p^2}\right)^{-1}.\tag{1}$$
Now, let $\chi$ be the non-principal Dirichlet character $\!\!\pmod{4}$ and $L(s,\chi)$ the associated Dirichlet L-function. We have:
$$ L(2,\chi) = \sum_{n\geq 0}\frac{(-1)^n}{(2n+1)^2} = \prod_{p}\left(1-\frac{\chi(p)}{p^2}\right)^{-1},\tag{2} $$
$$ L(4,\chi) = \sum_{n\geq 0}\frac{(-1)^n}{(2n+1)^4} = \prod_{p}\left(1-\frac{\chi(p)}{p^4}\right)^{-1},\tag{3} $$
$$ \frac{L(4,\chi)}{L(2,\chi)}=\prod_{p}\left(1+\frac{\chi(p)}{p^2}\right)^{-1}=\prod_{p\equiv 3\!\!\pmod{4}}\left(1-\frac{1}{p^2}\right)^{-1}\prod_{p\equiv 1\!\!\pmod{4}}\left(1+\frac{1}{p^2}\right)^{-1}\tag{4}$$
hence:

$$ S= \sum_{n\in P}\frac{1}{n^2}=\frac{\pi^2}{6}-\frac{4\, L(4,\chi)}{3\, L(2,\chi)}\cdot\!\!\prod_{p\equiv 1\!\!\pmod{\!\! 4}}\!\!\left(1+\frac{1}{p^2}\right).\tag{5}$$

</s>