Visualizations
294 / 500

294 · Fractals

Indra's Pearls

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.

  • Grandma's recipe
  • Depth-first word search
  • Newton's method on Farey trace polynomials
  • Additive glow strokes

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

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.
PreviousEuclidean RhythmsRisograph bead rings play world rhythms made by a neutron accelerator timing algorithm. NextFireworksShells arc, burst and crackle with glowing, fading sparks.

Related visualizations

  • Apollonian GasketFractals An endless packing of kissing circles, each engraved with its exact integer curvature.
  • Newton BasinsFractals Drag the roots of a polynomial and Newton's method paints a fractal.
  • Lyapunov FractalFractals Type a string of A and B and the logistic map grows gold and teal enamel jewelry.
  • Julia SetFractals A fractal that reshapes itself as its complex constant wanders.
  • Hyperbolic TilingMath An endless koi garden of {p,q} ponds tiling the Poincare disk, with fish circling.
  • IFS EditorFractals Sculpt fractals by dragging affine parallelograms while the chaos game redraws them.
  • Root BraidsMath Loop a quintic's coefficients and its roots braid, swap and refuse to come home.
  • Road to ChaosMath The logistic map's bifurcations, Mandelbrot bulbs and a cobweb, linked in one picture.
  • Sound of MandelbrotFractals Hover the Mandelbrot set to see and hear orbits: each bulb's period plays as a loop.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs