Related Stories

Mathematical references and in-jokes are peppered throughout The Simpsons, thanks to a swag of physics and maths degrees amongst the show's writers. But "Homer3" is without doubt the most intense and elegant integration of mathematics into an episode since the series began a quarter of a century ago.

The storyline begins quite innocently with Patty and Selma, Homer's sisters-in-law, paying a surprise visit to the Simpsons.

Keen to avoid them, Homer hides behind a bookcase, where he encounters a mysterious portal that seems to lead into another universe. Diving through the portal he leaves behind his two-dimensional Springfield environment and enters an incredible three-dimensional world. Homer is utterly perplexed by his new extra dimensionality and notices something shocking: "What's going on here? I'm so bulgy. My stomach sticks way out in front."

Instead of being drawn in the classic flat-animation style of The Simpsons, scenes set in this higher dimension have a sophisticated three-dimensional appearance. When Homer approaches a signpost indicating the x, y, and z axes in his new three-dimensional universe, he alludes to the fact that he is standing within the most sophisticated animated scene ever to have appeared on television: "Man, this place looks expensive. I feel like I'm wasting a fortune just standing here. Well, better make the most of it." And promptly belches.

Marge cannot fathom what has happened to Homer, because she can hear him but not see him. Help is at hand in the form of Professor John Nerdelbaum Frink, Jr, who explains "Well, it should be obvious to even the most dimwitted individual, who holds an advanced degree in hyperbolic topology, that Homer Simpson has stumbled into . . . the third dimension*."

With the help of a blackboard, Frink goes on to explain the concept of higher dimensions:

Professor Frink: Here is an ordinary square.

Chief Wiggum: Whoa, whoa! Slow down, egghead!

Professor Frink: But suppose we extend the square beyond the two dimensions of our universe along the hypothetical z-axis . . . There.

Everyone: [gasps]

Professor Frink: This forms a three-dimensional object known as a cube, or a Frinkahedron in honour of its discoverer.

Frink's explanation illustrates the relationship between two and three dimensions. In fact, his approach can be used to explain the relationship between all dimensions.

If we start with zero dimensions, we have a zero-dimensional point. This point can be pulled in, say, the x direction to trace a path that forms a one-dimensional line. Next, the one-dimensional line can be pulled in the perpendicular y direction to form a two-dimensional square. This is where Professor Frink's explanation picks up, because the two-dimensional square can be pulled in the z direction, which is perpendicular to its face, to form a three-dimensional cube (or Frinkahedron). Finally, it is mathematically, if not physically, possible to go one step further by dragging the cube into another perpendicular direction (labelled the w dimension) to form a four-dimensional cube. Cubes in four (or more) dimensions are known as hypercubes.

Does my universe look dense in this?

Despite Professor Frink's deep understanding of higher dimensions, the bad news is that he is unable to save Homer, who is left to wander across his new universe. This leads to a bizarre series of events that ends with a visit to an erotic cake store.

During this adventure, Homer encounters several fragments of mathematics which materialise in the three-dimensional landscape. Blink and you'll miss a false solution to Fermat's last theorem (1,78212 + 1,84112 = 1,92212), and a cosmological equation (ρm0 > 3H02/8πG) that predicts Homer's high density 3D universe will ultimately collapse due to its own gravitational attraction. Indeed, this is exactly what happens toward the end of the segment.

Just before Homer's universe disappears, Cohen dangles a particularly intriguing mathematical morsel for the discerning viewer (shown in the image above). Alongside a slightly unusual arrangement of Euler's equation (eiπ + 1 = 0 ) over Homer's left shoulder, the relationship P = NP can be seen over Homer's right shoulder. Although the majority of viewers would not have noticed these three letters, let alone given them a second thought, P = NP represents a statement about one of the most important unsolved problems in theoretical computer science.

P = NP ... or not

P = NP is a statement concerning two types of mathematical problems. P stands for polynomial and NP for nondeterministic polynomial. In crude terms, P-type problems are easy to solve, while NP-type problems are difficult to solve, but easy to check.

For example, multiplication is easy and so is classified as a P-type problem. Even as the numbers being multiplied get bigger, the time required to calculate the result grows in a relatively modest fashion.

By contrast, factoring is an NP-type problem. Factoring a number simply means identifying its divisors, which is trivial for small numbers, but rapidly becomes impractical for large numbers. For example, if asked to factor 21, you would immediately respond 21 = 3 x 7. However, factoring 428,783 is much harder. Indeed, you might need an hour or so with your calculator to discover that 428,783 = 521 x 823. Crucially, though, if someone handed you the numbers 521 and 823 on a slip of paper, you could check within a few seconds that these are the correct divisors. Factoring is thus a classic NP-type problem: hard to solve for large numbers, yet easy to check.

Or . . . is it possible that factoring is not as difficult as we currently think?

The fundamental question for mathematicians and computer scientists is whether factoring is genuinely hard to accomplish, or whether we are missing a trick that would make it simple. The same applies to a host of other supposedly NP-type problems—are they all genuinely hard, or are they merely hard because we are not smart enough to figure out the way to solve them easily?

This question is of more than mere academic interest, because some important technologies rely on NP-type problems being intractable. For example, there are widely used encryption algorithms that depend on the assumption that it is hard to factor big numbers. However, if factoring is not inherently difficult, and someone discovers the trick that makes factoring simple, then it would undermine these encryption systems. In turn, this would jeopardize the security of everything from personal online purchases to high-level international political and military communications.

The problem is often summarised as "P = NP or P ≠ NP?", which asks the question: Will apparently difficult problems (NP) one day be shown to be just as easy as simple problems (P), or not?

Finding the solution to the mystery of P = NP or P ≠ NP? is on the mathematicians' most wanted list — there is even a $1 million prize on its head. It's clear from the appearance of P = NP behind Homer that the scriptwriter (and computer scientist) David S Cohen thinks NP-type problems are indeed much easier than we currently think. There he's in disagreement with the majority of researchers, but if the pundits are right it'll be at least a century before we know the answer. No doubt the Homer3 episode will feature in the celebrations or commiserations that ensue.

* Frink's statement suggests that the characters in The Simpsons are trapped in a two-dimensional world, and therefore they struggle to imagine the third dimension. The animated reality of Springfield is slightly more complicated than this, because we regularly see Homer and his family crossing behind and in front of each other, which ought to be impossible in a strictly two-dimensional universe.

About the author:Simon Singh has a PhD in particle physics, and is an award-winning director and author of the best-selling books Fermat's last theorem, The Code Book and Big Bang. This is an edited extract from his latest book The Simpsons and their Mathematical Secrets, published by Bloomsbury.