<s>[INST] Generalization of Leibniz formula for $\pi$ The well-known Leibniz formula for $\pi$ is
$$
1-\frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \ldots = \frac{\pi}{4}.
$$
Looking at some nonstandard techniques, I've happened upon the following formula:
\begin{equation} \label{armdark}
\begin{split}
\Big( \frac{1}{1} + \frac{1}{3} &+ \ldots + \frac{1}{2q-1}\Big) - \Big( \frac{1}{2q+1} + \ldots + \frac{1}{4q-1}\Big) \\ 
&+ \Big( \frac{1}{4q+1} + \ldots + \frac{1}{6q-1}\Big) - \Big( \frac{1}{6q+1} + \ldots + \frac{1}{8q-1}\Big) + \ldots \\
& \qquad \qquad = \frac{\pi}{4q} \sum_{k=0}^{q-1} \Big(\frac{1+\tan(\frac{\pi}{4}(\frac{q-1-2k}{q}))}{1-\tan(\frac{\pi}{4}(\frac{q-1-2k}{q}))} \Big).
\end{split}
\end{equation}
In other words, we are summing the reciprocals of the odd integers, but rather than signs which alternate at each successive term we are adding $q$ positive terms in a row, then $q$ negative ones, then $q$ positive ones, etc. Clearly, this reduces to the Leibniz formula if $q=1$, but if $q=2$ we get
$$
\frac{1}{1} + \frac{1}{3} - \frac{1}{5} - \frac{1}{7} + \frac{1}{9} + \frac{1}{11} - \frac{1}{13} - \frac{1}{15} + \ldots = \frac{\pi \sqrt{2}}{4},
$$
and for $q=3$,
$$
\frac{1}{1} + \frac{1}{3} + \frac{1}{5} - \frac{1}{7} - \frac{1}{9} - \frac{1}{11} + \frac{1}{13} + \frac{1}{15} +  \frac{1}{17} - \ldots = \frac{5 \pi}{12},
$$
and so forth. If we want to do this sort of thing for all positive integers, rather than just the odd ones, then the formula is 
\begin{equation} \label{embeth}
\begin{split}
\Big( \frac{1}{1} + \frac{1}{2} &+ \ldots + \frac{1}{q}\Big) - \Big( \frac{1}{q+1} + \ldots + \frac{1}{2q}\Big) \\ 
& + \Big( \frac{1}{2q+1} + \ldots + \frac{1}{3q}\Big) - \Big( \frac{1}{3q+1} + \ldots + \frac{1}{4q}\Big) + \ldots \\
& \qquad \qquad = \frac{\ln 2}{q} + \frac{\pi}{2q} \sum_{k=1}^{q-1} \Big(\frac{1+\tan(\frac{\pi}{4}(\frac{q-2k}{q}))}{1-\tan(\frac{\pi}{4}(\frac{q-2k}{q}))} \Big).
\end{split}
\end{equation}
This reduces to known results for $q=1,2$ (e.g. for $q=1$ the sum on the right is empty, and we get $1-\frac{1}{2} + \frac{1}{3} - \frac{1}{4} + \ldots = \ln 2$), and taking for instance $q=3$ we get
$$
\frac{1}{1} + \frac{1}{2} + \frac{1}{3} - \frac{1}{4} - \frac{1}{5} - \frac{1}{6} + \frac{1}{7} + \frac{1}{8} + \frac{1}{9} - \ldots = \frac{2\pi}{3\sqrt{3}} + \frac{\ln 2}{3},
$$
and $q=4$ gives 
$$
\frac{1}{1} + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} - \frac{1}{5} - \frac{1}{6} - \frac{1}{7} - \frac{1}{8} + \ldots = \frac{\pi(1+2\sqrt{2})}{8} + \frac{\ln 2}{4}.
$$
I don't know too much about these types of sums, so my question is whether anyone has seen these sums before, and/or how someone might go about proving them. I mean, I have proofs of them, but I'm curious to see whether and how more standard techniques can produce them.
Thanks in advance,
Greg
 [/INST] The idea is to use $\sum_{n=1}^\infty \exp(2\pi i nm/\ell)/n=-\log(1-\exp(2\pi i m/\ell))$ for any $m$ not divisible by $\ell$. From here you can find $\sum_{n=1}^\infty c_n/n$ for any $\ell$-periodic sequence $c_n$ such that $\sum_{n=1}^\ell c_n=0$, by finding $d_m$'s such that $c_n=\sum_{m=1}^\ell d_m\exp(2\pi i nm/\ell)$, and hence 
$$\sum_{n=1}^\infty c_n/n=-\sum_{m=1}^\ell d_m\log(1-\exp(2\pi i m/\ell))\qquad(*)$$
The numbers $d_m$ can be found as (inverse finite Fourier transform if you wish)
$$d_m=\frac{1}{\ell}\sum_{n=1}^\ell c_n \exp(-2\pi i nm/\ell)$$
(notice that $d_\ell=0$). You now need to compute $d_m$'s for your favorite sequence $c_n$ and simplify the finite sum $(*)$.
</s>