The vision of the world as mathematically structured is traditionally credited to Pythagoras. One of the cornerstones of this vision is the notion of musical consonance as mathematically structured. Music is built from consonant intervals, the relationships between tones that sound good together. Musically consonant intervals correspond to mathematically simple integer frequency ratios. An "A" pitch with frequency 440 Hertz and the "A" pitch an octave higher, with frequency 880 Hertz, have the frequency ratio 2:1. The 440 A relates to the 660 E that is a perfect fifth above it, with a frequency ratio of 3:2.

Musically, a song is a pattern of notes that are related by a variety of such consonant intervals. Of course songs also involve rhythmic patterns etc., but here I am just focusing on harmonic patterns.

Patterns arise in many ways, but generally they are the outcome of some sort of process. For example, tree rings appear from the varying growth rate of the tree through the regular changing of the seasons. Another kind of pattern arises as liquids cool and solidify. A quick cooling will form finer grained crystals; slow cooling allows the crystals to grow larger. Thermodynamic phase transitions, such as freezing and melting, are a rich field for the study of how order can emerge spontaneously. Musical patterns can be generated by thermodynamic simulation; consonant clusters of notes, such as chords, are similar to crystals that emerge from the process of freezing.

The algorithmic composition method I describe here relies on thermodynamic simulation to choose the pitches to be played at each time. The simulation works with a matrix of points at which a pitch is to be played. This matrix defines connections between such points. Pitches to be played at the same time are connected; pitches played at successive times are connected. Musical patterns generally have a structure of repetition and variation. The matrix is constructed with a fixed repetition structure: connections are made between pitches played at the corresponding points in successive cycles of repetitions.

Thermodynamic simulation is driven by temperature as a key control parameter. Degrees of consonance correspond to energetic possibilities. At high temperatures, pitches are chosen relatively freely; only the most dissonant choices are discouraged. At low temperature, only the most consonant choices are allowed between connected points in the matrix. Initially the points in the matrix are assigned random pitches. The simulation begins at a very high temperature, and then gradually the temperature is reduced. The pitches in the matrix are randomly reassigned again and again. Gradually patterns of mutual consonance begin to emerge.

While the temperature is still quite high, very little orderly structure has emerged: 118edo 3x3x3x3x3 1.

A graphical score also shows a lack of structure:

Here the vertical axis is the pitch, and the horizontal axis is time.

A slow cooling process will allow long range order to emerge, so eventually the entire matrix becomes consonant: 118edo 3x3x3x3x3 22

At an intermediate temperature, there can be fluctuations within an overall harmonic framework, a balance of order and variation that approaches musicality: 118edo 3x3x3x3x3 13

The harmonic movement here is quite limited. One avenue that can open up a richer harmonic landscape is the introduction of tempered tuning. The tuning used here divides octaves into 118 equal steps (118edo), instead of the conventional 12 equal steps (12edo) of a piano. Dividing octaves into some moderate number of equal steps is a practical way to organize the set of pitches used in a composition. If the pure rational intervals such as the perfect fifth 3:2 and the major third 5:4 are used, these can be combined in an infinite number of ways. If the number of equal steps per octave is chosen carefully, good approximations for these pure intervals are available: four steps of 12edo is 1.2599, quite close to the pure 1.25. 38 steps of 118edo is a frequency ratio of 1.2501, imperceptably close to the pure 1.25.

Another feature of these tempered tunings is that the infinite number of ways to combine the fundamental consonances will give only a finite number of results, within an overall pitch range. A given interval can be constructed from multiple combinations of fundamental consonances. For example, in 12edo, a major third can be reached by moving four perfect fifths up and then down two octaves. Each tuning has a different pattern of such combinational coincidences. A *Tonnetz* diagram provides a useful summary:

In this diagram, the octaves are omitted. E.g. all the ways to play a "C" note in various octaves are all represented as just "C". This diagram is for the 118edo tuning, so instead of the usual 12 note names like "C", "C#", etc., the numbers 0 to 117 are used.

The repeating structure in this diagram, e.g. the multiple occurrances of the 0 pitch, are a result of the tempering of the tuning. E.g., moving by 8 perfect fifths and then a major third will result in the same pitch where one started (moving as many octaves as needed). This property of tempered tunings introduces the possibility of loops in a compositional structure. The Tonnetz diagram shows that loops in 118edo need to be quite long: there are no short paths from a 0 pitch to another 0 pitch in the diagram.

The compositional matrix used above was given a repetition/variation structure of a five dimensional torus with circumferences uniformly size 3. This created a large space but where no large loops will easily arise. Another large compositional space is a two dimensional torus with circumferences size 18. The compositional torus can easily accommodate tuning loops as long as 18 measures. This is long enough that several loops in the tuning space can fit.

Starting the thermodynamic simulation from a random pitch assignment and gradually cooling, these sorts of tuning loops will tend to get trapped in the matrix. When the system is cooled to a very low temperature, the tuning loops remain: 118edo 18x18 cold.

The harmonic movement makes even this very orderly pattern somewhat interesting. At a moderately higher temperature, there are short term fluctuations together with long range movement, producing a composition that is even more musical: 118edo 18x18 10.