Maths WorkshopMaths problems with full solutions
Exercise 1652Number theory › Divisibility and gcdL1Added 3 Nov 2026

GCD via the Euclidean matrix

#gcd#Euclidean algorithm#matrix

Statement

Show that the Euclidean algorithm applied to (a,b)(a,b) can be written as a sequence of matrix multiplications with matrices in SL2(Z)SL_2(\mathbb{Z}), and deduce that the gcd is preserved.

Hint

Each step (a,b)↦(b,a−qb)(a,b)\mapsto(b,a-qb) is left multiplication by (011−q)\begin{pmatrix}0&1\\1&-q\end{pmatrix}, which has determinant −1-1.

Show solutionHide solution

Solution

Step. If a=qb+ra=qb+r, the transformation (a,b)↦(b,r)(a,b)\mapsto(b,r) is (011−q)(ab)=(ba−qb)\begin{pmatrix}0&1\\1&-q\end{pmatrix}\begin{pmatrix}a\\b\end{pmatrix}=\begin{pmatrix}b\\a-qb\end{pmatrix}.

Determinant. det⁡(011−q)=−1\det\begin{pmatrix}0&1\\1&-q\end{pmatrix}=-1, so this matrix is in GL2(Z)GL_2(\mathbb{Z}) with inverse (q110)\begin{pmatrix}q&1\\1&0\end{pmatrix}.

GCD preservation. The map (a,b)↦(b,a−qb)(a,b)\mapsto(b,a-qb) preserves gcd⁡\gcd because the two components generate the same ideal in Z\mathbb{Z}.

Conclusion. The Euclidean algorithm is a sequence of elementary transformations in GL2(Z)GL_2(\mathbb{Z}), and the gcd is preserved.