Evaluation of integral with double arctan How can we evaluate this integral?
$$\int _0^{\pi }\arctan \left(\frac{\sin x}{a+\cos x}\right)\arctan \left(\frac{\sin x}{b+\cos x}\right)dx$$
I have solved this problem for $a,b\ne (-1,1)$ my result is:
$$\int _0^{\pi }\arctan \left(\frac{\sin x}{a+\cos x}\right)\arctan \left(\frac{\sin x}{b+\cos x}\right)dx=\frac{\pi }{2}\operatorname{Li}_2\left(\frac{1}{ab}\right)$$
Is there anyone who solve this integral for $a,b \in (-1,1)$ ?
 A: The Fourier series given in the comments has the problem of not working for $|r| < 1$. Here's one that does:
$$
\tan^{-1}\left(\frac{\sin x}{r-\cos x}\right)  = \pi\theta(x-\cos^{-1}r) - x - \sum_{k=1}^\infty\frac{r^k}{k} \sin(kx) 
$$
where $\theta$ is the unit step function. Not the prettiest admittedly, but we take what we can get.
So, let's try this in the integral. Substitute $x\rightarrow\pi-x$ to get this form, assume WLOG that $a < b$, and let $\alpha = \cos^{-1}a$, $\beta = \cos^{-1}b$
\begin{multline}
\int_0^\pi\tan^{-1}\left(\frac{\sin x}{a - \cos x}\right)\tan^{-1}\left(\frac{\sin x}{b - \cos x}\right)dx \\
= \int_0^\pi\left[\pi\theta(x-\alpha) - x - \sum_{k=1}^\infty\frac{a^k}{k} \sin(kx) \right]\left[\pi\theta(x-\beta) - x - \sum_{m=1}^\infty\frac{b^m}{m} \sin(m x) \right]dx
\end{multline}
OK, that's a lot of integrals. The relevant ones are
$$
\int_0^\pi\left[\pi\theta(x-\alpha) - x\right]\left[\pi\theta(x-\beta) - x\right]dx = \frac{\pi}{2}\left[(\pi-\alpha)^2 + \beta^2 -\frac{\pi^2}{3}\right]
$$
$$
\sum_{m=1}^\infty\frac{b^m}{m}\int_{\alpha}^\pi\sin(mx)dx = \sum_{m=1}^\infty\frac{b^m}{m^2}\left(\cos(m\alpha) -\cos(m\pi)\right) = \operatorname{Re}\left[\operatorname{Li}_2(be^{i\alpha})\right]-\operatorname{Li}_2(-b)
$$
$$
\sum_{m=1}^\infty\frac{b^m}{m}\int_0^\pi x\sin(mx)dx =-\pi \sum_{m=1}^\infty \frac{(-b)^m}{m^2} = -\pi \operatorname{Li}_2(-b)
$$
$$
\sum_{m=1}^\infty\sum_{k=1}^\infty \frac{b^ma^k}{km}\int_0^\pi\sin(mx)\sin(kx)dx = \frac{\pi}{2}\sum_{m=1}^\infty \frac{(ab)^m}{m^2} = \frac{\pi}{2}\operatorname{Li}_2(ab)
$$
Putting this disaster together gives
$$
\frac{\pi}{2}\operatorname{Li}_2(ab) + \frac{\pi}{2}\left[(\pi-\alpha)^2 + \beta^2 -\frac{\pi^2}{3}\right] - \pi\operatorname{Re}\left[\operatorname{Li}_2(be^{i\alpha})+\operatorname{Li}_2(ae^{i\beta})\right]
$$
I guess for completion I should include $|a| < 1 < |b|$. A similar analysis gives
$$
\pi\operatorname{Re}[\operatorname{Li}_2(b^{-1}e^{i\alpha})]-\frac{\pi}{2}\operatorname{Li}_2\left(\frac{a}{b}\right)
$$
I'm not sure if $\operatorname{Re}[\operatorname{Li}_2(be^{i\alpha})]$ has a simplification that would make this more elegant.
