ON BACH’s MUSIC & MATHEMATICS
Bach’s Invisible Architecture: The Mathematical Underpinnings of a Musical Genius
How Network Theory, Group Theory, and Fractals Reveal the Complexity of Harmony in Johann Sebastian Bach’s Music
Mathematical patterns and structures in Johann Sebastian Bach's music are legendary. Many avenues have been taken into the mathematical analysis of his work, but some of them are especially intriguing.
Researchers have used, for example, network theory to analyse Bach’s compositions, representing scores as networks of nodes (notes) and edges (transitions between notes). They found that Bach’s music, particularly toccatas and preludes, has higher information entropy compared to randomly generated networks as a measure. This means that these pieces are more information-rich and contain more surprises[1][2]. Chorales, which are hymns meant to be sung, have networks that are relatively sparse in information but still more information-rich than random networks. In contrast, toccatas and preludes, which are often written for keyboard instruments and are meant to entertain and surprise, communicate a wealth of information through their complexity[1][2].
Bach’s music also demonstrates various types of symmetry, such as inversion and transposition. These techniques can be interpreted as group operations in group theory, which is the mathematical framework for symmetry. Such symmetries are integral to Bach’s compositional techniques and contribute to the structural beauty of his music[3][4].
😉 Entropy is a measure of information richness, unpredictability, or complexity in Bach’s music, indicating how varied and surprising the compositions can be.
Bach-Entropy Versus Random-Walk
To quantify the information in Bach’s music, researchers use the entropy of random walks on networks of note transitions by constructing and analysing networks where notes are represented as nodes and transitions between notes as edges. This approach allows for the quantification of the information content in Bach’s compositions through several key steps.
Each piece of music by Bach is conceptualized as a network where each note (considering its pitch and duration) represents a node, and each transition from one note to another is represented by an edge connecting these nodes. This network representation captures the structure and complexity of musical compositions[7].
😉 A random walk on a network is a path that consists of a succession of random steps on nodes.
The entropy of these networks is calculated using the concept of random walks. A random walk on a network is a path that consists of a succession of random steps on nodes. The entropy of a random walk reflects the unpredictability or randomness of the path taken through the network. In the context of Bach’s music, higher entropy indicates a greater level of complexity and information richness because it suggests a higher number of possible paths (or note transitions) that could be taken, reflecting the intricate structure of the compositions[5][7].
To assess the information content of Bach’s music, researchers compare the entropy of the music networks to that of randomly generated networks. This comparison reveals to which extent Bach’s compositions have higher entropy than random networks, indicating that they are more information-rich and complex. This higher entropy suggests that Bach’s music is not only highly structured but also contains a level of unpredictability and surprise, contributing to its aesthetic and emotional impact[5][6].
By quantifying the information content through entropy, it is possible to group and categorize different kinds of Bach’s compositions according to their information content and network structure. This analysis shows that various compositional forms by Bach, such as fugues and choral pieces, can be categorically distinguished based on their information richness and the structural properties of their note transition networks[7].
By applying the principle of maximizing entropy, it is further possible to explore how the structured information in Bach’s music might be inferred by humans. Using a model for human inference of networks, the findings suggest that Bach’s music communicates large amounts of information while maintaining small deviations from the true network structure. This implies that the compositions are efficiently structured for communication, enabling rapid and effective transmission of musical information to listeners[7].
The Bach-Entropy of Chorales, Toccatas, and Preludes
Chorales, toccatas, and preludes are two types of compositions by Johann Sebastian Bach that exhibit different levels of information density when analysed through the lens of network theory.
Chorales are hymns that are meant to be sung by a congregation, usually with a simple and catchy melody carried by soprano singers, while the lower voices provide harmony. These pieces are very meditative and designed for group singing in churches. When analysed using network theory, interestingly, chorales are found to have relatively lower entropy compared to other forms of Bach’s compositions. This lower entropy indicates that chorales are in their structure less complex and more predictable, which aligns with their purpose of facilitating congregational singing and meditation[8][2].
Toccatas and preludes, on the other hand, are often written for keyboard instruments and are intended to entertain and surprise the listener. These compositions are characterized by their complexity and a higher level of information entropy. When represented as networks of note transitions, toccatas and preludes show a greater number of possible paths or note transitions, which reflects their intricate structure and the element of surprise they are meant to convey. This higher entropy suggests that these pieces are more information-rich and complex, providing a wealth of information through their elaborate musical narratives[2].
Mathematical Structure and Symmetry in Bach’s Music
Bach’s compositions are celebrated for their use of symmetry and counterpointing musical techniques. These can be analysed through the lens of mathematics, particularly group theory. Inversion, for instance, is a technique where a musical theme or motif is mirrored around a central axis, so that each interval in the original sequence is replicated in reverse direction. For example, if the original theme moves up a step, the inverted theme moves down a step. This technique creates a notion of symmetry that can be mathematically described and contributes to a thematic development within a piece.
Transposition, another technique, involves shifting a piece of music to a different key. This means that the entire piece is played using the same intervals between notes but starting from a different root note. Indeed, in group theory, transposition can be considered an operation that moves every element of a set (the notes of a piece) consistently, while maintaining the structure of the music but changing its tonal centre.
Another remarkable technique is retrograde. Here, a musical line is just played backwards. Retrograde inversion combines both retrograde and inversion, meaning the theme is played backwards and upside down. These techniques create a palindromic form of symmetry that can also be analysed mathematically.
A more sophisticated musical form, in Bach’s work, is canon. Etymologically, the name is ultimately derived from the Arabic word, “qanun”, via Greek, “kanon”, meaning “law” or “rule”. In a canon, a melody is introduced and then imitated after a short delay by another voice or instrument at a different pitch. A fugue is an even more complex form where a theme is introduced by one voice and then successively taken up by others. These forms rely on strict rules of counterpoint, which can be considered as mathematically precise notions, through the ways they create complex patterns of repetition and variation.
From Symmetry to Calculated Asymmetry
While not directly related to group theory, Bach’s music often exhibits proportional structures that can be analysed mathematically. For example, the number of measures in certain sections of his music sometimes relates to each other in ways that can be described using ratios or other mathematical relationships, reflecting calculated asymmetries.
The Golden Ratio and Fibonacci numbers are mathematical concepts that have fascinated artists, architects, and musicians for centuries due to their appearance in nature and their aesthetic properties. The Golden Ratio, approximately equal to 1.618, and the Fibonacci sequence, where each number is the sum of the two preceding ones (0, 1, 1, 2, 3, 5, 8, 13, …), are often cited for their supposed presence in art and music, suggesting a universal aesthetic appeal.
There has been speculation and analysis regarding the presence of the Golden Ratio and Fibonacci numbers. Some researchers and music enthusiasts have attempted to find such patterns in Bach’s works, for example in the distribution of movements in a suite, the arrangement of sections within a piece, or the timing of key events in his compositions. The idea is that Bach might have used these mathematical principles to achieve a balance and beauty in his music that resonates with the natural order and proportions found in the Golden Ratio and Fibonacci sequence.
However, despite these speculations, there is no conclusive evidence that Bach intentionally incorporated the Golden Ratio or Fibonacci numbers into his compositions. Although it is possible to observe instances where the proportions of the Golden Ratio or the sequence of Fibonacci numbers can be observed, these occurrences might be merely coincidental or a result of Bach’s inherent sense of balance and proportion.
Final Fractal Thoughts
Indeed, Bach was known for his profound creative understanding of music theory, his skill in counterpoint, and his ability to invent and create complex and emotionally compelling compositions.
Hence, it is likely that his compositional inventions and decisions were driven predominantly by musical intuition, highly structured artistic expression, and the conventions of the Baroque period, rather than by an explicit intention to use mathematical patterns. Researchers and musicians have even explored the fractal aspects of Bach’s music, noting that certain pieces exhibit fractal-like structures.
😉 A fractal is a pattern that repeats, similar to itslef, at different scales, showing similar complexity no matter how closely you look at it, much like zooming into a never-ending, intricate design.

For example, Harlan Brothers — a jazz guitarist and mathematician — has identified fractal structures in Bach’s work, such as the phrasing of notes in the Cello Suite №3, which he reported in a study published in the journal Fractals in 2007[9]. Brothers’ analysis suggests that the suite’s self-similarity bears a resemblance to the Cantor Comb, a representation of the historical fractal known as the Cantor Set[9][12].

The Hsus — a scientist and his musician son —, have also proposed that some of Bach’s music, like Invention №1 in C Major, exhibits a fractal structure. They suggested that fundamental musical patterns persist in the music even when notes are added or removed, and they have developed a system to condense music to its underlying substance using fractal geometry[10]. In this context, the fractal geometry of music has been compared to natural landscapes, suggesting that music can be studied through a visual representation of acoustic signals. The analysis has substantiated the self-similarity of Bach's music. It has been observed that the progression towards baroque and classical composers is evident by the resemblance to fractal geometry in both Bach's and Mozart's music, emulating certain geometrical aspects of the harmony of nature. [11]◼︎
Sources
[1] https://www.scientificamerican.com/article/secret-mathematical-patterns-revealed-in-bachs-music/ [2] https://physics.aps.org/articles/v17/21 [3] https://www.irishtimes.com/news/science/the-mathematician-s-patterns-like-those-of-the-composer-must-be-beautiful-1.3096020 [4] https://mathscholar.org/2021/06/bach-as-mathematician/ [5] https://arxiv.org/pdf/2301.00783.pdf [6] https://www.reddit.com/r/classicalmusic/comments/1ahc1xj/mathematicians_converted_hundreds_of_compositions/ [7] https://journals.aps.org/prresearch/abstract/10.1103/PhysRevResearch.6.013136 [8] https://www.classicfm.com/composers/bach/guides/chorales-guide/ [9] https://geometrymatters.com/hunting-bachs-fractals/ [10] https://www.nytimes.com/1991/04/16/science/j-s-bach-fractals-new-music.html [11] https://link.springer.com/chapter/10.1007/978-3-642-78097-4_3 [12] http://mathtourist.blogspot.com/2008/09/fractal-in-bachs-cello-suite.html?m=1