Math in Magic Tricks: The Algebra Behind the Astonishment
The secret is not mind reading. It is that the variable cancels on purpose.
By Daon Opus · Updated October 25, 2026
Ask a friend to think of any number, keep it secret, and follow your instructions. Add two, triple it, subtract six, divide by three, subtract the original number, add four. Without knowing what they picked, you announce the answer: four.
For a moment it feels like mind reading. Then someone asks why it worked, and the answer turns out to be less mysterious and more satisfying. There was never any way for the original number to survive. The trick was built so that it would cancel itself, and algebra is the tool that lets you see it happen on paper.
Write the trick down one step at a time
Let the secret number be n. That single letter is the whole point, because it stands for whatever your friend chose without committing to any value. Now follow the steps exactly as spoken.
Start with n. Add two: n + 2. Triple it: 3(n + 2) = 3n + 6. Subtract six: (3n + 6) - 6 = 3n. Divide by three: 3n ÷ 3 = n. Subtract the original number: n - n = 0. Add four: 0 + 4 = 4.
Look at what is left. At every turn the operations built up around n, but division and subtraction tore it back down until nothing of it remained except zero. The directions were not random. They were a recipe designed to undo themselves, and the final four is the only thing the instructions could possibly produce. Our guide to algebraic expressions is exactly the set of translation skills that makes this sentence readable.
Try a slightly different version to be sure. Start with n, double it, add six, divide by two, subtract the original number, subtract three. Work it out: 2n, 2n+6, (2n+6)/2 = n+3, n+3-n = 3, 3-3 = 0. No matter what n is, you end at zero. The operations pair up: double undoes in effect when combined with divide by two, add six undone by subtract three, and subtract n clears the rest. Once you see those pairs, the magic loses its mystery and gains its elegance.
An identity, not an equation to solve
There is a precise way to say what is happening. The whole chain is an expression in n that simplifies to the constant 4 for every value of n. In algebra, a statement that is true for all values of the variable is called an identity. An equation like 2n + 1 = 9 is different: it is true for only one value of n, and solving linear equations means finding that value. A trick like this is the reverse. The answer is forced because the structure is an identity.
That distinction matters because it tells you where to look. If you think you are solving, you will look for a missing number. If you see it is an identity, you look for cancellation. The magician does not guess. They construct an identity on purpose, then disguise the simplification behind friendly instructions.
Once you start looking, you can spot the pattern. Any time the instructions multiply by a number and later divide by the same number, and add and subtract matching amounts in a way that returns to n, the variable is at risk. The trick is to arrange those moves so that nothing is left but a constant chosen in advance.
It is worth showing the audience that nothing sneaky is going on by trying two or three different starting numbers quickly in their heads. Seven becomes four, zero becomes four, negative two becomes four. The test is not about speed but about variety. The algebra proves it for every number at once, which is stronger than testing a dozen by hand.
Build your own trick from the end backwards
Once you see the trick, you can make one, and it is far easier than it looks. Pick the answer you want people to get, say seven. Now work backwards from seven, doing the opposite of each operation you plan to say. If you want them to subtract three at the end, work backwards by adding three. If you want them to divide by two in the middle, work backwards by multiplying by two.
Build a short chain forward from n, and undo it backwards to land on seven. Keep the chain short, because every extra step gives more room for mental arithmetic errors, and a magician with the right answer is no good if the audience gets lost halfway through. The math is the show behind the scenes, not the show itself.
A useful test is to force the variable to appear twice. Start with n, add n (giving 2n), add ten, divide by two (giving n+5), subtract n. You are left with five, and you can never avoid it. Tricks like this work best when the audience cannot see you simplifying, but the algebra makes every move predictable from the first line.
Be careful with division. If you tell someone to divide by two, you must have arranged for the expression to be even at that point. In a well built identity, the terms combine so that the factor cancels or matches exactly. Working backwards helps catch that mistake before you perform the trick in front of someone.
A good trick stays hidden. A good math lesson pulls it apart. The goal here is the second one: take something that felt like a secret and turn it into something you could explain to a friend with a pencil and paper.
Tricks are fixed forms, puzzles are open ones
There is a useful boundary worth drawing. A math puzzle like a magic square asks you to find a solution that fits many constraints at once. A trick like this one has only one possible answer no matter what you do, because the constraints were written to force it. Both are fun, but they train different muscles. Puzzles stretch your search. Tricks show you the power of a structure.
Our guide to puzzles and riddles spends time on guess-my-number and magic squares for exactly this reason: they look playful, but they build the habits of reasoning. Adding algebra to that is the moment the habit becomes explicit. You stop noticing a pattern and start proving it.
That proof is exactly what makes the reveal satisfying. The trick is not that someone can guess a number, but that an equation has only one solution regardless of which number goes in. Once you see that, you are not watching magic. You are watching cancellation.
Try it at the table
Do the four-step trick above with someone, and tell them the answer before they add four. Watch their face change when they realize they were never needed. Then hand them a pencil and write the line for n through to 4 together.
Ask them to spot where n disappeared. That single question is more valuable than doing ten more tricks, because it points to the idea itself: algebra can reveal what is always true, even when it looks like it depends on a choice.
Now try the same test with a different starting number in front of them, writing both lines side by side. The n column changes, but the constant column is identical. That visual is often the moment it clicks: the arithmetic looks different, but the structure is the same, and the structure forces the result.
Write one trick down and watch the variable vanish. Our free math apps give practice with algebraic expressions one step at a time, and Math Q&A is where to bring a trick you invented to see if the algebra actually works.