Integral $\int_0^\infty \log(1-e^{-a x})\cos (bx)\, dx=\frac{a}{2b^2}-\frac{\pi}{2b}\coth \frac{\pi b}{a}$ $$\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
 A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{{\cal J}\equiv\int_{0}^{\infty}\ln\pars{1 - \expo{-ax}}\cos\pars{bx}\,
     \dd x={a \over 2b^{2}} - {\pi \over 2b}\,\coth\pars{\pi b \over a}:\
     {\large ?}.\quad a > 0,\ b > 0}$.

\begin{align}
{\cal J}&\equiv
\Re\int_{0}^{\infty}\ln\pars{1 - \expo{-ax}}\expo{\ic bx}\,\dd x
=\Re\int_{0}^{\infty}\sum_{n = 1}^{\infty}\pars{-\,{\expo{-nax} \over n}}
\expo{\ic bx}\,\dd x
\\[3mm]&=-\,\Re\sum_{n = 1}^{\infty}{1 \over n}\int_{0}^{\infty}
\expo{-\pars{na - \ic b}x}\,\dd x
=-\,\Re\sum_{n = 1}^{\infty}{1 \over n}\,{1 \over na - \ic b}
\\[3mm]&=-\,{1 \over a}\Re\sum_{n = 0}^{\infty}
{1 \over \pars{n + 1}\pars{n + 1 - \ic b/a}}
=-\,{1 \over a}\,
\Re\bracks{\Psi\pars{1} - \Psi\pars{1 - \ic b/a} \over 1 - \pars{1 - \ic b/a}}
\end{align}
  where $\ds{\Psi\pars{z}}$ is the
  Digamma Function
  ${\bf\mbox{6.3.1}}$.

\begin{align}
{\cal J}&=-\,{1 \over b}\,\Im\bracks{\Psi\pars{1} - \Psi\pars{1 - {b \over a}\,\ic}}
={1 \over b}\,\Im\Psi\pars{1 - {b \over a}\,\ic}
\end{align}

With the identity
  ${\bf\mbox{6.3.13}}$:
  $$
{\cal J}={1 \over b}\braces{%
-\,{1 \over 2\pars{-b/a}} + \half\,\pi\coth\pars{\pi\bracks{-\,{b \over a}}}}
$$

$$\color{#00f}{\large%
{\cal J}\equiv\int_{0}^{\infty}\ln\pars{1 - \expo{-ax}}\cos\pars{bx}\,\dd x
={a \over 2b^{2}} - {\pi \over 2b}\,\coth\pars{\pi b \over a}}
$$
A: 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}. $$
A: Consider the integral
\begin{align}
I = \int_{0}^{\infty} \ln(1-e^{-ax}) \ \cos(bx) \ dx.
\end{align}
Expand the logarithm to obtain
\begin{align}
I &= - \sum_{n=1}^{\infty} \frac{1}{n} \ \int_{0}^{\infty} e^{-a n x} \ \cos(bx) \ dx \\
&= - \sum_{n=1}^{\infty} \frac{1}{n} \ \frac{an}{ a^{2} n^{2} + b^{2} } \\
&= - \frac{1}{a} \ \sum_{n=1}^{\infty} \frac{1}{n^{2} + (b/a)^{2}}.
\end{align}
Using the expansion
\begin{align}
\coth(\pi x) = \frac{1}{\pi x} + \frac{2 x}{\pi} \sum_{n=1}^{\infty} \frac{1}{n^{2} + x^{2}}
\end{align}
then the value of the integral becomes
\begin{align}
\int_{0}^{\infty} \ln(1-e^{-ax}) \ \cos(bx) \ dx = \frac{a}{2 b^{2}} - \frac{\pi}{2 b} \ \coth\left(\frac{b \pi}{a}\right).
\end{align}
A: This may not be the easiest method, but you appear to be interested in a contour way of going about it. 
starting from your $$-a/b\int_{0}^{\infty}\frac{\sin(bx)}{e^{ax}-1}dx$$
Consider the function$$f(z)=\frac{e^{ibz}}{e^{az}-1}$$
Use a rectangle in the first quadrant with height $\displaystyle 2\pi i/a$ with quarter circle indents around $2\pi i/a$ and $0$.
There will be 6 portions to put together:
$$I_{1}+I_{2}+I_{3}+I_{4}+I_{5}+I_{6}=0........(1)$$
The integral can be set to 0 because there are no poles inside the contour. 
Along bottom horizontal on x axis:  $$I_{1}=\int_{\epsilon}^{R}\frac{e^{ibx}}{e^{ax}-1}dx$$
up right vertical side:  
$$\left|\frac{e^{ibR}}{e^{aR}-1}\right|\to 0, \;\ as \;\ R\to \infty$$
$$I_{2}=0$$
along top horizontal:  $$I_{3}=-\int_{\epsilon}^{R}\frac{e^{ib(x+2\pi i/a)}}{e^{a(x+2\pi i/a)}-1}dx=-e^{-2\pi b/a}\int_{\epsilon}^{r}\frac{e^{ibx}}{e^{ax}-1}dx$$
top quarter circle around indent at $2\pi i/a$,  
where x varies from 
$(\epsilon, \epsilon+\frac{2\pi i}{a})$ to $(0,\frac{2\pi i}{a}-\frac{2\pi i}{a}\epsilon)$
$$I_{4}=\frac{-\pi i}{2}Res\left(f(z), \frac{2\pi a}{b}\right)=\frac{-\pi i}{2}\cdot \frac{e^{ib(2\pi i/a)}}{ae^{a(2\pi i/a)}}=\frac{-\pi i}{2a}e^{-2\pi b/a}$$
Down left vertical side. parameterize with $\displaystyle z=iy, \;\ dz=idy$
$$I_{5}=-i\int_{\epsilon}^{2\pi/a}\frac{e^{-by}}{e^{ayi}-1}dy$$
Quarter circle indent around the origin with x varying from $\displaystyle (0,i\epsilon)$ to $\displaystyle (\epsilon, 0)$.
$$I_{6}=\frac{-\pi i}{2}Res(f,0)=\frac{-\pi i}{2}\cdot \frac{e^{ib(0)}}{ae^{a(0)}}=\frac{-\pi i}{2a}$$
Now, assemble all the portions by plugging them all into (1):, and let $\displaystyle \epsilon\to 0, \;\ R\to \infty$
$$\int_{C}\frac{e^{ibz}}{e^{az}-1}dz=\int_{0}^{\infty}\frac{e^{ibx}}{e^{ax}-1}dx+I_{2}-e^{-2\pi b/a}\int_{0}^{\infty}\frac{e^{ibx}}{e^{ax}-1}dx$$
$$-\frac{\pi i}{2a}e^{-2\pi b/a}-\frac{\pi i}{2a}-i\int_{0}^{2\pi /a}\frac{e^{-by}}{e^{ayi}-1}dy=0$$
$$\rightarrow (1-e^{-2\pi b/a})\int_{0}^{\infty}\frac{\sin(bx)}{e^{ax}-1}dx+\int_{0}^{2\pi/a}\frac{(-i)e^{-by}}{e^{ayi}-1}dy=\frac{\pi i}{2a}(1+e^{-2\pi b/a})$$
By taking imaginary parts, the last integral(the one going down the left vertical side) can be shown to be equal to
$$\int_{0}^{2\pi/a}\frac{e^{-by}}{2}dy=\frac{1-e^{-2\pi b/a}}{2b}$$
solving for the integral in question, we finally have:
$$\int_{0}^{\infty}\frac{\sin(bx)}{e^{ax}-1}dx=\frac{\frac{\pi}{2a}(1+e^{-2\pi b/a})-\frac{1-e^{-2\pi b/a}}{2b}}{1-e^{-2\pi b/a}}$$
$$=\frac{\pi}{2a}\coth(\frac{\pi b}{a})-\frac{1}{2b}$$
multiplying this by the $-a/b$ from the beginning reduces it to a form that can be written in terms of hyperbolic trig functions as the solution suggests.
and, we ultimately get:
$$\frac{a}{2b^{2}}-\frac{\pi}{2b}\coth(\frac{\pi b}{a})$$
