TITLE: Enumerating cosets of the modular group
QUESTION [6 upvotes]: Suppose we chose the generators $f(z) = z+1, g(z) = z-1, h(z) = -1/z$ for the modular group $\Gamma$ (i.e. the group of fractional linear tranformations $z \mapsto (az +b)/(cz+d)$ with $a,b,c,d \in \mathbb{Z}$ and $ad - bc = 1$).
I would like to know of an algorithm for producing "words" in (i.e. compositions of) the generators $f,g,h$ such that one obtains exactly one element of each coset of $\Gamma/H$ where $H$ is the subgroup generated by $f$.
I'm interested in this because it would help me make better pictures of the modular group.  I wrote a program (available here) for making pictures in the hyperbolic plane such as the following:
(source)
The above picture was generated by applying all words of length less than a certain length (maybe 12 or something) to a single "triangle+stickman".  The chosen generators were $h$ and $h \circ f$ which give the modular group the structure of a free product of finite cyclic groups.
However the pictures are unsatisfactory and do not improve as much as one would like by increasing the "depth" (i.e. max length of words chosen).  It seems better to go deep into each coset (i.e. apply $f$ and its inverse a bunch of times) and then transform that.  Here's a picture with just 8 cosets (but many transformations were chosen for each):
(source)

REPLY [3 votes]: The specific question you asked has been answered, but you asked for an algorithm, and there does exist an implemented algorithm that can solve problems of this type.
Under certain conditions, which are roughly equivalent to $H$ being a finitely generated quasiconvex subgroup of an automatic group $G$, you can construct a "coset word acceptor" as part of a "coset automatic structure" for $H$ in $G$, where $G$ is defined by a finite presentation, and $H$ is defined by a finite set of generating words. The coset word acceptor is a finite state automaton which accepts a unique word over the generators of $G$ for each right coset of $H$ in $G$. In particular, this will work for any finitely generated subgroup of a virtually free group, as in your example.
The algorithm is implemented as part of the $\mathtt{kbmag}$ package, which is available as a standalone or as a $\mathsf{GAP}$ package. With your example, the coset word acceptor has $6$ states.