*This episode of *Inquiring Minds, *a podcast hosted by best-selling author Chris Mooney and neuroscientist and musician Indre Viskontas**, also features a discussion of some of the science behind Thanksgiving: Why thankfulness is good for us, and what kinds of food safety issues you should know about when it comes to Thanksgiving leftovers.*

*To catch future shows right when they are released, subscribe to *Inquiring Minds* via iTunes or RSS. You can also follow the show on Twitter at @inquiringshow and like us on Facebook.*

Simon Singh may not sound like your average fan of *The Simpsons*. He has a PhD in particle physics from Cambridge and made an award-winning documentary about Fermat’s Last Theorem. Let’s be frank: He’s a math geek.

But then, so are a surprisingly large number of the show’s writers. You may not have realized it, but as Singh shows in his new book, *The Simpsons and their Mathematical Secrets,* a seemingly endless supply of mathematical jokes and references are crammed into each *Simpsons *episode.

“There are lots of mathematicians on the Simpson’s [writing team] … and they still have a great affection towards numbers and geometry,” says Singh in this week’s interview on the *Inquiring Minds* podcast (listen below).

Singh first noticed the advanced mathematical genius of the satirical middle class American family during a 1998 *Simpsons* episode titled, “The Wizard of Evergreen Terrace.” In it, Homer jots down a few equations on a blackboard in his quest to become an inventor. One of these equations jumped out at Singh, who is author of the bestselling book *Fermat’s Enigma*: *The Epic Quest to Solve the World’s Greatest Mathematical Problem. *The “enigma” here centers on Fermat’s assertion that (forgive us for what is about to follow) while there are an “infinite number of solutions” to the following equation:

x² + y² = z²

… it is impossible to find any solutions (that are three different whole numbers) for this equation

x³ + y³ = z³

… or for this equation

x

^{4}+ y^{4}= z^{4}

… or for any other equation with the same structure, but whole number exponents greater than 2. Fermat famously (or rather, infamously) scribbled in the margin of a notebook that he had found a mathematical proof demonstrating this impossibility but that didn’t have the room to write it down.

Homer Simpson’s brain is not very large (something *The Simpsons* has proven through X-ray). Nonetheless, Bart and Lisa’s famously dense dad proceeds to write down an apparent solution to Fermat’s last theorem, alongside some other high-level concepts. And if you whip out your calculator and do the math for one of the equations below (3,987^{12} + 4,365^{12} = 4,472^{12}), you will find — spookily — that Homer has, apparently, bested Fermat.

“This equation about Fermat’s last theorem is in *The Simpsons* and I can’t miss things like that — they hit me straight between the eyes,” says Singh. (Did Homer actually prove Fermat wrong? Stand by — we’ll explain at the end.)

At first, Singh thought that the mathematical joke was a one-off — a nod from one of the writers, David X. Cohen, who has a BA in physics from Harvard and an MS in computer science from Berkeley. But after a bit of research, Singh discovered a close connection between math and *The Simpsons.*

It’s not just Homer who displays his mathematical prowess on the show: None of the major Simpsons characters is exempted from these, er, calculated jokes. Consider for instance a 2010 *Simpsons *episode titled “MoneyBart,” in which Lisa needs to add extracurricular activities to her resume, and so decides to coach Bart’s little league baseball team to diversify her portfolio. Taking the scientific approach, she immerses herself into sabermetrics, the use of complicated statistics to make managerial decisions. At first, her strategies transform Bart’s team from losers to winners, but during one critical at bat, Bart eschews Lisa’s advice to avoid swinging at anything … and wins the game with a fluke home run.

Lisa is furious, and tosses him off the team. Once again, her use of probabilities and statistical models puts the team on top, with one commentator calling her coaching style “a triumph of number crunching over the human spirit.”

But at the state championship, Lisa needs to bring Bart back on the team, as one of her players falls victim to a juice overdose. Once again, he’s faced with the choice of following her instructions or acting on his gut. This time, though, his instinctual response costs the team the game.

“According to Lisa, baseball demands to be analyzed and understood, whereas Bart believes the sport is all about instinct and emotion,” Singh says. “Does analysis destroy the intrinsic beauty of the world around us … or does it make the world even more beautiful?” This is the kind of question that has sown discord between science and society for centuries, meaning that *The Simpsons* is, arguably, plumbing some fairly deep waters here. In any case, Singh knows which side he’s on. He quotes physicist Richard Feynman, who once said that “science knowledge only adds to the excitement and mystery and awe … I don’t understand how it subtracts.”

So what draws math geeks to the seemingly frivolous world of TV comedic writing in the first place? Singh argues that the, er, correlation between *The Simpsons* and math is no accident. Rather, it’s a harmonious and natural relationship in many ways.

For one thing, animation these days requires fairly advanced programming skills, with knowledge of trigonometry, geometry, and calculus. “There is indeed a lot of mathematics behind the scenes,” opined Pixar computer scientist Tony DeRose in a recent talk at the Mathematical Association of America. So it makes sense for today’s hi-tech animators to have degrees in physics, computer science, and math. But what about comedy writers?

Singh reports that one of the mathematicians on the *Simpsons *writing team, J. Stewart Burns, draws a parallel between puzzles, which represent the very essence of math, and jokes. “Both have carefully constructed setups, both rely on a surprise twist, and both effectively have punch lines. Indeed, the best puzzles and jokes make you think and smile at the moment of realization,” Singh writes.

And there’s another reason, Singh speculates, behind the preponderance of mathematicians on the writing team of *The Simpsons* (compared with other successful sitcoms like *30 Rock *or *Modern Family*)*. *Unlike scientists who might be more comfortable with uncertainty and the messiness inherent in experimentation, Singh notes that mathematicians prefer to be in complete control. He quotes Al Jean, another *Simpsons* writer with a BS in math from Harvard: “Live-action TV is like experimental science, because actors do it the way they want to do it and you have to stick within those takes. By contrast, animation is more like pure mathematics, because you have real control over exactly the nuance of the line, how the lines are delivered and so on … animation is a mathematician’s universe.”

So we know what you’re wondering: Did Homer really best Fermat in “The Wizard of Evergreen Terrace,” finding a solution to the equation that the mathematician proved had no solution?

“If you check Homer’s solution on your phone’s calculator, Homer’s right!” says Singh. “So what gives?”

“The way you resolve this problem,” Singh continues, “is that your phone calculator is not accurate enough to see the error. Homer discovered what’s known as a ‘near-miss solution'” — it turns out that simpler calculators don’t calculate out to enough decimal places to show that the equation doesn’t work after all.

“I think it’s a lovely little joke about how there shouldn’t be a solution, but Homer found a solution,” Singh says.

And therein lies one of the most compelling aspects of the longest running sitcom in TV history: the many jokes, references and gags that the animators and writers insert into nearly every frame. One viewing is never enough.

*This story was produced as part of the *Climate Desk* collaboration.*