← StudyX Devlog

Why the Order of Operations Matters: Teaching Function Composition With a Puzzle

HiroHiro · Game Designer @ StudyXMath GatesHow-To
Why the Order of Operations Matters: Teaching Function Composition With a Puzzle

Take the number 4. Add 2, then multiply by 3, and you get 18. Multiply by 3 first, then add 2, and you get 14. Same number, same two steps, different answer.

Most children meet this idea only as a rule for reading written sums: multiplication before addition. I think the idea underneath is bigger and more interesting than the rule. Doing one operation after another is function composition, and the order you do them in changes the result. When I designed Math Gates, this was the first thing I wanted a child to feel with their hands before anyone gave it a name. This post collects the small examples I kept coming back to, for parents and teachers who want to try them at a kitchen table or on a whiteboard.

Two orders, two answers

Start with the pair from the top and try a few more starting numbers.

Start +2 then ×3 ×3 then +2
4 6, then 18 12, then 14
5 7, then 21 15, then 17
10 12, then 36 30, then 32

The answers are always 4 apart. That is worth a pause, because a child who notices it is already asking a mathematician’s question: why always 4?

The reason is that in the first order, the +2 goes through the ×3 and becomes +6. Written out, (x + 2) × 3 is 3x + 6, while x × 3 + 2 is 3x + 2. Whatever you start with, the gap is 6 minus 2. You do not need to show the algebra to an eight-year-old. It is enough to ask “what happened to the 2?” and let them trace it through.

When order does not matter

It is just as important to see where order makes no difference. +3 then +5 gives the same result as +5 then +3. ×2 then ×3 gives the same as ×3 then ×2. Two additions can swap. Two multiplications can swap. It is the mix of the two kinds that breaks.

I like to let children sort pairs of steps into “swaps fine” and “does not swap” on their own. They usually expect everything to swap, since that is what they learned about adding, and the first counterexample surprises them. That surprise is the lesson.

This is not quite “order of operations”

At school, “order of operations” usually means the convention for reading an expression: 4 + 2 × 3 is 10, not 18, because the multiplication is done first. That rule is about notation. It tells you how to read what someone wrote.

Composition is about what you actually do, step by step. Brackets are how we write it down: (4 + 2) × 3 is 18, and 4 × 3 + 2 is 14. I think children accept brackets much more easily once they have felt that the two orders are genuinely different machines. Then the brackets are not an arbitrary rule. They are the only way to say which machine you mean.

Undoing a machine

Going back is where composition gets interesting. Take 4, multiply by 3 to get 12, add 2 to get 14. How do you get from 14 back to 4?

You undo each step with its opposite, in reverse order. First subtract 2, which gives 12. Then divide by 3, which gives 4. Try it the other way round and it falls apart: 14 divided by 3 is not a whole number.

It is the same as getting dressed. Socks go on before shoes, so shoes come off first. Children know this already. They just have not connected it to numbers.

Working backwards

The same idea turns into a problem-solving tool. Say you start at 3, you need to reach 20, and you have a +2 and a ×4 to use.

You could try both orders. Or you can start from 20 and ask what the last step was. If the last step was ×4, the number before it was 5, and 5 is 3 + 2. That works: +2, then ×4. If the last step was +2, the number before it was 18, and 18 is not 3 × 4. So that order is out.

With two steps, guessing is almost as fast. With four or five steps and a few extra choices, working backwards is much faster, because each step back throws away options you would otherwise have to try. I think this is one of the most useful habits a child can take into algebra, where “what number went in?” is most of the work.

Things that never change

Some steps have properties you can rely on without calculating. Doubling always gives an even number. Adding 2 never changes whether a number is odd or even.

Start at 7 and you need an even number. Add 2 as many times as you like: 9, 11, 13. You will never get there. Double once and you have 14. The question was never “how many steps?” It was “which kind of step?”

Mathematicians call this kind of property an invariant. Children do not need the word. What they need is the experience of stopping, instead of trying one more +2, and noticing that the attempt cannot work.

Trying it without any app

You need a pencil and paper.

  1. Draw two boxes in a row, labelled +2 and ×3. Let the child choose a number, predict what comes out, then work it through. Swap the boxes and predict again.
  2. Ask them to guess before calculating. Prediction is the part that builds understanding. Calculating only checks it.
  3. Play “guess my machine”. You hide the rule. They give you numbers, you give back results, and they work out what your boxes are.
  4. Run it backwards. “My machine gave 14. What went in?”
  5. Ask them to say what they found in their own words. If they can say “the order matters when you mix adding and multiplying”, they have it.

Keep the numbers small. The point is the structure. If every step is a struggle to calculate, the structure disappears behind the arithmetic.

Where Math Gates comes in

Math Gates is the puzzle game I made around these ideas. A bit carrying a number travels in a straight line across a board. You place gates that change the number and mirrors that turn the path by 90 degrees, and the port at the end only accepts one value. Because the bit only goes straight, the order it meets the gates is decided by where you put them. If you want to add before you double, you have to bend the path with a mirror so it meets the adding gate first. Composition turns into a layout problem you can see.

The game does not explain any of the ideas above in advance. The path is drawn as soon as you place a piece, so you read before you run instead of guessing. After you clear a puzzle, a card names what you just did and shows the formula behind it, such as “Times and plus depend on the order” or “+2 never changes odd or even”. The tray always holds one more gate than you need, and the fewest gates earns three stars, so there is always a reason to look for a shorter machine. There are 140 puzzles in seven worlds, from adding and subtracting to logic. It is made for ages 8 and up. The game is free with ads between clears, and a one-time purchase removes them.

If the arithmetic itself is still slow, that is worth working on separately, because a child who spends all their attention on 12 + 2 has none left to see the structure. For that I would point to StudyX MathCal, our handwriting drill app for mental math.

My own view is that the order of steps is one of the first truly mathematical ideas a child can discover alone. A pencil, two boxes and the number 4 are enough to start.

Download on the App Store