Dice and Polynomials – Part 1

Can polynomials help calculate probabilities?
Can polynomials help calculate probabilities?

Imagine you have two coins. One side is blank, and one has a single dot. You flip the coins. How many ways can you get 0 dots? How many ways can you get 1 dot? How many ways can you get 2 dots?

If you got answers like “1 way / 2 ways / 1 way” you got it right.

Now, another question. If I multiply together 1.x0 + 1.x1 and 1.x0 + 1.x1, that is, (1+x) times (1+x), what is the coefficient of x0 ? of x1 ? of x2 ? If you got answers like “1 / 2 / 1”, you got it right.

If you ask similar questions for three coins, or (1+x)3, you still get the same answers : 1, 3, 3 and 1. There’s a good reason for this – the question “how many ways can you get 2 dots” is, in a way, the same question as “what is the coefficient of x2 ?”. This has huge implications, it gives a great new way to calculate probabilities, and more.

Imagine I have a coin. Or a die. Whatever. Some of the faces have dots. I’ll represent each dot by ‘x’. The dots showing up on one side will be all multiplied together, so a face with three dots would be x3. A face with one dot would be x3, or x, and one with no dots would be x0, or 1. So the two sides of my coin are 1 and x, and the 6 sides of a normal die are x, x2, x3, x4, x5 and x6.

Now, what about the whole coin or die? To represent the whole die, I’ll add up all its faces. The coins at the start are each 1+x, and a normal die is x + x2 + x3 + x4 + x5 + x6. Or, if I had a strange die whose faces were 1, 2, 2, 2, 3 and 3, it would be represented by the polynomial x + x2 + x2 + x2 + x3 + x3, that is, x + 3x2 + 2x3.

In these polynomials, the coefficient of each power of x represents the number of ways to get that number of dots. So, for my strange die, the coefficient of x2 is 3 because there are three ways to get a 2.

Now, why are we going to all the trouble to write down polynomials representing these dice? The comes when you want to toss two or more of these dice, and count how many ways there are to get certain numbers. If I

  • take two dice
  • work out their polynomials
  • multiply the polynomials together to get a new polynomial

then the new polynomial tells me the number of ways to get each number of dots when I toss the pair of dice, just like each individual polynomial does for its individual die.

  • If I take two normal dice,
  • Their polynomials are x + x2 + x3 + x4 + x5 + x6 and x + x2 + x3 + x4 + x5 + x6,
  • which multiply to give  x2 + 2x3 + 3x4 + 4x5 + 5x6 + 6x7 + 5x8 + 4x9 + 3x10 + 2x11 + x12 ,

and this tells me that there are 2 ways to get a 3, 3 ways to get a 4, 6 ways to get a 7, and only 1 way to get a 12. That’s why, when you’re playing monopoly, you get 6’s, 7’s and 8’s almost half the time. Let’s see another example.

  • If I take two funny dice, whose faces are 1, 2, 2, 2, 3 and 3,
  • their polynomials are x + 3x2 + 2x3 and x + 3x2 + 2x3 ,
  • which multiply together to give x2 + 6x3 + 13x4 + 12x5 + 4x6,

so there is 1 way to get a 2, six ways to get a 3, thirteen ways to get a 4, and so on.

This trick works with three dice, four, or any number of dice. For example,

  • If I take three normal dice,
  • Their polynomials are x + x2 + x3 + x4 + x5 + x6, x + x2 + x3 + x4 + x5 + x6, and x + x2 + x3 + x4 + x5 + x6,
  • which multiply together to give x3 + 3x4 + 6x5 + 10x6 + 15x7 + 21x8 + 25x9 + 27x10 + 27x11 + 25x12 + 21x13 + 15x14 + 10x15 + 6x16 + 3x17 + x18 ,

So, while there’s only 10 ways to get 16, 17 or 18, there are 100 ways to get an 8, 9, 10 or 11, which explains why we always had to cheat to create Dungeons and Dragons characters that could actually survive a typical adventure.

So, by representing dice as polynomials, some fiendishly difficult probability questions suddenly become easy-peasy. You now know how to work out, for example, the chance of getting a 10 on three four-sided dice – just multiply together a few polynomials, instead of doing the contortedly complicated combination-counting you thought you needed before.

If you want to learn more about this technique, the words to google are “probability generating functions”, or move on to Dice and Polynomials – Part 2.

 

One thought on “Dice and Polynomials – Part 1”

Comments are closed.