Why doesn't the substitution $x=it$ work in the integral $\int\frac{x^2}{{(x^2+1)}^2}dx$? For İntegral $$\int\frac{x^2}{{(x^2+1)}^2}dx$$  I used this substitution $x=it$
We have,

$$\begin{align}
\int\frac{x^2}{{(x^2+1)}^2}dx &=-i\int\frac{t^2}{{(t^2-1)}^2}dt \\
&=-\frac i4\left( \int\frac{1}{t-1}dt+\int\frac{1}{(t-1)^2}dt-\int\frac{1}{t+1}dt+\int\frac{1}{(t+1)^2}dt\right) \\
&=-\frac i4\left(\ln\left|\frac{t-1}{t+1}\right|-\frac{2t}{t^2-1}+C \right)
\end{align}$$ 

In the answer the function $\ln$ doesn't included.
My answer is wrong. Where is the mistake? I can not see.
 A: Complex substitutions is a common source of error in real integration. It often leads to wrong results if you don't know what you are doing and to do the derivation you have attempted to do rigorously you cannot get away from the theory of complex integration and the complex logarithm.
However the beauty of indefinite integration is that you can use whatever method you like (rigorous or not) to get the answer as long as you check in the end by differentiating the result and show that you recover the integrand.
In your case a naive derivation can indeed give the correct answer. If we naively use $\int \frac{{\rm d}t}{t+a} = \log(t+a)$ then we end up with
$$\int \frac{x^2}{(x^2+1)^2}{\rm d}x = -\frac{i}{4}\left[\log\left(\frac{t-1}{t+1}\right) - \frac{2t}{t^2-1} \right]_{t=x/i} + C$$ 
Now using a known connection between the logarithm and the arctan-function $\arctan(x) = \frac{1}{2i}\log\left(\frac{x-i}{x+i}\right)$ we end up with the manifestly real result
$$\int \frac{x^2}{(x^2+1)^2}{\rm d}x = \frac{\arctan(x)}{2} - \frac{x}{2(1+x^2)} + C$$ 
For the crucial step to make it a valid proof: differentiating the right hand side we find that we do indeed recover the integrand showing that the answer is correct (even through the derivation was a bit sketchy).
A: It has been pointed out in the comments while your substitution is ill formed.
Here is a way to solve it by substitution.
The group $1+x^2$ calls for a change of variable $x=\sinh(u)$ or $x=\tan(u)$. 
In this case the first one, doesn't work so well, you can try it and get $\displaystyle\int \frac{\sinh(u)^2}{\cosh(u)^3}\mathop{du}$ which is not very desirable.
Instead $x=\tan(u)$ gets $dx=(1+\tan(u)^2)\mathop{du}$ to cancel with the denominator and reduce the exponent.
$\displaystyle\int \dfrac{x^2}{(1+x^2)^2}\mathop{dx}=\int \dfrac{\tan(u)^2}{1+\tan(u)^2}\mathop{du}=\int \sin(u)^2\mathop{du}=\frac 12u-\frac 14\sin(2u)=\frac 12u-\frac 14\left(\dfrac{2\tan(u)}{1+\tan(u)^2}\right)$
Finally $$\displaystyle\int \dfrac{x^2}{(1+x^2)^2}\mathop{dx}=\frac 12\arctan(x)-\frac 14\left(\dfrac{2x}{1+x^2}\right)$$
A: your result can be written in a simpler form as:
$$-\frac{i}{4}\left( \frac{2t}{{{t}^{2}}-1}+\ln \left( 1+t \right)-\ln \left( 1-t \right) \right)$$
now substitute $t=-ix$
$$\begin{align}
  & =-\frac{i}{4}\left( \frac{2\left( -ix \right)}{{{\left( -ix \right)}^{2}}-1}+\ln \left( 1-ix \right)-\ln \left( 1+ix \right) \right) \\ 
 & =-\frac{i}{4}\left( \frac{2ix}{{{x}^{2}}+1}+\ln \left( 1-ix \right)-\ln \left( 1+ix \right) \right) \\ 
 & =-\frac{i}{4}\left( \frac{2ix}{{{x}^{2}}+1}+\left( \left( ix \right)-\frac{{{\left( ix \right)}^{2}}}{2}+\frac{{{\left( ix \right)}^{3}}}{3}-\cdots  \right)+\left( \left( ix \right)+\frac{{{\left( ix \right)}^{2}}}{2}+\frac{{{\left( ix \right)}^{3}}}{3}-\cdots  \right) \right) \\ 
 & =-\frac{i}{4}\left( \frac{2ix}{{{x}^{2}}+1}+2\left( ix \right)+\frac{2{{\left( ix \right)}^{3}}}{3}+\frac{2{{\left( ix \right)}^{5}}}{5}+\cdots  \right) \\ 
 & =-\frac{i}{4}\left( \frac{2ix}{{{x}^{2}}+1}+2ix-\frac{2i{{x}^{3}}}{3}+\frac{2i{{x}^{5}}}{5}-\cdots  \right) \\ 
 & =\frac{1}{2}\left( \frac{x}{{{x}^{2}}+1}+x-\frac{{{x}^{3}}}{3}+\frac{{{x}^{5}}}{5}-\cdots  \right) \\ 
 & =\frac{1}{2}\left( \frac{x}{{{x}^{2}}+1}+{{\tan }^{-1}}\left( x \right) \right) \\ 
\end{align}$$ 
