PRiMAL
Explore with PRogramming, Math, and ALgorithms...
(under construction)


Musical scales
A fascinating (unpublished) idea by myself and my PhD student based on number theory can produce patterns that resemble the keys on a piano. It is given by tracing the points $(k, ka \bmod n)$ for $k=0,\ldots, n$, where $\gcd(a,n)=1$. Observe how Figure 4 mimics the sequence of white and black keys in an octave, but with an added dimension. Since the modulo operator wraps around vertically, and assuming $k=n$ coincides with $k=0$ horizontally, this is really a two-dimensional torus. In the following figure, the scale given by $(k, 5k \bmod 12)$ for $k=0,\ldots,12$, peaks are the sharps (in black).

Define the white distance of two non-peaks as the number of non-peaks between them plus one, and their chromatic distance as the number of peaks and non-peaks between them plus one. For any given non-zero white distance, how many chromatic distances exist? All these mathematical questions can be explored using a program, and sometimes a simple visualization with desmos. Once conjectures are made, the math will heavily rely on number theory.

Following this, a flavor of algorithmic music composition can be explored. For instance, are there chords of length $\ell$ (i.e. consisting of $\ell$ non-peaks) that exhibit specific chromatic distances among the $\ell$ notes? Can an algorithm for finding such chords benefit from the math and avoid exhaustive search?

Some advanced open-ended explorations include: Do ``beautiful" chords have specific geometric structures? Do we gain anything by making the points $(ak \bmod n, bk \bmod n)$ where $\gcd(a,n)=\gcd(b,n)=1$ and sorting them by their $x$-coordinates? What if we drop the co-primality requirement?