On the stabilizer in $\mathrm{GL}(2,\mathbb{Z})$ of a real quadratic irrationality $\DeclareMathOperator\GL{GL}$Let $\theta$ be a real quadratic irrationality with discriminant $\Delta$; let $\mathcal{O}_\Delta$ denote the resulting quadratic order of discriminant $\Delta$ in $\mathbb{Q}[\theta]$; let $\GL(2,\mathbb{Z})_\theta$ denote the stabilizer subgroup of $\theta$ with respect to the action of $\GL(2,\mathbb{Z})$ on $\mathbb{R} \setminus \mathbb{Q}$ by fractional linear transformations. It turns out (see, e.g., F. Halter-Koch, Quadratic Irrationals, Theorem 5.2.10) that the map
$$
 \GL(2,\mathbb{Z})_\theta \to \mathcal{O}_\Delta^\times, \quad \begin{bmatrix}k&l\\m&n\end{bmatrix} \mapsto m\theta + n
$$
is an isomorphism with explicit inverse given by
$$
 \frac{u + v\sqrt{\Delta}}{2} \mapsto \begin{bmatrix} \frac{u+bv}{2} & -cv \\ av & \frac{u-bv}{2}\end{bmatrix},
$$
where $(a,b,c)$ is the type of $\theta$, i.e., the unique $(a,b,c) \in \mathbb{Z}^3$ such that $a \neq 0$, $b^2-4ac$ is not a square, and $\theta = \frac{b+\sqrt{b^2-4ac}}{2a}$, so that $\Delta = b^2-4ac$. Is there a traditional attribution for this result?
My apologies if this is well-known—I’m afraid I’m not a number theorist, so even googling this has been an uphill climb for me.
[By way of explanation, I’m interested in this result because it’s well-known to be at the heart of the existence and classification of non-trivial noncommutative line bundles over the corresponding noncommutative $2$-torus $C(\mathbb{T}^2_\theta)$, cf., for instance, Kodaka’s computation of its Picard group.]
 A: I think Stanley is correct, as the table of contents of the Halter-Koch book is  within the limited number of pages in the online preview. There is a recent book by Lehman worth checking,
Meanwhile, I wrote a short note on the correspondence between forms and ideals. The main reference, not stated there, was Cohen, A course in Computational Algebraic Number Theory, especially section 5.2  in pages 225-230.
For an indefinite binary quadratic form, integer coefficients, and discriminant $\Delta=b^2-4ac$ positive but not a square,   we take any integer solution to the Pell type
$$  \tau^2 - \Delta \sigma^2 = 4 $$  and produce the matrix
$$
P = 
\left(
\begin{array}{}
\frac{\tau - b \sigma}{2} & -c \sigma \\
a \sigma &  \frac{\tau + b \sigma}{2}
\end{array}
\right)
$$
which solves $P^T HP = H$ where $H$ is the Hessian matrix of $ax^2+ b xy + c y^2.$
The identity involved is
$$
 \left(
\begin{array}{}
\frac{\tau - b \sigma}{2} & a \sigma \\
-c \sigma &  \frac{\tau + b \sigma}{2}
\end{array}
\right)
\left(
\begin{array}{}
2a &b \\
b &  2c
\end{array}
\right)
\left(
\begin{array}{}
\frac{\tau - b \sigma}{2} & -c \sigma \\
a \sigma &  \frac{\tau + b \sigma}{2}
\end{array}
\right) =
\left(
\begin{array}{}
2a &b \\
b &  2c
\end{array}
\right)
$$
Note that the determinant of $P$ is positive. Many forms have stabilizers with determinant $-1$ as well.

