Math you can hear#

Mathematicians and musicians have been borrowing from each other for a very long time. These pages collect fourteen of those meetings, from Sanskrit poetry to Steve Reich, and turn each one into something you can play.

Every example has the same three parts, so you can connect what you read, what you see and what you hear:

  1. A formula, in the words of the person who found it.
  2. A few lines of Python that turn the formula into an eddy pattern. Edit them, or move the sliders and dropdowns.
  3. A picture of the pattern, with a cursor. Press ▶ Play and a cursor moves over the picture in time with the music, so you can see which part of the math you are hearing.

Controls change the music on the next loop, without stopping it. Only one player sounds at a time, and ■ Hush stops it.

How the pictures are drawn#

The drawings are plain SVG built from strings, one small function for each kind (blocks, ring, curve, cloud, braid, lattice, tiles), with nothing beyond eddy, marimo and numpy. Each returns an eddy.marimo.Picture: the SVG plus a list of cursor marks, each with the cycles during which it shows.

Mark Draws
cursor.sweep(begin, end, x0, x1, top, bottom) a vertical line that moves from x0 to x1
cursor.dot(begin, end, x, y) a ring around a point
cursor.hand(begin, end, cx, cy, r) a clock hand that turns once round
cursor.outline(begin, end, points) the outline of a polygon

player.load(render(pattern, cycles, cps), picture) plays the pattern and draws the marks on the picture from the player's own audio clock. The drawing functions are in the notebook, where you can read and change them.

Take it into a notebook#

Math you can hearAll fourteen examples in one notebook. molab is marimo's free cloud notebook service: it installs eddy for you, and you can change any of the code.

More to try#

A few connections that are not here yet, each a short step from the code on these pages:

  • Markov chains. Hiller and Isaacson's Illiac Suite (1957) and Xenakis' Analogique A draw each note from a table of probabilities that depends on the last one.
  • Twelve-tone rows. Transposing, inverting and reversing a row are the symmetries of a 12-sided polygon; rev and a minus sign get you most of the way.
  • Orbital resonances. The planets of TRAPPIST-1 circle their star in near-whole-number ratios, which is a polyrhythm: .fast(8 / 5), .fast(5 / 3), ...
  • More of Simone Conradi's pictures. Julia sets, chaos games with Möbius maps, Newton fractals: any picture made by following points gives you a path to play.

eddy is the pattern engine of Vortex, the Python port of TidalCycles, repackaged with a numpy synth. GPL-3.0-or-later. The examples run in your browser with marimo islands and Pyodide.