TITLE: Integral $\int_0^\infty \log(1-e^{-a x})\cos (bx)\, dx=\frac{a}{2b^2}-\frac{\pi}{2b}\coth \frac{\pi b}{a}$
QUESTION [17 upvotes]: $$\mathcal{J}:=\int_0^\infty \log(1-e^{-a x})\cos (bx)\, dx=\frac{a}{2b^2}-\frac{\pi}{2b}\coth  \frac{\pi b}{a},\qquad \mathcal{Re}(a)>0, b>0.
$$
I tried to write
$$
\mathcal{J}=-\int_0^\infty  \sum_{n=1}^\infty\frac{e^{-anx}}{n}\cos(bx)\,dx 
$$
but the taylors series, $\log (1-\xi)=-\sum_{n=1}^\infty \xi^n/n, \ |\xi|<1$, thus this is not so useful for doing the integral.  I tried to also write
$$
\mathcal{J}=\frac{1}{b}\int_0^\infty \log(1-e^{-ax})d(\sin bx)=\frac{1}{b}\left(\log(1-e^{-ax})\sin (bx)\big|^\infty_0  -a\int_0^\infty 
\frac{\sin (bx)}{{e^{ax}-1}}dx \right),
$$
the boundary term vanishes so we have
$$
\mathcal{J}=\frac{a}{b}\int_0^\infty \frac{\sin(bx)}{1-e^{ax}}dx=\frac{a}{b}\mathcal{Im}\bigg[\int_0^\infty \frac{e^{ibx}}{e^{ax}-1}dx\bigg]
$$
which I am not sure how to solve.  Notice there are singularities at $x=2i\pi n/a, \ n\in \mathbb{Z}$.  
We need to calculate the residue for all the singularities along the imaginary axis.  The residue contribution to the integral
$$
2\pi i\cdot \sum_{n= 0}^\infty \frac{ e^{-2\pi  nb/a}}{e^{2i \pi n}}=2\pi i \sum_{n=0}^\infty e^{n(
-2\pi b/a-2i\pi)}=\frac{2\pi i}{e^{-(2\pi b/a+2\pi i)}}$$
Taking the imaginary part gives and re-writing the integral gives a different result.
Where did I go wrong?  How can we calculate this?  Thanks

REPLY [2 votes]: Let
$$ I(a)=\int_{0}^{\infty}\ln(1-e^{-ax})\cos(bx)dx. $$
Then
\begin{eqnarray}
I'(a)=&=&\int_{0}^{\infty}\frac{xe^{-ax}}{1-e^{-ax}}\cos(bx)dx\\
&=&\int_{0}^{\infty}\sum_{n=0}^\infty xe^{-a(n+1)x}\cos(bx)dx\\
&=&\sum_{n=0}^\infty \frac{(a(n+1)-b)(a(n+1)+b)}{(a^2(n+1)^2+b^2)^2}\\
&=&\sum_{n=1}^\infty \left(\frac{1}{a^2n^2+b^2}-\frac{2b^2}{(a^2n^2+b^2)^2}\right)\\
&=&\frac{1}{2}\left(\frac{1}{b^2}-\frac{\pi^2}{a^2\sinh^2(\frac{b\pi}{a})}\right).
\end{eqnarray}
So
$$ I(a)=\frac{a}{2b^2}-\frac{\pi\cot(\frac{b\pi}{a})}{2b}. $$