<s>[INST] How to find$\int x^2 \arctan(x) \;dx $ I was solving $\int x^2 \arctan(x) \;dx $
I set $u=x^2$, $dv= \arctan(x)$, so I could get $du=2x$, $v=x\arctan(x)-\frac12\ln(1+x^{2})$.
From $\int x^2 \arctan(x)\;dx = uv - \int v \; du$ 
I got
$$\begin{align*}&\int x^2 \arctan(x) \; dx =\\
&x^3\arctan(x) -\frac12\ln(1+x^{2})-\int 2x\left[x^{2}\arctan x -\frac12\ln(1+x^2)\right]\;dx \end{align*}$$
and simplified if; then I got 
$$3\int x^2\arctan(x) \;dx = x^3 \arctan(x)-\frac12\ln(1+x^2)+\int x\ln(1+x^2) \;dx$$
after that I use $w=\ln(1+x^2) \; dv =dx$ to find $\int x\ln(1+ x^2)$ 
but I got
$$x^2 \arctan(x)-\int 2x\arctan(x) \; dx$$
If I got $$x^2 \arctan(x)-\int 2x^2 \arctan(x)\;dx$$ instead, it would be easy to solve the question....
How can I solve this question and if you find any my mistake could you post this wall ?? 
Thank you ! 
 [/INST] $$\int{ x^2 \cdot \tan^{-1} x} dx = $$
$$ \tan^{-1} x dx = du $$
$$ x\cdot\tan^{-1} x - \frac{1}{2}\log(x^2+1) = u $$
$$ x^2 = v $$
$$ 2xdx = dv $$
$$\int{ x^2 \cdot \tan^{-1} x} dx = x^2\left(x\cdot\tan^{-1} x - \frac{1}{2}\log(x^2+1) \right)-\int 2x\left(x\cdot\tan^{-1} x - \frac{1}{2}\log(x^2+1) \right)dx$$
$$I = {x^2}\left( {x\cdot{{\tan }^{ - 1}}x - \frac{1}{2}\log ({x^2} + 1)} \right) - 2I + \int {x\log \left( {{x^2} + 1} \right)} dx$$
$$3I = {x^2}\left( {x\cdot{{\tan }^{ - 1}}x - \frac{1}{2}\log ({x^2} + 1)} \right) + \frac{1}{2}\int {\log u} du$$
$$3I = {x^2}\left( {x\cdot{{\tan }^{ - 1}}x - \frac{1}{2}\log ({x^2} + 1)} \right) + \frac{{{x^2} + 1}}{2}\left[ {\log \left( {{x^2} + 1} \right) - 1} \right]$$
$$I = \frac{{{x^2}}}{3}\left( {x\cdot{{\tan }^{ - 1}}x - \frac{1}{2}\log ({x^2} + 1)} \right) + \frac{{{x^2} + 1}}{6}\left[ {\log \left( {{x^2} + 1} \right) - 1} \right]$$
This simplifies to $$I = \frac{{{x^3}}}{3}\cdot{\tan ^{ - 1}}x + \frac{1}{6}\log \left( {{x^2} + 1} \right) - \frac{{{x^2}}}{6} + C $$
which coincides with WA's solution. 
</s>