The Simpsons & Mathematics

Ahead of his lecture at the Black Box, author Simon Singh writes about secret equations in Halloween episodes

In the run up to Halloween 2014, while most people are thinking about ghosts, ghouls, phantoms and poltergeists, I think of The Simpsons.

Each year, for the last quarter of a century, the series has broadcast a special Halloween episode, collectively titled 'Treehouse of Horror'.

As a devout fan, 'Treehouse of Horror VI' will always be my particular favourite, as it contains the most mathematically intense scenes ever broadcast within a primetime television show.

Before exploring this episode further, it is important to point out that 'Treehouse of Horror VI' is just one of dozens of episodes of The Simpsons that contain mathematics.

People perhaps do not usually associate The Simpsons with complicated equations, but it is not so surprising when you realise that many of the writers on the show have strong backgrounds in mathematics. This includes a couple who have undergraduate degrees in mathematics, one with a master’s degree, a couple with PhDs and an ex-Yale University professor.

The writer/mathematician responsible for the equations in 'Treehouse of Horror VI' is David S Cohen, who later went on to become executive producer on Futurama, an animated sitcom that contains just as much mathematics as The Simpsons.

While researching my book, The Simpsons and Their Mathematical Secrets, Cohen told me about the various bits of mathematics that he had smuggled into the 1995 Halloween episode.

The show contains three short stories and Cohen was responsible for the final one, 'Homer3'. The plot starts with Homer entering a portal and encountering a peculiar three-dimensional universe, which supposedly goes beyond the flat two-dimensional landscape of Springfield.

The animation then changes to futuristic computer graphics, with mathematical nuggets flying across the backdrop. For example, the letters P and NP can be seen over Homer’s right shoulder for a few moments.

Most viewers would not have paid much attention to these letters, and even the eagle-eyed ones may not have realised that they alluded to one of the most important unsolved problems in theoretical computer science – such a deep puzzle that there is a reward of $1m for whoever can solve the mystery.

It is tempting to start explaining the P v NP problem, but I hope you will forgive me if I point keen readers to Wikipedia or, better still, my book or my talk at the Black Box in Belfast on October 24.

Other bits of mathematics in the episode include: Euler’s identity, e^iπ + 1 = 0, arguably the most beautiful equation in history; and a series of hexadecimal digits (base 16), which represent a message written in ASCII, a notation for turning numbers into letters. That particular message reads 'Frink rules!'

Then there is a Utah teapot (which also makes cameo appearances in Toy Story and Monsters, Inc.), which is a standard object used to compare different ways of mathematically modelling 3D objects; and Fermat’s Last Theorem, the subject of my first book and the most notorious problem in the history of mathematics.

While writing my book, I had always assumed that the writers of The Simpsons would never succeed in surpassing this level of mathematical density, but when executive producer Al Jean was in London last month, he told me that a special cross-over episode (The Simpsons meets Futurama) could hold some geeky surprises this autumn.

There is also an upcoming episode of The Simpsons in which Lisa becomes a member of a school mathematics team (a mathlete), and of course, for those Simpsons and maths geeks like myself, there is 'Treehouse of Horror XXV', which has just been broadcast in America.

Simon Singh lectures at the Black Box, Belfast on October 24 as part of the Friday Salons project organised in conjunction with the NI Science Festival.