“The mind counting without being conscious that it is counting.” That’s how the the philosopher Leibniz described listening to music. By the time he came along, the idea that music and maths had a deep connection had been around for two millenia. It started with Pythagoras, flourished in the Renaissance, and then faded away in the Age of Reason. Leibniz’s view was already dated when he uttered it. People had stopped looking to music for a beautiful image of the “mystical mathematics of heaven,” as Sir Thomas Browne called it. Psychology and meaning and emotions took over.

Now maths is making a comeback. It’s partly because cognitive scientists have become very interested in the ways the brain grasps musical patterns. It turns out there are overlaps between musical and linguistic and mathematical ability, which have spawned all kinds of theories about how music arose in prehistory. Oliver Sachs has written about the miraculous powers of music to bring patients out of long-term catatonic states.

Also maths has changed in recent times. It’s no longer just about numbers. It’s about groups and symmetries and chaos and complexity. Mathematicians are in search of patterns, and music is all about pattern-making. In the work of some modern composers, the new maths and the new music actually touch. Webern’s music is full of little melodic shapes turned around on their axes, or reversed as if seen in a mirror. The Greek-French composer Iannis Xenakis conjured sounds out of Bernouilli’s equations, and Brownian motion.

All this was revealed in a brilliant lecture on music and symmetry, given by Marcus du Sautoy as part of the Swedish Radio Symphony Orchestra’s Interplay series. Symmetry is something music has at the very basic level of sound. Look at the make-up of a single sound on a 3-d oscilloscope, and you find the more pure and beautiful the sound, the more symmetry it has. The purest sound of all is a sine wave, and that looks like a circle. And a circle has infinite axes of symmetry.

All very neat. But for most people the sine wave isn’t beautiful, it’s dull. **Stravinsky**** **said its empty purity was like a castration threat. What he wanted was scrunchy, dirty, human sounds. There’s a film of him going to the piano, punching out the very scrunchy Rite of Spring chord, and saying with a grin, “I LOVE dissonance.” We all do – maybe not quite as much as Stravinsky, but without a taste for harmonies which have a spice of dissonance in them, we couldn’t follow the simplest harmonic progression.

That simple example hints that real music might need a healthy dash of disorder to be interesting. As du Sautoy pointed out, artists and musicians have been aware that a too perfect symmetry is fatal to art. Thomas Mann said the perfect symmetry of a snowflake is a foretaste of death. “To be perfectly symmetrical is to be perfectly dead,” said Stravinsky.

Does that mean that maths is actually beside the point, when it comes to understanding music? Certainly not. Mathematicians are intrigued by disorder, because they’ve discovered that they can actually grasp it with new mathematical tools. But beyond that, I get a sense from de Sautoy that maths itself is tainted by the human. Without the human element of curiosity and an appetite for beauty, mathematical discovery would grind to a halt. “Maths is a narrative, it has an emotional trajectory,” he said to me after his lecture. “You’re following a train of thought through to something, and sometimes it’s obscure, or it might lead somewhere totally new which opens up a new landscape.”

For me this remark pointed to another deep affinity between maths and music. Maths is full of true equations. There are an infinite number of them, and a computer can be programmed to produce them by the million. Similarly, in “normal” harmonic music (modern music is a different case) there are an infinite number of “true” harmonic progressions, i.e. ones which obey the laws of harmony you learn at conservatoire. But most of them are deadly dull.

Why do we choose one rather than another? Because it captivates us, for a reason we can’t quite define. It may because in some way the progression bends the rules, or actually breaks them. Bach broke the rules quite often, but that doesn’t mean we lesser mortals can do it (as I was often reminded as a student, after handing in a ham-fisted chorale harmonisation). If we could define the thing that gives that special x factor to harmonic progressions, we could produce them to order, or get a computer to do it.

The case with maths isn’t quite the same. There the rules can’t be bent at all. But there’s a similar need to find a pattern with that extra something, which opens the door to a new world. As the American mathematician Marson Morse put it, “From an infinity of designs the mathematician chooses one pattern for beauty’s sake, and pulls it down to earth.” As a description of what composers do, that could hardly be bettered.