Friday, January 4, 2013

Shooting Dice

(%i1) powerdisp:true$

Shooting Dice and Generating Functions

A die has six sides with pips. Thus, the generating function is:

(%i2) f:sum(x^j,j,1,6);
dice_0

Although not explicitly written, each term has a coefficient of 1. Hence, there is only one way to shoot the numbers 1,2,3,4,5 and 6.

Craps (two dice)

(%i3) expand(f^2);
dice_1

The above says there is 1 way to shoot a two (snake eyes), namely 2=1+1.
There are two ways to shoot a 3 (3=1+2=2+1).
There are 3 ways to shoot a four, namely 4=1+3=2+2=3+1.
...

(%i4) fg:sum(a(i)*x^i,i,1,6);
dice_2

(%i5) fg2:expand(fg^2);
dice_3

(%i6) coeff(fg2,x,5);
dice_4

This shows the four ways to get a 5, namely 5=2+3=3+2=1+4=4+1

(%i7) coeff(fg2,x,7);
dice_5

Six ways to get a seven, namely 7=3+4=4+3=2+5=5+2=1+6=6+1
...

Three dice

(%i8) expand(f^3);
dice_6

There is one way to shoot a 3, namely 3=1+1+1/
There are three ways to get a 4, namely 4=1+1+2=

(%i9) fg3:expand(fg^3);
dice_7

(%i10) coeff(fg3,x^4);
dice_8

4=1+1+2=1+2+1=2+1+1

(%i11) coeff(fg3,x,11);
dice_9


Created with wxMaxima.

No comments: