# Fractal music: the mathematics behind 'techno' music.

Have you ever been driven mad by your students' playing electronic music loudly? Here's how to channel their passion. Interest them with a description of the mathematics employed in its creation. This article describes sound waves, their basis in the sine curve, Fourier's theorem of infinite series, the fractal equation and its application to the composition of music, together with algorithms (such as those employed by meteorologist Edward Lorenz in his discovery of chaos theory) that are now being used to compose fractal music on computers (or synthesisers) today.

Fractal images, those colourful paisley-like patterns (e.g., the Mandelbrot and Julia sets) are visual representations of certain mathematical functions that manifest self-similarity at all scales--meaning that each small part of the fractal can be observed to be a reduced replica of the whole. They are produced by mapping the output of equations to coloured screen pixels.

The parameters in fractal music are sonic rather than visual and can include: pitch, rhythmic values and d[y.sub.n]amics (in music, variations in the volume of sound). For the first step in composing music using Mandelbrot's (1983) fractal, iterative (non-linear) quadratic equation Z [??] [z.sup.2] + c (where the solution is fed back into the equation) sonic elements are mapped. The mapping process is the link between numbers and sound. The numbers generated by the fractal equation can supply the coordinates of frequency, duration and amplitude to a composer, or, young experimenter.

The first iteration of the fractal equation Z [??] [z.sup.2] + c will present a pair of coordinates depending on the initial values of z and c--the seed (z and c can both be complex numbers--pairs of real numbers). If you process, say, 1 000 000 iterations of the equation, then you will have 1 000 000 pairs of coordinates that are all closely related and produce a seemingly complex, but self-similar pattern. The coordinates when graphed create an image with coloured pixels, and music (or noise) when musical parameters such as frequency, duration and amplitude are used.

As the reader is no doubt aware, in mathematics mapping is a law according to which every element of a given set X has been assigned a completely defined element of another given set Y, and X may coincide with Y. Many composers throughout history have used mapping in writing their compositions including J. S. Bach (Diaz-Jerez, 1999); but what are the sounds we call music and how

Physics of sound waves

Every sound and every succeeding sound can be represented by a curve (Jeans, 1988). When the prongs of a tuning fork vibrate, the vibrations are transmitted to the air, our ears feel the vibrations and we can hear a sound. Sound waves are made by adding an infinite series of sine waves (pure waveforms). That a sound wave is a sine wave can be easily demonstrated in the classroom with a tuning fork, a needle and a piece of smoked glass.

If a stiff bristle from a brush or a gramophone needle is attached to the prong of a tuning fork and that needle is run along a piece of smoke-stained glass (taking care that it moves in a straight line and at a perfectly steady speed), a wavy line will be the result; see Figure 1 from Jeans.

[FIGURE 1 OMITTED]

Fourier analysis

Today's music synthesiser, which uses computer technology to create complex sounds from the pure notes produced by simple oscillator circuits is a direct result of the calculus and the development of the technique to manipulate infinite series of functions--Fourier analysis (Devlin, 1994); calculus here being defined as differential calculus: the analysis of pattern of motion or change.

Fourier's theorem

Fourier's theorem gives a mathematical description of any phenomenon, such as a sound wave, that can be considered as a "periodic" function of time, that is, a function that keeps on repeating a cycle of values (ibid.). The pattern of any sound wave can be built up from the simple sine wave pattern produced from the sine function but it may take an infinite number of sine waves to give a particular waveform. Which is where the computer, with its power to do very many calculations very quickly, is needed. Figure 2 shows a diagram of the sine function.

[FIGURE 2 OMITTED]

Fourier's theorem states (Devlin, 1994) that if y is a periodic function of time (that keeps on repeating some cycles of values) and if the frequency of its period is, say, 100 times per second, then y can be expressed as: y = 4 sin200[pi]t + 0.1 sin400[pi]t + 0.3 sin600 [pi]t + ...

As you can see in each term the time t is multiplied by 2[pi] times the frequency. The coefficients (4, 0.1, 0.3 ...) are added to give the particular waveform y. The first term, 100, is called the first harmonic and its frequency is called the fundamental frequency. The other terms are known as the higher harmonics and are multiples of the fundamental frequency. As Devlin concludes, in effect Fourier's theorem tells us that the pattern of any sound wave (no matter how complex) can be built up from the simple, pure wave pattern produced by the sine function.

Though the technology of the music synthesiser is very recent the mathematics was worked out in the late eighteenth century by Fourier, Euler, Bernoulli and Jean d'Alembert, following the work of Newton, Leibniz, Cauchy and Weierstrass on calculus. The fractal equation was devised by Benoit Mandelbrot well into the twentieth century (1983), building on the work of Raul Julia much earlier in the century in 1917. "Julia" sets are the result of applying the mathematics of the chaos theory to computer graphics in the complex plane. Figure 1 shows how imaginary numbers are are plotted in the complex plane. (Chaos theory is the set of theories concerned with dynamical systems, i.e., systems that are in constant flux, such as the weather or air turbulence, which often behave unpredictably due to their sensitivity to minute variations of the conditions of their initial state; e.g., truncating the decimal points in an equation from say six to three.) When iterating a formula such as Z [??] [z.sup.2] + c, where z is a complex number represented by a point x + iy, the imaginary number square root of -1 causes the plotted points to reflect their positions across the axes and to rotate around the origin, (Madden, 1998).

Fractal music on the Internet

Nowadays many Internet sites describe fractal music and the mathematics that produces it. One such site is www.geocities.com/SiliconValley/Haven/4386. The site was written by composer, musician and computer programmer Diaz-Jerez (1999). His descriptions of the music available from his Internet site are interesting because they describe how different algorithms are used to produce fractal music. The equations used by Edward Lorenz in his study of weather are just some of these algorithms.

In 1963 the meteorologist Edward Lorenz used calculus as part of his research into climatology. His computer worked out answers to six decimal places but to get a compact printout while conducting a meteorological study he truncated the numbers, only printing out the first three digits. The truncation errors in the fourth decimal place were tiny compared with any of a hundred minor factors that might trigger climate change and Lorenz had assumed that such variations could only lead to slightly different solutions for the equations. He was wrong, and he immediately wrote a deep and original analysis of his results that became the beginning of chaos theory. Here are his original equations from Bourke (1997) which Diaz-Jerez (2000) claims can be equally interesting for their musical output:

dx/dt = a(y - x)

dy/dt = x(b - z) - y

dz/dt = xy - cz

On the Diaz-Jerez (2000) site the composer Diaz-Jerez details the mathematics behind the music on his CD. One of the compositions described is named the "Lorenz", after Edward Lorenz.

Lorenz (CD Fractal Sounds--Volume 1)

Here is Diaz-Jerez's example translated into commonly accepted, traditional mathematical notation. (The site notation is somewhat puzzling initially but easy to translate into correct mathematical notation: an asterisk * means multiply, a letter followed by n or n + 1 in parentheses denotes a subscript n or n + 1, and [conjunction] denotes powers, e.g., x [conjunction] 3 denotes [x.sup.3].) There are three axes X, Y and Z, and three constants a, b and c.

Lorenz. Electronic mapping of the first 20 000 iterations of Lorenz three-dimensional chaotic attractor:

[x.sub.n+1] = [x.sub.n] + (-a x [x.sub.n] x dt) + (a x [y.sub.n] x dt)

[y.sub.n+1] = [y.sub.n] + (b x [x.sub.n] x dt) - ([z.sub.n] x [x.sub.n] x dt)

[z.sub.n+1] = [z.sub.n] + (-c x [z.sub.n] x dt) + ([x.sub.n] x [y.sub.n] x dt)

The X coordinate was mapped to an absolute frequency scale ranging from 110 to 880 Hz. The Y coordinate was mapped to a duration scale ranging from 1 to 10 milliseconds. The Z coordinate was mapped to amplitude, ranging from 0.25 to 1. The intertwining orbits of this attractor are clearly audible as ascending and descending glissandi. Frequencies are realized as pure sine waves. (Diaz-Jerez, 2000)

Lorenz attractor

The output of non-linear equations provides mathematicians, scientists and composers with a vast number of coordinates. At first it appears that points appear randomly, but then it becomes clear that all points remain within the boundaries of a pattern, and the patterns revolve around a central area that seems to attract the points. These images are called strange attractors and they show the order underlying these dynamical systems. The "Lorenz attractor" was discovered when Lorenz mapped the points created during his study of meteorological data. It looks like an owl's eyes (see Figure 4) with two areas of attraction at the centre of each loop (Farrell, 2004). (Glissandi are the sounds you make when you run your hand along, say, the notes of a piano.)

[FIGURE 4 OMITTED]

The graph that produces the Lorenz attractor can be seen at the Bourke (1997) site and is shown in Figure 5 below. A commonly used set of constants is a = 10, b = 28 and c = 8/3.

[FIGURE 5 OMITTED]

Lorenz attractor exists--an interesting proof

Even very powerful, fast computers cannot work with numbers to an infinite decimal point; mathematicians have to truncate equations with answers in irrational numbers to a limited number of decimal points. Since Lorenz discovered that his equations are "sensitive to initial conditions", that tiny differences at the start become amplified exponentially with the passing of time, mathematicians have been looking for a rigorous proof that exact solutions of the Lorenz equations will resemble the shape generated on a computer by numerical approximations. Stewart (2000) describes the proof that was produced by W. Tucker in 1999. The mathematics used by Tucker was rigorous, taking about 30 hours on a fast computer.

Students and techno

As for the music produced by the fractal equation and synthesisers, some students love it and some hate it, but all students will willingly debate its merits. One of the terms students use to describe such music is techno. Two Internet sites that offer software for students to compose their own fractal music are Diaz- Jerez (2000) and Musinum (2003). The Diaz-Jerez program, FractMus, writes standard MIDI files from students' compositions and also translates compositions into fractal images. Both FractMus and Musinum require Windows.

Integrated curriculum aspects

Obviously computer-generated music and the fractal equation may be introduced with the commencement of the study of calculus (sine curves, gradients) and after students have mastered algebra. The tuning fork experiment may be easily executed in class with or without cooperation from a physics teacher. The use of Fourier analysis and Mandelbrot's fractal equation in the generation of computer or techno music could be mentioned as an interesting application, along with other well-known applications of the fractal equation in studies of climatology, coastlines, soil erosion, mountains, seismic patterns and other aspects of nature such as: snowflakes, ferns, the branches of a tree, and the florets of a cauliflower.

Fractals, iterations and self-similarity are also part of undergraduate studies in mathematics at good universities in Australia and abroad. Music students and those students interested in studying computer science at university would perhaps be interested in the binary notation aspects of computer-generated music in the postscript attached (see below).

The study of fractals is a good way to introduce topics such as fractal geometry and the fractal equation. Learning about fractal music is a rich context for learning fractals, mapping, iterative equations, self-similarity, the Mandelbrot and Julia sets, and aspects of number theory such as: real and imaginary numbers, prime numbers and bases other than 10. Most students are interested in music (and computers) and may be motivated to learn mathematics by studying, for example, the Lorenz attractor and the techno music it produces when mapped to sonic parameters.

American educators state the study of fractals aids the study of a wide variety of topics in the K-12 curriculum including scientific notation, coordinate systems and graphing, number systems, convergence, divergence and self-similarity. See the National Center for Supercomputing Applications (NCSA) education site The Fractal Microscope at http://archive.ncsa.uiuc.edu/Edu/Fractal/ Fractal_Home.html for details about how students can be motivated to learn fractal geometry. For example, instead of a teacher telling students to learn about a given set of axes and its coordinate system, zooming in on a fractal image actually encourages students to ask the teacher about these systems.

NB: Although it is not certain whether the study and enjoyment of music helps the study of mathematics, it is possible, since both are symbol systems and the recognition of pattern is important for both.

Aesthetics

As to whether music produced by the fractal equation is good music it must be remembered that:
``` Although there is nothing in principle to
prevent any kind of mathematics from being
used to generate some sort of music, very
little music (if any) that currently exists can
be explained entirely in terms of mathematics.
The presence of the
culturally-situated mind guarantees this
non-commutative relationship. (Borthwick,
2000, p. 662.)
```

It is of course primarily the composer's musical talent that determines the quality of a piece of music. As Diaz-Jerez (1999) comments, plugging in some parameters and pushing a few buttons is not going to produce a masterpiece! This said, the use of mathematics and computers has produced some good music, although it lacks a human dimension in performance (Crotty 2001).

Composers Gyorgy Ligeti and Charles Wuorinen have been working with fractals for decades as part of their compositional procedure (Quaglia, 2000). Also, one of Larry Sitsky's compositions Quartet for Wind incorporates sequences that are initially generated by a random number generator and are subsequently manipulated by computer transformations (Nisbet, 1991).

According to Diaz-Jerez (1999, p. 110): "it is an arresting thought that something produced from a purely mathematical procedure can be so aesthetically pleasing". I wonder if mathematics teachers and students would agree with him? Debate this with your class!

[FIGURE 3 OMITTED]

Acknowledgment

Many thanks to Gad Abraham and Kim Renner for their comments, and to musicologist Joel Crotty of Monash University for a very interesting interview.

Postscript

For students and teachers who are interested in more detail (including composing and musical notation).

Fractal music sites on the Internet

Diaz-Jerez's (2000) FractMus site is a site where twelve algorithms from fractals, number theory and chaotic dynamics are used to generate music. Musinum (2003) has a similar site and program, and there are no doubt others on the Internet. (Please note that the two programs named are written for Windows PCs.)

Remember, the algorithms that generate fractal images and music are very simple and they are looping: the solution of the equation is repeatedly fed back into itself.

There is no one way to map numerical output to music. Different mappings can be applied to the same numerical output. For example, the output of fractal equations can be mapped to different sets of notes and the music will differ accordingly (Diaz-Jerez, 1999).

One of the most fertile algorithms, the Morse-Thue sequence (ibid.), shows self-sufficiency. It is generated by the non-negative integers 0, 1, 2, 3, 4, 5, 6, and so on, expressed in binary notation, or base 2. (Binary notation, the simplest notation, only uses the digits 0 and 1. Computers always calculate in binary notation because it can be easily mapped to electrical devices. The presence of current is represented by 1 and no current by 0. The basis of binary notation is, of course, Boolean algebra.)

Diaz-Jerez (1999) gives the following example of the Morse-Thue sequence: it is generated by the non-negative integers 0, 1, 2, 3, 4, 5, 6 and so on, expressed in base 2 or binary notation:

0 1 10 11 100 101 110 111 1000 1001 ...

Take the sum of the digits modulo 2 (known as the "digital root") of each number, thus forming the following sequence:

0, 1, 1, 0, 1, 0, 0 ...

This sequence can also be generated by iterating the map: 0 is changed to 01 and 1 is changed to 10. Starting with a single 0 you can make a "tree":

[ILLUSTRATION OMITTED]

Also, you can create each generation by appending the complement of the preceding one, as follows:

[ILLUSTRATION OMITTED]

The sequence shows a high degree of self-similarity; for example, if every term in the sequence is removed the sequence remains unchanged:

[ILLUSTRATION OMITTED]

Also, removing every second couple keeps the sequence unchanged:

[ILLUSTRATION OMITTED]

To make music the composer selects a base in which to count (in the original sequence, base 2), multiplies the number shown in the Start Counter (say 17) by the multiplier chosen, then converts to the selected base. For example, for base 3, multiplier 3 and Counter 17:

3 * 17 = 51 [right arrow] base 3 = 1220

The digits of this number are then added, (in base 10):

1 + 2 + 2 + 0 = 5

and made the modulo operation with the number of notes in the scale, times the number of octaves. Assuming you are using C major (7 notes) and one octave it gives:

5 mod (7 * 1) = 2

This is then added to the starting note. Some base-multiplier combinations give an amazing variety, while others do not (Diaz- Jerez, 2000).

For "Morse-Thue Numbers (Base 2)", Diaz- Jerez (2000) describes the sonification of the natural number sequence in the following manner:
``` The first 1000 multiples of the first 10 000
natural numbers were calculated in
sequence, yielding ten million data points:

1, 2, 3, 4, 5, 6, ... 1000;
2, 4, 6, 8, 10, 12, 14, ... 2000;
3, 6, 9, 15, 18, 21, ... 3000;
4, 8, 12, 16, 20, 24, 28, ... 4000.

All numbers were then expressed in binary
notation (base 2):

1, 10, 11, 100, 101, 110, ... ;
10, 100, 110, 1000, 1010 ... ;
11, 110, 1001, 1100, 1111, ...

Finally the digits in each number were added
giving the final sequence:

1, 1, 2, 1, 2, 2, ... , 1, 1, 2, 1, 2, ... , 2, 2, 2, 2,
4, ...

This ten million data set was then
normalised to the interval [-1, 1] and interpreted
as a wave form at 44.1 kHz (kilohertz:
a unit of frequency equal to 1000 hertz: one
cycle per second) sampling rate. With Morse-
Thue Primes and Morse-Thue Primes (8 kHz)
the first 10 000 and 2000 prime numbers
respectively are used to produce music (Diaz-
Jerez, 2000).
```

3n + 1 numbers

Other algorithms such as "3n + 1 numbers" can be mapped to musical parameters in a similar way. 3n + 1 numbers or "hailstone numbers" are described as follows:
``` Take any whole number greater than 1. If it
is even, divide it by two, if odd, multiply by 3
and add 1; continue with this process until
you reach the number 1..... Take for example
the number 7. It generates the following
sequence:

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5,
16, 8, 4, 2, 1, 4, 2, 1, 4, 2, 1 ...
(Diaz-Jerez, 2000)
```

It is thought that all numbers "fall" to 1 after a finite number of iterations. Some numbers have very long sequences before falling to 1. Others have shorter sequences with 27 as the smallest. Although the sequences seem chaotic there is a hidden order in the music generated, according to Diaz-Jerez (2000).

Self-similarity

If all the above seems an inordinate amount of trouble to exert in order to produce a few numbers to feed into a computer, it should be noted that one of the most interesting aspects of fractal music is its self-similarity. If you have self-similarity in the integers it is reflected in the music. If you remove every other note of the melody, you are left with the same melody as the original. If you repeat this procedure with the already truncated melody, the result is no different. Therefore, the melody is self-similar. See Figure 6 below to see Diaz-Jerez's examples of this in musical notation.

[FIGURE 6 OMITTED]

Diaz-Jerez (1999) contains the addresses of several Internet sites that are sources of other algorithms and programs students may use to compose their own music, although unfortunately some are now out-of-date. Two of them still available are the (already mentioned) www.geocities.com/SiliconValley/Haven/4386, and Musinum: www.forwiss.uni-erlangen.de/~kinderma/musinum. Or, a general search for "fractal music" may be conducted.

References

Borthwick, A. (2000). Review of Books: Fractals in music: Introductory mathematics for musical analysis, by Charles Madden. Music & Letters, 81, 661-662.

Bourke, P. (1997). The Lorenz Attractor in 3D. Retrieved 8 August 2004 from http://astronomy.swin.edu.au/~pbourke/fractals/lorenz.

Crotty, J. (2001). Interview of musicologist by author, 2 November.

Devlin, K. (1994). Mathematics: The Science of Patterns (p. 52). New York: Scientific American Library.

Diaz-Jerez, G. (1999). Fractals and music: Patterns in nature can be a musical inspiration. Electronic Musician, October, 108-113.

Diaz-Jerez, G. (2000). Fractmus: Fractal Music Composition Software. Retrieved 8 August 2004 from http://www.geocities.com/SiliconValley/Haven/4386/algorith.html.

Guedj, D. (1998). Numbers: The Universal Language. London: Thames & Hudson.

Jeans, J. (1937). Science and Music. Cambridge: Cambridge University Press.

Madden, C. (1999). Fractals in Music: Introductory Mathematics for Musical Analysis. Salt Lake City, Utah: High Art Press.

Mandelbrot, B. (1983). Fractal Geometry in Nature (rev. ed.). New York: W. H. Freeman and Company.

Musinum (2003). Music in the numbers. Retrieved 8 August 2004 from http://www.forwiss.uni-erlangen.de/~kinderma/musinum.

National Center for Supercomputing Applications (2003). The Fractal Microscope. Retrieved 8 August 2004 from http://archive.ncsa.uiuc.edu/Edu/Fractal/Fractal_Home.html.

Nisbet, S. (1991). Mathematics and music. The Australian Mathematics Teacher, 47 (4), 4-8.

Stewart, I. (2000). The Lorenz attractor exists. Nature, 406 (6799), [August 31] 948-949.

Quaglia, B. (1998). Reviews: Publications--Charles Madden: Fractals in music: Introductory mathematics for musical analysis. Computer Music Journal, 24, 84-86.
COPYRIGHT 2005 The Australian Association of Mathematics Teachers, Inc.
No portion of this article can be reproduced without the express written permission from the copyright holder.
Author: Printer friendly Cite/link Email Feedback Padula, Janice Australian Mathematics Teacher 8AUST Jun 22, 2005 3850 The history of the calculus. Hands-on numbers. Mathematical logic Mathematics Mathematics education Symbolic and mathematical logic Techno music