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 $$