An integral Lobachevsky calculated incorrectly $\int_{0}^{\infty}\frac{(e^x-e^{-x})x}{e^{2x}+e^{-2x}+2\cos(2a)}dx$ In a recent lecture a professor told a story about the integral below.  Lobachevsky calculated this integral at first time incorrectly. Following the publication of the integral,  Ostrogradsky sent a letter with correct answer to Lobachevsky.
What is the right answer?
$$I(a)=\int_{0}^{\infty}\frac{(e^x-e^{-x})x}{e^{2x}+e^{-2x}+2\cos(2a)}dx$$
withe $0\leq a \leq \pi$.
 A: We can restrict the values of $a$ to be between $0$ and $\pi/2$ as $\cos(2a)= \cos[2(\pi-a)]$. With this $$I(a) = \frac{\pi a}{4 \sin(a)} \qquad 0\leq a \leq \frac{\pi}{2}.$$
The calculation can be done along the following line:


*

*As the integrand is symmetric the integration region can be extended to the full real line
$$I(a) = \frac{1}{2} \int_{-\infty}^{\infty}dx\, \frac{(e^x-e^{-x})x}{e^{2x}+e^{-2x}+2\cos(2a)}.$$

*The substitution $z= e^{x}$ brings the integral onto the form
$$I(a) = \frac{1}{2} \int_0^\infty dz\,\frac{(z^2-1) \log z}{z^4 + 2 z^2 \cos(2a) + 1}.$$

*A standard trick can be employed to bring it on the form
$$I(a) = \frac{1}{4} \sum_{z_n} \,\text{Res}_{z=z_n} \frac{(z^2-1) \log^2 z}{z^4 + 2 z^2 \cos(2a) + 1}$$ where $z_n$ are the zeros of $z^4 + 2 z^2 \cos(2a) + 1$ and the branch cut of $\log$ is along the negative real line.

*The 4 zeros of $z^4 + 2 z^2 \cos(2a) + 1$ are given by $\bar z=\pm i e^{\pm i a}$. The residues assume the form $$\text{Res}_{z=\bar z} \frac{(z^2-1) \log^2 z}{z^4 + 2 z^2 \cos(2a) + 1} = \frac{(\bar z^2 - 1)\log^2 \bar z}{4 \bar z^3 +4 \bar z \cos 2a}.$$

*Putting everything together, we obtain
the result quoted above (after some tedious but straightforward calculation).
A: \begin{align}
I(a)=&\int_{0}^{\infty}\frac{(e^x-e^{-x})x}{e^{2x}+e^{-2x}+2\cos2a}\overset{ y=e^{-x}}{ dx }\\
=&\int_0^1 \frac{(y^2-1)\ln y}{y^4+2y^2 \cos 2a+1}dy
= -\int_0^1 \frac{\ln y }{2\sin a}\ 
d\left(\tanh^{-1}\frac{2y\sin a}{1+y^2}\right)\\
\overset{ibp}=& \ \frac1{2\sin a}\int_0^1\frac1y \ \tanh^{-1}\frac{2y\sin a}{1+y^2}\ dy= \frac1{2\sin a}K(a)
\end{align}
With
$K’(a)= \int_0^1 \frac{2(1+y^2)\cos a}{y^4+2y^2\cos 2a+1}dx=\tan^{-1}\left(\frac{2y\cos a}{1-y^2} 
\right)_0^1=\frac\pi2
$
$$I(a)= \frac1{2\sin a}\int_0^a K’(s)ds=\frac{\pi a}{4\sin a}
$$
A: For $0\leq a\leq \dfrac{\pi}{2}$
\begin{align}J(a)&=\int_{0}^{\infty}\frac{(e^x-e^{-x})x}{e^{2x}+e^{-2x}+2\cos(2a)}dx=\int_{0}^{\infty}\frac{x\sinh(x)}{\cosh(2x)+\cos(2a)}dx\\
&\overset{\text{IBP}}=-\frac{1}{2\sin a}\left[x\text{ arctanh}\left(\frac{\sin a}{\cosh x}\right)\right]_0^\infty+\frac{1}{2\sin a}\int_0^\infty \text{ arctanh}\left(\frac{\sin a}{\cosh x}\right)dx\\
&=\frac{1}{2\sin a}\int_0^\infty \text{ arctanh}\left(\frac{\sin a}{\cosh x}\right)dx\\
\end{align}
Define for $0\leq a\leq \dfrac{\pi}{2}$,
\begin{align}F(a)&=\int_0^\infty \text{ arctanh}\left(\frac{\sin a}{\cosh x}\right)dx,F(0)=0\\
F^\prime(a)&=2\cos a\int_0^\infty \frac{\cosh(x)}{\cosh(2x)+\cos(2a)}dx\\
&=\left[\arctan\left(\frac{\sinh(x)}{\cos a}\right)\right]_0^\infty=\frac{\pi}{2}\\
F(a)&=F(a)-F(0)=\int_0^a F^\prime(t)dt=\frac{\pi}{2}\int_0^a 1 dt=\frac{a\pi}{2}
\end{align}
Therefore,
\begin{align}\boxed{J(a)=\frac{a\pi}{4\sin a}}\end{align}
A: Integrate the function $$f(z) =\frac{z(e^{z}-e^{-z})}{e^{2z}+e^{-2z}+2\cos(2a)} = \frac{z\sinh(z)}{\cosh(2z)+ \cos (2a)}, \quad 0 < a < \frac{\pi}{2},$$ counterclockwise around a rectangular contour with vertices at $z= \pm R, \pm R + i \pi$.
As $R \to \infty$, the integral vanishes on the left and right sides of the contour because the magnitude of $f(z)$ decays exponentially to zero as $\Re(z) \to \pm \infty$.
Therefore, we have
$$ \begin{align}  &\int_{-\infty}^{\infty} \frac{x \sinh(x)}{\cosh(2x)+\cos(2a)} \, \mathrm dx + \int_{\infty}^{-\infty}\frac{(x + i \pi) \left(-\sinh (x)\right) }{\cosh(2x) + \cos(2a)} \, \mathrm d x  \\ &= 2 \pi i \left( \operatorname{Res} \left[f(z) , i \left(a + \frac{\pi}{2} \right) \right] + \operatorname{Res} \left[f(z) , i \left(\frac{\pi}{2} -a \right) \right] \right) \\ &= 2 \pi i \left( \lim_{z \to i \left(a+ \frac{\pi}{2} \right)} \frac{z \sinh(z)}{2 \sinh(2z)} + \lim_{z \to i \left(\frac{\pi}{2}-a \right)} \frac{z \sinh(z)}{2 \sinh(2z)}\right) \\ &= 2 \pi i \left(\lim_{z \to i \left(a+ \frac{\pi}{2} \right)} \frac{z}{4 \cosh(z)}+ \lim_{z \to i \left(\frac{\pi}{2}-a \right)} \frac{z}{4 \cosh (z)} \right) \\ &= 2 \pi i \left(  \frac{i \left(a+ \frac{\pi}{2} \right)}{-4\sin(a)} + \frac{i \left(\frac{\pi}{2}-a \right)}{4 \sin(a)}\right) \\ &= \frac{\pi a}{\sin(a)}. \end{align}$$
Equating the real parts on both sides of the equation, we get $$2 \int_{-\infty}^{\infty} \frac{x \sinh(x)}{\cosh(2x)+\cos(2a)} \, \mathrm dx = 4 \int_{0}^{\infty} \frac{x \sinh(x)}{\cosh(2x)+\cos(2a)} \, \mathrm dx = \frac{\pi a}{ \sin (a)}. $$
A: Let $k=e^{ai}$. Then, by partial fractions,
$$I(a)=\int_0^\infty(\frac{k^2}{k^2-1}\frac{xe^x}{e^{2x}+k^2}-\frac{1}{k^2-1}\frac{xe^x}{e^{2x}+k^{-2}})dx.$$
By using $\int_{-\infty}^{\infty}\frac{xe^x}{e^{2x}+c^2}dx=\frac{\pi\ln(c)}{2c}$ (... variant of Problem 732, Problems in the Theory of Functions of a Complex Variable, L. Volkovsky, G. Lunts, I. Aramanovich, Translated from Russian by Victor Shiffer, Mir Publishers, Moscow),
$$I(a)=\frac{k^2}{k^2-1}\frac{\pi\ln(k)}{2k}=\frac{k\pi\ln k}{2(k^2-1)}=\frac{ai\pi e^{ai}}{2(e^{2ai}-1)}=\frac{\pi a}{4\sin a}.$$
