<s>[INST] Solve for $\int_{0}^{+\infty} \frac{\ln \left(x^{2}+2 \sin a \cdot x+1\right)}{1+x^{2}} d x$ It is known that $$\int_{0}^{+\infty} \frac{\ln \left(x^{2}+2 \sin a \cdot x+1\right)}{1+x^{2}} d x=\pi \ln \left|2 \cos \frac{a}{2}\right|+a \ln \left|\tan \frac{a}{2}\right|+2 \sum_{k=0}^{+\infty} \frac{\sin (2 k+1) a}{(2 k+1)^{2}}$$
In an attempt to derive the equation, I utilized 
$$\sum_{n=0}^{\infty}\left(\frac{e^{i x}}{a}\right)^{n}=\frac{1}{1-\frac{e^{i x}}{a}}=\frac{a(a-\cos x)}{a^{2}-2 a \cos x+1}+i \frac{a \sin x}{a^{2}-2 a \cos x+1}$$, where a>1
and $$\sum_{n=0}^{\infty}\left(ae^{i x}\right)^{n}=\frac{1}{1-ae^{i x}}=\frac{a(a-\cos x)}{a^{2}-2 a \cos x+1}+i \frac{a \sin x}{a^{2}-2 a \cos x+1}$$, where a<1
The series expansion for $\ln \left(x^{2}+2 \sin a \cdot x+1\right)$ can be obtained by integrating the imaginary part of the equation and plugging in $x=\frac{\pi}{2}-a$, $a=x$
However, I still failed to get the desired result by using this series expansion. I wonder whether I can obtain the equation through such Fourier series or I just missed some important point. Any help would be appreciated. 
 [/INST] Let's follow the advice by @Sonal_sqrt. For $-\pi/2<a<3\pi/2$,
$$\int_0^\infty\frac{\cos a\ dx}{1+2x\sin a+x^2}=\tan^{-1}\left.\frac{x+\sin a}{\cos a}\right|_{x=0}^{x=\infty}=\frac{\pi}{2}-a,$$
so, if $I(a)$ is the given integral, then (for the same range of $a$)
\begin{align}
I'(a)&=\int_0^\infty\frac{2x\cos a\ dx}{(1+x^2)(1+2x\sin a+x^2)}
\\&=\cot a\int_0^\infty\left(\frac{1}{1+x^2}-\frac{1}{1+2x\sin a+x^2}\right)dx
\\&=\cot a\left(\frac{\pi}{2}-\frac{1}{\cos a}\Big(\frac{\pi}{2}-a\Big)\right)=\frac{a}{\sin a}-\frac{\pi}{2}\tan\frac{a}{2}.
\end{align}
Knowing $I(0)=-2\int\limits_0^{\pi/2}\ln\cos t\,dt=\pi\ln 2$, and integrating $a/\sin a$ by parts, we have
$$I(a)=\pi\ln\Big|2\cos\frac{a}{2}\Big|+a\ln\Big|\tan\frac{a}{2}\Big|-\int_0^a\ln\Big|\tan\frac{x}{2}\Big|\,dx.$$
Finally, note that
$$-\ln\Big|\tan\frac{x}{2}\Big|=\Re\ln\frac{1+e^{ix}}{1-e^{ix}}=2\sum_{n=0}^{\infty}\frac{\cos(2n+1)x}{2n+1},$$
and integrability of this series is shown using Dirichlet's test.
</s>