It’s no secret that many of the writers on The Simpsons are great big nerds. A lot of them went to Harvard, a school noted for the high collective IQ of its student body, and got degrees in subjects like Applied Mathematics, Computer Science, and Physics. All that brainpower resulted in one of the funniest, sharpest sitcoms in television history, at least in the early going. It also bled into the show in less obvious ways, as Simon Singh makes clear in an excerpt from his book The Simpsons And Their Mathematical Secrets, published by Bloomsbury and now available in paperback.

The excerpt takes an extremely detailed look at a throwaway joke tucked into the background of “The Wizard Of Evergreen Terrace,” an episode from the show’s tenth season that finds Homer following in the footsteps of Thomas Edison and trying to become a great inventor. While trying to come up with ideas, Homer scribbles down the following on a blackboard:

The blackboard isn’t prominently featured in the episode, and most viewers could be forgiven for ignoring it in favor of giggling over the ingenuity of Homer’s makeup gun. According to Singh, however, it contains a college semester’s worth of mathematical in-jokes. The third equation, for example, predicts that the universe will eventually implode under its own weight, a setup paid off when there’s a minor implosion in Homer’s basement. The fourth line involves topology, an area of geometry in which researchers study shapes by bending and stretching them into different forms. Here, Homer has transformed a doughnut into a sphere, an impossible feat in topology, by taking progressively bigger bites out of it, as is his wont.

The second line suggests that Homer has solved Fermat’s last theorem, a subject Singh spends over half the excerpt discussing. It’s too involved to summarize here, but it suffices to say that it’s not the kind of intellectual puzzle viewers have been led to believe Homer capable of solving. The full except is up on BoingBoing, alongside another one identifying which writers on The Simpsons and Futurama were incredibly, dumbfoundingly nerdy, instead of just the ordinary kind of nerdy required to write for an animated comedy show. They’re both absorbing reads, and go a long way toward proving that your sixth grade teacher may have been right about math being fun after all.