Solution (source code)

= Solution

The characteristic polynomial of $A$ is
$$
t^2-(\operatorname{tr}A)t+1.
$$
When $|\operatorname{tr}A|>2$, its discriminant is positive, so $A$ has two distinct real <eigenvalues> $\lambda,\lambda^{-1}$ and two independent real <eigenvectors>. Let $P$ have those eigenvectors as columns. Rescaling one column makes $\det P=1$ without changing the diagonalization. Hence $P\in SL_2(\mathbb R)$ and
$$
\boxed{P^{-1}AP=\begin{pmatrix}\lambda&0\\0&\lambda^{-1}\end{pmatrix}.}
$$
This is the normal form of a <hyperbolic element of PSL2(R)>.