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!