$\int_{-\infty}^\infty f(T(x))\,\frac{dx}{\pi(1+x^2)} = \int_{-\infty}^\infty f(y)\,\frac{dx}{\pi(1+y^2)}$ when $T(x)=\frac{x^2 -1}{2x}$ and $T(0)=0$ 
Let $T:\Bbb R\to\Bbb R$ be given by
$$T(x) = \frac{1}{2}\left(x- \frac1x \right)$$
for $x\ne 0$, and $T(0) = 0$. The substitution $y = T(x)$ establishes the following integral equality for any $f\in L^1$:
$$\int_{-\infty}^\infty f(T(x))\, \frac{dx}{\pi(1+x^2)} = \int_{-\infty}^\infty f(y)\, \frac{dx}{\pi(1+y^2)} $$


First of all, $T(0^+) = T(-\infty) = -\infty$, and $T(0^-) = T(\infty) = \infty$. Also, on solving $2y = x - \frac1x$ for $x$, we get $x = y\pm \sqrt{y^2 + 1}$. Since $T$ is injective when restricted to $(-\infty, 0)$ and $(0, \infty)$, we split the integral into two parts;
$$\int_{-\infty}^\infty f(T(x))\, \frac{dx}{\pi(1+x^2)} = \int_{-\infty}^0 f(T(x))\, \frac{dx}{\pi(1+x^2)} + \int_0^\infty f(T(x))\, \frac{dx}{\pi(1+x^2)}$$
Putting $y = T(x)$, we get
$$\int_{-\infty}^0 f(T(x))\, \frac{dx}{\pi(1+x^2)} = \underbrace{\frac{1}{2\pi}\int_{-\infty}^\infty f(y)\, \frac{(2y^2 + 2y\sqrt{y^2 + 1} + 1)\, dy}{(y^2 \pm y\sqrt{y^2 + 1} + 1)^2}}_{I_1}$$
and
$$\int_0^\infty f(T(x))\, \frac{dx}{\pi(1+x^2)} = \underbrace{\frac{1}{2\pi}\int_{-\infty}^\infty f(y)\, \frac{(2y^2 + 2y\sqrt{y^2 + 1} + 1)\, dy}{(y^2 \pm y\sqrt{y^2 + 1} + 1)^2}}_{I_2}$$
Finally,
$$\int_{-\infty}^\infty f(T(x))\, \frac{dx}{\pi(1+x^2)} = I_1 + I_2$$
but I am hesitant to add the two integrals up since it's not clear to me which branch of $x$ (in terms of $y$) to pick, i.e., $x = y + \sqrt{y^2 + 1}$ or $x = y - \sqrt{y^2 + 1}$? How should I go about this?

Reference: Pg. $19$, Section $2.1$, Ergodic Theory with a view towards Number Theory by Manfred Einsiedler and Thomas Ward.
 A: Notice that the restrictions of $T$  to $(-\infty,0)$ and $T$ to $(0,\infty)$, denoted by $T_-$ and $T_+$ respectively,  are strictly monotone increasing functions onto $\mathbb{R}$. Moreover
\begin{align}
T^{-1}_+(y)&=y+\sqrt{y^2+1}>0\\
T^{-1}_-(y)&=y-\sqrt{y^2+1}<0
\end{align}
This shows which branches to use in the OP

Perhaps a simpler method to prove the main statement in the OP is to show that the map $T$ is invariant with respect the probability measure $\mu(dx)=\frac{1}{\pi}\frac{1}{1+x^2}\,dx$ (the standard Cauchy measure on $\mathbb{R}$),  that is $\mu(T^{-1}(A)=\mu(A)$ for all $A\in\mathscr{B}(\mathbb{R})$ for then,
$$\int f\circ T\,d\mu=\int f\,d(\mu\circ T^{-1})=\int f\,d\mu$$
Since the cumulative distributions fully characterize probability measure on $\mathbb{R}$, it suffices to show that $\mu\big(T^{-1}((-\infty,a])\big)=\mu((-\infty,a])$ with $a\in\mathbb{R}$.
Given $a\in\mathbb{R}$, let
\begin{align}
\alpha_+=a+\sqrt{a^2+1}\qquad \alpha_-=a-\sqrt{a^2+1}
\end{align}
$\alpha_-<0< \alpha_+$ are the roots of the equation
$T(x)=a$, $x\neq0$. Notice that $T^{-1}((-\infty,a])=(-\infty,\alpha_-]\cup(0,\alpha_+]$; whence
\begin{align}
\mu((-\infty,\alpha_-])&=\frac{1}{\pi}\arctan(\alpha_-)+\frac12\\
\mu((0,\alpha_+])&=\frac1{\pi}\arctan(\alpha_+)
\end{align}
\begin{align}
\mu(T^{-1}(-\infty,a])&=\frac1{\pi}\big(\arctan(a+\sqrt{a^2+1})+\arctan(a-\sqrt{a^2+1})\big)+\frac12\\
&=\frac{1}{\pi}\arctan(a) +\frac12=\mu((-\infty,a])
\end{align}
That latter identity follows from
$$\tan(\theta+\psi)=\frac{\tan(\theta)+\tan(\psi)}{1-\tan(\theta)\tan(\psi)}$$

The paper Letac, G., Which Functions Preserve Cauchy Laws?,
Proceedings of the American Mathematical Society,
Vol. 67, No. 2 (Dec., 1977), pp. 277-286, contains a more detailed study of invariant measures of the Cauchy distribution,
