So, there I was, idly figuring out one of Barney's fiendish puzzles ("How many pairs of dice would you have to throw to be 95% certain of seven being the modal total?") when I started thinking about the binomial expansion (don't tell the Mathematical Ninja!)

You know it: if you expend $(a+b)^n$, you get the rows of Pascal's triangle as your coefficients: $(1+x)^9 = 1 + 9x + 36x^2 + 84x^3 + ...$. However, I was more interested in trinomials. How do you expand $(a+b+c)^3$, say?

I worked it out by hand, of course, because that's the kind of guy I am: $(a+b+c)^3 = a^3 + b^3 + c^3 + 3(a^2b + a^2c + b^2a + b^2c + c^2a + c^2b) + 6abc$; a quick check says there are 27 terms there, as you'd hope.

But then I looked at $(a+b+c)^4$ and threw my pen down in disgust. Surely, I thought, there has to be a better way than multiplying out so many brackets? Of course there is. You just need to generalise Pascal's triangle to three dimensions!

A three-dimensional triangle is a tetrahedron, which (sad to say) is a bit tricky to typeset. Instead of rows, Pascal's tetrahedron has layers. Layer 1 gives the coefficients for $(a+b+c)^1$:

$$\begin{array}{ccc} & 1& \\ 1 & & 1 \end{array}$$

Each row and diagonal (both ways!) represents a different letter: I consider the top-middle cell to be for the $a^1b^0c^0$ term, although if you prefer $b$ or $c$ to be at the top, it's robust to rotations!

You work out the second layer using the rule "each cell is the sum of its three neighbours in the layer above" - and it looks like this:

$$\begin{array}{ccccc} &&1&& \\ &2 && 2 \\ 1 && 2 && 1 \end{array}$$

All of the squared terms show up once, and all of the cross-terms show up twice, just like when the Mathematical Ninja squares brackets.

Layer 3 is where it gets interesting:

$$\begin{array}{ccccccc} &&&1&&& \\ &&3 && 3 \\ &3 &&6 && 3 \\ 1 && 3 && 3 && 1 \end{array}$$

It works! All of the cubed terms show up once, all of the terms like $a^2b$ come up three times, and there, in the middle, the big-daddy cross term, the six $abc$s.

But hang on a minute: there's a pattern emerging! Each of the sides of each layer is just a row from Pascal's triangle - and each row looks suspiciously like a multiple of one of Pascal's rows. Let's check it for layer 4:

$$\begin{array}{ccccccccc}

&&&&1&&&& \\

&&&4&&4&&& \\

&&6&&12&&6&&\\

&4&&12&&12&&4&\\

1&&4&&6&&4&&1

\end{array}$$

The first row is one lot of the first row of Pascal's triangle. The second row is four times the second row. The third row is six times the third row... even the multipliers come from Pascal's triangle!

So, if you want to figure out, say, the coefficient for $a^3b^2c^2$ in the expansion of $(a+b+c)^7$, you can figure it out easily enough! You need the seventh layer, and the fifth row of it - which will start with $^7C_3 = 35$. There will be five elements in that row, each of which is 35 times the corresponding element from the fifth row of Pascal's triangle - and we want the middle one. That'll give us $35~^4C_2 = 210$ as our coefficient.

In general, the coefficient for $a^pb^qc^r$ works out to be $^{p+q+r}C_p (q+r)C_q$, or -- better still -- $\frac{(p+q+r)!}{p!q!r!}$ -- which anyone doing OCR S1 will recognise from their combinations and permutations work.

In fact, this isn't restricted to trinomials: if you wanted to work out coefficients for $(a+b+c+d+e)^{10}$ (crazy fool!), for each term you could simply work out the factorial of each power, multiply them all together, and divide $10!$ by the result.

## MathbloggingAll

Pascal’s tetrahedron http://t.co/zmRXyqoJW2