Why we are allowed to divide numerator and denominator of the integrand by $x^2$? Consider
$$\int\frac{x^2+1}{x^4+x^2+1}dx$$
One way to evaluate it, is dividing the numerator and denominator by $x^2$ and we have:
$$\int\frac{1+\frac1{x^2}}{x^2+1+\frac1{x^2}}dx=\int\frac{d(x-\frac1x)}{(x-\frac1x)^2+3}$$
And so on.
My question is: how we are allowed to divide the numerator and denominator by $x^2$ (in other word multiply it by $\frac{\frac1{x^2}}{\frac1{x^2}}$) ?  We can do it only if $x\neq0$ and in the original integral $x$ can be zero rather than other integrals.
 A: You are right.  There is a problem with this.  Integrating,
$$
\int\frac{du}{u^2+3} = \frac{1}{\sqrt{3}}\arctan\left(\frac{u}{\sqrt{3}}\right)
=\frac{1}{\sqrt{3}}\arctan\left(\frac{x-\frac{1}{x}}{\sqrt{3}}\right)
=: F_1(x)
$$
we get this:

Whereas, a good antiderivative is
$$
F_2(x) := \frac{1}{\sqrt{3}}\left(\arctan\frac{(2x+1)}{\sqrt{3}}+
\arctan\frac{(2x-1)}{\sqrt{3}}\right)
$$
and looks like this

On any interval $[a,b]$ with $0 \notin [a,b]$ we have $F_1-F_2$ is constant on $[a,b]$.  If we want to use $F_1$ to evaluate an integral $\int_a^b$ with $a < 0 < b$, we have to do it in two parts:
$$
\int_a^0 + \int_0^b = (F_1(0^-)-F_1(a))+(F_1(b)-F_1(0^+)).
$$
Of course this is not the only example of this phenomenon.  So when evaluating an integral using the Fundamental Theorem, we should always check for jumps in our antiderivative and act accordingly.
A: It's because $x$ is an indeterminate. Dividing the numerator and denominator by $x^2$, i.e.,
$1 = \frac{1/x^2}{1/x^2}$
is valid since cancelling the numerator and denominator does give you 1. You will run into trouble instead when one of the bounds in the integral is $0$, forcing you to plug in $x=0$ into $\frac{1}{x^2}$ using the Fundamental Theorem of Calculus.
