Evaluate a Dirichlet series related to the ring of Gaussian integers For any positive integer $n$, let $S_n$ denote the number of solutions to the equation $x^2+y^2=n$, where $(x,y)\in\mathbb{N}^2$.
How to evaluate $\displaystyle\sum_{n=1}^\infty\frac{(-1)^nS_n}{n}$ ?
Note that the sum can be written as $\displaystyle\sum_{x=1}^\infty\sum_{y=1}^\infty\frac{(-1)^{x+y}}{x^2+y^2}$.
Thanks for help.
 A: The ring of Gaussian integers $\mathbb{Z}[i]$ is an Euclidean domain, hence a UFD. It follows that
$$ r_2(n) = \left|\{(a,b)\in\mathbb{Z}^2:a^2+b^2=n\}\right| $$
is a multiple of a multiplicative function:
$$ r_2(n) = 4\left(\chi_4*1\right)(n) = 4\sum_{d\mid n}\chi_4(d) $$
where $\chi_4(d)$ equals $1$ iff $d\equiv 1\pmod{4}$, $-1$ iff $d\equiv 3\pmod{4}$ and zero otherwise.
If $n\in\mathbb{N}^+$ is not a square we have $S_n=(\chi_4*1)(n)$, if $n$ is a square we have $S_n=(\chi_4*1)(n)+1$.
By Gauss circle problem the average value of $S_n$ is $\frac{\pi}{4}$; the series $\sum_{n\geq 1}\frac{(-1)^n S_n}{n}$ is conditionally convergent and
$$ \sum_{n\geq 1}\frac{(-1)^n S_n}{n} = \sum_{n\geq 1}\frac{(-1)^n (\chi_4*1)(n)}{n}+\sum_{n\geq 1}\frac{(-1)^{n^2}}{n^2} = \sum_{n\geq 1}\frac{(-1)^n (\chi_4*1)(n)}{n}-\frac{\pi^2}{12}. $$
For any $s>1$ we have
$$ \sum_{n\geq 1}\frac{(-1)^n (\chi_4*1)(n)}{n^s}=-\sum_{n\geq 1}\frac{(\chi_4*1)(n)}{n^s}+2\sum_{\substack{n\geq 1\\n\text{ even}}}\frac{(\chi_4*1)(n)}{n^s}=\left(-1+\frac{2}{2^s}\right)\zeta(s)L(\chi_4,s) $$
and the limit of the RHS as $s\to 1^+$ is $-\frac{\pi}{4}\log 2$. It follows that
$$ \sum_{n\geq 1}\frac{(-1)^n S_n}{n}=-\frac{\pi}{4}\log(2)-\frac{\pi^2}{12}$$
but one is not allowed to rearrange $\sum_{x\geq 1}\sum_{y\geq 1}\frac{(-1)^{x+y}}{x^2+y^2}$ into $\sum_{n\geq 1}\frac{(-1)^n S_n}{n}$ due to the lack of absolute convergence of the double series. On the other hand
$$ \sum_{x\geq 1}\sum_{y\geq 1}\frac{(-1)^{x+y}}{x^2+y^2} = \sum_{x\geq 1}\frac{(-1)^x\left(-1+\frac{\pi x}{\sinh(\pi x)}\right)}{2x^2}=\frac{\pi^2}{24}+\frac{\pi}{2}\sum_{x\geq 1}\frac{(-1)^x}{x\sinh(\pi x)}=\frac{\pi^2}{12}-\frac{\pi}{4}\log(2) $$
can be proved through the Poisson summation formula.
A: The identity $(k+l)^2+(k-l)^2=2\,(k^2+l^2)$ seems to show a one-to-one correspondence between representations of $n$ and $2n$ as a sum of two squares, so we would have $S_{2n}=S_n$, but... it's not that simple: if $k=l$, $(2k)^2+0^2$ on the LHS is not a valid representation, while on the other hand, the valid $k^2+k^2$ on the LHS corresponds to the invalid $2(k^2+0^2)$ on the RHS. As a consequence, we have $S_{2n}=S_n+1$ for $n=k^2$, and $S_{2n}=S_n-1$
 for $n=2k^2$. But if we define $$S'_n=\begin{cases}
S_n,  & \text{if $n$ is not a square} \\
S_n+1, & \text{if $n$ is a square}
\end{cases}$$ we'll have $S'_{2n}=S'_n$ for all $n$, and obviously,
$$\sum^\infty_{n=1}\,(-1)^n\,\frac{S_n}n=\sum^\infty_{n=1}\,(-1)^n\,\frac{S'_n}n+\sum^\infty_{k=1}\,(-1)^{k-1}\frac1{k^2}=\sum^\infty_{n=1}\,(-1)^n\,\frac{S'_n}n+\frac{\pi^2}{12}$$
Then, we can evaluate partial sums of the series on the RHS:
$$\sum^{2N}_{n=1}\,(-1)^n\,\frac{S'_n}n=2\,\sum^N_{n=1}\,\frac{S'_{2n}}{2n}-\sum^{2N}_{n=1}\,\frac{S'_n}n=-\sum^{2N}_{n=N+1}\,\frac{S'_n}n$$
Since we're interested in the limit $N\to\infty$, we need  the $S'_n$ only for large $n$. The sequence itself doesn't have nice asymptotics, but
$$T_n=\sum^n_{k=1}S'_k$$ does: there's the well-known result
$$\sum^n_{k=1}S_k=\frac{\pi}4n+O(\sqrt{n}).$$  It's easy to understand it intuitively: it's the number of all pairs $(k,l)$ with  $k^2+l^2\le n$, i.e. the number of integer points in a quarter of a disc with radius $\sqrt{n}$, and area $\dfrac{\pi}4\,n$.
Of course, this implies $$T_n=\frac{\pi}4n+r_n\tag1$$ with $$r_n=O(\sqrt{n}),$$ because $S_n$ and $S'_n$ differ by $1$ only for square $n$. 
Thus, we can write
\begin{align}
\sum^{2N}_{n=N+1}\,\frac{S'_n}n&=\sum^{2N}_{n=N+1}\,\frac{T_n-T_{n-1}}n=\sum^{2N}_{n=N+1}\,\frac{T_n}n-\sum^{2N}_{n=N+1}\,\frac{T_{n-1}}n=\sum^{2N}_{n=N+1}\,\frac{T_n}n-\sum^{2N-1}_{n=N}\,\frac{T_n}{n+1}\\
&=\sum^{2N}_{n=N+1}\,\frac{T_n}{n(n+1)}+\frac{T_{2N}}{2N+1}-\frac{T_{N}}{N+1}
\end{align}
But $\dfrac{T_n}n$ converges due to (1), so $\dfrac{T_{2N}}{2N+1}-\dfrac{T_{N}}{N+1}\to0$ as $N\to\infty$. $\displaystyle\sum^\infty_{n=1}\,\frac{r_n}{n(n+1)}$ converges, so $\displaystyle\sum^{2N}_{n=N+1}\,\frac{r_n}{n(n+1)}\to0$ as $N\to\infty$. $$\sum^{2N}_{n=N+1}\,\frac{\frac{\pi}4\,n}{n(n+1)}=\frac{\pi}4\,\sum^{2N}_{n=N+1}\,\frac1{n+1}=\frac{\pi}4\,(H_{2N+1}-H_{N+1})\to\frac{\pi}4\,\ln 2$$ as $N\to\infty$, so we see that the infinite series converges, indeed, and
$$\sum^\infty_{n=1}\,(-1)^n\,\frac{S'_n}n=-\frac{\pi}4\,\ln 2.$$ This means
$$\sum^\infty_{n=1}\,(-1)^n\,\frac{S_n}n=\frac{\pi^2}{12}-\frac{\pi}4\,\ln 2=0.2780705108482126856110353587636091\ldots,$$ and that's in rather good agreement with numerical results: the sum over all $n<100000000$ is about $0.27807045832349575$.
