# How do you find the primitive/integral of $\arctan(x)$?

I tried searching for how you derive the integral/primitive of $\arctan(x)$, but I can't find any question on S.E with an answer that clearly explains this. I feel that there should be one, since it is rather fundamental knowledge, and it does come up every now and then as part of S.E questions.

So the primitive can be looked up and it should be the following: $$\int \arctan(x)~dx = x\arctan(x) - \frac{1}{2}\ln(1+x^2) + C$$ How do you get the result?

The integral can be solved by using integration by parts. The trick is to think of the function as a product of $\arctan(x)$ and $1$, both with respect to $x$.

We solve the integral by choosing to integrate $1$ to $x$ and differentiate $\arctan(x)$ into $\frac{1}{1+x^2}$ which is easier to integrate: $$\int\arctan(x)\cdot 1~dx = x\arctan(x) - \int \frac{x}{1+x^2}~dx + C_0$$ and we can use the fact that $\frac{1}{2}\left(\frac{d}{dx}\ln(1+x^2)\right) = \frac{x}{1+x^2}$ to integrate $\frac{x}{1+x^2}$ so the last integration results in the given primitive: $$x\arctan(x) - \int\frac{x}{1+x^2}~dx = x\arctan(x) - \frac{1}{2}\ln(1+x^2) +C$$

Indeed, if you know a primitive for $f$, say $F$, you can derive a primitive for $f^{-1}$ in the same way: putting $x=f(u)$, so $u=f^{-1}(x)$, we have $dx = f'(u) \, du$, so \begin{align} \int f^{-1}(x) \, dx &= \int u f'(u) \, du \\ &= uf(u) - \int f(u) \, du \\ &= f(u)u-F(u)+C \\ &= x f^{-1}(x) - F(f^{-1}(x))+C. \end{align} For example, in this case $f(u)=\tan{u}$, so a primitive is $\log{\lvert \sec{u} \rvert} = \frac{1}{2}\log{(1+\tan^2{u})} = \frac{1}{2}\log{(1+x^2)}$, and the result follows. One can apply the same rule for $\log{x}$, and all the other trigonometric and hyperbolic inverses.

$$\int \arctan(x)dx$$ Apply Integration By Parts: $u=\arctan(x),v^{\prime}=1$. Then we get $$=\arctan(x)x-\int\frac{1}{x^2+1}(x)dx$$ $$=x\arctan(x)-\int\frac{x}{x^2+1}dx$$ $$=x\arctan(x)-\frac12\ln|x^2+1|+C$$ $$\int \arctan(x)dx=x\arctan(x)-\frac12\ln| x ^ 2 +1|+C$$

$$I=\int{\arctan(x)}dx$$ let $x=tan(u)$ so $\frac{dx}{du}=\sec^2(u)$ and $dx=\sec^2(x)du$

so: $$I=\int{u\sec^2{(u)}}du$$ Then use integration by parts to solve.

$$I=u\tan{(u)}-\int\tan{(u)}du=u\tan{(u)}+\ln{(\cos{(u)})}+C=x\arctan{(x)}-\frac{1}{2}\ln{(\sec^2{(u))}}+C$$ and since $x^2=\tan^2{(u)}$ and $\tan^2{(u)}+1=\sec^2{(u)}$

$$I=xarctan(x)-\frac{1}{2}\ln|x^2+1|+C$$