How a Futurama writer’s plot problem led to a totally new math proof

In an episode of the cartoon, a machine lets characters swap bodies, but they can’t switch back with the same person. Math helps all the characters return to their original bodies

A screengrab from an episode of the animated show Futurama.

In the "Prisoner of Benda" Futurama episode, a machine lets two characters swap bodies with each other.

20th Century Fox Television

This article is from Proof Positive, our friendly math newsletter that's delivered to your inbox every Tuesday afternoon. Sign up today and read it first.


Nerdy jokes are no longer rarities on TV. As I wrote about a few weeks ago, even The Simpsons is rife with mathematical high jinks. But Futurama has taken nerd humor to an extreme. Consider the episode “The Prisoner of Benda.” Its writer, Ken Keeler, had to formulate an original mathematical proof to solve a significant plot problem.


On supporting science journalism

If you're enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.


The episode’s story begins innocuously. The ingenious Professor Farnsworth invents a machine that can swap the minds of two people. In a bid to be young again, he swaps bodies with the character Amy, who, for her part, is eager to be in a body in which she can eat as much as she wants without having to watch her figure.

After the switch is made, the pair realize that the transformation cannot be easily reversed because the device works only once for each pairing of bodies. And so other characters in the series also get involved: in total, they use the machine seven times. The bodies and minds of nine characters are mixed up so wildly that it becomes hard to keep track of who is who at any given time.

Along the way, characters have wild motivations for seeking transformation: the robot Bender wants to pilfer Emperor Nikolai’s yacht and takes Amy’s form to seduce the guards; Leela slips into the professor’s form to find out why Fry loves her; to take revenge, Fry wants to be ugly and swaps his body with the alien lobster Dr. Zoidberg, and so on.

In the end, of course, everyone wants to get back to their own bodies. But at this point in the story, Keeler faltered. He needed to untangle the characters without having two of the same people use the machine more than once; the pairs had to always be different. Keeler realized that he would have to introduce new characters into the episode to solve the problem. But how many? Keeler has a Ph.D. in mathematics and realized he faced this question: How many extra people does it take to untangle the body-swapping problem with n figures?

He had no clue what a solution might look like. The number of additional people could grow with the size n of the group or be constant. There didn’t yet seem to be an answer in the literature, so Keeler set out to solve the problem himself. And after some head-scratching, he finally developed a proof: two more characters would be enough to resolve the messy situation, regardless of how many people swapped bodies.

Solution in Sight!

In the series, the Globetrotters, talented basketball players with brilliant scientific skills, save the day. Two of the players, “Sweet” Clyde Dixon and Ethan “Bubblegum” Tate, solve the problem on a blackboard—by writing out Keeler’s proof.

But how exactly did Keeler do it? He abstracted the problem by imagining n objects arranged in the wrong order, say (2, 3, 4, 5, ..., i, i + 1, ..., n, 1). The goal is to restore the set (1, 2, 3, ... , n) by swapping the objects pair-wise with two new elements, x and y. You can notate such a swap by (i, x); then i and x change their positions. Thus you have a new set (2, 3, 4, 5, ..., i, i + 1, ..., n, 1, x, y).

Keeler found that you must first divide the set into one group that goes from 1 to i and another that goes from i + 1 to n. Then you swap every misplaced element of the first set with x and every one of the second with y. At the very end, you swap out xwith i + 1 and y with 1: (1, x) (2, x) (3, x) ... (i, x) × (i + 1, y) (i + 2, y) ... (n, y) × (i + 1, x) × (1, y). Regardless of how i is chosen, after these permutations, you ultimately end up with an ordered set (ignoring x and y): (1, 2, 3, ... , i, i + 1, ..., n). In fact, it does not matter the way in which the objects were originally ordered. The method always works.

To see Keeler’s proof in action, you can create a table mapping out the initial body swap pairings. Drawing simplified stick figures in which a person’s mind is one color and their body is a different color helps with this step. Once you’ve drawn and colored in each of the characters, you’ll note that Fry and Zoidberg can be set apart from the other characters because they have only swapped with each other.

Now, with the help of Sweet Clyde and Bubblegum Tate, you can try to reunite the respective minds with their bodies. Zoidberg and Fry require four steps. Expressing their false composition abstractly by (2, 1), we get the following set with Clyde (x) and Tate (y): (2, 1, x, y). Because there are only two objects, i = 1 must exist. Thus, according to Keeler’s approach, the following permutations are necessary: (1, x), (2, y), (2, x) and (1, y). Performing them one after the other, the set changes as follows: (2, x, 1, y), (y, x, 1, 2), (y, 2, 1, x), (1, 2, y, x).

Color coded heads and bodies show body swaps between nine Futurama characters. Four swaps are performed to restore Fry and Zoidberg’s minds with their bodies. In the first swap, Zoidberg’s body is swapped with Clyde’s body. In the second swap, Fry’s is swapped with Tate’s. In the third swap, Fry’s is swapped with Clyde’s. In the fourth swap, Zoidberg’s is swapped with Tate’s.

Eve Lu

Of course, Sweet Clyde and Bubblegum Tate are now switched. Theoretically they could get into the machine and swap, but they should instead help the other seven characters, which they do. The characters solve the problem in a total of 13 steps using this method (though the smallest number needed is actually nine). By the end, everyone’s mind is restored with their body.

Keeler was pleased with his result but didn’t consider it significant enough to publish. Mathematicians Ron Evans, Lihua Huang and Tuan Nguyen did it for him: In 2014 they published a nine-page improved version of his proof in the American Mathematical Monthly. Keeler should be proud that Futurama succeeds in presenting and proving an unsolved mathematical problem—without losing any entertainment value.

This article originally appeared in Spektrum der Wissenschaft and was reproduced with permission. It was translated from the original German version with the assistance of artificial intelligence and reviewed by our editors.

It’s Time to Stand Up for Science

If you enjoyed this article, I’d like to ask for your support. Scientific American has served as an advocate for science and industry for 180 years, and right now may be the most critical moment in that two-century history.

I’ve been a Scientific American subscriber since I was 12 years old, and it helped shape the way I look at the world. SciAm always educates and delights me, and inspires a sense of awe for our vast, beautiful universe. I hope it does that for you, too.

If you subscribe to Scientific American, you help ensure that our coverage is centered on meaningful research and discovery; that we have the resources to report on the decisions that threaten labs across the U.S.; and that we support both budding and working scientists at a time when the value of science itself too often goes unrecognized.

In return, you get essential news, captivating podcasts, brilliant infographics, can't-miss newsletters, must-watch videos, challenging games, and the science world's best writing and reporting. You can even gift someone a subscription.

There has never been a more important time for us to stand up and show why science matters. I hope you’ll support us in that mission.

Thank you,

David M. Ewalt, Editor in Chief, Scientific American

Subscribe