Compute this Indefinite Integral A friend of mine asked me to solve this integral
$$\int_0^{\infty}\frac{\tan^{-1}(ax)dx}{x(1+x^2)}, a>0 , a\neq1. $$
but has no idea what is the answer or whether it can be solved or not. I tried pretty much everything I know but I failed so I tried using Residue calculus but got stuck in choosing the particular contour . Since there are 3 singularity points at x = 0 ,$i$ ,$-i$ , I decided to break the denominator $\frac{1}{x(1+x^2)}$into partial fractions $\frac{1}{x}-\frac{x}{1+x^2}$. That way I only had to deal with a singularity at 0 and $i$ seperately but I find it quite hard to navigate my way forward.
Please help and also explain the importance of the condition $a>0$ .
 A: Hint: Use Feynman's integration method, and partial fraction decomposition, you would get:
$$\frac {df(a)}{da}=\frac {\pi}{2(a+1)}$$
Here $f(a)$ is your original required integral. After that the question is quite elementary.
PS: I see the same thing has been done in the comment section. What is the protocol now? Should I delete?
A: Too long for a comment.
Integral can be evaluated via contour integration.
Because $\arctan(ax)$ has branch points and requires cut to make the integrand single-valued, it would be more convenient to integrate by part first: $$J(a)=\int_0^\infty\arctan (ax) \frac{1}{2}d\Bigl(\log\frac{x^2}{1+x^2}\Bigr)=-\frac{a}{2}\int_0^\infty\frac{dx}{1+a^2x^2}\log\frac{x^2}{1+x^2}$$ $$=-\frac{1}{2}\int_0^\infty\frac{a\,dx}{1+a^2x^2}\log\frac{x^2}{1+x^2}=-\frac{1}{2}\int_0^\infty\frac{dt}{1+t^2}\log\frac{t^2}{a^2+t^2}$$
Integral $\int_0^\infty\frac{\log t}{1+t^2}=0$ (can be shown via the change $t=\frac{1}{x}$), so
$$J(a)=\frac{1}{2}\int_0^\infty\frac{\log (t^2+a^2)}{1+t^2}dt=\frac{1}{2}\Re \int_{-\infty}^\infty\frac{\log (t+ia)}{1+t^2}dt$$
$\log (t+ia)$ is a single-valued function in the upper half of the complex plane, so we can close the contour by adding a half-circle of radius $R$ in the upper half-plane. Integral along this half-circle $\to0$ as $R\to\infty$
$$J(a)=\Re\Bigl(2\pi i \frac{1}{2}Res_{t=i}\frac{\log (t+ia)}{(t+i)(t-i)}\Bigr)=\frac{\pi}{2}\Re\log(i+ia)=\frac{\pi}{2}\log(1+a)$$
