In the 1995 Halloween episode of the award-winning animated sitcom *The Simpsons*, two-dimensional Homer Simpson accidentally jumps into the third dimension. During his journey in this strange world, geometric solids and mathematical formulas float through the air, including an innocent-looking equation: 1782^{12} + 1841^{12} = 1922^{12}. Most viewers surely ignored this bit of mathematical gobbledygook.

On the fan discussion site alt.tv.simpsons, however, the equation caused a bit of a stir. “What’s going on, he seems to have disproved Fermat’s last theorem!” one fan marveled, referring to the famous claim by Pierre de Fermat—proved just months earlier—that for any exponent *n* bigger than 2, there are no nonzero whole numbers *a*, *b*, and *c* for which *a*^{n} + *b*^{n} = *c*^{n}. The Simpsons equation, if correct, would be a counterexample to the theorem, meaning that the proof had been wrong.

Plug the equation into any run-of-the-mill calculator and it seems to check out. The 12th root of 1782^{12} + 1841^{12}, according to a calculator, is 1,922. Yet it’s easy to see that the equation is false, because the left-hand side is odd, while the right-hand side is an even number. There’s no paradox here: It’s simply a matter of the calculator’s round-off error.

To David X. Cohen, the *Simpsons* writer who concocted the equation, the fans’ responses were a source of glee. Cohen had written a computer program specifically to look for what mathematicians call Fermat “near misses”: combinations of numbers *a*, *b*, *c*, and *n* that come so close to satisfying Fermat’s equation that they would seem to work when tested on a calculator.

Why go to such lengths for a background joke that would flash across the screen in a matter of seconds? Mainly for the fun of it, but also to flex intellectual muscles that don’t typically get exercised in Hollywood script rooms: Cohen has a master’s degree in computer science.

As a mathematically inclined *Simpsons* writer, Cohen is in good company. Although nobody would call *The Simpsons* a science show, the writing staff boasts an impressive array of former mathematicians, scientists, and computer scientists. Over the years, they have injected their brand of geeky humor into the show. They’ve written hundreds of math jokes, ranging in subtlety from Cohen’s fake Fermat equation to open jabs at the mathematical illiteracy of the general public. Math has occasionally even provided the theme of an episode.

## Digital details

The *Simpsons* writers have a perfectionistic streak when it comes to math on the show, even when it’s just for a throwaway joke. For instance, after Cohen realized that his Fermat near miss could be refuted so easily by an even-odd argument, he refined his computer program to produce a new one without that flaw: 3987^{12} + 4365^{12} = 4472^{12}, which appeared on Homer Simpson’s basement blackboard in 1998.

In another episode, Kwik-E-Mart proprietor Apu brags that he can recite pi to 40,000 decimal places. “The last digit is 1,” he announces. To get that detail right, the *Simpsons* writing team faxed a query to NASA, where mathematician David Bailey obliged with the digit in question.

The writers never put in a math joke simply to tickle only their own funny bones, according to Ken Keeler, a *Simpsons* writer with a Ph.D. degree in applied math. “We always think there are a moderate number of viewers who will get it,” he said last October during a panel discussion about math on *The Simpsons* at the Mathematical Sciences Research Institute in Berkeley, Calif. “Based on the newsgroups and fan sites, it seems as if somebody finds everything we put in.”

The *Simpsons* writers often play on mathematical cultural stereotypes, extracting humor by exaggerating both the mathematical illiteracy of the U.S. public and the nerdiness and self-aggrandizement of the mathematically gifted. In a characteristic exchange, in the third-dimension episode, mad scientist Professor Frink tries to explain to Police Chief Wiggum the nature of the three-dimensional space through which Homer Simpson is wandering.

**Frink:** 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. . . . (drawing on a blackboard) Here is an ordinary square.

**Wiggum:** Whoa, whoa—slow down, egghead!

**Frink:** But suppose we extend the square beyond the two dimensions of our universe, along the hypothetical z-axis, there. This forms a three-dimensional object known as a “cube,” or “Frinkahedron” in honor of its discoverer.

“One of the themes we’ve harped on is Professor Frink trying to seize credit for something,” Keeler says. “That should be very familiar to people in academia.”

Gender issues in mathematics take center stage in “Girls just want to have sums,” which aired on April 30. It lampoons the scandal that ensued in 2005 when Lawrence Summers, then president of Harvard University, suggested that women are innately inferior at mathematics.

In that *Simpsons* episode, Springfield Elementary School Principal Skinner is ousted after casually remarking that girls aren’t much good at math. Skinner’s female replacement divides the boys and girls into separate schools since, she says, girls can’t learn math around “aggressive, obnoxious” boys.

Brainy 8-year-old Lisa Simpson is delighted until she attends the girls’ math class. “How do numbers make you feel?” the teacher begins. “What does a plus sign smell like? Is the number 7 odd or just different?” Aghast, Lisa poses as a boy to attend the ghettolike boys’ school, where real math is being taught.

At the climax, the *Simpsons* writers leave the issue of women in mathematics tantalizingly unresolved. As Lisa, aka Jake, accepts the award for best math student, she says, “I guess the real reason we don’t see many women in math and science is. . .” only to be hurried off stage so that the award for best flautist can be presented.

## Simpsonian evolution

Most of the mathematically inclined *Simpsons* writers also wrote for *Futurama*, an animated science fiction series that aired on network television from 1999 to 2003. On that show, math jokes abounded.

In a typical scene, two robots meet and discover what to them is an amazing coincidence: their serial numbers are, respectively, 3370318 and 2716057. As the robots high-five delightedly, they explain to their bewildered human companions that both numbers are expressible as the sum of two cubes.

The exchange is a not-so-veiled reference to a famous mathematical anecdote. When mathematician G.H. Hardy visited mathematical prodigy Srinivasa Ramanujan in a London hospital in 1917, he lamented to Ramanujan that his taxi had a very boring number, 1729. On the contrary, Ramanujan immediately replied, that number is very interesting: It’s the smallest number expressible as the sum of two cubes in two different ways.

In contrast to *The Simpsons*, *Futurama* permitted the writers to let their mathematical fancies run wild and to cram in math references for their personal delectation, Keeler says. “That’s why it’s not on the air any more,” he jokes.

Yet even on *The Simpsons*, the writers constantly have their radars tuned for opportunities to incorporate math humor. Jeff Westbrook, who has a Ph.D. in computer science, said at the panel discussion that he’s on the lookout for a way to work in the Bridges-of-Königsberg problem. Mathematician Leonhard Euler famously attacked this problem in 1736, using graph theory to show that there is no route through the city of Königsberg, Germany, that traverses each of its seven bridges just once.

In the meantime, Westbrook says, the *Simpsons* writers embedded some mathematically interesting numbers in the season finale, which has since aired on May 21. In that episode, a singing star tells her estranged baseball-player husband that she will come back to him if he can correctly guess the attendance of that day’s ballgame: 8,191, 8,128, or 8,208.

At the panel discussion, Westbrook declined to elaborate on just how these numbers are interesting. In the same spirit, we leave that question as a challenge to readers. (Visit the *Simpsons* post at http://blog.sciencenews.org/ to let us know what you figure out.) As Homer Simpson would surely say, “D’oh!”