Integration of arctan(x) is itself? Sorry if this seems like a useless question, but I can't seem to work out what's wrong with the following reasoning, which leads to what is definitely an incorrect answer.

so,
$$
\int \arctan(x) dx = x \arctan(x) - \int \frac{x}{1+x^2}dx
$$

Pretty standard so far, then instead of using substitution to evaluate the second integral, I used integration by parts again:

$$
\int \frac{x}{1+x^2}dx=x \int \frac{1}{1+x^2}dx - \int \frac{1}{1+x^2}dx
$$

Which should be true, but must be where the problem is because this leads to

$$
x \arctan(x) - \arctan(x)
$$

which implies

$$
\int \arctan(x) dx = \arctan(x)
$$

Which is clearly wrong as arctan tends to a value whereas the areas under the curve does not, plus loads of other reasons why this is clearly a mistake.

Can somebody help me find out where I've gone wrong
You can't take the $x$ out of the first integral on the right side because $x$ is the integration variable and is not a constant. You would have to handle it differently like this: Let $u = 1+x^2$, and can you continue to the finish?
I figured out the problem pretty much as soon as I posted this, the second integral is a double integral, i.e.

$$
\int \frac{x}{1+x^2}dx=x \int \frac{1}{1+x^2}dx - \int \int \frac{1}{1+x^2}dx^2
$$

Which leads to

$$
\int \arctan(x) dx =x \arctan(x) - x \arctan(x) - \int \arctan(x) dx
$$