Evaluate $\int_0^\infty \frac{\arctan(3x) - \arctan(9x)}{x} {dx}$

An easy way to evaluate the integral is using Frullani's theorem $$\int_0^\infty \frac{f(ax)-f(bx)}{x}\,dx=\bigg[f(0)-f(\infty)\bigg]\ln\left(\frac{b}{a}\right)$$ Taking $f(x)=\arctan(x)$ then the integral is simply evaluated to $$-\frac{\pi}{2}\ln3$$


Method 1 A difference of arctangents is exactly the kind of quantity produced when computing the definite integral of the familiar integrand $\frac{1}{1 + y^2}$, which suggests we rewrite the integral (replacing the numerical constants with general constants $a, b > 0$) as a double integral: $$\int_0^{\infty} \int_{ax}^{bx} \frac{1}{x(1 + y^2)} dy \,dx.$$ Reversing the order of integration (which requires some justification that is often suppressed when learning multiple integration) gives $$\int_0^{\infty} \int_{y/b}^{y/a} \frac{1}{x(1 + y^2)} dx \,dy.$$

Now, integrating the inner integral and then the outer one is straightforward; the result should be $$\frac{\pi}{2} \log \frac{b}{a},$$ which in your case is $$-\frac{\pi}{2}\log 3.$$

Method 2 By request, here's an alternate solution that uses the (perhaps undertaught) method of differentiating under the integral:

Regard the integral $$\int_0^{\infty} \frac{\arctan bx - \arctan ax}{x} \,dx$$ as a function $I(b)$ of $b$. Then, one can justify that when computing the derivative $I'(b)$ we can differentiate under the integral sign: \begin{align} I'(b) &= \frac{d}{db} \int_0^{\infty} \frac{\arctan bx - \arctan ax}{x} \,dx \\ &= \int_0^{\infty} \frac{d}{db}\left(\frac{\arctan bx - \arctan ax}{x}\right) \,dx \\ &= \int_0^{\infty} \frac{dx}{1 + (bx)^2} \\ &= \left.\frac{1}{b} \arctan bx \,\right\vert_0^{\infty} \\ &= \frac{\pi}{2b} \textrm{.} \end{align} Integrating gives that $$I(b) = \frac{\pi}{2} \log b + I_0$$ for some constant $I_0$. On the one hand, $I(a) = \frac{\pi}{2} \log a + I_0$, and on the other, $$I(a) = \int_0^{\infty} \frac{\arctan ax - \arctan ax}{x} \,dx = 0,$$ so $I_0 = -\frac{\pi}{2} \log a$, and thus the original integral is $$\int_0^{\infty} \frac{\arctan bx - \arctan ax}{x} \,dx = I(b) = \frac{\pi}{2} \log b - \frac{\pi}{2} \log a = \frac{\pi}{2} \log \frac{b}{a},$$ which agrees with the solution from the first method.