Modular forms-$SL(2,\Bbb Z)$- matrices with determinant $n$ I have the following problem: Let $\Gamma(n)$ denote the $2\times 2$ matrices with determinant $n$ and integer coefficients. Given $A,\hat{A} \in \Gamma(n)$ does there exist a $B \in \Gamma(1)= SL(2,\mathbb{Z})$ such that $A= B\hat{A}$?
I initially thought this is the case and have written down $A$ and $\hat{A}$ explicitly. It turned out that $B$ indeed has determinant $1$ but the coefficients are not necessarily integers. Can one impose certain restrictions on $A$ and $\hat{A}$ to get $B\in \Gamma(1)$ or are there just exceptional cases when this is true?
Thanks a lot for any ideas!
 A: The set you are calling $\Gamma(n)$ is one that comes up a lot in modular-form theory, but you need to be a little careful, because (as DietrichBurde points out) modular-forms people usually use the notation $\Gamma(n)$ for something else. Let me use the notation $X(n)$ for your set instead.
As you've realised, if you take any two matrices $A, \hat A \in X(n)$, then there will always exist a unique matrix $B$ such that $A = B \hat{A}$, and $B$ obviously has determinant 1; but $B$ won't usually have integer entries. So not all matrices in $X(n)$ are in the same orbit under left-multiplication by $SL_2(\mathbf{Z})$.
However, the orbits under the left-multiplication action of $SL_2(\mathbf{Z})$ are quite easy to describe. Let me say a matrix $M \in X(n)$ is good if $M = \begin{pmatrix} a & b \\ 0 & d\end{pmatrix}$ where $a \ge 1, d \ge 1$, $ad = n$, and $0 \le b < d$.
Theorem: for any $A \in X(n)$, there is a unique $B \in SL_2(\mathbb{Z})$ and $\hat A \in X(n)$ such that $BA = \hat A$ and $\hat A$ is good.
You might enjoy trying to prove the existence of $\hat A$ yourself: think about multiplying $A$ by something in $SL_2(\mathbb{Z})$ to kill the bottom corner, as a first step.
The good matrix $\hat A$ associated to $A$ is called the Hermite normal form of $A$. So two matrices $A, A'$ in $X(n)$ are related by an element of $SL_2(\mathbf{Z})$ if and only if they have the same Hermite normal form. If you look in Wikipedia (and follow the links there) you'll find lots of information about Hermite normal forms. 
For instance, it's quite easy this way to find out what $X(2)$ looks like: there are exactly three possible Hermite normal forms, so $X(2)$ is made up from three different orbits under $SL_2(\mathbf{Z})$ (and in fact there are exactly $p + 1$ Hermite normal forms in $X(p)$ for any prime $p$).
A: This is not an answer, but a comment, which might help to clarify the question. The set $\Gamma(n)$, as you have defined it, is not a group, because the inverse has integer coefficients if and only if the determinant is a unit in $\mathbb{Z}$, i.e., is $\pm 1$. Usually $\Gamma(n)$ is defined as a congruence subgroup. Explicitly it is described as follows:
$$ {\displaystyle \Gamma (n)=\left\{{\begin{pmatrix}a&b\\c&d\end{pmatrix}}\in \mathrm {SL} _{2}(\mathbb {Z} ):a,d\equiv 1{\pmod {n}},b,c\equiv 0{\pmod {n}}\right\}} 
$$
A: The adjugate matrix $\text{ adj}(\hat{A}) \in \mathbb{Z}^{2 \times 2}$ whenever $A \in \mathbb{Z}^{2 \times 2}$ 
$$\hat{A} \text{ adj}(\hat{A}) = \det(\hat{A}) I$$
Thus $\hat{A}^{-1} = \frac{1}{n}\text{ adj}(\hat{A}) $ and $$B = A \hat{A}^{-1}=\frac{1}{n}A\text{ adj}(\hat{A}) $$
Which means that $n B \in \mathbb{Z}^{2 \times 2}$ but $B$ doesn't have to be, take $$A = \scriptstyle \begin{pmatrix} 1 & 0 \\ 0 & n\end{pmatrix}, \qquad \hat{A} = \scriptstyle \begin{pmatrix} n & 0 \\ 0 & 1\end{pmatrix}$$
