show that $\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx=\frac{\pi^2}{4} \operatorname{sech}^2 \left(\frac{a\pi}{2}\right) $ 
Show that $$\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx=\frac{\pi^2}{4} \operatorname{sech}^2\left(\frac{a\pi}{2}\right) $$

I think we can solve it by contour integration, but how? and it would be better if there were two ways, the first with real analysis and the second with complex analysis.
 A: Here's another complex analytic approach.
Since 
$$\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx
\quad\textrm{and}\quad
\int_{0}^{\infty}\frac{\sin ax}{\sinh x}dx$$ 
are uniformly convergent, differentiation and integration commute.
Also, the integrals are even. 
We find 
$$\begin{eqnarray*}
\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx
&=& \frac{\partial}{\partial a} \int_{0}^{\infty}\frac{\sin ax}{\sinh x}dx \\
&=& \frac{1}{2} \frac{\partial}{\partial a} \int_{-\infty}^{\infty}
    \frac{\sin ax}{\sinh x}dx \\
&=& \frac{1}{2}\frac{\partial}{\partial a} \mathrm{Im}
    \int_{-\infty}^{\infty}\frac{e^{iax}}{\sinh x}dx.
\end{eqnarray*}$$
We close the contour for the last integral along a semicircular contour in the upper half plane. Here we assume, with little loss of generality, that $\mathrm{Re}(a)>0$.
(Due to the good behavior of $e^{iax}$, the integral along this contour is zero.)
We pick up the residues in the upper half plane occurring at $x=in\pi$, where $n=1,2,\ldots$. 
Thus, 
$$\begin{eqnarray*}
\int_{0}^{\infty}\frac{x\cos ax}{\sinh x}dx
&=&  \frac{1}{2}\frac{\partial}{\partial a} \mathrm{Im} \,2\pi i
    \sum_{n=1}^\infty \mathrm{Res}_{x_n=i n\pi}
    \frac{e^{iax_n}}{\sinh x_n} \\
&=&  \frac{1}{2}\frac{\partial}{\partial a} \mathrm{Im} \,2\pi i
    \sum_{n=1}^\infty
    \frac{e^{-n\pi a}}{\cosh i n\pi} \\
&=&  \pi \frac{\partial}{\partial a}
    \sum_{n=1}^\infty (-1)^n e^{-n\pi a} \\
&=& -\pi \frac{\partial}{\partial a} \frac{1}{1+e^{a\pi}} \\
&=& \frac{\pi^2 e^{a\pi}}{(1+e^{a\pi})^2} \\
&=& \frac{\pi^2}{4}\mathrm{sech}^2\frac{a\pi}{2}.
\end{eqnarray*}$$
A: We of course assume that $a$ is real here.  For a complex analysis, consider the integral
$$\oint_C dz \frac{\sin{a z}}{\sinh{z}}$$
where $C$ is the following contour:

Because there are no poles in the interior of the contour, this integral is zero by Cauchy's theorem.  On the other hand, the contour integral is equal to
$$\int_{\epsilon}^R dx \frac{\sin{a x}}{\sinh{x}} + i \int_0^{\pi} dy \frac{\sin{a(R+i y)}}{\sinh{(R+i y)}} + \\ \int_R^{\epsilon} dx \frac{\sin{a(x+i \pi)}}{\sinh{(x+i \pi)}} + i \epsilon \int_0^{-\pi/2} d\phi \, e^{i \phi} \frac{\sin{a(i \pi + \epsilon e^{i \phi})}}{\sinh{(i \pi + \epsilon e^{i \phi})}} + \\i \int_{\pi-\epsilon}^{\epsilon} dy \frac{\sin{i a y}}{\sinh{i y}} + i \epsilon \int_{\pi/2}^0 d\phi \, e^{i \phi} \frac{\sin{a \epsilon e^{i \phi}}}{\sinh{\epsilon e^{i \phi}}} $$
We take the limits as $R \to \infty$ and $\epsilon \to 0$; in these limits, the second and sixth integrals vanish.  We also need only consider the real part of the above expression, as the integral of interest is real; this then eliminates the fifth integral from consideration altogether, and we need only examine the real part of the third.  By expanding the trig functions using, e.g., addition theorems, we get the following relation:
$$\left (1+\cosh{\pi a}\right) \int_0^{\infty} dx \frac{\sin{a x}}{\sinh{x}} - \frac{\pi}{2} \sinh{\pi a} = 0$$
or
$$\int_0^{\infty} dx \frac{\sin{a x}}{\sinh{x}} = \frac{\pi}{2} \tanh{\frac{\pi a}{2}}$$
Of course, this is not the integral desired.  Nevertheless, assuming everything is absolutely convergent (which it is here), we may differentiate both sides with respect to $a$ and reverse order of derivative and integral to get
$$\int_0^{\infty} dx \frac{x \cos{a x}}{\sinh{x}} = \frac{\pi^2}{4} \text{sech}^2{\frac{\pi a}{2}}$$
as was to be shown.
A: I'm going to use the approach of Ron Gordon  and try to find the integral $\int_0^{\infty}\dfrac{\sin ax}{\sinh x}  dx$, but with real methods. First of all, we have that,
$$\dfrac 1{\sinh x}=2\sum_{k=2n+1,n\in\mathbb{N}}exp(-kx)$$
So,
$$\int_0^{\infty}\dfrac{\sin ax}{\sinh x}  dx=2\int_0^{\infty}\sin ax \sum_{k=0}^\infty \exp(-(2k+1)x)dx$$$$=2a\sum\dfrac{1}{a^2+(2k+1)^2}=\pi \coth \pi a-\frac\pi2 \coth\frac{\pi a}{2}$$
Differentiating with respect to a we get the answer.(The sum is obtained by taking the infinite product for $\sinh x$, taking logs and differentiating.)
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
$\ds{\bbox[5px,#ffd]{\int_{0}^{\infty}{x\cos\pars{ax}
\over \sinh\pars{x}}\,\dd x =
{\pi^{2} \over 4}\on{sech}^{2}\pars{\pi a \over 2}}:\
{\Large ?}.}$

\begin{align}
&\bbox[5px,#ffd]{\int_{0}^{\infty}{x\cos\pars{ax}
\over \sinh\pars{x}}\,\dd x} =
\totald{}{a}\int_{0}^{\infty}{\sin\pars{ax}
\over \sinh\pars{x}}\,\dd x
\\[5mm] = &\
2\,\totald{}{a}\Im\int_{0}^{\infty}
{\expo{\ic ax} - 1 \over \expo{x} - \expo{-x}}\,\dd x
\\[5mm] = &\
2\,\totald{}{a}\Im\int_{0}^{\infty}
{\expo{-\pars{1 - \ic a}x} - \expo{-x} \over 1 - \expo{-2x}}
\,\dd x
\\[5mm] \stackrel{2x\ \mapsto\ x}{=}\,\,\,&
\totald{}{a}\Im\int_{0}^{\infty}
{\expo{-\pars{1/2 - \ic a/2}x}\,\,\, - \expo{-x/2} \over 1 - \expo{-x}}\,\dd x
\\[5mm] = &\
\totald{}{a}\Im\left[\int_{0}^{\infty}
{\expo{-x} - \expo{-x/2} \over 1 - \expo{-x}}\,\dd x
\right.
\\[2mm] &\
\phantom{\totald{}{a}\Im\left[\right.}
\left.-\int_{0}^{\infty}
{\expo{-x} \expo{-\pars{1/2 - \ic a/2}x} \over 1 - \expo{-x}}
\,\dd x\right]
\\[5mm] = &\
\totald{}{a}\Im\bracks{\Psi\pars{1 \over 2} -
\Psi\pars{{1 \over 2} - {a \over 2}\,\ic}}
\\[5mm] = &\
\totald{}{a}\bracks{-\Psi\pars{1/2 - a\ic/2} +
\Psi\pars{1/2 + a\ic/2} \over 2\ic}
\\[5mm] = &\
-\,{\ic \over 2}
\totald{}{a}\bracks{\pi\cot\pars{\pi\bracks{{1 \over 2} - {a \over 2}\,\ic}}}
\\[5mm] = &\
-\,{\pi\,\ic \over 2}
\totald{}{a}\bracks{\tan\pars{{\pi a \over 2}\,\ic}}
=
{\pi \over 2}
\totald{}{a}\bracks{\tanh\pars{\pi a \over 2}}
\\[5mm] = &\
\bbx{{\pi^{2} \over 4}\on{sech}^{2}\pars{\pi a \over 2}} \\ &
\end{align}
