Header tag

Tuesday, 28 April 2020

Summing Square Numbers and Triangle Numbers

"A grocer stacks apples in pyramids made of layers of equilateral triangles. How many apples will he need to fill four levels of apples?  A second grocer stacks apples in pyramids made up of layers of squares - how many apples will he need to fill four levels of apples in each tower?"

Firstly, let's borrow a picture for the first grocer's tower - this one contains the first five layers.


This is the series of triangle numbers:
The first row is one apple
The second row is three apples

The third row is six apples
The fourth row would be ten apples
Total = 1 + 3 + 6 + 10 =20 apples

And for the second tower, which is the series of square numbers:



The first row is just one apple.
The second row is four apples
The third row is nine apples (three squared)
And the fourth row would contain 16 apples (four squared).

1 + 4 + 9 + 16= 30 apples

These are the two ways of most densely packing spheres - in triangular fashion (left), or in a square fashion (right).  I've covered the density of sphere packing in hexagonal planes in a previous blog.

Extension Task

Now, to extend this simple problem a little further:  how many apples would be needed to produce a triangular tower (like the first grocer), or a square tower (like the second grocer) with n rows?

We need to determine expression for the nth term, and we can do this by taking differences between adjacent terms, and then the second (and if necessary) the third difference.

Triangular Tower (Tetrahedral)

The terms for the total numbers of apples are 1, 4, 10, 20, 35, 56 and so on.
The first difference is 1, 3, 6, 10, 15, 21 (the triangular numbers)
The second difference is 1, 2, 3, 4, 5, 6
And the third difference is 1, 1, 1, 1.

The third difference means that this is a cubic expression, and the value of the third difference (1) needs to be divided by 6 to give the coefficient a in the expression ax3 + bx2 + cx + d
Hence we know that the expression is x3/6 + bx2 + cx + d

We now have to subtract x3/6 from each of the xth value, and calculate the differences again (to determine what the coefficient b is), and then repeat the process to determine c.

Following this process, we can see that the expression for the nth term is

Tetrahedral Tower:  Tn = n3/6 + n2/2 + n/3


Square-based tower

The terms for the total numbers of apples are 1, 5, 14, 30, 55, 91 and so on.
The first difference is 1, 4, 9, 16, 25, 36 (the square numbers)
The second difference is 1, 3, 5, 7, 9, 11
And the third difference is 2, 2, 2, 2.

The third difference means that this is a cubic expression, and the value of the third difference (2) needs to be divided by 6 to give the coefficient a in the expression ax3 + bx2 + cx + d

Hence we know that the expression is x3/3 + bx2 + cx + d

We now have to subtract x3/3 from each of the xth value, and calculate the differences again (to determine what the coefficient b is), and then repeat the process to determine c, and d if needed.

Following this process, we can see that the expression for the xth (or the nth) expression is

Square-based Tower:  Tn = n3/3 + n2/2 + n/6

(As an aside, these solutions remind me of the puzzle I solved last year: 1/a + 1/b + 1/c = 1)

Sunday, 19 April 2020

More on Dice Games, Probability and Distributions

In a previous post I've analysed probability distributions from rolling two dice: looking at the sum of two dice (a well-known distribution), the difference; the largest of two dice and the smallest.  This article comes about following some home-schooling I've been doing with my children, looking at distributions of results for throwing one or two dice - this was an extension activity we looked at (and I'm examining it in more depth here).

In this article I'm going to examine a different distribution: rolling three dice and summing the two largest dice. This is clearly going to be skewed towards larger totals than the normal two-dice distribution- but by how much, why, and what does this distribution look like?

For example, there is only one way to get a sum of 2, which is to roll 1 1 1. However there are many ways to get 12, including 6 6 3, 6 6 2, and 6 6 1.

To abbreviate the analysis, I'd like to show and use the following results:

There is only one way to roll 1 1 1, 2 2 2 or 3 3 3.  This is self-evident but worth mentioning.


When one of the dice has a different value to the other two, there are three equivalent combinations: 4 4 5 is equivalent to 4 5 4 and 5 4 4. For any a a b, there are three equivalent combinations.

When the dice have three different values,  there are six equivalent combinations: a b c, a c b, b a c, b c a, c b a and c a b.

Onto the actual distribution, then:


Score List
















2 1 111 1















3 3 211 3















4 7 222 1 221 3 311 3











5 12 321 6 322 3 411 3











6 19 333 1 332 3 331 3 422 3 421 6 511 3





7 27 433 3 432 6 431 6 522 3 521 6 611 3





8 34 444 1 443 3 442 3 441 3 533 3 532 6 531 6 622 3 621 6
9 36 544 3 543 6 542 6 541 6 633 3 632 6 631 6



10 34 555 1 554 3 553 3 552 3 551 3 644 3 643 6 642 6 641 6
11 27 655 3 654 6 653 6 652 6 651 6







12 16 666 1 665 3 664 3 663 3 662 3 661 3






Total:  216   = 6*6*6 

The distribution is clearly skewed to the higher values, compared to the two dice distribution.  Interestingly, it's not even symmetrical either side of the mode of 9 - the values for 8 and 10 are the same, as are 7 and 11, but there are fewer ways of getting 12 compared to 6.

Here's the breakdown, which compares to "seven for everything" for the normal two-dice distribution.

Mode = 9
Median = 9

Mean 8.458

Comments:
In game design, if you want a character, figure or unit to move generally faster or perform better than a typical two dice distribution, then taking the two highest values from three dice will certainly achieve this, while still retaining a range of 2-12 spaces or points.  Your unit will hit harder, but can there's still a possibility that it will be outperformed by a two-dice unit.