Indefinite integration of $\ln(1+x^2)\arctan x$ We need to evaluate $$\int \ln(1+x^2)\arctan x \, \mathrm{d}x$$
My thoughts were to set $u = \arctan x \implies x = \tan u$ so that our integral is transformed to $$\int 2u \sec^2 u \ln \sec u \, \mathrm{d}u$$
Am I on the right path? How do I continue from here? Are there alternative ways of doing this? 
 A: We integrate by parts. First we find $\int \arctan x\, dx$.
$$\int \arctan x\, dx = (\arctan x)(x)-\int \frac{x}{x^2+1}\, dx$$
$$=(\arctan x)(x)-\frac{1}{2}\int \frac{d\left(x^2+1\right)}{x^2+1}=(\arctan x)(x)-\frac{1}{2}\ln(x^2+1)+C$$
$$\int \left(\ln\left(1+x^2\right)\right)\left(\arctan x\, dx\right)$$
$$=\ln\left(1+x^2\right)\left((\arctan x)(x)-\frac{1}{2}\ln(x^2+1)\right)-$$
$$-\int \left(\frac{2x}{1+x^2}\right)\left((\arctan x)(x)-\frac{1}{2}\ln(x^2+1)\right)\, dx$$
It's enough to find:
$$\int \left(\frac{2x}{1+x^2}\right)\left((\arctan x)(x)-\frac{1}{2}\ln(x^2+1)\right)\, dx=$$
$$=2\int \arctan x\, dx -2\int \frac{1}{1+x^2}\arctan x\, dx-\int \frac{x\ln\left(x^2+1\right)}{x^2+1}\, dx$$
We have $3$ integrals. We know the $1$st one. The $2$nd one is:
$$\int \frac{1}{1+x^2}\arctan x\, dx=\int \arctan x\, d(\arctan x)=\frac{(\arctan x)^2}{4}+C$$
The $3$rd one is:
$$\int \frac{x\ln\left(x^2+1\right)}{x^2+1}\, dx=\frac{1}{2}\int \frac{\ln(x^2+1)}{x^2+1}\, d\left(x^2+1\right)$$
$$=\frac{1}{2}\int \ln\left(x^2+1\right)\, d\left(\ln\left(x^2+1\right)\right)$$
$$=\frac{\left(\ln\left(x^2+1\right)\right)^2}{4}+C$$
A: Hint The substitution $x = \tan u$ is certainly the most natural first step.
Since our integrand in $u$ is a product of functions, applying integration by parts is a reasonable choice. Taking $$v = u, \qquad dw = \sec^2 u \log \sec u$$ gives
$$dv = du, \qquad w = u + \tan u (\log \sec u - 1)$$
(deriving this formula for $w$ requires another application of integration by parts). So, the integration by parts formula gives that our integral is
$$\int u \sec^2 u \log \sec u = \left(u + \tan u (\log \sec u - 1)\right) - \int   \left(u + \tan u \log \sec u - \tan u\right) du .$$ Separating the integral on the r.h.s. gives three integrals: The integrals $$\int u \,du \qquad \textrm{and} \qquad \int \tan u\,du$$ are standard, and the integral $$\int \tan u \log \sec u$$ can be handled with a substitution. Back-substituting then gives the antiderivative as a function of $x$.
