### Television

# The Simpsons' Secret? It's Written by Math Geeks

For 25 seasons, *The Simpsons* writers have been smuggling math onto Americans' TV screens. Author Simon Singh helps Ira decode the show's numberplay, while former *Simpsons* writer David X. Cohen remembers how he helped Homer solve Fermat's Last Theorem (sort of).

(SOUNDBITE OF 'THE SIMPSONS' THEME)

IRA FLATOW, HOST:

That, of course, is the theme of the longest running sitcom in American history. "The Simpsons" kicked off its 25th season this year. And if you've ever seen the show, you know how Homer Simpson is no math genius. He's more interested in the pie of pastry than 3.14. But in the episode "The Wizard of Evergreen Terrace," Homer does something extraordinary. He seems to have found a counter example to the notorious math problem Fermat's Last Theorem. What's going on here?

Author Simon Singh wanted to know and he investigates that question plus a lot more in his new book "The Simpsons and Their Mathematical Secrets." He says "The Simpsons" set is populated with number-loving writers who have been smuggling math into the series for years, usually without us noticing. Simon Singh joins me from London to help us unpack some of these math gags. Welcome to SCIENCE FRIDAY, Dr. Singh.

SIMON SINGH: My pleasure. Good to talk to you.

FLATOW: Thank you. Also joining me is David X. Cohen. He is a former Simpson writer and an executive producer of "The Simpsons" sister series "Futurama." He joins us from Los Angeles. Welcome, David.

DAVID COHEN: Thank you very much. Happy to be here.

FLATOW: Simon, how did the Simpsons' writers - how did that room become a magnet for mathematicians?

SINGH: I think it goes back to the very, very beginning. A couple of people, like Mike Reiss who was a really talented young mathematician. When he was a teenager he competed in math competitions. And Al Jean who was a really, really bright young teenager. He was so bright that he went to Harvard to study math when he was only 16 years old. So both these two people, Mike Reiss, Al Jean both loved math, both loved comedy writing.

So when they went to Harvard they took part in Harvard Lampoon and they wrote for the Harvard Lampoon. They formed a comedy-writing partnership. And when they graduated, fairly soon afterwards, they joined the writing team of the very first series of "The Simpsons." And so in that very first series - well, in pretty much the first episode, "Bart the Genius," we have a reference to calculus, in fact a very old joke about calculus.

And they seem to have been doing this ever since. Al and Mike still work on "The Simpsons" and bit by bit they brought other people onboard. And this tradition of putting in mathematical jokes has just gone on for years and years.

FLATOW: 1-800-989-8255, if you'd like to talk about "The Simpsons" and all the math that's in there. Let's talk about this Fermat's Last Theorem. How did it end up in "The Simpsons?"

SINGH: Well, I mean, I spotted it because, you know, I suppose I've been watching "The Simpsons" for maybe 10 or 12 years before I noticed the mathematics and the reference to Fermat's Last Theorem in "The Wizard of Evergreen Terrace." It really hit me straight between the eyes because that was the first - you know, the first book I'd ever written was all about Fermat's Last Theorem. So when it appears in "The Simpsons," that's something I'm not going to miss.

I mean, I could tell you how it appeared in "The Simpsons," but David X. Cohen is the man who's responsible so...

FLATOW: Take it away.

COHEN: All right. This is my moment to shine. That episode, like many "Simpsons" episodes, had a background that was calling out to be filled up with something. In this case we had a blackboard. So up in - late in the show - late in the process of making the show we suddenly say, wait a second, Homer's a genius in this episode writing on a blackboard. We better have something there.

So as the science and math nerd on the staff at that time, I was called upon to fill up this chalkboard with stuff. So in this case it's apparently a counter example to Fermat's Last Theorem, which says that for the equation a to the n plus b to the n equals c to the n, there are no solutions of n is greater than 2.

So what I decided to do, as a former computer science guy, was to write a computer program that would look for very, very near misses to this equation, so close that if you tried them out on a calculator, it would appear correct to the number of digits that most people had available on their calculators, at least at that time.

So in the episode Simon's talking about I have one that's correct to ten places. So many people tried it out on their calculators and I was very, very pleased the day after it aired to see some people gathering on the Internet to converse about it and saying, what's going on here? This seems to be a counter example to the theorem, which I think had just been proven at that time. So it was pretty inexplicable. So that was my goal.

FLATOW: Did you all find out that there were mathematicians and people who were interested in math as part of your "Simpsons" audience?

COHEN: We found out by sticking these things in basically for our own benefit, you know. Because these are sort of background jokes, things that you can only see really if you freeze frame later on, at that time a VCR, or nowadays on your DVR. It didn't really matter to us that much if people got them. You know, we just wanted to fill up the space and make it look like Homer was doing something smart.

So only later when we saw people discussing it energetically on the Internet did we realize people were actually getting these jokes that were done really pretty much for our own amusement.

FLATOW: And were you allowed and are the writers still allowed free rein to stick in math whenever they'd like to?

COHEN: Yes, believe it or not. "The Simpsons" has always been kind of an oddball among TV shows because the inmates run the asylum, meaning the writers obviously in this case. And there's always been great freedom for the writing staff there, thanks to Jim Brooks and Matt Groening demanding that when the show first came on the air.

So the head writers, Al Jean and Mike Reiss early on that Simon mentioned, and later Bill Oakley and Josh Weinstein, among others, were very encouraging of people to just put in obscure references to whatever they were interested in. You know, it's not always math. Sometimes there are obscure references to history for example or whatever the particular writer's interested in.

And our theory was if you put in a very obscure joke in the background, those few people who get it will be so amazed that you hit this obscure thing that only they and a few other people know about, that they'll really be hooked for life. So over the course of 25 seasons of course everybody gets their own private joke in the background at some point.

FLATOW: So the inmates are running the asylum over there, yeah. I want to play a clip of the episode called "Homer Cubed." And in this clip, Simon, maybe you could tell us about this. Homer enters the third dimension. Let me play it first.

(SOUNDBITE OF TV SHOW, 'THE SIMPSONS')

DAN CASTELLANETA: (as Homer Simpson) What's going on here? I'm so bulgy. My stomach sticks way out in front and my - ah.

YEARDLEY SMITH: (as Lisa Simpson) Wow, where's my dad.

HANK AZARIA: (as Professor Frink) Well, it should be obvious to even the most dimwit individual who holds an advanced degree in hyperbiotopology that Homer Simpson has stumbled into the third dimension.

COHEN: Simon, it's almost "Twilight Zone" there.

SINGH: You're spot on, I think. I mean, again, I kind of defer to David on this one. This is entirely his creation, that segment of "Treehouse of Horror 6." But, I mean, vitally a bit about the math and then David can tell you a bit about how this show came to be and the link to "Twilight Zone." But, you know, in that one 6- or 7-minute story, there is another false solution to Fermat's Last Theorem, a near miss false solution, very clever one.

There is a reference to the Utah teapot which is a way of modeling three dimensional objects which kind of test how good your mathematical modeling is. There's a reference to Cartesian coordinates. The whole story is about math in higher dimensions and what reality and higher dimensions might be like. There's an appearance by Euler's identity which is E to the I pi plus one equals zero, although slightly rearranged in this episode.

That's one of the most beautiful equations in mathematics if you took a poll of mathematicians. There's also an equation which says p equals np which is an answer to a question which is worth a million dollars if you can solve it. Mathematicians have no idea what the answer to this question is. And the question is essentially this in very, very crude terms. You have simple questions and hard questions in math.

And the question is, are the hard questions really hard or could one day they be made easy? Is there a trick that we're missing? If the hard questions, which are called np could be made easy, which is a p type question, then p equals np. And that's what appears in this episode. We see the line p equals np. So we have an episode of "The Simpsons" postulating an answer to an unsolved riddle in mathematics.

And then in "Futurama" which is the sister series to "The Simpsons"- and David was co-creator of that series, we see another writer, I think it's Jeff Westbrook, in an episode called "Put Your Heads on My Shoulder." We see an episode where - a scene where Amy and Fry are in a stationary cupboard. And on the shelf there are two folders. One is marked p and one is marked np.

So what Jeff Westbrook is saying is, no, no, the hard ones will always be in a separate folder and the easy problems will always be in a separate folder. So he's contradicting "The Simpsons" episode by saying p does not equal np.

Now, I mean, that's quite a confusing explanation. Listeners may not have followed it all in detail. But essentially what I'm trying to say here is we've got a debate about the outcome of an incredibly important conjecture in mathematics spanning across two animated series.

FLATOW: Yeah. Yeah.

SINGH: So that's the depth to which these writers are playing around and having fun with math and having fun with the audience who picks up on what they're doing.

FLATOW: David, when you write that do you think they will have that fun?

COHEN: I always...

FLATOW: Or are you just doing it for yourself?

COHEN: You know, as I said before, we were originally sort of just doing these freak things for ourself. In this particular episode I would say things are a little bit different because this is one episode of "The Simpsons" where the math and science of it is really front and center. The example before was the background gag with the blackboard. This one, the very plot of the episode was mathematical in terms of Homer entering a higher dimension.

So it's a little different in this case. And I want to mention a couple of things about it to put it in its historical perspective. This was back in 1995, is that right, Simon? Something like that.

SINGH: Yeah. Maybe '96.

COHEN: '96. And at that time it was very, very expensive to do this kind of 3-D graphics for television that we were going to attempt to do. This was, again, credit to Bill Oakley and Josh Weinstein. They had the original idea and assigned it to me to write it. So we couldn't really afford to do it but they fished around a little bit and this company Pacific Data Images ended up volunteering their time to do this very expensive animation for us.

So there was actually an explanation from some of these jokes, the math jokes that Simon's talking about that relates to this, in terms of us saying P equals NP in that episode. That was referring to the difficulty of rendering the computer graphics on computers at that time. And we were saying, oh, this isn't so hard. This problem is pretty easy after all if we can do it for TV. So that was sort of the reason we chose that answer in that episode.

FLATOW: Have you had - I'm sorry, go ahead.

COHEN: Go ahead. And similarly, there was actually another equation if we can go all the way from math to physics, if we can make that huge...

FLATOW: Right.

COHEN: ...transition for a second, there was another equation floating around in the third dimension relating to astrophysics and it was saying that the universe would ultimately contract and collapse on itself. Which is what happens to that universe in that episode. It sounds like our prediction was not that accurate for our universe but it was very accurate for Homer's universe.

FLATOW: Have "The Simpsons," you know, at the very beginning where they all climb into the couch, has any math ever been used in that little opening there?

COHEN: Hmm. Good question. Now I'm going to defer to Simon who's been researching this more recently.

(LAUGHTER)

SINGH: I've got a feeling that there is a - I was going to say Addish. I don't mean Addish; I mean Escher. I think there's an Escher gag around the sofas where the family arrive into a kind of a universe where gravity is pulling in three perpendicular directions. So sometimes even in the (unintelligible) there is mathematics. And by the way, you're right, it was 1995, David. I was wrong on that.

But there is this physics element to it. You have gravity pulling in different directions or a gravitational equation in "Treehouse of Horror VI" and I was giving a talk today about this topic, about mathematics and "The Simpsons" and "Futurama" at the Cavendish Laboratory in Cambridge where they've got a very, very strong particle physics group there. I say that because I used to be a member of it a long time ago.

But on one of the blackboards where David put a false solution to Fermat's Last Theorem there's also an equation that predicts the math of the Higgs boson. And, you know, this is extraordinary stuff.

FLATOW: Yeah. Yeah.

SINGH: And the prediction is somewhat high. But the professors at the Cavendish Laboratory in Cambridge were very impressed and were saying, you know, for 1994 which I think was the date maybe of that episode - no, 1998 - that was not a bad at all prediction for the Higgs boson. So, you know.

FLATOW: Not bad for - yeah.

SINGH: Professionals are very impressed by what goes on in "The Simpsons."

FLATOW: This is SCIENCE FRIDAY. I'm Ira Flatow. We're talking with Simon Singh, author of the book "The Simpsons and their Mathematical Secrets" and David X. Cohen, a former "Simpson" writer, executive producer of "Futurama," the "Simpsons" sister series. 1-800-989-8255. Quick phone call before the break. Matthew in Denver. Hi, Matthew.

MATTHEW: Hi there. I wondered if Bart in the opening chalkboards has ever written out pi.

FLATOW: Has Bart ever written pi on the - as a, you know, punishment exercise, right?

SINGH: No. I don't think there's been anything particularly mathematical in those gags but I've seen a lot of people parody it with mathematics. So there are lots of sketches on the Internet of Bart doing the chalkboard gag but with complicated math instead, or complicated equations repeated line after line.

COHEN: That's actually a good idea if we ever are a little short on ideas for the episode. We could just have Bart writing pi and never finishing and that could fill up whatever time we needed to fill up.

(LAUGHTER)

MATTHEW: OK. You can give me a call...

COHEN: I may have to steal that idea.

MATTHEW: ...to give me my royalties for that.

(LAUGHTER)

FLATOW: Right. Thanks for calling. 1-800-989 - well, are there things in the hopper that you haven't finished that you'd like to get in, you know, while you still can?

COHEN: "Futurama" just finished up, so that was my main vehicle for sneaking these things in. But there's always time still on "The Simpsons." It never quite seems to end. And in fact, there is a crossover "Futurama" - "Simpsons" episode coming up next fall for any of you joint fans. And that will certainly have a lot of math and science in it.

FLATOW: Yeah. Well, you know, you have a character named Fry and we're always very - we're always happy to a guy named Fry because we're SciFri.

(LAUGHTER)

FLATOW: Very close to our heart. 1-800-989-8255. Let's go to Richard in Fremont. Hi, Richard.

RICHARD: Hey guys. I had a question for David. I'm a big fan of "The Simpsons" and I've noticed the number of 37 pops up a lot more than an accident. And I was wondering if, David, you could expound if there's any significance to that.

COHEN: Hmm. That's funny. There is a number that I purposefully stick in periodically into episodes and that's the number 24. So I don't actually - I don't know the 37. I know that 24 is the series - very unmathematical. It was my uniform number in little league because I was a fan of Willie Mays.

FLATOW: So, hey.

COHEN: So I took his number. So I can tell you 24 - there's like, a, you know, proposition 24 they vote on ending.

(SOUNDBITE OF DIAL TONE)

COHEN: He wasn't that interested in my answer, apparently.

(LAUGHTER)

FLATOW: No, they just listen on the radio. It's a little easier.

COHEN: Because I didn't talk about 37 a lot of the audience lost interest there.

FLATOW: Thirty-seven.

(LAUGHTER)

FLATOW: In grad school, you studied something called burnt pancake problem. What is that?

COHEN: Oh, it's very, very important. This is a theoretical problem where you have to imagine you have a stack of pancakes on your plate for breakfast and they're all different sizes. And ideally you would like to have them in that nice, neat arrangement where the biggest one is on the bottom, then they're in order up to the smallest one on top.

But when you get served the pancakes initially they're all out of order and the only way you can sort them is to stick a spatula in, somewhere in the middle of the stack, lift up the ones above it and flip them all over and put them back down. The question is if you have a stack of N pancakes and you are a very smart flipper, what is the fastest - what is the number of flips that it takes to sort this stack of pancakes out into the proper arrangement.

And then...

FLATOW: I'm going to have to hold you there.

COHEN: Sure.

FLATOW: We'll get an answer after the break.

COHEN: OK.

FLATOW: Stations love that, I know.

COHEN: It's very dramatic.

FLATOW: We're going to come back, talk more with David X. Cohen and Simon Singh, author of "The Simpsons and their Mathematical Secrets." Stay with us after this break. We'll be right back.

(SOUNDBITE OF MUSIC)

FLATOW: I'm Ira Flatow. This is SCIENCE FRIDAY from NPR.

(SOUNDBITE OF MUSIC)

FLATOW: This is SCIENCE FRIDAY. I'm Ira Flatow. We're talking this hour about the math hidden in "The Simpsons" and "Futurama," two of the most acclaimed animated shows of all time, with my guests Simon Singh, author of "The Simpsons and their Mathematical Secrets." David X. Cohen, a former "Simpson" writer and executive producer of "Futurama," "The Simpsons" sister series. Our number 1-800-989-8255.

And when I rudely interrupted David Cohen he was telling us about these famous burnt pancake problem.

COHEN: Yeah. We left off at a very dramatic moment when I was about to reveal the answer to this problem. And the question was how many spatula flips does it take to sort a stack of N pancakes? And the answer is nobody is quite sure even to this day but the best we can do is sort of put bounds on it. It takes at least this many flips, at most that many flips.

And a particularly interesting thing about this problem is that one of the earliest papers written on the subject was actually coauthored by Bill Gates of Microsoft fame. And I think it's the only paper that he's known to have published, though. That's the one thing I have in common with Bill Gates.

FLATOW: Does it have any practical application at all?

COHEN: We've struggled a little bit to claim that. Let me put it that way. I know one area where it may relate is in terms of looking at DNA, where you look at bits of DNA that have broken off and reverse themselves from generation to generation. And you'd say, oh, how many flips did it take to get from this starting point to this end point. And you might say how many mutations or how many generations it might've taken to get from one point to another.

FLATOW: Hmm. Yeah. Well, you're trying to fake it a little.

(LAUGHTER)

COHEN: Did you buy it enough to offer me some grant money? That's the question.

(LAUGHTER)

FLATOW: Right. As if "The Simpsons" need grant money, right?

(LAUGHTER)

FLATOW: 1-800-989-8255. We have something, another clip that I want to play, something called a clip from the season finale, "The Prisoner of Benda." This is Sweet Clyde explaining the "Futurama" theorem.

(SOUNDBITE OF SHOW, "FUTURAMA")

JOHN DIMAGGIO: (as Bender) Cube to E to the D.

KATH SOUCIE: (as Professor Farnsworth) So it is possible for us all to get back to our original bodies?

UNIDENTIFIED MAN: (as character) Stone cold munching, prof. Sweet Clyde, characterize your inversion theory.

DAVID HERMAN: (as Sweet Clyde) Basically, no matter how permeated up your minds are they can be restored using at most two extra players.

SOUCIE: (as Professor Farnsworth) And they say pure math has no real world applications.

FLATOW: There you go. Not quite the season finale but really a finale of a great piece. Simon, you spent a lot of time writing about "The Prisoner of Benda." What's so special about that episode?

SINGH: Well, so the episode involves the - Professor Farnsworth has a mind switching machine and characters have fun switching minds occupying other people's bodies and there's kind of an orgy of mind switching. And by the end of the episode, though, everybody wants to get back to their original bodies.

Now, the problem is that the mind switching machine has a glitch. Once two people have swapped, they can't swap back. And it's not clear that people can therefore get back to their own bodies by maybe alternative routes. It's not clear if that's possible. So Ken Keeler, who has a Ph.D. in applied math from Harvard and who was AT&T Bell Laboratories and who's been a writer on "The Simpsons" and "Futurama," he decided to look at this problem from a mathematical point of view.

Given N people and given Y switches, what would you require to guarantee that everybody can get back to their original bodies? And he went away and came up with a proof which is generally known as the Futurama Theorem. Ken's very modest about it; he says it's no big deal but it's a nice little theorem. And other mathematicians have played with it as well and added to it a bit.

But the bottom line is that according to the Futurama Theorem, as long as two fresh people are added into the mix, then they give you the flexibility, the wriggle room, you need for everybody else to get back to their original bodies. And it's a lovely little theorem. And, you know, it shows the extent of what's going on in "Futurama" and "The Simpsons."

Because this is probably the only example in the history of television of a comedy writer creating a bespoke theorem purely to resolve a plot point. It's, you know, an extraordinary piece of mathematics.

COHEN: Wasn't there one episode of "The Golden Girls" that had that also?

(LAUGHTER)

SINGH: I talk about "Are You Being Served?" or "Benny Hill" when I'm talking in the U.K. but it's the same point.

FLATOW: Well, that brings me to a good question. What is there about the connection between comedy writing and mathematicians? Why are mathematicians willing to give up a career at Harvard and go into comedy writing? I mean, they can't believe at the beginning it's for the money. What is there - is there something, you know, we hear a connection between mathematicians and music a lot. Do you think - I'll ask both of you - David, do you think that there's sort of a brainiac connection between the two?

COHEN: You know, I've been asked this question a lot and I used to always try to make something up on the spot and it would always sound a little concocted. And I started saying, no, there's no connection at all. But ultimately I have settled on one answer. You can decide how phony baloney it sounds.

That at least in terms of mathematical proofs and writing jokes, this is my observation. That in both cases you're trying to get to an end point. In the case of the mathematical theorem it's a statement that you think is true but you need to prove it from a starting point. In the case of a joke for a script, the way we write it, you need to get some information across, like, you know, there's going to be a talent show at the school.

FLATOW: Yeah.

COHEN: But you have to say it in a way that's funny. So in both cases you have this end point. You're not sure how you're going to get there. And on top of that, you're not sure it's possible to get there. You know, there may not be a really funny way to deliver the information and there may not be a proof to get to your statement, even if it is true.

So in both cases you're sort of flying by the seat of your pants and going on your experience and your intuition that there's a way to get from point A to point B.

FLATOW: Yeah.

COHEN: And even as I'm saying this I feel like I should have stuck with the answer no. They're not really that similar.

(LAUGHTER)

COHEN: But...

FLATOW: Simon, you got...

COHEN: ...there's one possibility.

FLATOW: Yeah. OK. So it's good as any.

SINGH: Well, yeah. I mean, I asked all the - I met the writers last year and they were very generous with their time and I asked them this question as well. And everybody came up with an answer. And I have a chapter that's kind of all about their different answers. And the one common theme that people seem to suggest was the idea that mathematics is about logic and so these people enjoy playing with logic, they enjoy stretching it, bending logic.

And then occasionally you break the logic. And when you break the logic you get to the illogical. And maybe that's where humor arises. Also I think, you know, if you have a mathematical mind you just have a different view on the world. You're slightly an outsider. You have an odd perspective on the world. And again, maybe a lot of comedians and comedy writers are slightly outside to the mainstream.

I think observationally there's definitely something there because you have a, you know, huge gang of mathematicians on "The Simpsons" and "Futurama" and then people like Tom Lehrer.

FLATOW: Yeah. Yeah.

SINGH: You know, the greatest musical satirist of the 20th century, a math professor at Harvard. In the U.K. we have some of the best comedians, people like Dara O'Briain. He may not be well known in America but he has a degree in math and physics from Dublin and he's, you know, one of the top rated standup comics over here. Dave Gorman, an award-winning comedy writer who was doing mathematics in Manchester before he left to become a comedy writer.

So observation that there's definitely something there but the explanation, yeah, not clear.

FLATOW: Maybe Har...

COHEN: That's a better answer. I'm going to use that from now on.

FLATOW: Maybe Harvard ought to put out a course in comedy writing for all those mathematicians.

COHEN: One thing all comedy writers hate is trying to figure out why something is funny, I think. So that's why we all kind of hem and haw, because we don't want to give the answer and we don't really want to know. We're just like is it funny or not? If it is, put it in.

SINGH: It reminds me, I mean, it's about almost like scientists talking about the philosophy of science. That's one thing that scientists just hate talking about, the philosophy of science. And I think it was Richard Feynman who said, you know, scientists are about as interested in the philosophy of science as birds are interested in ornithology.

(LAUGHTER)

FLATOW: Well, we have tried to do programs over the 22 years we've been on, on are scientists funny? You know, and - see? Just like that. We have crickets chirping in the background when we try to do it.

(LAUGHTER)

FLATOW: All right. Although we do know some very funny scientists. When you sit them down, they're, you know, it's the mic fright or whatever it is, that they just...

COHEN: You know, I studied physics and computer science before I became a comedy writer and I always found that all of my fellow students - maybe not all but a good percentage of them - were funny people. So I certainly observed that throughout my life. And, again, I don't have a good explanation but I believe it is true.

FLATOW: Mm-hmm. David, being in scifi there are a lot of science jokes in "Futurama." Do you have a favorite one?

COHEN: Yes, I do have one that I like to quote. There's an episode where a character, Professor Farnsworth, is at the horse races in the future and there's a very close finish, so close that they call it a quantum finish and they have to take a photo. And they ultimately rule one horse the winner, causing the professor to lose his bet. And he says no fair. You changed the outcome by measuring it. And I thought that's a joke you would not see on most sitcoms on TV.

FLATOW: You're right. See, it's a take off on Schrodinger's cat then. How often do people send in jokes? Do they send in math, say, hey, put this on or do that kind of stuff there?

COHEN: No. Nobody sends in any - well, I was about to say nobody sends in anything. I think they do but it goes in the trashcan before we see it, probably for legal reasons. But what actually happens is sometimes there is a need for some math that's a little beyond the level of even our retired and lapsed scientists on our staff and that's when we usually call on some of our old friends who are real, actual, working scientists.

Often my friend David Schiminovich, for example, who's an astrophysicist at Columbia.

FLATOW: Mm-hmm.

COHEN: But he has provided a lot of the real hardcore math and science, including the estimate of the mass of the Higgs boson that Simon mentioned.

FLATOW: Right. Simon, what's your favorite number to crop up in "The Simpsons" or "Futurama"?

SINGH: Well, I really think it's my favorite number before I noticed it in "Futurama" but it's 1729 - 1,729. And it's the number of the Nimbus Spaceship, Zapp Brannigan's spaceship. I think it's Bender's unit number. It's a number of a universe that Fry pops out of in the "Farnsworth Parabox." And so why does this number 1729 keep cropping up in "Futurama"?

Well, it relates to an Indian mathematician called Ramanujan. And very, very briefly the story is that Ramanujan was this incredibly, brilliantly naturally gifted mathematician in India. He had very little schooling but he just would invent theorems that were beautiful and elegant and rich and original. And so a Cambridge mathematician said, look, you've got to come to England. You've got to come over and work with me.

So he got on a ship and he came to Cambridge and he flourished. He was just a genius. But physically he really suffered. He died when he was only 33. And so he was ill in hospital and G.H. Hardy, the professor who invited him over, went to visit him in hospital, took a taxi. Got out of the taxi, went in to Ramanujan's room, sat next to his bed and, now, Ramanujan was dying so there wasn't much they could really talk about.

But Ramanujan said, oh, OK. What was the number of the taxi you took to get here? And Hardy said it was 1729. This "Futurama" number, 1729. And, oh, it wasn't very interesting, though. Not an interesting number. And Ramanujan said, no, no, no, that's really interesting. That's really interesting because 1729 is the smallest number that's the sum of two cubes in two different ways.

I think it's 12 cubed plus one cubed and it's also 10 cubed plus nine cubed. Now, again, people don't need to follow that bit of math but the important thing is that Ramanujan could pluck these things out of thin air.

FLATOW: Yeah.

SINGH: And then the other wonderful this is that it's a hundred years ago since Ramanujan wrote to Hardy and now we see this number cropping up in this animated science fiction sitcom with the writers kind of paying their respect, playing a little tribute, to Ramanujan, this mathematician that maybe very few viewers would necessarily know about.

FLATOW: Mm-hmm. I'm Ira Flatow. This is SCIENCE FRIDAY from NPR. Talking with Simon Singh, author of the book "The Simpsons and their Mathematical Secrets" and David X. Cohen, former "Simpsons" writer and executive producer of "Futurama." Is there such a thing as a former writer, David? I just, you know, it's like a former president or something?

COHEN: Former writer for a TV show, yes. If you mean more philosophically, I guess...

FLATOW: No.

COHEN: No. I guess we're always going to be scribbling something. But I kind of left "The Simpsons" behind when I went to "Futurama" so I've been gone from there for a while. Although I visit once in a while.

FLATOW: Do you need to have a different mindset to write math for the different shows?

COHEN: No, not really. I mean, I think the thing they have in common is, again, it's a little more broad than this. It's not that the shows are a hundred percent open to math only but that they are open to any kind of smart and interesting ideas. And at "The Simpsons" even through all the different incarnations and different show runners, they've always been people who encouraged the writers to really go into depth about subjects they were interested in.

So, you know, somebody else could and probably has written a book about "The Simpsons" and history of "The Simpsons" and philosophy. There are some of these books. So it's just very rare you get to work on a TV show where whatever you're interested in you have the opportunity to sneak it in.

FLATOW: Yeah. Well...

SINGH: And sometimes there's an overlap between different areas of interest. In the episode, the "Futurama" episode "The Honking," the crew go to a haunted castle and blood appears on the wall and it's the digits - I think the digits are 01-01-10-01-01. Which isn't very interesting. As a binary number, it's 357. It's not very interesting. But then Bender sees the number reflected in a mirror. So it's now 10-10-01-10-10.

Now that is binary but in decimal it's 666 which is the number of The Beast and is very terrifying. And Bender gets up and runs away. Now, what's lovely about that is that's never explained to the viewer. The only way a viewer would understand why Bender's so scared is if they can do binary to decimal conversion on the fly in half a second. Which is an astonishing...

FLATOW: Yeah. That's something.

SINGH: ...levels of love of mathematics required. But that's also a reference to "The Shining" when the boy Danny goes into his mother's bedroom and writes red rum on the door. Red rum, red rum. And then the mother sees it reflected in the mirror which is Murder backwards, Red rum. So you have the twin reference to a 1980s classic horror film and a binary reference to the number of The Beast.

FLATOW: And that's why sometimes you have freeze frames or you can freeze your VCR in the old days and then try out the number and see if it's working.

COHEN: Yeah. And by the way, another reason these jokes appeared is because "The Simpsons," the arrival of the Simpsons in the TV schedule was right around the time that everyone pretty much had a VCR for the first time so it became possible to do these freeze frame jokes where you actually were cognizant that the viewer would be able to go back and look at them later.

You know, in the '70s or earlier, people didn't have VCRs widely and you couldn't - there was no point in writing jokes that the person would have to go back and look at it later. So the timing just happened to work out to make these things possible.

FLATOW: Mm-hmm. Gentlemen, I want to thank you both for taking time with be with us. A fascinating look behind "The Simpsons" and, you know, I've been watching it for years, these math things pop in and out. I really didn't know whether you guys were intentionally doing it or not. It's nice to hear that you guys were. Congratulations. And David, anything on the future for you, what you'd like to do?

COHEN: I would like to rest a little bit...

(LAUGHTER)

COHEN: ...after the grueling ups and downs of "Futurama" but I will be back with something good, so.

FLATOW: All right. We'll watch for it.

COHEN: Sure.

FLATOW: Simon Singh, thank you very much for taking time to be with us today and good luck on the book. "The Simpsons and their Mathematical Secrets." Great read there.

SINGH: Good to talk to you.

FLATOW: You too.

SINGH: Cheers.

FLATOW: And as I say, David X. Cohen is a former "Simpson" writer and executive producer of "Futurama."

Copyright © 2013 NPR. All rights reserved. Visit our website terms of use and permissions pages at www.npr.org for further information.

NPR transcripts are created on a rush deadline by Verb8tm, Inc., an NPR contractor, and produced using a proprietary transcription process developed with NPR. This text may not be in its final form and may be updated or revised in the future. Accuracy and availability may vary. The authoritative record of NPR’s programming is the audio record.