Can someone please help me explain this fallacy

Although $x=-1$ implies $y=-1$ and $x=1$ implies $y=1$, this does not mean the integral on $y$ can be written "from $-1$ to $1$". We need to consider the actual regions of integration, not just the boundary points.

$-1 \leq x \leq 1$ implies $y \leq -1$ or $y \geq 1$. (We can ignore the single point $x=0$.) So the correct transformation is:

$$ \int_{-1}^1 \frac{dx}{1+x^2} = \int_{-\infty}^{-1} \frac{dy}{1+y^2} + \int_1^{\infty} \frac{dy}{1+y^2} $$

The minus sign from $dy = -\frac{dx}{x^2}$ is removed, because when dealing with sets rather than just a monotone increasing or decreasing function on single intervals, we must use the absolute value of the derivative.


This is just a slightly different take on aschepler's answer, showing a few more steps:

$$\begin{align} \int_{-1}^1{1\over1+x^2}\,dx &=\int_{-1}^0{1\over1+x^2}\,dx+\int_0^1{1\over1+x^2}\,dx\\ &=\int_{-1}^{-\infty}{1\over1+(1/y)^2}\,{-dy\over y^2}+\int_\infty^1{1\over1+(1/y)^2}\,{-dy\over y^2}\\ &=\int_{-\infty}^{-1}{1\over y^2+1}\,dy+\int_1^\infty{1\over y^2+1}\,dy \end{align}$$

where the negative sign from $dx=-dy/y^2$ goes into reversing the limits of integration, i.e., $\int_b^a=-\int_a^b$.