“Yuk,” said the student, faced with $(x+y+z)^2$. FOIL doesn’t work.”

The Mathematical Ninja thought carefully before speaking: on the one hand, FOIL was a cheap tactic with a single use, but on the other, the student hadn’t said $x^2 + y^2 + z^2$, which would have meant instant decapitation.

“I had a student once, from China,” said the Mathematical Ninja. “He had learnt $(a + b)^2 = a^2 + b^2 + 2ab$.”

“That doesn’t help,” said the student. “I’ve got three things, not just two.”

“Ah, but it extends,” said the Mathematical Ninja, with the faintest hint of smugness. You add up the individual squares, then add every possible pair of products twice. So $(x + y + z)^2 = x^2 + y^2 + z^2 + 2(xy + yz + zx)$.”

“Nicely symmetrical,” spotted the student. He didn’t really know what it meant, but he knew it was the kind of phrase the Ninja would approve of. “How about cubes?”

“Cubes get messy,” said the Ninja. “You have to account for each possible pair of products of one thing and another cubed; otherwise, it’s similar. It’s $x^3 + y^3 + z^3 + 3(xy^2 + yx^2 + xz^2 + zx^2 + yz^2 + zy^2) + 6xyz$, but you’ll probably just want to work that out on the fly.”

The student nodded. Getting the Ninja to admit that not everything should be done in the head was a victory, of sorts.