algorithm for reducing to the fundamental domain $\mathbb{H}/SL(2,\mathbb{Z})$ I have $y << 1$ and $x \in [0,1]$ uniformly chosen at random and I want to find its representative in the fundamental domain with $\big|\mathrm{Re} \; \tau \big|< \frac{1}{2}$ and $|\tau| > 1$.  

How do we find this representative? And how it related to the Euclidean algorithm.

This question has been considered by Gauss and Legendre, and has been studied quite recently. The magic words are "lattice reduction in two dimensions", and a magic reference is this paper of Vallee/Vera
