Limit sets of Kleinian groups, strung as glowing necklaces of nested circles and pearls.
Two complex traces, ta and tb, become a pair of Mobius maps through 'Grandma's recipe' from the book Indra's Pearls, chosen so the commutator abAB is parabolic. A depth-first search walks the tree of reduced words in a, b and their inverses; for each word it maps three fixed points of commutators and generators, and once those images are within a pixel of each other it draws the short arc between them and backs up. The leaves arrive in order along the limit set, so it is drawn as one continuous necklace, with a pearl on the circle through each branch's three points. Cusp groups on the boundary of the Maskit slice are found live with Newton's method on trace polynomials built by the Farey recursion, and the small trace plane plots that fractal boundary.
Try it. Drag the ta and tb handles on the trace plane, or drag anywhere on the necklace to nudge ta. Click a ring on the pad, or press 1 to 9, to snap to a cusp group or a classic. C swaps pearls for nested circles; Space resumes the tour.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Draw the limit set of a Kleinian group, the lace-like fractals from the book Indra's Pearls, with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Write tiny helpers for complex numbers and for 2x2 complex matrices (multiply, invert, apply as a Mobius map z -> (a z + b) / (c z + d)).
- Implement "Grandma's recipe" from the book: from two complex traces ta and tb, compute tab = (ta tb - sqrt(ta^2 tb^2 - 4 (ta^2 + tb^2))) / 2, then z0 = (tab - 2) tb / (tb tab - 2 ta + 2i tab), and build the generators a and b with the formulas given in chapter 6. Let A and B be their inverses. Start with ta = tb = 2.
- Order the generators a, b, A, B. For each generator g, find the attracting fixed point of g itself and of the two commutators that start with g and go around the list one way and the other (for a these are abAB and aBAb).
- Do a depth-first search over words: for a word W ending in generator g, map those three fixed points by W. If they are within about a pixel of each other, draw lines between them; otherwise recurse into W times each of the three generators that does not undo g, in cyclic order. Cap the depth at about 60.
- Fit the drawing to the window. With ta = tb = 2 you should see an Apollonian gasket.
Once that works, make it beautiful:
- Use a dark background, additive blending and two passes per line (a wide faint glow, then a thin bright line), with the color drifting along the curve.
- Let the mouse drag ta around a small complex-plane pad and redraw live. Try ta = 1.91 + 0.05i, tb = 2, and ta = 1.958591 + 0.011279i, tb = 2.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as solving for cusp groups with Newton's method, drawing the nested circles at each depth, or animating between groups.