Invertible rational matrices with positive determinant decomposition I'm doing some exercises from Diamond and Shurman's 'A first course in modular forms' and I got stuck at exercise $1.2.11$, in particular, I cannot prove the following:
Show that every matrix in $GL_2^+(\mathbb{Q})$ (invertible matrices with rational entries and positive determinants) can be written in the following form
$$r\alpha\begin{pmatrix}a&b\\0&d\end{pmatrix},$$
where $r$ is a positive rational number, $\alpha$ is in $SL_2(\mathbb{Z})$ (invertible matrices with integer entries and determinant $1$) and $a,b,d\in\mathbb{Z}$ are relatively coprime. Especially the last part is what baffles me, as I don't know how to properly find such numbers for a general matrix. Any help/hint is greatly appreciated.
 A: Let $M=\begin{pmatrix} m_{11} & m_{12} \\ m_{21} & m_{22} \end{pmatrix}$ be a matrix in $GL_2^{+}(\mathbb Q)$. We wish to show that $M$ can be decomposed as
$$
M=r\alpha t \tag{1}
$$
where $r\in{\mathbb Q}^{+}$, $\alpha\in SL_2(\mathbb Z)$ and $t\in T$ with
$$
T=\Bigg\lbrace \begin{pmatrix} a & b \\ 0 & d \end{pmatrix}
\ \Bigg| \  a,b,d \in \mathbb Z, gcd(a,b,d)=1 \Bigg\rbrace \tag{2}
$$
Since the (positive) common denominator of the coefficients of $M$ can be put inside $r$ in (1), we can assume without loss that all the $m_{ij}$'s are in $\mathbb Z$.
Then, let $g$ be the (positive) gcd of $m_{11}$ and $m_{21}$. By Bezout's identity, there are integers $u$ and $v$ such that $um_{11}+vm_{21}=g$. Next, introduce the matrix
$$
\beta=\begin{pmatrix} v & u \\ -\frac{m_{11}}{g} & \frac{m_{21}}{g} \end{pmatrix} \in SL_2(\mathbb Z) \tag{3}
$$
Then, by construction, the lower-left coefficient of $\beta M$ is zero :
$$
\beta M = \begin{pmatrix} a' & b' \\ 0 & d' \end{pmatrix} \tag{4}
$$
Next, let $h$ be the (positive) gcd of $a',b'$ and $d'$. If we put
$$
r=h, \ \alpha=\beta^{-1}, t = \begin{pmatrix} \frac{a'}{h} & \frac{b'}{h} \\ 0 & \frac{d'}{h} \end{pmatrix} \tag{5}
$$
we see that (1) is satisfied.
