My little engineering students are studying a bit of probability as part of their first year mathematics, and their textbook is full of questions like “If two fair dice are thrown, what is the probability that the sum is at least 5?”. Like almost every probability textbook written since the dawn of time, it will include a table such as this:

or a picture such as this:

illustrating all possible throws of two dice. From either of these the number of ways of obtaining a sum is given by:

sum: 2 3 4 5 6 7 8 9 10 11 12 #: 1 2 3 4 5 6 5 4 3 2 1

From a table such as this it is easy to answer all probability questions from the book. Very few books, however, go into the question about sums from three or more dice. I imagine that there is little further learning of probability to be gained by thus extending the problem, so for multiple “throws” coins are used rather than dice.

However, the mathematics is quite fun. Suppose (6-sided, fair) dice are thrown. In how many ways can the sum be obtained? Let’s call this number . From the table above, you can see that, for example . But what is the value, for example, or , or of ?

Look at the case . We are interested in the number of sums where . Such a sum should immediately suggest a generating function, and for this example the generating function is

Thus . And in general is the coefficient of in . This result is of course also given on Mathworld. And we can calculate these with Sage:

sage: dx = x+x^2+x^3+x^4+x^5+x^6 sage: expand(dx^3).coeff(x,10) 27

There’s nothing to stop us trying larger numbers of dice and larger sums, for example 10 dice and the sum of 34 for the value of :

sage: expand(dx^10).coeff(x^34) 4325310

However, this can be slow. For large values of Sage has to do a lot of computation. When I tried with , my computer ground to a halt as all memory was sucked up by Sage, which crashed a bit later. (For those of you concerned about Sage abuse, I gave it a nice cup of tea after a restart and we’re still good friends.) So we would like a more efficient method of computing for large and .

Note that by the definition of as a coefficient of , and as we are using 6-sided dice, if follows that

.

If we let for less than or greater than we can produce a simple dice program:

sage: def dice(k): d = 6*[1] for i in range(k-1): t = 5*[0] + d + 5*[0] d = [sum(t[i:i+6]) for i in range(len(t)-5)] return d ....:

Then:

sage: dice(2) [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1] sage: dice(3) [1, 3, 6, 10, 15, 21, 25, 27, 27, 25, 21, 15, 10, 6, 3, 1]

Notice that the outcome of `dice(k)` gives the number of sums for all starting at . So then

sage: def t(k,n): return dice(k)[n-k]

Then:

sage: t(2,10) 3 sage: t(3,10) 27 sage: t(100,350) 15237092858379903128111407924086725562812976591205826140530848189030092709496

Big enough for ya?

**Addendum**

Thanks to a correspondent (see below) the use of polynomial rings vastly simplifies matters.

For example, without doing any programming:

sage: R.<x> = PolynomialRing(ZZ) sage: dx = R([1]*6)*x sage: dx x^6 + x^5 + x^4 + x^3 + x^2 + x sage: (dx^3)[10] 27 sage: (dx^100)[350] 15237092858379903128111407924086725562812976591205826140530848189030092709496

All results are given instantaneously. The nice thing about his approach is that it enables us to mix and match dice. Suppose we throw 11 cubical dice, 13 octahedral dice, and 15 dodecahedral dice. In how many ways can we obtain the sum of 200?

In one step:

sage: ((R([1]*6)*x)^11*(R([1]*8)*x)^13*(R([1]*12)*x)^15)[200] 69232087336767815011624465024995662

Back in the old days when we didn’t have computers to do this, we found them using the arithmetic triangle… Even now, students might wonder …

nice post.

you could use sage directly for larger k if you use a Polynomial Ring instead of the Symbolic Ring:

{{{

def t(n, k):

R. = ZZ[]

p = R([1]*6)*x # x + x^2 … x^6

return (p^k)[n]

}}}

this still works instantly for t(5000, 1000). But you will still run into memory problems at some point.

Fantabulous! I have to try reprogramming this into javascript and making a web page for it! I have done a very nice activity with Year 8 students where they throw three dice and attempt to gain some grasp over (a) the number of ways a number can be found as a sum of three dice, and (b) the most likely sum(s).

Isn’t it strange that at times the simplest tips are generally the greatest!

Hello would you mind sharing which blog platform you’re using? I’m looking to start my own

blog in the near future but I’m having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something unique.

P.S Sorry for getting off-topic but I had to ask!

I chose WordPress because when I started it seemed to have the best support for mathematics. And there are also WordPress blogs by some of the world’s top mathematicians (Terry Tao, for example). I don’t know what’s out there now, because I haven’t looked. WP still works for me, though.

Currently it seems like Expression Engine is the preferred blogging platform

available right now. (from what I’ve read) Is that what you are using on your blog?

Its such as you read my mind! You appear to know so much approximately

this, like you wrote the book in it or something. I feel that you just can do with some % to drive the message house a little bit, but other than that, this is great blog.

A fantastic read. I’ll definitely be back.

You’re so cool! I do not believe I have read through a single thing like this before. So nice to discover somebody with a few unique thoughts on this subject. Seriously.. thanks for starting this up. This site is one thing that’s needed on the internet,

someone with a bit of originality!

Simply wish to say your article is as astounding. The clearness for your

post is just spectacular and that i can suppose you’re an expert on this subject. Fine with your permission allow me to clutch your RSS feed to keep updated with coming near near post. Thank you one million and please keep up the rewarding work.

Right now it seems like Expression Engine is the preferred blogging platform available right now.

(from what I’ve read) Is that what you are using on your blog?

I have been browsing online more than 2 hours

today, yet I never found any interesting article like

yours. It is pretty worth enough for me. In my view, if all web owners and bloggers made good content as you

did, the internet will be a lot more useful than ever before.

I visited many web sites but the audio quality for

audio songs present at this site is truly excellent.

What’s up everyone, it’s my first visit at this web site, and article is truly fruitful in

favor of me, keep up posting these articles.

Hey would you mind letting me know which web host you’re working with?

I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most.

Can you suggest a good web hosting provider at a reasonable price?

Thanks, I appreciate it!

It’s very trouble-free to find out any matter on web as compared

to textbooks, as I found this paragraph at this website.

Nice post. I learn something new and challenging

on blogs I stumbleupon on a daily basis. It will always be useful to read through content from other authors and practice a little something from their web sites.

Greetings! Very useful advice within this article!

It’s the little changes that make the most important

changes. Many thanks for sharing!

t(2,9)=4 surely not 5

Apparently he doesn’t believe in making corrections.

Wonderful blog! I found it while searching on Yahoo News.

Do you hae any suggestions on hoow to get listed in Yahoo News?

I’ve been trying for a while but I never seem to get there!

Many thanks

here’s someone who derived a general formula for it.I think it’ll be useful for manual calculation.

http://equax.blogspot.in/2013/11/summing-dice-throws.html

It’s the best time to make a few plans for the long ruun and it’s time to be happy.

I’ve read this publish and if I may I wish to

recommend you few fascinating things or suggestions. Maybe youu can write next articles relating to this article.

I wish to leawrn more things about it!

We aare a group of volunteerss and opening a new scheme in our community.

Your website offered us with valuable information to work on.You have done an impressive

jjob and our whole community will be thankrul to you.

I blog quite often and I seriously appreciate your information.

Your article has really peaked my interest. I will bookmark your site

and keep checking for new information about once per week.

I subscriged to your RSS feed too.

I think the admin of this web site is truly working hard in

favor of his site, since her every mterial is quality based data.

You actually make it seem so easy with your presentation buut I find this topic to be actually something which

I think I would never understand. It seems too comolicated and extremely

broad for me. I’m looking forward for your next post,

I will try to get the hang oof it!

Beyond hair’s-breadth, tegument and nails, the coolheaded thing that silica

is probably to molecular screen keep dry.

proper, so you will in spades get an alternative to experience multiple purchases.

Some of these dry packs can even out be carcinogenic so ever continue them forth from children.

Hey there! Do you know if they make any plugins to ckckddcakbde

Hi my friend! I want to say that this article is awesome,

great written and include almost all vital infos.

I would like to look extra posts like this .