Moreover, when Fermat further increased the power to which x, y, and z are raised, his efforts to find a set of solutions were thwarted again and again. He began to think that it was impossible to find whole number solutions to any of the following equations:

  x3 + y3 = z3

  x4 + y4 = z4

  x5 + y5 = z5

  x6 + y6 = z6

  ⋮

  xn + yn = zn,

  where n > 2

  Eventually, however, he made a breakthrough. He did not find a set of numbers that fitted one of these equations, but rather he developed an argument that proved that no such solutions existed. He scribbled a pair of tantalizing sentences in Latin in the margin of his copy of Diophantus’s Arithmetica. He began by stating that there are no whole number solutions for any of the infinite number of equations above, and then he confidently added this second sentence: “Cuius rei demonstrationem mirabilem sane detexi, hanc marginis exiguitas non caperet.” (I have discovered a truly marvelous proof of this, which this margin is too narrow to contain.)

  Pierre de Fermat had found a proof, but he did not bother to write it down. This is perhaps the most frustrating note in the history of mathematics, particularly as Fermat took his secret to the grave.

  Fermat’s son Clément-Samuel later found his father’s copy of Arithmetica and noticed this intriguing marginal note. He also spotted many similar marginal jottings, because Fermat had a habit of stating that he could prove something remarkable, but rarely wrote down the proof. Clément-Samuel decided to preserve these notes by publishing a new edition of Arithmetica in 1670, which included all his father’s marginal notes next to the original text. This galvanized the mathematical community into finding the missing proofs associated with each claim, and one by one they were able to confirm that Fermat’s claims were correct. Except, nobody could prove that there were no solutions to the equation xn + yn = zn (n > 2). Hence, this equation became known as Fermat’s last theorem, because it was the only one of Fermat’s claims that remained unproven.

  As each decade passed without a proof, Fermat’s last theorem became even more infamous, and the desire for a proof increased. Indeed, by the end of the nineteenth century, the problem had caught the imaginations of many people outside of the mathematical community. For example, when the German industrialist Paul Wolfskehl died in 1908, he bequeathed 100,000 marks (equivalent to $1 million today) as a reward for anyone who could prove Fermat’s last theorem. According to some accounts, Wolfskehl despised his wife and the rest of his family, so his will was designed to snub them and reward mathematics, a subject that he had always loved. Others argue that the Wolfskehl Prize was his way of thanking Fermat, because it is said his fascination with the problem had given him a reason to live when he was on the verge of suicide.

  Whatever the motives, the Wolfskehl Prize catapulted Fermat’s last theorem into public notoriety, and in time it even became part of popular culture. In “The Devil and Simon Flagg,” a short story written by Arthur Porges in 1954, the titular hero makes a Faustian pact with the Devil. Flagg’s only hope of saving his soul is to pose a question that the Devil cannot answer, so he asks for a proof of Fermat’s last theorem. After accepting defeat, the Devil said: “Do you know, not even the best mathematicians on other planets—all far ahead of yours—have solved it? Why, there’s a chap on Saturn—he looks something like a mushroom on stilts—who solves partial differential equations mentally; and even he’s given up.”

  Fermat’s last theorem has also appeared in novels (The Girl Who Played with Fire by Stieg Larsson), in films (Bedazzled with Brendan Fraser and Elizabeth Hurley), and plays (Arcadia by Tom Stoppard). Perhaps the theorem’s most famous cameo is in a 1989 episode of Star Trek: The Next Generation titled “The Royale,” in which Captain Jean-Luc Picard describes Fermat’s last theorem as “a puzzle we may never solve.” However, Captain Picard was wrong and out of date, because the episode was set in the twenty-fourth century and the theorem was actually proven in 1995 by Andrew Wiles at Princeton University.5

  Wiles had dreamed about tackling Fermat’s challenge ever since he was ten years old. The problem then obsessed him for three decades, which culminated in seven years of working in complete secrecy. Eventually, he delivered a proof that the equation xn + yn = zn (n > 2) has no solutions. When his proof was published, it ran to 130 dense pages of mathematics. This is interesting partly because it indicates the mammoth scale of Wiles’s achievement, and partly because his chain of logic is far too sophisticated to have been discovered in the seventeenth century. Indeed, Wiles had used so many modern tools and techniques that his proof of Fermat’s last theorem cannot be the approach that Fermat had in mind.

  This point was alluded to in a 2010 episode of the BBC TV series Doctor Who. In “The Eleventh Hour,” the actor Matt Smith debuts as the regenerated Eleventh Doctor, who must prove his credentials to a group of geniuses in order to persuade them to take his advice and save the world. Just as they are about to reject him, the Doctor says: “But before you do, watch this. Fermat’s theorem. The proof. And I mean the real one. Never been seen before.” In other words, the Doctor is tacitly acknowledging that Wiles’s proof exists, but he rightly does not accept that it is Fermat’s proof, which he considers to be the “real one.” Perhaps the Doctor went back to the seventeenth century and obtained the proof directly from Fermat.

  So, to summarize, in the seventeenth century, Pierre de Fermat states that he can prove that the equation xn + yn = zn (n > 2) has no whole number solutions. In 1995, Andrew Wiles discovers a new proof that verifies Fermat’s statement. In 2010, the Doctor reveals Fermat’s original proof. Everyone agrees that the equation has no solutions.

  Thus, in “The Wizard of Evergreen Terrace,” Homer appears to have defied the greatest minds across almost four centuries. Fermat, Wiles, and even the Doctor state that Fermat’s equation has no solutions, yet Homer’s blackboard jottings present us with a solution:

  3,98712 + 4,36512 = 4,47212

  You can check it yourself with a calculator. Raise 3,987 to the twelfth power. Add it to 4,365 to the twelfth power. Take the twelfth root of the result and you get 4,472.

  Or at least that is what you get on any calculator that can squeeze only ten digits onto its display. However, if you have a more accurate calculator, something capable of displaying a dozen or more digits, then you will find a different answer. The actual value for the third term in the equation is closer to

  3,98712 + 4,36512 = 4,472.000000007057617187512

  So what is going on? Homer’s equation is a so-called near-miss solution to Fermat’s equation, which means that the numbers 3,987, 4,365, and 4,472 very nearly make the equation balance—so much so that the discrepancy is hardly discernible. However, in mathematics you either have a solution or you do not. A near-miss solution is ultimately no solution at all, which means that Fermat’s last theorem remains intact.

  David S. Cohen had merely played a mathematical prank on those viewers who were quick enough to spot the equation and clued-up enough to recognize its link with Fermat’s last theorem. By the time this episode aired in 1998, Wiles’s proof had been published for three years, so Cohen was well aware that Fermat’s last theorem had been conquered. He even had a personal link to the proof, because he had attended some lectures by Ken Ribet while he was a graduate student at the University of California, Berkeley, and Ribet had provided Wiles with a pivotal stepping-stone in his proof of Fermat’s last theorem.

  Cohen obviously knew that Fermat’s equation had no solutions, but he wanted to pay homage to Pierre de Fermat and Andrew Wiles by creating a solution that was so close to being correct that it would apparently pass the test if checked with only a simple calculator. In order to find his pseudosolution, he wrote a computer program that would scan through values of x, y, z, and n until it found numbers that almost balanced. Cohen finally settled on 3,98712 + 4,36512 = 4,47212 because the resulting margin of error is minuscule—the left side of the equation is
only 0.000000002 percent larger than the right side.

  As soon as the episode aired, Cohen patrolled the online message boards to see if anybody had noticed his prank. He eventually spotted a posting that read: “I know this would seem to disprove Fermat’s last theorem, but I typed it in my calculator and it worked. What in the world is going on here?”

  He was delighted that budding mathematicians around the world might be intrigued by his mathematical paradox: “I was so happy, because my goal was to get enough accuracy so that people’s calculators would tell them the equation worked.”

  Cohen is very proud of his blackboard in “The Wizard of Evergreen Terrace.” In fact, he derives immense satisfaction from all the mathematical tidbits he has introduced into The Simpsons over the years: “I feel great about it. It’s very easy working in television to not feel good about what you do on the grounds that you’re causing the collapse of society. So, when we get the opportunity to raise the level of discussion—particularly to glorify mathematics—it cancels out those days when I’ve been writing those bodily function jokes.”

  CHAPTER 4

  The Puzzle of Mathematical Humor

  As might be expected, many of the mathematical writers of The Simpsons have a passion for puzzles. Naturally, this love of puzzles has found its way into various episodes.

  For example, the world’s most famous puzzle, the Rubik’s Cube, crops up in “Homer Defined” (1991). The episode features a flashback to 1980, the year the cube was first exported from Hungary, when a younger Homer attends a nuclear safety training session. Instead of paying attention to the instructor’s advice on what to do in the event of a meltdown, he is focused on his brand-new cube and cycling through some of the 43,252,003,274,489,856,000 permutations in order to find the solution.

  Rubik’s Cubes have also appeared in the episodes “Hurricane Neddy” (1996) and “HOMЯ” (2001), and the Rubik’s Cube was invoked as a threat by Moe Szyslak in “Donnie Fatso” (2010). As proprietor and bartender of Moe’s Tavern, Moe regularly receives prank calls from Bart asking to speak with particular people with fictitious and embarrassing names. This prompts Moe to call out to everyone in the bar with lines such as “Has anyone seen Maya Normousbutt?” and “Amanda Hugginkiss? Hey, I’m looking for Amanda Hugginkiss.” The “Donnie Fatso” episode is notable because Moe receives a phone call that is not a prank and not from Bart. Instead, Marion Anthony D’Amico, head of Springfield’s notorious D’Amico crime family, is calling. Fat Tony, as he is known to his friends (and enemies), simply wants Moe to find out if his Russian friend Yuri Nator is in the bar. Assuming that this is another prank by Bart, Moe makes the mistake of threatening the caller: “I’m gonna chop you into little pieces and make you into a Rubik’s Cube which I will never solve!”

  A more ancient puzzle appears in “Gone Maggie Gone” (2009), an episode that is partly a parody of Dan Brown’s novel The Da Vinci Code. The storyline begins with a total solar eclipse, ends with the discovery of the jewel of St. Teresa of Avila, and revolves around the false belief that Maggie is the new messiah. From a puzzle lover’s point of view, the episode’s most interesting scene concerns Homer, who finds himself trapped on one side of a river with his baby (Maggie), his dog (Santa’s Little Helper), and a large bottle of poison capsules.

  Homer is desperate to cross the river. There is a boat, but it is flimsy and can only carry Homer and one other item at a time. Of course, he cannot leave Maggie with the poison because the baby might swallow a capsule, and he cannot leave Santa’s Little Helper with Maggie in case the dog bites the baby. Hence, Homer’s challenge is to work out a sequence of crossings that will allow him to ferry everybody and everything safely to the other side.

  As Homer begins to think about this predicament, the animation style changes and the problem is summarized in the style of a medieval illuminated manuscript, accompanied by the words: “How does the fool cross the river with his burdens three?” This is a reference to a medieval Latin manuscript titled Propositiones ad Acuendos Juvenes (Problems to Sharpen the Young), which contains the earliest reference to this sort of river-crossing problem. The manuscript is a marvelous compilation of more than fifty mathematical puzzles written by Alcuin of York, regarded by many as the most learned man in eighth-century Europe.

  Alcuin poses an identical problem to Homer’s dilemma, except that he frames it in terms of a man transporting a wolf, a goat, and a cabbage, and he has to avoid the wolf eating the goat, and the goat eating the cabbage. The wolf is essentially equivalent to Santa’s Little Helper, the goat has the same role as Maggie, and the cabbage is in place of the poison.

  The solution to Homer’s problem, which he works out for himself, is to start by taking Maggie across the river from the original bank to the destination bank. Then he would return to the original bank to collect the poison, and row back to the destination bank and deposit the poison. He cannot leave the poison with Maggie, so he would bring Maggie back to the original bank and leave her there, while he takes Santa’s Little Helper across to the destination bank to join the poison. He would then row back to the original bank to collect Maggie. Finally, he would row to the destination bank to complete the challenge with everyone and everything having safely crossed the river.

  Unfortunately, he is unable to fully implement his plan. For when Homer leaves Maggie on the destination bank, at the end of the first stage, she is promptly kidnapped by nuns. This is something that Alcuin failed to factor into his original framework for the problem.

  In an earlier episode, “Lisa the Simpson” (1998), a puzzle plays an even more important role by triggering the entire plotline. The story starts in the school cafeteria, where Lisa sits opposite Martin Prince, who is perhaps Springfield’s most gifted young mathematician. Indeed, Martin experiences life from an entirely mathematical perspective, as demonstrated in “Bart Gets an F” (1990), in which Bart temporarily befriends Martin and offers him some advice: “From now on, you sit in the back row. And that’s not just on the bus. It goes for school and church, too . . . So no one can see what you’re doing.” Martin then reframes Bart’s advice in terms of mathematics: “The potential for mischief varies inversely to one’s proximity to the authority figure!” He even jots down the equation that encapsulates Bart’s wisdom, in which M represents the potential for mischief and PA is proximity to an authority figure:

  In the cafeteria, Martin becomes interested in Lisa’s lunch, which is not the usual cafeteria food, but rather a vacuum-packed space-themed meal. When Lisa holds up the lunch and explains that it is “what John Glenn eats when he’s not in space,” Martin spots a puzzle on the back of the packet. The challenge is to find the next symbol in this sequence:

  Martin solves the puzzle in the blink of an eye, but Lisa remains perplexed. She gradually becomes more and more frustrated as students sitting nearby, including Bart, say that they can identify the next symbol in the sequence. It seems that everyone can work out the answer . . . except Lisa. Consequently, she spends the rest of the episode questioning her intellectual ability and academic destiny. Fortunately, you will not have to suffer such emotional turmoil. I suggest you spend a minute thinking about the puzzle, and then take a look at the answer provided in the caption here.

  The lunch puzzle is noteworthy because it helped to shore up the mathematical foundations of The Simpsons by playing a part in attracting a new mathematician to the writing team. J. Stewart Burns had studied mathematics at Harvard before embarking on a PhD at the University of California, Berkeley. His doctoral thesis would have involved algebraic number theory or topology, but he abandoned his research before making much progress, and he received a master’s degree instead of a PhD. The reason for his premature departure from Berkeley was a job offer from the producers of the sitcom Unhappily Ever After. Burns had always harbored ambitions to become a television comedy writer, and this was his big break. Soon he became friends with David S. Cohen, who invited Burns to the offices of The Simpsons in order to
attend a table reading of an episode, which happened to be “Lisa the Simpson.” As the storyline unfolded, including the number-based puzzle, Burns gradually felt that this was where he belonged, working alongside Cohen and the other mathematical writers. While working on Unhappily Ever After, Burns was labeled as the geeky mathematician with a master’s degree. By contrast, when he joined The Simpsons, a master’s degree in mathematics was no longer exceptional. Instead of being labeled a geek, he became known as the go-to guy for toilet humor.

  Although David S. Cohen cannot remember if he suggested the puzzle that appears in “Lisa the Simpson,” he certainly drew the initial sketches. The puzzle, almost as it appeared in the episode, is in the lower line of this page of doodles. Solving the problem relies on noticing that the left and right halves of each symbol are mirror images of each other. The right half of the first symbol is 1, and the left half is its reflection. The right half of the second symbol is 2, and the left half is its reflection. The pattern continues with 3, 4, and 5, so the sixth symbol would be 6 joined to its own reflection.

  The upper line suggests Cohen was thinking of using the sequence (3, 6, 9), but this idea was abandoned, probably because the fourth element, 12, would have required two digits. The middle line, which shows the sequence (1, 4, 2, 7), was also abandoned. It is unclear what the fifth element of the sequence would have been, and Cohen can no longer remember what he had in mind.