# Infinite sum involving number of solutions to $k=i^2+j^2$

I want to calculate the following sum: $$S=\sum_{k=1}^\infty (-1)^{k-1}\frac{r_2(k)}{k}$$ Where $r_2(k)$ is the number of ways to write $k$ in the form $i^2+j^2$ where $i,j\in\mathbb Z$. I was able to transform it into: $$\frac S 4 -\frac{\pi^2}{12}=\sum_{i=1}^\infty{\sum_{j=1}^\infty \frac{(-1)^{i+j-1}}{i^2+j^2}}$$ But I'm not sure if it helps. Any help is highly appreciated.

• Do you have the closed form answer to this series? – r9m Jun 7 '15 at 19:15
• It should be $S=\pi\log 2$. – Jack D'Aurizio Jun 7 '15 at 19:18
• No, but I was told that it has a closed form. – Redundant Aunt Jun 7 '15 at 19:18

I suppose we could start with the fact that: $$r_2(n) = 4(d_{1,4}(n) - d_{3,4}(n))$$

where, $d_{a,b}(n)$ is the number of divisors of $n$ that are congruent to $a\pmod{b}$.

Hence, $\displaystyle \sum\limits_{n=1}^{\infty} r_2(n)x^n = 4\sum\limits_{n=0}^{\infty} (-1)^{n}\frac{x^{2n+1}}{1-x^{2n+1}}$

Thus, \displaystyle \begin{align}\sum\limits_{n=1}^{\infty} (-1)^{n-1}\frac{r_2(n)}{n} &= 4\sum\limits_{n=0}^{\infty} (-1)^{n-1}\int_0^{-1} \frac{x^{2n}}{1-x^{2n+1}}\,dx \\&= 4\sum\limits_{n=0}^{\infty} (-1)^{n}\frac{\log (1-(-1)^{2n+1})}{2n+1}\\&= 4\log 2\sum\limits_{n=0}^{\infty} \frac{(-1)^{n}}{2n+1} = \pi\log 2\end{align}

• Wow, thats impressive! – Redundant Aunt Jun 7 '15 at 19:31
• Could you explain how the integration is coming into play here? – Tyler Hilton Jun 8 '15 at 4:49
• @TylerHilton we are dividing both sides, the generating function (LHS) identity (Lambert series of $r_2(n)$ on RHS) by $x$ and integrating term by term on both sides. $\sum\limits_{n=1}^{\infty} (-1)^n\frac{x^{2n+1}}{1 - x^{2n+1}}$ converges uniformly in the interval $(-1,0]$ (as you can verify by Weierstrass M-Test) hence we can have term by term integration. – r9m Jun 8 '15 at 8:15
• @r9m Thanks. This may be out of my scope, but what is the purpose of integration here? – Tyler Hilton Jun 8 '15 at 16:52
• @TylerHilton I'm not sure what you mean by purpose of integration .. but the only way I could think atm of getting $\frac{r_2(n)}{n}$ from the Lambert series is by integrating term by term after dividing by $x$, I mean $\displaystyle \int_0^{t} r_2(n)x^{n-1}\,dx = \frac{r_2(n)}{n}t^{n}$, then taking $t = -1$ gives the alternating series. – r9m Jun 8 '15 at 16:56

For any $a,b\in\mathbb{N}\setminus\{0\}$ we have: $$\int_{0}^{+\infty}\frac{\sin(ax)}{a} e^{-bx}\,dx = \frac{1}{a^2+b^2}\tag{1}$$ so by multiplying both sides of $(1)$ by $(-1)^a (-1)^b$ and summing over $a\in[1,+\infty),b\in[1,+\infty)$ we get: $$\sum_{a,b\geq 1}\frac{(-1)^{a+b}}{a^2+b^2}=\int_{0}^{+\infty}\frac{\text{Im}\log(1+e^{ix})}{1+e^x}\,dx=\frac{\pi^2}{24}-\sum_{k=1}^{+\infty}\pi k\int_{(2k-1)\pi}^{(2k+1)\pi}\frac{dx}{1+e^x}\tag{2}$$ and: $$\begin{eqnarray*}\sum_{k=1}^{+\infty}\pi k\int_{(2k-1)\pi}^{(2k+1)\pi}\frac{dx}{1+e^x}&=&\pi\sum_{k=0}^{+\infty}\log\left(1+e^{-(2k+1)\pi}\right)\\&=&\pi\log\prod_{k\geq 0}\left(1+e^{-(2k+1)\pi}\right)\\&=&\pi\log\left(2^{1/4}e^{-\pi/24}\right)\tag{3}\end{eqnarray*}$$ where the last identity is kindly provided by a special value of the Dedekind eta function. $$S = \pi\log 2 \tag{4}$$ readily follows.

Another possible approach is given by noticing that $(-1)^k r_2(k)$ is four times a multiplicative function, hence, by Dirichlet convolution: $$S = 4\left(\sum_{n\geq 1}\frac{(-1)^n}{2n-1}\right)\cdot\left(\sum_{n\geq 1}\frac{(-1)^n}{n}\right)=4\cdot\frac{\pi}{4}\cdot\log 2.\tag{5}$$

• @r9m: we both exploited the fact that the set $\{a^2+b^2\}$ is a semigroup, but in two different manners, you by writing $r_2(k)$ as a multiple of a multiplicative function, me by computing a $j$-invariant, essentially. – Jack D'Aurizio Jun 7 '15 at 20:36

We note the estimate of the summation function of $r_{2}(n)$:

$$S(n) = \sum\limits_{k=1}^{n} r_2(k) = \pi n + \mathcal{O}(\sqrt{n})$$

where, $S(n)$ is the number of integer points inside the disk of radius $\sqrt{n}$.

Since, $k = i^2+j^2 \iff 2k = (i+j)^2+(i-j)^2$, we have, $r_2(2k) = r_2(k)$.

Hence, $$\displaystyle \sum\limits_{k=1}^{2n} (-1)^{k-1}\frac{r_2(k)}{k} = \sum\limits_{k=1}^{2n}\frac{r_2(k)}{k} - 2\sum\limits_{k=1}^{n}\frac{r_2(2k)}{2k} = \sum\limits_{k=n+1}^{2n} \frac{r_2(k)}{k}$$

Now, by Abel Summation identity: \begin{align} \sum\limits_{k=n+1}^{2n} \frac{r_2(k)}{k} &= \sum\limits_{k=n}^{2n} \left(\frac{1}{k} - \frac{1}{k+1}\right)S(k) + \frac{S(2n)}{2n+1} - \frac{S(n)}{n} \\ &= \sum\limits_{k=n}^{2n} \frac{S(k)}{k(k+1)} + \frac{S(2n)}{2n+1} - \frac{S(n)}{n}\end{align}

Since, $\displaystyle \frac{S(n)}{n} = \pi + \mathcal{O}(n^{-1/2})$

\begin{align} \sum\limits_{k=n}^{2n} \frac{S(k)}{k(k+1)}&= \pi\sum\limits_{k=n}^{2n}\frac{1}{k+1} + \mathcal{O}\left(\sum\limits_{k=n}^{2n}\frac{1}{k^{1/2}(k+1)}\right)\\&=\pi\sum\limits_{k=n}^{2n}\frac{1}{k+1} + \mathcal{O}(n^{-1/2}) \end{align}

Hence, $$\sum\limits_{k=1}^{2n} (-1)^{k-1}\frac{r_2(k)}{k} = \pi\sum\limits_{k=n}^{2n}\frac{1}{k+1} + \mathcal{O}(n^{-1/2})$$

i.e., $$\sum\limits_{k=1}^{\infty} (-1)^{k-1}\frac{r_2(k)}{k} = \pi\log 2$$

• (+1) That is also very nice. – Jack D'Aurizio Jun 7 '15 at 23:31

Not knowing much about Dirichlet convolution, here's how I derived the result that Jack D'Aurizio mentioned in his answer.

The sum of two squares function has the representation $$r_{2}(k) = 4 \sum_{d|k} \sin \left(\frac{\pi d}{2} \right).$$

See equation 25.

So $$\sum_{k=1}^{\infty} (-1)^{k-1} \frac{r_{2}(k)}{k} = 4 \sum_{k=1}^{\infty} \frac{(-1)^{k-1}}{k} \sum_{d|k} \sin \left(\frac{\pi d}{2} \right).$$

Then assuming we can switch the order of summation,

\begin{align} \sum_{k=1}^{\infty} (-1)^{k-1} \frac{r_{2}(k)}{k} &= 4 \sum_{d=1}^{\infty} \sin \left(\frac{\pi d}{2} \right) \sum_{k \, \text{such that} \, d|k} \frac{(-1)^{k-1}}{k} \\ &= 4 \sum_{d=1}^{\infty} \sin \left(\frac{\pi d}{2} \right) \sum_{k=1}^{\infty}\frac{(-1)^{kd-1}}{kd} \\ &= 4 \sum_{d=1}^{\infty} \sin \left(\frac{\pi d}{2} \right) \sum_{k=1}^{\infty}\frac{(-1)^{k-1}}{kd} \tag{1} \\ &= 4 \sum_{d=1}^{\infty} \frac{\sin \left(\frac{\pi d}{2} \right)}{d} \sum_{k=1}^{\infty} \frac{(-1)^{k-1}}{k} \\&= 4 \sum_{d=0}^{\infty} \frac{(-1)^{d}}{2d+1} \sum_{k=1}^{\infty} \frac{(-1)^{k-1}}{k}\\ &= 4 \left(\frac{\pi}{4} \right) \left(\log 2 \right) \\ &= \pi \log 2. \end{align}

$(1)$ When $d$ is even, $\sin \left(\frac{\pi d}{2} \right)$ is zero.

• (+1) This is another cute way of avoiding having to integrate the Lambert Series :-) Nice!!! :D – r9m Jun 10 '15 at 15:20