The Mathematics of the Movie "21"

by Jeff Moehlis

The movie "21" is the story of MIT students who "count cards" to improve their probability of winning the card game Blackjack at casinos. Not surprisingly, this movie has a lot of mathematics in it. Most obvious is the "counting of the cards", which is based on the techniques published in Edward O. Thorpe's 1962 book "Beat the Dealer". Discussions of the method and mathematics of "card counting" are described on various other websites. On this website, you can learn about other mathematical ideas which appear in the movie. I hope that this increases your enjoyment of the movie and perhaps teaches you some mathematics!


The Fibonacci Series

In "21", when Ben Campbell (played by Jim Sturgess) is celebrating his birthday, the cake says

0, 1, 1, 2, 3, 5, 8, 13, ...

These are the first terms in the Fibonacci Series, which was used as an example in the book Liber Abaci published in 1202 by Leonardo Fibonacci. This is obtained by first writing the numbers "0, 1", then defining each subsequent number as the sum of the previous two numbers in the series. Thus, the third number in the series is 1 = 1+0, the fourth number is 2 = 1+1, the fifth number is 3 = 2 + 1, etc. The next number on the cake would be 21=13+8, for Ben's 21st birthday. Clever, huh? (Hmmm, does "21" refer to Blackjack or Ben's age?) Ben will have to wait until he is 34 = 21+13 for his next "Fibonacci birthday".

One can define other Fibonacci Series by specifying different numbers in the first two slots. For example, the Fibonacci Series starting with "2, 5" is

2, 5, 7, 12, 19, 31, 50, ...


The Monty Hall Problem

Consider the following variation of the final round of the classic TV game show Let's Make A Deal:

There are three doors, and behind one of them is a car, while behind the other two are goats. If you choose the door with the car behind it, you win the car. Now, say you choose Door 1. The host Monty Hall then opens either Door 2 or Door 3, behind which is a goat. (He knows what is behind each door, and never opens the door with the car behind it.) Monty now gives you the choice: do you want to stick with Door 1, or switch to the other door. What should you do? Or does it matter?

A similar question is posed to Ben Campbell (played by Jim Sturgess) by Professor Micky Rosa (played by Kevin Spacey) in the movie "21". Without hesitation Ben answers this correctly, which convinces Professor Rosa that Ben would be a good addition to their "card counting team". Before reading on, try to answer this yourself.

One solves this problem by comparing the probability of choosing the car if you stick with your original choice to the probability of choosing the car if you switch after Monty opens the one door. Note that the car has an equal probability of 1/3 of being behind Door 1, Door 2, or Door 3.

First, suppose that your strategy is to stick with your original choice of Door 1. Then you only win if the car is behind Door 1, so that your probability of winning is 1/3.

Next, suppose that your strategy is to switch doors. We break this into three cases:

  • If the car is behind Door 1, Monty will open either Door 2 or Door 3 to reveal a goat. You switch to the other of Door 2 or Door 3, and in either case you switched to a door with a goat behind it (remember, the car is behind Door 1).

  • If the car is behind Door 2, Monty will open Door 3. This is because he always opens a door with a goat behind it, and he can't open Door 1 because that was your original choice. So the only door you can switch to is Door 2, which is the door with the car behind it. Ding! You win!

  • If the car is behind Door 3, Monty will open Door 2. This is because he always opens a door with a goat behind it, and he can't open Door 1 because that was your original choice. So the only door you can switch to is Door 3, which again is the door with the car behind it. Ding! You win!

    So if your strategy is to switch doors, you win 2/3 = 1/3 + 1/3 of the time. (Remember, the probability is 1/3 that the car is behind any particular door.) Therefore, a better strategy is to switch doors - the calculated probabilities indicate that you are twice as likely to win if you do this! Ben's correct answer in the movie "21" indicates that he is a good person for "counting cards". Not only does it show that he is clever, but it also demonstrates that he realizes that it is best to go with the choice which maximizes your probability of winning. This realization is essential to the success of "counting cards" for Blackjack.

    In 1990, a similar question appeared in a letter to Marilyn vos Savant's Ask Marilyn column in Parade (which comes in some Sunday newspapers). Marilyn gave the correct answer, but many readers (including mathematics professors) believed that this was incorrect. So don't feel too bad if you got it wrong when you answered it for yourself. But now you know!


  • The Newton-Raphson Method

    You might recall from an algebra class that the solutions to the equation

    are given by the quadratic formula

    Suppose instead that you want to find a value for x which solves the general algebraic equation

    f(x) = 0.

    Such a value for x is called a root of f(x). Except for special choices of f(x), such as f(x) = a x2 + b x + c as above, one cannot find the roots using algebraic operations.

    In the movie "21", Professor Micky Rosa (played by Kevin Spacey) is lecturing on the Newton-Raphson method for finding the roots of f(x). This was developed independently by Isaac Newton and Joseph Raphson in the 1600's. The idea is to make a guess for a root of the equation (let's call it x0), then to use this guess to generate a value for x (let's call it x1) which is (hopefully) even closer to the root than the original guess. This is done by drawing the tangent line to the function f(x) at x=x0, and taking x1 as the value for x at which this straight line goes through zero. (For those of you who know calculus, you will recognize that this tangent line is determined by the derivative of f(x).) By iterating this procedure over and over to generate x2, x3, etc, one (hopefully) obtains values which are better and better approximations to the root. I keep saying "hopefully" because the Newton-Raphson Method isn't always successful, although it is more likely to be if you make a good initial guess. This figure illustrates the method:

    This method was developed well before computers existed, but turns out to be ideal for implementation on a computer: one uses a loop to generate successive values of xn.


    Counting Cards

    A nice discussion of "counting cards" for Blackjack is given in this Wikipedia article .


    Now let's count the number of times this page has been visited:


    Visit Author Jeff Moehlis' website. Also, check out his music site music-illuminati.com.