My question might seem similar to this question -"https://math.stackexchange.com/questions/1965777/substitution-makes-the-integral-bounds-equal" but I'll expand on why it doesn't resolve my query.
First off, let's take a look at this integral - $$ I = \int_0^\infty \frac{x^2-1}{x^4+1} dx$$
Dividing both the numerator and denominator by $x^2$, we get
$$ I = \int_0^\infty \frac{1-\frac{1}{x^2}}{x^2+\frac{1}{x^2}} dx = \int_0^\infty \frac{1-\frac{1}{x^2}}{({x+\frac{1}{x}})^2-2} dx$$
Now, if we take $x+\frac{1}{x}=u$, then
$$I= \int_\infty^\infty \frac{du}{u^2-2}$$
Now, the aforementioned question I linked suggested that substitutions must be injective and if not then I should break them in intervals where they are injective, so I did as suggested -
$$I= \int_\infty^2 \frac{du}{u^2-2} + \int_2^\infty \frac{du}{u^2-2} = \int_\infty^2 \frac{du}{u^2-2}-\int_\infty^2 \frac{du}{u^2-2}=0$$
Now, the result $I=0$ is fortunately true in this case but how do I know that the two infinities in the two integrals I compared in the last step are equal? What if the two infinties aren't equal in some other question? Or am I completely off in my handling of this integral? Please help!
The expression$$\int_\infty^\infty\frac{\mathrm du}{u^2-2}$$makes no sense.
You have$$\int_0^\infty\frac{1-\frac1{x^2}}{\left(x+\frac1x\right)^2-2}\,\mathrm dx=\int_0^1\frac{1-\frac1{x^2}}{\left(x+\frac1x\right)^2-2}\,\mathrm dx+\int_1^\infty\frac{1-\frac1{x^2}}{\left(x+\frac1x\right)^2-2}\,\mathrm dx.\label{a}\tag1$$Now, if you apply the substitution $u=x+\frac1x$ to the first integral of the RHS of \eqref{a}, then you get$$\int_\infty^2\frac{\mathrm du}{u^2-2}\label{b}\tag2$$and if you apply it to the second integral of the RHS of \eqref{a}, then you get$$\int_2^\infty\frac{\mathrm du}{u^2-2}.\label{c}\tag3$$It is clear that the sum of \eqref{b} with \eqref{c} is equal to $0$.
Or you can prove that the RHS of \eqref{a} is $0$ by applying the substitution $u=\frac1x$ to its first integral. You shall get\begin{align}\int_0^1\frac{1-\frac1{x^2}}{\left(x+\frac1x\right)^2-2}\,\mathrm dx&=\int_\infty^1\frac{1-u^2}{\left(\frac1u+u\right)^2-2}\times\left(-\frac1{u^2}\right)\,\mathrm du\\&=-\int_1^\infty\frac{1-\frac1{u^2}}{\left(u+\frac1u\right)^2-2}\,\mathrm du,\end{align}which is the symmetric of the second integral of the RHS of \eqref{a}. Therefore, the LHS of \eqref{a} is equal to $0$.