Skip to content

The Modular Group

The modular group is the group of integer matrices of determinant , taken up to overall sign. It acts on the upper half-plane by Möbius transformations , and the quotient is the modular surface — the object that continued fractions, binary quadratic forms, the Farey tree and the -invariant are all secretly about.

What makes it a good fit here is that it is a free product, . A free product has no relations to speak of, so every element is a word, and questions about the group become questions about words — which is combinatorics this catalogue already knows how to count.

The payoff at the end of the page: a conjugacy class in this group is a closed orbit of a flow, that orbit is a knot in the complement of a trefoil, and the knot's linking number with that trefoil is something you can read off the word by counting letters.

Two generators, three alphabets

The group is generated by

with the inversion and the translation . In , has order and has order ; those two are the free factors.

But there are three useful alphabets, and they name the same elements:

alphabetletterswhat a word is
the geometric generatorsan alternating product — the exponents are a continued fraction
, a positive word, unique for any matrix with non-negative entries — and it is a path down the Stern–Brocot tree
necklace up to rotationa conjugacy class — i.e. a closed geodesic

A matrix is a word

The peel is the subtractive Euclidean algorithm, so it never has to search.

source
<notatio-cell value="ModularWord(ModularMatrix(1, 1, 1, 2))" />
<notatio-cell value="ModularWord(ModularMatrix(5, 3, 3, 2))" />
<notatio-cell value='ModularTrace("LRLR")' />
<notatio-cell value="ModularSTWord(ModularMatrix(3, 2, 4, 3))" />

Why the peel never needs a search is worth a sentence: subtracts row 2 from row 1 and subtracts row 1 from row 2, so comes off when and , and when and . Both conditions at once would force and , hence determinant — impossible. There is never a choice to make.

The trace sorts elements into three kinds, and the trichotomy is the whole geometry: elliptic elements () are rotations of finite order, parabolic ones () fix a single point on the boundary, and hyperbolic ones () translate along a geodesic. Only the last kind has a closed geodesic, and a positive word is hyperbolic exactly when it uses both letters.

The trichotomy

All-L or all-R is parabolic: a word has to turn both ways to close up.

source
<notatio-cell value='ModularKind("LR")' />
<notatio-cell value="ModularKind(ModularMatrix(1, 5, 0, 1))" />
<notatio-cell value="ModularKind(ModularMatrix(0, -1, 1, 0))" />

Words are continued fractions

The / word of a positive rational is its path down the Stern–Brocot tree, and the runs of that path are its continued fraction — with the last run one short, because the final step is the arrival rather than a turn. Three objects, one description.

One object, three names

π's famous convergent: three rights, seven lefts, fifteen rights.

source
<notatio-cell value="ContinuedFraction(355 / 113)" />
<notatio-cell value="SternBrocotPath(355, 113)" />
<notatio-cell value='FromSternBrocotPath("RLR")' />
<notatio-cell value="FromContinuedFraction([3, 7, 16])" />

The Fibonacci fractions alternate perfectly — — which is the sense in which the golden ratio is the "most irrational" number: its path never commits to a direction, so no convergent is ever unusually good.

Farey

Consecutive Farey fractions satisfy ps − qr = ±1 — a determinant, i.e. a group element.

source
<notatio-cell value="FareySequence(5)" />
<notatio-cell value="FareyNeighbours(1, 3, 1, 2)" />
<notatio-cell value="FareyNeighbours(1, 3, 2, 3)" />

Closed geodesics are necklaces

Here is the step that turns geometry into counting. Conjugating a positive word by its own first letter rotates it: . So a conjugacy class of positive words is precisely a word up to cyclic rotation — a binary necklace.

And a hyperbolic conjugacy class is a closed geodesic on the modular surface. So:

closed geodesics of symbolic length binary necklaces of length , less the two constant ones (which are parabolic, not hyperbolic).

That is a closed form, , and the primitive geodesics — those not a repeat of a shorter one — are counted by the aperiodic necklaces, the Lyndon words: .

Every geodesic of a given length

Named by the least rotation, which is the canonical name of a necklace.

source
<notatio-cell value="ModularClasses(4)" />
<notatio-cell value='ModularClass("RLL")' />
<notatio-cell value='ModularClass("LRL")' />
<notatio-cell value='IsPrimitiveClass("LRLR")' />

The word length is the geodesic's symbolic period — how many times it crosses the fundamental domain. Its geometric length is , so the trace is the real weight, and the two orderings do not agree: and have the same word length but traces and . The shortest closed geodesic on the modular surface is , with trace ; its fixed point is the golden ratio.

The same cycles, as quadratic forms

Gauss got to these cycles from a completely different direction, and it is worth seeing that they are the same ones.

A binary quadratic form is , carried by its triple , with discriminant . The modular group acts on forms by substituting , the discriminant is invariant, and the orbits are the classes — the objects class numbers count.

When and is not a perfect square the form is indefinite, and the thing that makes it belong here happens: a class does not contain one distinguished reduced form but a whole cycle of them. Step round that cycle with and you are running the continued fraction of the form's root; it closes because that expansion is periodic. So

a class of indefinite forms a cycle of reduced forms a periodic continued fraction a closed geodesic.

A class is a cycle

The cycle length is always even — ρ flips the sign of the leading coefficient.

source
<notatio-cell value="FormCycle(QuadraticForm(1, 1, -1))" />
<notatio-cell value="ReducedForms(60)" />
<notatio-cell value="FormClassNumber(60)" />
<notatio-cell value="FormClassNumber(12)" />

The stabiliser of a form is generated by its automorph, built from the fundamental solution of Pell's equation :

whose determinant is and whose trace is . Since that matrix is hyperbolic — so the form's class really is one of the closed geodesics above, and it has an word like any other.

Pell, the automorph, and back to a word

The automorph fixes the form, and its word is the geodesic the class names.

source
<notatio-cell value="PellSolution(5)" />
<notatio-cell value="FormAutomorph(QuadraticForm(1, 1, -1))" />
<notatio-cell value="FormAction(QuadraticForm(1, 1, -1), FormAutomorph(QuadraticForm(1, 1, -1)))" />
<notatio-cell value="ModularWord(FormAutomorph(QuadraticForm(1, 1, -1)))" />

That the -cycles really are the equivalence classes is the load-bearing claim, and it is checked against an oracle that never mentions : given two forms, a transforming matrix must have a first column with , and along the resulting family the middle coefficient moves in steps of exactly — so the matrix is solved for rather than searched, and the check is exact.

The knots they draw

Now the geometry. The modular flow is the geodesic flow on the unit tangent bundle of the modular surface, and its closed orbits are exactly the hyperbolic conjugacy classes above. The striking fact is what that unit tangent bundle is:

The space the flow lives in is the complement of a trefoil knot in the -sphere. So every closed orbit is a closed curve in that complement — a modular knot. Étienne Ghys proved that these are precisely the Lorenz knots, the periodic orbits of the Lorenz attractor, and that their linking number with the missing trefoil has a completely elementary description:

Count the letters. That is the linking number.

Ghys's theorem, as a calculation

A geodesic that turns equally both ways has linking number zero.

source
<notatio-cell value='LinkingWithTrefoil("LLRR")' />
<notatio-cell value='LinkingWithTrefoil("LRRRR")' />
<notatio-cell value='WordSymbol("LRRRR")' />
<notatio-cell value='LinkingWithTrefoil("LLLR")' />

Where the arithmetic comes in

Counting letters is one description of that linking number. The other comes from number theory and looks nothing like it. Rademacher's function is

where is a Dedekind sum — the same sum that appears in the transformation law of the Dedekind eta function and in the exact formula for the partition numbers. The Rademacher symbol corrects into a class function:

Nothing in that formula mentions words. That equals on every hyperbolic element is the theorem, and it is what the package's tests check — one side by brute-force Dedekind sums over the matrix, the other by counting letters in a string.

The other side of the identity

Φ alone is not conjugation-invariant; only the corrected Ψ is.

source
<notatio-cell value="DedekindSum(4, 3)" />
<notatio-cell value="RademacherPhi(ModularMatrix(1, 7, 0, 1))" />
<notatio-cell value='RademacherPhi("LLLR")' />
<notatio-cell value='RademacherSymbol("LLLR")' />

The Dedekind sums are computed straight from the definition and then checked against reciprocity,

which is an independent enough statement to catch any slip in the sawtooth.

Things worth knowing

  • The sign in is real. Rebuilding a matrix from its word can hand back . That is not a bug; it is the the group quotients out, and every comparison here is up to that sign.
  • A word has to turn both ways. All- and all- words are parabolic — they fix a cusp rather than a geodesic — which is why the necklace count is always two short of the full one.
  • Word length is not geodesic length. The symbolic period counts crossings of the fundamental domain; the trace measures the actual length. Sorting geodesics by one does not sort them by the other.
  • is a quasimorphism, not a homomorphism. It is only almost additive, and it is only after the correction that it becomes an invariant of the closed orbit. Rotating a positive word cannot show the difference — the correction is constant on the positive cone — but conjugating by does.

What this connects to

  • Numeral systems — the continued fraction here is a numeral system, and the Stern–Brocot path is its digit string.
  • Binary necklaces and Lyndon words in the enumeratio catalogue count the closed geodesics exactly.
  • Class numbers and Pell's equation — the form cycles above are the arithmetic face of the same objects, and FormClassNumber counts them.
  • Lorenz knots and braids are the natural next step: Ghys's theorem says the modular knots are Lorenz knots, which are closures of positive braids, so the braid group is what turns these words into actual knot diagrams and invariants.