To explore the mathematics of music, it is important to begin with the basics. Most simply, math can be seen in music through basic geometry. Moving from one key to another is as simple as applying a translation. Build a graph with the note letter as one axis and flat, natural, and sharp (in repetition) as the second axis. Then any note can be plotted on the graph as a point, and any melody can be plotted as a line. To switch from one key to another, it is as simple as translating that line. Take the point that is the center of the key (for C major it would be a C natural) and translate it to the point that is the center of the new key. The melody line simply needs to follow the same translation, and the new line will be the melody in the new key.
A similar idea can be applied to reflective melodies. Just as shapes in geometry can reflect over a line, melodies in music are often reflected over a note and played in succession with the original melody. However, this is easier accomplished with more complicated mathematics than line reflections. Canons and fugues can be written with ease when done with permutations. This is done using a musical idea called counterpoint. Counterpoint is when there are multiple melodies that are in harmony with each other, but are different in melody and rhythm. To find these mathematically, permutations can be built with numbers assigned to the notes of a diatonic scale. The melody is written across rows and then down columns. "To write a counterpoint, it is necessary to insert other voices that produce consonant intervals between them and the first melodic line (cantus firmus). To find consonant notes with respect to the first voice, we can move along the corresponding co-diagonal" (Mazzola, Mannone, & Pang, 13). This is a quick way to find a counterpoint that is still in harmony with the original melody while maintaining its independence.
Music is also full of ratios. "When plucking two strings of the same length, the ratio between their lengths is 1:1, resulting in identical and harmonious sounds (sounds that blend well together). Moreover, differing ratios of string lengths will produce various harmonic intervals, such as the octave (string ratio of 1:2), the fifth (2:3), and the fourth (3:4)" (Azaryahu, Ariel, & Leikin, 1). Musicians determined long ago that each harmonic interval traditionally sounds better when followed by specific harmonic intervals. This can be explained by their ratios. These ratios are also useful for key changes. Geometric translation can be used to change the key of the melody, and these ratios can be used to preserve the harmony. If the harmonic ratios from the original piece are applied to the transformed melody, they will produce the same harmony in the new key. However, these ratios are not always rational, despite the implication. "Traditionally, scales of Western music were, and still are, theorized as further subdivisions of a big musical interval represented by the ratio 1:2, called the octave . A modern piano has twelve keys inside each octave, and, to make the distance between the tones equal, each tone has to be higher than the previous one by the twelfth root of two, which is an irrational number." (Braguinski, 15). Thus ratios explain dissonance as well. Playing two tones that are directly next to each other causes what musicians call dissonance, a set of tones that are not in harmony and cause the listener to feel unsettled. This dissonance can also be explained by ratios: two tones that are adjacent are unable to be written as a rational ratio, but instead must be written as an irrational ratio using the twelfth root of two.
Fractals can also be found in music. Fractals in geometry are defined by the function log N = c - D log r, where N and r are variables, c is a proportionality constant, and D is the fractal dimension. With this function in mind, Crilly, Earnshaw, and Jones explored how to mathematically represent a piece of music. "After considerable investigation we suggest that the length of a music score, Ei, can be represented by the sum of all note intervals in a composition, i.e., all the primaries, seconds, thirds, fourths, ... , etc., with values of i equal to 1, 2, 3, 4, 5, ... , etc. The shortest beat of a composition can be considered the unit C to measure the 'length' of the total intervals, i, of a music score. If the shortest 'length' is a sixteenth beat, we can measure the total interval by summing up the note intervals between successive sixteenth beats" (Crilly, Earnshaw, & Jones, 29). By using this representation, they found that the sums of many classical compositions, especially those by Bach, can also be represented by the fractal function. In contrast, many examples of "natural music", like the singing of birds, are not able to be represented by the fractal function using the same summation representation. Thus it can be observed that fractals are something that are unique to music, not just a characteristic of sound.
Probability concepts can also be used to find the key of a composition. This uses an idea called "Key-Profile Analysis" (White, 250). To perform a Key-Profile Analysis, one must first build the pitch-class distribution for the composition. A pitch-class distribution is a model of the occurrence frequency of every tone within the piece. Every key signature has an expected value pitch-class distribution. To determine the key signature of a composition, compare its pitch-class distribution to the expected value distributions. The closest match is the most likely key signature.
The optimal voice leading can also be found through mathematical models. Specifically, through matrices. Optimal voice leading is the optimized number of voices and their tones to connect a chord to the tonal center of a piece of music. First a matrix link must be formed using "the number of voices... (and) the nabla distances between all the classes of X and TC" (Montiel, Agustin-Aquino, Gomez, Kastine, Lluis-Puebla, & Milam, 224). Then a combinatorial optimization algorithm is applied, called the Hungarian Method (225). The new matrix resulting from this algorithm will give the optimal voice leading.