<s>[INST] Unexpected outcome of integral A given method for calculating $\int^1_{-1} \frac 1 {1+x^2} \, dx$ is
\begin{align}
& \int^1_{-1} \frac 1 {1+x^2} \, dx=\int^1_{-1} \frac 1 {x^2(1+\frac 1 {x^2})} \, dx = -\int^1_{-1} \frac 1 {1+(\frac 1 x)^2} \,d(1/x) = \left.-\arctan\left(\frac 1 x\right)\right|_{x=-1}^1 \\[10pt]
= {} & -\arctan(1) + \arctan(-1)=-\frac{\pi}{2}.
\end{align}
This differs from the expected outcome $$\int^1_{-1} \frac 1 {1+x^{2}}dx= \arctan x \Big|_{x=-1}^1=\arctan(1)-\arctan(-1)=\frac \pi 2.$$
Is there something wrong with the first calculation? I noticed that $\frac{1}{1+x^{2}}-1=\frac{1}{1+(\frac{1}{x})^{2}}$, but I don't yet see how this can be of any help.
 [/INST] Upon enforcing the substitution $x=1/t$, the domain transforms from $[-1,1]$ to $(-\infty,-1)\cup [1,\infty)$.  Hence we have
$$\begin{align}
\int_{-1}^1\frac{1}{1+x^2}\,dx&= \int_{-\infty}^{-1}\frac{1}{1+t^2}\,dt+\int_1^\infty \frac{1}{1+t^2}\,dt\\\\
&=\left(\arctan(-1)+\frac\pi2\right)+\left(\frac\pi2 -\arctan(1)\right)\\\\
&=\frac{\pi}{2}
\end{align}$$
</s>