“The Simpsons” can seem to have been around forever, so deeply wound into our culture that you sometimes forget humans created it and other humans shaped it into its present form. In this respect, it’s a lot like mathematics. According to Simon Singh, a widely read author of popular books about math, the comparison runs a lot deeper than that. In fact, as he explains in “The Simpsons and Their Mathematical Secrets,” the show’s writing team is lousy with ex-mathematicians, and the episodes are pincushioned with mathy in-jokes and background sight gags.

Like a lot of mathematicians, I already knew this. We are a small tribe, and we tend to know each other. J. Stewart Burns, who wrote for “The Simpsons” and its aesthetic cousin “Futurama,” used to grade my abstract algebra homework in college, and he and I spent a summer in Duluth, Minn., doing research in graph theory before he went off to do graduate work at Berkeley. And Burns wasn’t even the most mathematically accomplished writer in the room — that would be Ken Keeler, who holds a PhD in applied math from Harvard and worked at Bell Labs before moving into television.

When Burns started work at “The Simpsons,” Singh reports, “his 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.” (This is consistent with my memories of him.) Other mathy writers on the staff included a former New Jersey state champion mathlete and a prodigy who started as a Harvard math major at 16.

You might hope — or, depending how you swing, fear — that the heavy representation of supernumerates among the writers created a running subtext of mathematics below the surface of the story, a kind of secret seminar led by a crew of yellow-skinned, eight-fingered teaching assistants. The truth is less dramatic. The mathematics in “The Simpsons” doesn’t, for the most part, drive the plot; it’s a series of occasional wink-and-nod references by means of which the writers signal their membership in the in-group.

Singh uses the show as a thread along which to string mini-essays on some of math’s greatest hits, including Fermat’s Last Theorem (a purported counterexample to which is written on a blackboard in an episode called “The Wizard of Evergreen Terrace”), Euler’s identity e + 1 = 0 (which shows up on the spine of a book in “MoneyBART”) and perfect numbers (one of which, 8,128, appears on the JumboVision at Springfield Stadium in “Marge and Homer Turn a Couple Play”). Sometimes Singh lets go of the thread entirely, as when he writes about Simpson’s paradox and Simpson’s rule, named after two different mathematical Simpsons, neither of them Homer.

‘The Simpsons and Their Mathematical Secrets’ by Simon Singh (Bloomsbury USA)

Occasionally the mathematics does wind more deeply into the story, most notably in the 2010 “Futurama” episode “The Prisoner of Benda.” The plot turns on a device called the Mind-Switcher, which performs just the function its name suggests; over the course of the episode, as the apparatus is used with greater and greater abandon, the minds of the characters shuttle from body to body like singles switching bedrooms in a French farce. By the end, not a single consciousness remains in its proper skull. What’s worse, the characters can’t just retrace their steps to reunite each mind with its original body; the Mind-Switcher, having operated on a pair of minds, isn’t allowed to switch the same two minds again.

Ken Keeler, who wrote the episode, realized that in order to get everything sorted out it might be necessary to introduce new characters, whose bodies could be used as waystations through which the minds could find their way home. An ordinary writer would have been content simply to find a way out of the episode. But Keeler became obsessed with the problem in its full generality, finally composing a proof that, no matter how wild the original fiesta of Mind-Switching, the damage can always be repaired once two new people are added to the system. This question may sound abstruse, but the part of math it belongs to — “combinatorial group theory” — is one of the hottest things going at the moment, with major advances popping up everywhere from Paris to Los Angeles. Keeler’s theorem isn’t one of those big advances, but it’s a real theorem, certainly the deepest piece of mathematics ever featured in a prime-time sitcom.

Most of “The Simpsons and Their Mathematical Secrets” is about math, not comedy. But the most interesting parts of the book are the moments when the two pursuits come together. It’s a cliche by now that mathematics is supposed to be somehow allied with classical music. But why should music be the only art form to resonate with math? One “Simpsons” writer tells Singh: “I think the mathematical mind lends itself best to writing very silly jokes, because logic is at the heart of mathematics. The more you think about logic, the more you have fun twisting it and morphing it. I think the logical mind finds great humor in illogic.”

Math, like comedy, derives its force from elegance, concision and moments of explosive surprise. A really great mathematical argument can make you laugh out loud. As the example of “The Simpsons” shows, it’s all in how you tell it.

Jordan Ellenberg is a professor of mathematics at the University of Wisconsin at Madison. His book “How Not to Be Wrong: The Power of Mathematical Thinking” will be published in June.


By Simon Singh

Bloomsbury. 253 pp. $26