Prove this $ \int_0^\infty\frac{\coth^2x-1}{(\coth x-x)^2+\frac{\pi^2}{4}}dx=\frac45 $ I have trouble with this seemingly simple problem
$$
K=\int_0^\infty\frac{\coth^2x-1}{(\coth x-x)^2+\frac{\pi^2}{4}}dx=\frac45.\tag{A}
$$
Here is the Wolfram Alpha computation Proof.
I tried to find residue at the pole $x=\frac{\pi i}{2}$ and get $\frac{9}{5\pi i}$ (link to WA). Therefore residue theorem tell me that $K=\frac{18}{5}\neq\frac45$. I'm stuck. How to prove (A)?
 A: To answer your question, it is not correct because, while you have calculated the residue of the integrand correctly, you are assuming that the contour of integration is a semicircle.  This semicircle encompasses other poles in the complex plane, which explains why your result is not right.
Evaluating a real integral via the Residue Theorem can be a tricky business.  Here's a start: what contour?  The semicircle seem horrible, because how do we get the other poles?  Better is a closed contour that contains only the pole at $z=i \pi/2$. 
Now we need to determine the form of the integrand we need in the contour integral.  Remember, somehow we should get the original integral back using a direct parameterization of the contour.  So, without further ado...
Consider the contour integral
$$\oint_C dz \, \tanh{\left [z-\operatorname{arctanh}{\left (z-i \frac{\pi}{2} \right )} \right ]} $$
which is equal to
$$\oint_C dz \, \frac{\displaystyle 1-z \coth{z} + i \frac{\pi}{2} \coth{z}}{\displaystyle \coth{z}-z+i \frac{\pi}{2}} $$
where $C$ is the rectangle with vertices $\pm R$ and $\pm R+i \pi$.  
The contour integral is then equal to
$$\int_{-R}^R dx \frac{\displaystyle 1-x \coth{x} + i \frac{\pi}{2} \coth{x}}{\displaystyle \coth{x}-x+i \frac{\pi}{2}} + i \int_0^{\pi} dy \, \frac{\displaystyle 1-(R+i y)\coth{(R+i y)} + i \frac{\pi}{2} \coth{(R+i y)}}{\displaystyle \coth{(R+i y)} - (R+i y) +  i \frac{\pi}{2}} \\ + \int_{R}^{-R} dx \frac{\displaystyle 1-x \coth{x} - i \frac{\pi}{2} \coth{x}}{\displaystyle \coth{x}-x-i \frac{\pi}{2}}\\ + i \int_{\pi}^0 dy \, \frac{\displaystyle 1-(-R+i y)\coth{(-R+i y)} + i \frac{\pi}{2} \coth{(-R+i y)}}{\displaystyle \coth{(-R+i y)} - (-R+i y) +  i \frac{\pi}{2}}$$
Now consider the second and fourth integrals, i.e., those over the vertical edges of the rectangle.  We consider the limit as $R \to \infty$.  Note that the integrand of the second integral approaches $1$ in this limit, while the integrand of the fourth integral approaches $-1$.  (Exercise for the reader.)  Thus, the sum of these two integrals is $i 2 \pi$.
We can also combine the integrand of the first and third integrals to get the integrand of the integral we seek, times $i \pi$.  Thus, the contour integral is equal to (after exploiting the evenness of that integrand)
$$i 2 \pi \int_0^{\infty} dx \, \frac{\coth^2{x}-1}{\displaystyle (\coth{x}-x)^2+\frac{\pi^2}{4}} + i 2 \pi$$
By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the residue at the pole $z=i \pi/2$.  Interestingly enough, this pole is not simple, but is instead a third-order pole.  Given the integrand, I find it easier to compute the Laurent series directly and use that to find the residue.  However, I will simply state the result as follows:
$$\operatorname*{Res}_{z=i \pi/2} \frac{\displaystyle 1-z \coth{z} + i \frac{\pi}{2} \coth{z}}{\displaystyle \coth{z}-z+i \frac{\pi}{2}} = \frac{9}{5} $$
so that
$$i 2 \pi \int_0^{\infty} dx \, \frac{\coth^2{x}-1}{\displaystyle (\coth{x}-x)^2+\frac{\pi^2}{4}} + i 2 \pi = i 2 \pi \frac{9}{5} $$
or

$$  \int_0^{\infty} dx \, \frac{\coth^2{x}-1}{\displaystyle (\coth{x}-x)^2+\frac{\pi^2}{4}} = \frac{4}{5} $$

ADDENDUM
Let's take a look at that residue calculation. For this, it helps to know that
$$\coth{\left ( z + i \frac{\pi}{2} \right )} = \tanh{z}$$
and
$$\tanh{z} = z - \frac13 z^3 + \frac{2}{15} z^5 + O \left ( z^7 \right )$$
so that the integrand looks like, in the neighborhood of $z=i \pi/2$,
$$ \frac{1-z \tanh{z}}{\tanh{z}-z} $$
Now we can find the Laurent expansion of this function about $z=0$, which looks like
$$-\frac{3}{z^3} \frac{\displaystyle 1-z^2 +O \left ( z^4 \right )}{\displaystyle 1-\frac{2}{5} z^2+O \left ( z^4 \right )} = -\frac{3}{z^3} \left [1-z^2 +O \left ( z^4 \right ) \right ] \left [1+\frac{2}{5} z^2+O \left ( z^4 \right ) \right ]$$
The residue is the coefficient of $z^2$ in the numerator, which may simply be read off as $9/5$ as stated above.  
ADDENDUM II
How do we show that $z=i \pi/2$ is the only pole inside the rectangle?  We can use Rouche's theorem.  For example, we would just need to show that, on the rectangle,
$$\left | \coth{z}-z \pm i \frac{\pi}{2} \right | \gt |\coth{z} | $$
On the horizontal sides of the rectangle, we see that
$$\left | \coth{x}-x \pm i \frac{\pi}{2} \right |^2 - |\coth{x} |^2 = \frac{\pi^2}{4} - \left (2 x \coth{x}-x^2 \right ) $$
which is indeed $\gt 0$ for all $x \in \mathbb{R} $. 
On the vertical sides of the rectangle, the inequality is obviously satisfied because $|\coth{(R + i y)}|$ approaches $1$ as $R \to \pm \infty$.
Therefore, by Rouche's theorem, the denominator of the integrand has the same number of zeroes inside the rectangle as $\coth{z}$, which is just the one at $z=i \pi/2$ and no others.  Thus, the only pole inside the rectangle is at $z=i \pi/2$.
