<s>[INST] Calculate the integral of the function only with the immediate integrals I need to calculate this indefinite integral:
$$
\int{\frac{x^2-1}{x^2+1}}dx
$$
I realized that the technique to solve is to "transform" the numerator equal to the denominator of the fraction so I tried this:
$$
\int{\frac{x^2-1}{x^2+1}}dx = \int{\frac{(x^2-1)+2}{x^2+1}}dx = \int{\frac{x^2-1}{x^2+1}}dx + \int{\frac{2}{x^2+1}}dx
$$
My problem is that my equation is returning to the original problem!The book suggests the following resolution , but why it appears this integral dx?
$$
\int{\frac{x^2-1}{x^2+1}}dx = \int{\frac{(x^2-1)-2}{x^2+1}}dx = \int dx - \int{\frac{2}{x^2+1}}dx = x - 2\int{\frac{1}{x^2+1}}dx = x - 2arctanx + c
$$
 [/INST] Try using long-division on your rational expression: 
$$\frac{x^2-1}{x^2+1}=\frac{(x^2+1)-2}{x^2+1}=1-\frac{2}{x^2+1}$$
So now we can integrate the $1$ (that is, $\int 1\ dx$), and subtract the integral of $\frac{2}{x^2+1}$ (which is $2\arctan(x)+C$).
Whenever you have a rational function whose numerator's degree is not smaller than its denominator's, a good first step is to do polynomial long-division. 
</s>