Pi in the Simpsons

Homer contemplates pi

Homer contemplates pi

Mathematics in the Simpsons

In a newly published book, Simon Singh presents a too little-known back story about the Simpsons TV show: underlying much of the clever screenplay are numerous references to somewhat sophisticated mathematics both in the Simpsons and in the follow-up Futurama.

Simon Singh is no stranger to either mathematics or show business. He directed an award–winning BBC documentary on Fermat’s Last Theorem and authored the best-selling book Fermat’s Enigma on the same topic. He is a physicist by training, with a Ph.D. from Cambridge and is engaged in a host of science popularization ventures.

Fermat’s Last Theorem disproved?

One of the more striking tidbits revealed by Singh is from an episode “The Wizard of Evergreen Terrace,” which aired on 20 December 1998. In this show Homer is determined to follow in Edison’s footsteps. The title itself is an allusion to Edison, who was known as the “Wizard of Menlo Park” (Menlo Park, New Jersey, not Menlo Park, California). At one point in the episode, several equations appear on a blackboard in the background, including the enigmatic “identity” 398712 + 436512 = 447212.

Only a handful of viewers recognized that this is a remarkable near-equality of the form of Fermat’s Last Theorem. The three integers are
16134474609751291283496491970515151715346481
47842181739947321332739738982639336181640625
63976656348486725806862358322168575784124416
In fact, the sum of the first two is
63976656349698612616236230953154487896987106
which agrees with the third number above to 10-digit accuracy, but of course is not equal.

This “identity” is the work of screenwriter David S. Cohen, one of several young mathematically-minded and trained screenwriters working on the show at the time. Singh also describes lovely episodes playing with time travel and dimensionality—remember the Simpsons are two-dimensional.

Pi in the Simpsons

Singh includes not one but two chapters on appearances of pi in the Simpsons. In the Simpsons show Marge in Chains, which aired on 6 May 1993, Marge is arrested for shoplifting some liquor. During the trial, Marge’s lawyer questions the reliability of the store’s proprietor, Apu Nahasapeemapetilon. However, when Apu is brought to the witness stand, he says that he has perfect memory: “In fact I can recite pi to forty thousand places. The last digit is 1.”

In his account of the creation of this script, Singh writes that writers Bill Oakley and Josh Weinstein originally just had Apu simply saying that he had been famous in India for his mental ability. But while discussing the draft script, they saw an opportunity to insert some mathematics. Their colleague Al Jean, who had just read of a world-record-setting recitation of pi, suggested that Apu could recite the 40,000th digit of pi.

Singh writes “The writers decided they needed some expert advice, so they contacted a brilliant mathematician named David Bailey, who at the time was working at the NASA Ames Research Center. Bailey responded by printing out all forty thousand decimal places of pi and mailing them to the studio.” (Today they could just look on the web.)

This “David Bailey” is, as you might guess, one of the two co-bloggers of this site. Indeed, in October 1992 Bailey received a fax from the Simpson’s show, requesting the 40,000 digits. A photocopy of this fax is available here. He dutifully performed the computation and sent the results back to the studio. Bailey justified the computation to his superiors at NASA by saying, in a report, that he was “helping the U.S. entertainment industry maintain leadership in the international marketplace.”

In a footnote, Singh writes

Bailey helped to invent the spigot algorithm for finding the digits of pi. A spigot is a type of tap, and a spigot algorithm generates answers in a tap like fashion, which means that pi is calculated drip by drip, digit by digit. The spigot algorithm can be tuned to generate any particular digit with perfect accuracy, so you might then think that it would be easy for Bailey to tune his algorithm to deliver the forty-thousandth digit. Unfortunately, Bailey’s algorithm only works in hexadecimal (base 16), not decimal (base 10), as Jonathan Borwein (the other co-blogger of this site) has proved.

This isn’t quite right. It is certainly true that Bailey was a co-discoverer, with Peter Borwein (brother of co-blogger Jonathan Borwein) and Simon Plouffe, of what is now known as the BBP formula for pi, namely:

bbp-formula

This formula, after a certain transformation, does permit one to directly calculate the nth digit of pi, in hexadecimal (or binary). For details on how this is done, see this brief note.

However, in other respects Singh isn’t quite right. The BBP formula is not correctly described as a “spigot” algorithm. Instead, its virtue is that it permits one to compute the nth digit, without any reference to any of the digits that came before; indeed, the previous digits have no place in the algorithm. Perhaps Singh was thinking of the spigot algorithm of Stanley Rabinowitz and Stan Wagon. This scheme indeed calculates digits of pi in a “spigot” fashion, with each new digit computed based on the string of all previous digits.

Actually, to compute the 40,000 digits requested by the Simpson’s show, Bailey used the Borwein quartically convergent algorithm for pi, which had been discovered a few years earlier by Jonathan Borwein  and his brother Peter Borwein. But this algorithm is not related to the BBP algorithm. Indeed, the BBP formula and algorithm were not discovered until 1996, three years after “Marge in Chains” appeared on TV.

Mathematics and science in popular TV

It is truly refreshing to see that at least a few renegade Hollywood screenwriters have been brave enough to introduce some non-trivial mathematics and science into popular TV.

It is sad that in most other Hollywood productions, scientific fields such as mathematics and physics, if they are mentioned at all, are objects of jokes and sometimes derision. The ‘mad scientist’ is an industry staple. One example is the long-running and Emmy-winning “Big Bang Theory,” in which the main characters are brilliant scientists who are depicted as the epitome of nerdiness.

That said, no one doubts they — or the mathematician hero of the 2005-2010 CBS show NUMB3RS — are smart or that science is important. Steven Hawking, Nobel prize winner George Smoot, StarTrek actors and others are delighted to make cameo performances.

And as Michael  Crichton  said in 1999 “All professions look bad in the movies … why should scientists expect to be treated differently?” Perhaps we should be happy to settle for ‘geek-chic’, or preferably ‘geeky’, being viewed as a positive attribute. It is doubtful that our current educational deficits in mathematics and science will be remedied until that is the case.

Comments are closed.