<s>[INST] Integrate rational function with multiple complex roots I want to integrate
$$
 \int_{-1}^1 \frac{x^2}{(1+n^2x^2)^2} dx.
$$
By WolframAlpha I know the solution is
$$
 \int_{-1}^1 \frac{x^2}{(1+n^2x^2)^2} dx = \frac{\arctan(n) - \frac{n}{n^2+1}}{n^3}.
$$
Do derive it on my own, I did a partial fraction decomposition and found
$$
 \frac{x^2}{(1+n^2x^2)^2} = \frac{\frac{1}{2n^2}}{1+n^2x^2} + \frac{\frac{1}{4n^2}}{(x-i/n)^2} + \frac{\frac{1}{4n^2}}{(x+i/n)^2}. 
$$
I checked this multiple times, but it must be wrong, because when I proceed with it I get
\begin{align*}
 \int_{-1}^1 \frac{x^2}{(1+n^2x^2)^2} dx
  & = \frac{1}{n^2} \left( \frac{1}{2} \int_{-1}^1 \frac{1}{1+n^2x^2} d x + \frac{1}{4} \int_{-1}^1 \frac{1}{(x-i/n)^2} d x + \frac{1}{4} \int_{-1}^1 \frac{1}{(x+i/n)^2} d x \right) \\
& = \frac{1}{n^2}\left( \frac{1}{2} \frac{\arctan(xn)}{n}\bigg\vert_{-1}^1 + \frac{1}{4} \left( \frac{-1}{x-i/n}\bigg\vert_{-1}^1 + \frac{-1}{x+i/n}\bigg\vert_{-1}^1 \right)\right) \\
& = \frac{1}{n^2} \left( \frac{\arctan(n)}{n} + \frac{1}{4} \left( \frac{-2}{1+1/n^2} + \frac{-2}{1+1/n^2}\right)\right) \\
& = \frac{1}{n^2} \left( \frac{\arctan(n)}{n} -\frac{1}{1+1/n^2} \right) \\
& = \frac{1}{n^2} \left( \frac{\arctan(n)}{n} - \frac{n^2}{n^2+1} \right) \\
& = \frac{\arctan(n)}{n^3} - \frac{1}{n^2+1}
\end{align*}
This result is consistent which what I found with WolframAlpha, but surely
$$
 \frac{\arctan(n)}{n^3} - \frac{1}{n^2+1} \ne \frac{\arctan(n) - \frac{n}{n^2+1}}{n^3}
$$
so what went wrong, I am sitting here since hours and do not see any fault...
 [/INST] A quick and dirty way to check this.  Let 
$$f(m) = \int_{-1}^1 \frac{dx}{1+m x^2}  = \frac{2}{m} \int_0^1 \frac{dx}{1/m+x^2} = \frac{2}{\sqrt{m}}\arctan \sqrt{m}$$
$$f'(m) = -\int_{-1}^1 dx \frac{x^2}{(1+m x^2)^2}  = -m ^{-3/2} \arctan{\sqrt{m}} + \frac1{m (1+m)}$$
Your integral is thus
$$-f'(n^2) = \frac{\arctan{n}}{n^3} - \frac1{n^2 (1+n^2)} $$
</s>