TITLE: How to evaluate $\int_0^A \frac{\tanh x}{x}dx$?
QUESTION [5 upvotes]: How to evaluate $$\int_0^A \frac{\tanh x}{x}dx$$
Where $A$ is a large positive number.
The answer is: $$\ln (4e^\gamma A/\pi)$$, where $\gamma$ is Euler constant.
I have no idea how to get this result. Here is a numerical result, blue is the original integral.

REPLY [12 votes]: That formula is indeed an asymptotic expansion. Indeed, integration by parts yields
$$ \int_{0}^{A} \frac{\tanh x}{x} \, dx = \tanh A \log A - \int_{0}^{A} \frac{\log x}{\cosh^2 x} \, dx $$
for $A > 0$, and we easily see
$$ \int_{0}^{A} \frac{\log x}{\cosh^2 x} \, dx = \int_{0}^{\infty} \frac{\log x}{\cosh^2 x} \, dx + \mathcal{O}(e^{-2A}\log A). $$
Finally, it is not impossible to compute the last integral, and the result is
$$ \int_{0}^{\infty} \frac{\log x}{\cosh^2 x} \, dx  = \log(\pi/4) - \gamma. \tag{*} $$
(I will skip this part, but if you want I will add a proof of this.) Putting altogether,
$$ \int_{0}^{A} \frac{\tanh x}{x} \, dx = \log A + \gamma - \log(\pi/4) + \mathcal{O}(e^{-2A}\log A). $$

Addendum. (Proof of $\text{(*)}$) Notice that
$$ I(s) := \int_{0}^{\infty} \frac{x^{s-1}}{\cosh^2 x} \, dx $$
defines a holomorphic function for $\Re(s) > 0$ and that the integral in $\text{(*)}$ is $I'(1)$. Our goal is to identify $I(s)$. This can be done by the following standard technique:
\begin{align*}
I(s)
&= \int_{0}^{\infty} 4x^{s-1} \cdot \frac{e^{-2x}}{(1 + e^{-2x})^2} \, dx \\
&= \int_{0}^{\infty} 4x^{s-1} \sum_{k=1}^{\infty} (-1)^{k-1} k e^{-2kx} \, dx \\
&= 2^{2-s} \Gamma(s) \sum_{k=1}^{\infty} (-1)^{k-1} k^{1-s} \\
&= 2^{2-2s}(2^s - 4) \Gamma(s) \zeta(s-1).
\end{align*}
This calculation works only when $\Re(s) > 2$, but the result remains valid for all of $\Re(s) > 0$ by the principle of analytic continuation. Then logarithmic differentiation gives
$$ I'(1) = I(1)\left( -3\log 2 + \frac{\Gamma'(1)}{\Gamma(1)} + \frac{\zeta'(0)}{\zeta(0)} \right). $$
Now the conclusion follows from known facts
$$ \zeta(0) = -\frac{1}{2}, \quad \zeta'(0) = -\frac{1}{2}\log(2\pi), \quad \Gamma'(1) = -\gamma. $$