About asymptotic behaviour of a divergent integral. I have the function $f(x) = x \tanh(\pi x) \log (x^2 +a^2)$ where $a$ is some positive real number. For the logarithm I am assuming a branch-cut along the positive imaginary axis starting at $x = ia$. So the branching effect on the "log" is that its imaginary part is $\pi$ on the right and above the point $ai$ on the positive imaginary axis and $-\pi$ on the left and above. 
I wanted to understand how the value of the integral of this function behaves when $x$ is integrated from $0$ to $A >0$. Using the parity symmetry of the function I extended it on a semi-circle in the upper half plane of radius $A$ about the origin. 
Then I did a large $A$ expansion ("Series" about $A=\infty$ on Mathematica) and found that $xf(x)$ (that would practically be the integrand when converted into a $\phi$ integral with $x = Ae^{i\phi}$), this function asymptotes as, $e^{2i\phi} \log(e^{2i\phi})A^2 + 2A^2 \log(A) + a^2$ (+ terms which go to zero as $A$ goes to infinity). Now on this asymptotic form the $\phi$ is integrable from $0$ to $\pi$ giving a finite answer.


*

*So relying on this Mathematica result can I say that this integral therefore diverges in the large $A$ limit as $ \text{(number)} A^2 + \text{(number)} A^2 \log(A)$ ? 

*Further I chose $a=2$ and it seems to me that on using "NIntegrate" Mathematica says that the integral of this function on a circle centered at $2i$ goes to zero as the radius goes to 0. 
Is this correct? 
Thinking analytically this seems to be right - if one does a small radius expansion of integrand about the branch point $2i$ then the integrand smoothly goes to $0$ in the small radius limit. One might fear that the small radius limit does not commute with the integral - to check that I also plotted the value of the numerical integration of the function around this circle as a function of the radius - and the graph does seem to go to zero smoothly in the zero radius limit. 
In doing the above Mathematica based checking I am trusting that Mathematica knows how to contour integrate a function around its branch-cut. Though thinking analytically I get that while going around the point $2i$ the function needs to be modified as follows (to fit with the branching convention stated earlier at the top) - that for $0 < \phi = arg(z - 2i = \epsilon e^{i \phi}) < \frac{\pi}{2}$ one adds a $-\frac{i3\pi}{2}$ to the $log (z^2 + 4)$ and add a $\frac{i\pi}{2}$ for $\frac{\pi}{2} \leq \phi  \leq 2\pi$. 
 A: You're interested in the asymptotic behavior of
$$
\begin{align}
I_a(A) &= \int_0^A x \tanh(\pi x) \log(x^2+a^2)\,dx \\
&= \int_1^A x \tanh(\pi x) \log(x^2+a^2)\,dx + \int_0^1 x \tanh(\pi x) \log(x^2+a^2)\,dx \tag{1}
\end{align}
$$
as $A \to \infty$.  Let's rewrite the integrand as
$$
\begin{align}
&x \tanh(\pi x) \log(x^2+a^2) \\
&\qquad = x \log(x^2+a^2) + x \log(x^2+a^2) \Bigl(\tanh(\pi x) - 1\Bigr) \\
&\qquad = x\log(x^2) + x\log(1+a^2/x^2) + x \log(x^2+a^2) \Bigl(\tanh(\pi x) - 1\Bigr). \tag{2}
\end{align}
$$
Now
$$
|\tanh(\pi x) - 1| = \frac{2}{1+e^{2\pi x}} \leq 2e^{-2\pi x} = O(e^{-2\pi x}) \qquad \text{as } x \to \infty, \tag{3}
$$
$$
\log(x^2 + a^2) = O(x) \qquad \text{as } x \to \infty, \tag{4}
$$
and
$$
\log(1+a^2/x^2) = \frac{a^2}{x^2} + O(x^{-4}) \qquad \text{as } x \to \infty, \tag{5}
$$
so using $(3)$, $(4)$, and $(5)$ in $(2)$ we have
$$
\begin{align}
x \tanh(\pi x) \log(x^2+a^2) &= x\log(x^2) + \frac{a^2}{x} + O(x^{-3}) + O(x^2 e^{-2\pi x}) \\
&= 2x\log x + \frac{a^2}{x} + O(x^{-3})
\end{align}
$$
as $x \to \infty$.  Therefore, if we write
$$
\begin{align}
&\int_1^A x \tanh(\pi x) \log(x^2+a^2)\,dx \\
&\qquad = \int_1^A \left(2x\log x + \frac{a^2}{x}\right)\,dx + \int_1^A \left(x\tanh(\pi x)\log(x^2+a^2) - 2x\log x - \frac{a^2}{x}\right)\,dx,
\end{align}
$$
$$
\tag{6}
$$
then the last integral converges as $A \to \infty$, and the second to last integral is
$$
\int_1^A \left(2x\log x + \frac{a^2}{x}\right)\,dx = A^2 \log A - \frac{1}{2}A^2 + a^2 \log A + \frac{1}{2}. \tag{7}
$$
Thus, defining
$$
\begin{align}
C(a) = &\frac{1}{2} + \int_1^\infty \left(x\tanh(\pi x)\log(x^2+a^2) - 2x\log x - \frac{a^2}{x}\right)\,dx \\&\qquad + \int_0^1 x \tanh(\pi x) \log(x^2+a^2)\,dx
\end{align}
$$
and combining $(1)$, $(6)$, and $(7)$ we get

$$
I_a(A) = A^2 \log A - \frac{1}{2}A^2 + a^2 \log A + C(a) + \epsilon_a(A),
$$
  where $\epsilon_a(A) \to 0$ as $A \to \infty$ for fixed $a \in \mathbb R$.

