The secret math behind catchy melodies
University of Waterloo researchers uncover the hidden mathematical equations in musical melodies
University of Waterloo researchers uncover the hidden mathematical equations in musical melodies
By Media RelationsWhy do some melodies feel instantly right, balanced, memorable and satisfying, even if you have never heard them before?
New research from the University of Waterloo suggests that more than creativity is at play. Behind many great melodies, researchers found something surprisingly powerful: symmetry. Their work shows that advanced algebra can reveal deep musical patterns that are not always obvious by ear or even on a written score.
The findings could help composers better understand what makes melodies work, as the study offers a recipe for generating new melodies that follow specific symmetry rules, opening new creative possibilities for composers and researchers.
“Our goal was to build a clear mathematical bridge between abstract algebra and the experience of listening to music,” said Dr. Olga Ibragimova, a PhD graduate in computational mechanics in Waterloo’s Faculty of Engineering. “When we think of melodies as shapes we can transform, it becomes clear that composers have been using these kinds of symmetries intuitively for centuries.”
To explore the blueprint of melody, the team used group theory, a branch of mathematics that studies symmetry and transformations. They simplified melodies into their essential note groups and examined how common musical changes affect structure. These changes include transposition, which shifts a melody up or down; inversion, which flips it; retrograde, which reverses it; and translation, which moves it through time.
Their analysis revealed symmetrical relationships in many melodies that help explain why certain musical phrases feel cohesive and complete.
The researchers created a framework that assigns each of the 12 notes in the chromatic scale a number from one to 12. This turns melodies into a form that can be studied using algebra. With this structure in place, they examined two major types of symmetry: tonal symmetry, which relates to the notes themselves, and positional symmetry, which relates to how those notes are arranged.
By separating those two layers, the team developed formulas showing how a melody can be transformed while keeping its underlying structure intact or intentionally reshaping it in predictable ways.
“What surprised us is how cleanly the mathematics separates tonal structure from positional structure,” said Dr. Chrystopher Nehaniv, a professor of systems design engineering at Waterloo. “This duality helps us identify patterns that are not obvious by ear or by looking at a musical score. It also means we can systematically construct and count all possible symmetric melodies for a given length.”
A paper on the study, Algebraic Applications in Investigation of Musical Symmetry, was published in the proceedings of the 6th AMMCS-International Conference on Applied Mathematics, Modeling, and Computational Science.

Read more
Robots the size of a soccer ball create new visual art by trailing light that represents the “emotional essence” of music

Read more
Waterloo prof leads a team of researchers to improve water quality through a community-focused approach underpinned by technical excellence

Read more
New medical device removes the guesswork from concussion screening in contact sports using only saliva
The University of Waterloo acknowledges that much of our work takes place on the traditional territory of the Neutral, Anishinaabeg, and Haudenosaunee peoples. Our main campus is situated on the Haldimand Tract, the land granted to the Six Nations that includes six miles on each side of the Grand River. Our active work toward reconciliation takes place across our campuses through research, learning, teaching, and community building, and is co-ordinated within the Office of Indigenous Relations.