Close Mobile Menu

A Formula for Funny: The Surprisingly Smart Humor of The Simpsons

March 15, 2021
by Dano Nissen
Image source: The Simpsons / Fox

Three Berkeley alumni ponder the connections between advanced scholarship and comedy writing.

FOR CENTURIES, FERMAT’S LAST THEOREM defied mathematicians to prove that there are, in fact, no natural numbers for x, y and z that can satisfy the equation xn+yn=zn when n is greater than 2. Countless great minds tried and failed, until 1995, when mathematician Andrew Wiles, after years of monk-like devotion, provided the undisputed proof once and for all. 

That is, until he was seemingly proved wrong, a few years later, by none other than Homer Simpson, whose only monk-like devotion is to doughnuts. 

Turns out, math is kinda funny—and so are philosophy and computer science. What, if anything, might explain this connection between heady academic pursuits and, say, Krusty the Clown?

In an episode of The Simpsons called “The Wizard of Evergreen Terrace,” Homer, dreaming of becoming an inventor, toils away in his basement, scrawling on the chalkboard: 398712+436512=447212—an equation that, per M. Fermat, should not, cannot exist.

And in fact, it doesn’t. Homer’s math was off. Not by much, but still. D’oh! 

Of course, the real question isn’t where Homer went wrong, but, rather, how in the hell this esoteric math reference made it into a cartoon in the first place?

The answer can be found in Simpsons writer, David S. Cohen, whose master’s dissertation in computer science at Berkeley posed the following problem: You’re served a stack of pancakes all burnt on one side and arranged top to bottom in random size order. Being a very particular diner, you request that the stack be taken back and rearranged with the largest pancake on the bottom, the smallest on the top, and all the burnt sides facing downwards. And one more thing, the cook must rearrange the pancakes by inserting a spatula at a given point in the stack and flipping all the pancakes as one unit. What’s the most efficient way for the cook (who, by now, wants to kill you) to satisfy your order? 

The problem is a variation of a classic pancake combinatorial problem first put forth by the mathematician Jacob Goodman, under the pseudonym Harry Dweighter. As in “harried waiter,” get it?

Turns out, math is kinda funny—and so are philosophy and computer science, at least judging by the fact that three Cal alumni with advanced degrees in those subjects—including Cohen, J. Stewart Burns, and Eric Kaplan—have logged long, impressive careers writing for The Simpsons and Futurama, the Matt Groening franchises that practically redefined American humor. Struck by this fact, California decided to probe a bit deeper to see what, if anything, might explain this connection between heady academic pursuits and, say, Krusty the Clown.

“We would be working on a script and all of a sudden get stuck on something and start working on a theorem,” says writer J. Stewart Burns. // Futurama / SYFY

Professionally, Cohen the writer goes by David X. Cohen. He added the “cool science fiction letter” because his birth name was already taken by a Writers Guild of America member when he applied. Technically, he was a professional comedy writer long before joining the Guild. “I would draw cartoons and force my sister to buy them,” Cohen says. But comedy wasn’t on his career radar until much later. “I grew up in a very science-y family …. As a kid, I never imagined anything else.” 

Cohen went to Harvard to study physics, which, to his biologist parents, didn’t pass the science purity test. “I destroyed my parent’s dreams by being a physicist,” he jokes. He also wrote for the famed Harvard Lampoon, a breeding ground for many a sitcom writer. 

He then attended UC Berkeley’s Ph.D. program in computer science where, he says, his colleagues were “almost uniformly very funny people.” 

He left the Ph.D. program early with a master’s and his burnt pancake dissertation to take his professional comedy chops to a wider audience than just his sister. He landed his first gig when soon-to-be TV comedy legend Mike Judge (an engineer in a previous career) was looking for “the very cheapest writers available” for his show Beavis and Butt-head. He would go on to staff write for The Simpsons and co-create Futurama.

“A good proof in mathematics has the form of a joke. Proofs should be as short as possible and should have a twist that is going to be ingeniously absurd.”—Jim Holt

In his many years writing for television, Cohen has come up with a theory on why there are so many math and science people on these two shows: “[Stories are] pitched in the form of a dramatic story with a beginning, middle, and end …. It has to have those key elements before you start the funny. In some respects if you were to look at it as a math proof, the story is the mathematical progression to get from your beginning stage to your end stage.”

Jim Holt agrees with that premise. A contributor to The New Yorker and former journalist-in-residence at Berkeley’s Mathematical Sciences Research Institute, Holt is also the author of a book on the history and philosophy of jokes called Stop Me If You’ve Heard This. “A good proof in mathematics has the form of a joke,” says Holt. “Proofs should be as short as possible and should have a twist that is going to be ingeniously absurd. There’s a formal isomorphism between a mathematical proof and a good joke of the absurdist body.”

By Holt’s standards, Fermat’s Last Theorem is a veritable sidesplitter. 

“Being good at pure mathematics and comedy means seeing completely unexpected connections between seemingly very dissimilar things,” he says. “The proof of Fermat’s Last Theorem was essentially obtained by showing elliptical functions in modular forms had this deep and unexpected connection.”

For his part, Cohen tries to avoid drawing too close a parallel between math and gag writing. But he is certain of one thing: “Every writer on The Simpsons is some kind of a nerd basically. Legal nerd. History nerd. I was the sci-fi/math nerd at the time.” The trend continued when he was in charge of the Futurama writers’ room. “I, in turn, hired a bunch of even nerdier writers.”

One of those nerds was J. Stewart Burns, who says, “comedy writers are a weird bunch … but way less weird than mathematicians.”

He would know. Burns completed his undergraduate degree in math at Harvard and, like Cohen, wrote for The Lampoon. “My interest in comedy came more out of my interest in joining this club that had a really cool building,” he says. The Lampoon had other perks: “[They] had parties in tuxedos and ate lobsters. … I thought I was wrecking my potential career by avoiding classes and spending all my time there.” Little did he know.

“The Simpsons” is “almost pure incongruity,” Holt says—something intellectuals often specialize in. “People who are amused by very abstract investigations are seeing the world in a way that diverges radically from the practical everyday mode of existence.”

Also like Cohen, Burns went on to pursue a Ph.D. at UC Berkeley, but left early with a master’s and a couple of spec scripts for Hollywood. He staffed on The Simpsons and then Futurama, where “all of the sudden, half our staff had majored in math.”

Perhaps because of that, he says, the Futurama room dealt more with abstractions that could be turned into jokes. By contrast, “At The Simpsons, I would come in with a really good joke and they’d just be like, ‘No one laughed so we’re not doing that.’ I think that’s normally how things work.”

In the Futurama room, where the watercooler talk often sounded like oral exams, he found company in his predilection for solving hard problems. “We would be working on a script and all of a sudden get stuck on something and start working on a theorem,” he says. “In most rooms, you blow off time talking about politics or what your kids and wives are up to.” In Futurama, he jokes, “we didn’t have kids or wives or care about politics.”

Jim Holt puts forth three basic theories of humor. The first, courtesy of Thomas Hobbes, is aggression. “Basically, making fun of people.” The second is repression theory, à la Freud. “A joke enables forbidden material to bubble to the surface of consciousness by evading the censor.” We laugh when latent desires for sex and violence sublimate into family programming. “The third is sheer incongruity,” he says. “Reveling in absurdity for its own sake and juxtaposing concepts that seem to have nothing to do with each other but have an unexpected and amusing deep affinity.” He deems the third form the most advanced.

The Simpsons is “almost pure incongruity,” he says—something intellectuals often specialize in. “People who are amused by very abstract investigations are seeing the world in a way that diverges radically from the practical everyday mode of existence of most people …. They translate incongruities into Lebenswelt, the world ordinary people live in.”

But the genius of the Groening shows is that they also operate on those two other levels. “The crude stuff is never crudity for its own sake. It always is redeemed by an aura of cleverness. There is something for everybody in The Simpsons. I like the way that even for the people really missing the highbrow jokes there are jokes at their level,” he says. “And the highbrow people can be flattered at the cultivation of their erudition.” 

Still, having a command of abstract thought doesn’t necessarily transfer to telling a good joke. “[There is] far from a perfect correlation,” admits Holt. He lists famous thinkers that wouldn’t pass muster at an open mic: mathematician Kurt Gödel, linguist Noam Chomsky, and philosopher Friedrich Nietzsche. No apparent sense of humor. That may help explain why Netflix is currently bereft of any existential stand-up specials. But Eric Kaplan, yet another Simpsons and Futurama writer with a Cal degree (Ph.D., philosophy), has a suggestion—Søren Kierkegaard. 

“Kierkegaard thinks that there are certain contradictions in human life and they’re unavoidable. So the best you can do is to feel them very intensely. Rather than come up with some way to think your way out of the contradiction you basically should acknowledge it and feel it. One of the best ways to do that, although not the best according to Kierkegaard, is comedy. Because comedy has to do with feeling the contradictory nature of a situation you are in.”

Kaplan has thought quite a bit about this subject. His dissertation, which he completed in 2017, was on comedy and the philosophy of Kierkegaard. He began his doctorate 25 years prior and left after four years to write for television. In his almost quarter-century leave of absence, he wrote for a wide range of programs. Among other credits, he staffed on The Big Bang Theory and Futurama, wrote an episode of The Simpsons, and co-created the irreverent Adult Swim cartoon The Drinky Crow Show

How is he able to hit so many different comedic notes? His academic background may have helped. “Philosophy is supposed to be a way that can communicate to anybody,” he says. As an undergrad, he also was interested in cross-cultural philosophy and majored in comparative religion, a great primer for understanding different worldviews—and different audiences. 

“When I look at the difference between Adult Swim and The Big Bang Theory, one thing I would say is people have different appetites for discomfort,” he says, pointing out the former whets that appetite, the latter not so much. 

And which would Kierkegaard have written for had he lived to see cable television? Kaplan says both. The Danish theologian adopted many different personas in his work, “each of which wrote differently and had a different philosophical perspective,” he explains. “And the kind of jokes that they made followed from their philosophical perspectives.” According to Kaplan, Kierkegaard’s mischievous and conniving Johannes the Seducer would be an Adult Swim writer. The ethics-bound Judge William would write for CBS. 

While Kaplan has a lot to say about the philosophy of humor, he’s part of a small club. “Philosophers have paid very little attention to comedy and have not said much that is of any value. That’s the sad truth. …. It’s a phenomenon [with] one leg in the rational and one leg in the irrational. Philosophers don’t like stuff like that …. They like both of the feet in the rational. Comedy is a little unclear. Is it a form of thinking or just a reflex? It’s not a phenomenon that philosophy in its current incarnation is terribly well-set to deal with.”

Cohen, Burns, and Kaplan all expressed some skepticism about the link between their studies and their comedy, but those studies have been put to work. Remember Cohen’s combinatorial problem with the burnt pancakes? He confronted a similar problem as the showrunner of Futurama: The characters Fry and Leela have swapped brains and are unable to switch them back. They are, however, able to switch brains with someone they have yet to switch with. Question: Is it possible for everybody to get their brains back? 

Cohen recalls that fellow writer Ken Keeler, who holds a Ph.D. in applied mathematics (yet another nerd Cohen hired), came in the day after the problem was posed with the solution. “He went to the dry-erase board and proved mathematically for any group of n people with their brains mixed up, they can be brought back to their original state by the one-way brain switcher as long as two new people (with their original brains) are added into the mix, with those two people also getting their brains back in the end,” he says.

In the resulting episode, Professor Farnsworth works out Keeler’s theorem on screen. Says Cohen, “I believe this is, in all likelihood, the only time in history that a mathematical theorem has served in such a heroic role in a TV comedy.” 

Dano Nissen 18 is a freelance journalist. He’s covered red carpets for Variety, regularly contributes to NPR member station KCRW, and is a proud UC Berkeley alumnus.

From the Spring 2021 issue of California.

Share this article