Skip to main content

The maths behind your favourite music

Maths and music - they're so similar that you'll find the same themes in George Ezra's Paradise as you will in your maths textbook, from algebra to patterns to ratios. Don't believe us? Read on...

You might not know it, but the perfect pop songs have a lot in common, and that’s not a coincidence. US start-up, Echonest, gave scores to every hit song in the past 40 years, scoring them for things like tempo, beat strength and rhythmic tendencies. They then used a formula to come up with an ultimate ‘Danceability’ score.

Here are the results for Michael Jackson’s Billie Jean, which awards the King of Pop a really high score of 92%:

And how do some more 2018 artists measure up? If you’re looking for the ultimate answer to who wins the Cardi B vs Nicki Minaj beef, the answer is Cardi-B. Her top rated song on Spotify – I Like It – gets 82%, while Minaj’s Goodbye only rates at 64% Lily Allen just pips her nemesis Cheryl Cole to the post, thanks to F*ck You getting 78%, while Fight For This Love only gets 74%.

Want to see how your favourite songs measure up? You can see it in action if you use Spotify, which allows you to use Echonest’s technology to sort your playlist by ‘danceability’. Just go here and log-in to your Spotify account, and get sorting.

And you know who else knows about this danceability formula? The music industry. Look at how the score of pop bangers has changed over time…

Unbelievably, a lot of that is due to just one dude. Max Martin is responsible for Britney’s Baby One More Time, Taylor Swift’s Bad Blood, Kesha’s Blow and Jessie J’s Bang, Bang. And that’s just the songs beginning with ‘B’ – here’s the full list. He’s had the most number of hits in the US Billboard Chart, second only to the Beatles’ producer George Martin.

Max Martin works on his own theory, called Melodic Maths.  It’s a toolbox of tricks that results in some pretty perfect pop songs. Take song lines: according to Max Martin’s Melodic Maths, a line has to have a certain number of syllables, and the next line must be its mirror image, AKA if X=19, then Y=19. He believes in this so strongly that he prioritises the melody over the lyrics – collaborators could write the cleverest line in the history of pop, but if it’s a couple of syllables too long, it’s not making the cut.

You can see in the Art of Song’s diagraming of Katy Perry’s California Girls, Max Martin doesn’t necessarily mind if the lines don’t make sense, it’s more important that everything is neatly mirrored.

And what does this create? An ear worm, a song you can’t get out of your head for months to come.

As anyone who has spent time solving equations will know, balance is key. So, to play us out, see if you can spot the patterns in another of Max Martin’s creations: Taylor Swift’s Shake It Off.

In his own words: “You need a balance, at all times. If the verse is a bit messy, you need it to be less messy right after. It needs to vary. Shake It Off is a good example, where the math behind the drama is pretty clear”.

So, if X chorus = banging tune + crazy trombones in the background, Y verse must = banging tune + a much simpler trombone bass line in the background. Can you hear it?





the MEI logo.
the Casio logo.
the Institute and Faculty of Actuaries logo.

More information


Resources and tools designed to help you guide your children through GCSE's and A-Levels.


Resources, tools and talking points designed to help you improve STEM subject participation and to engage more girls in the classroom.


We are always looking for new partners to help our campaign. Please get in touch!