<s>[INST] Integration with a quartic in the denominator $\frac{1}{(x^2-1)^2}$ I had to integrate $$\int\frac{x^2+1}{(x^2-1)^2} dx$$
Well my first approach was to write$\ (x^2+1)$ as $\ (x^2-1)+2$ so as to obtain fractions 
$$\frac{1}{(x^2-1)} + \frac{2}{(x^2-1)^2}$$ 
Now I know how to integrate the first part but how to integrate the second part i.e. a quartic (biquadratic) in the denominator?
(I got the answer to the original integral by dividing num and denom by $x^2$ and then substitution,but I want to know what could I have done with my first attempt)
 [/INST] We can Write $\displaystyle \frac{1}{(x^2-1)^2} = -\frac{1}{2}\left[\frac{1}{x^2-1}-\frac{(x^2+1)}{(x^2-1)^2}\right]$
So $$\displaystyle I = \int\frac{1}{(x^2-1)^2}dx = -\frac{1}{2}\left[\int\frac{1}{x^2-1}dx-\int\frac{x^2+1}{(x^2-1)^2}dx \right]$$
So we get $$\displaystyle I = \int\frac{1}{(x^2-1)^2}dx = -\frac{1}{4}\int\left(\frac{1}{x-1}-\frac{1}{x+1}\right)+\frac{1}{2}\int\frac{1+\frac{1}{x^2}}{\left(x-\frac{1}{x}\right)^2}dx $$
Now Put $\displaystyle \left(x-\frac{1}{x}\right)=t\;,$ Then $\displaystyle \left(1+\frac{1}{x^2}\right)dx = dt$
So we get $$\displaystyle \displaystyle I = -\frac{1}{4}\left[\ln|x-1|-\ln|x+1|\right]-\frac{1}{2}\cdot \frac{1}{x-\frac{1}{x}}+\mathcal{C}$$
So we get $$\displaystyle I = \int\frac{1}{(x^2-1)^2}dx = \frac{1}{4}\ln\left|\frac{x+1}{x-1}\right|-\frac{x}{2(x^2-1)}+\mathcal{C}$$
</s>