Think of a number (and don't forget it). Double it. Add six. Divide your answer by two. Now take away the number you first thought of. The number in your head is now... three!

Magic? Well, it is to an eight year old. Until you understand the basics of functions and algebra, the thought that a number can be predicted is a surprising one. And of course "magic" and "being surprised" are often the same thing. Pulling a rabbit out of a hat is magic because it goes against what we expect, and also because we can't explain how it has been done.

Let's look at another example of mathematical magic. This trick is going to make a number you choose appear six times (to get the best effect it helps if you have a calculator). Think of a number between 1 and 9. Now multiply it by 7, then by 3, next by 11, then by 37, and finally by 13.

If you haven't seen it before, the result will surprise you and make you smile. And even adults have been know to regard this as a magic trick (especially when it's dressed up with a bit of appropriate patter).

Like all tricks, it has a perfectly logical explanation. The numbers 3, 7, 11, 13 and 37 are the prime factors of 111,111. Why does it appear magical? Because we like pretty patterns, and our experience tells us that multiplying lots of familiar "boring" numbers doesn't normally produce something pretty. Incidentally, numbers that are made up entirely of ones are known by mathematicians as "repunits", and repunits have many interesting properties. For example, 1112=12321. Half of all repunits are exactly divisible by 11, and the other half when divided by 11 give a remainder of 1. (Actually that result is pretty obvious when you think about it.) Because of its everyday factors, I find the six digit repunit the most interesting one of all.

Maths and magic have been partners for a long time. Back in the days of Pythagoras, numbers were connected more with mysticism than with conjuring, but discoveries like the "3, 4, 5" triangle were enough to make people believe that some numbers must have magical powers. In the 19th century, Lewis Carroll (a.k.a. Charles Dodgson, a maths lecturer at Oxford) was fascinated by all sorts of tricks and puzzles to do with numbers, some of which magicians still use today. And in modern times, the maths populariser Martin Gardner is one of many mathematicians who are also practising conjurers.

All of these mathemagicians trade off the fact that you can usually predict precisely the outcome of doing something in mathematics, but only if you know the secret beforehand. And since so few people know the secrets of maths, it provides rich possibilities for mind-reading and other "miraculous" deeds.

One of the most ancient of mathematical curiosities is the so-called magic square. This one was known to the ancient Chinese, among others:

8 1 6 3 5 7 4 9 2

This square has the interesting property that every row and diagonal add up to 15, and although you can change it by rotating or reflecting it, the basic arrangement is unique. Unfortunately it is too well known to rate as a good bit of magic, but there are variants which are less well known and therefore more magical.

For example, I like this simple square:

11 66 98 89 99 88 16 61 86 91 69 18 68 19 81 96

In the square, every row, column and diagonal adds to 264. If you study it a bit more closely you should be able to see the simple principle behind it. However, what makes it particularly magical is that if you turn the square upside down, it becomes what appears to be a different magic square, but with the same magic total.

(In fact all of the numbers on the original square are simply mapped onto new positions in the inverted square, though it takes a while to figure out what the rule is for which goes where.)

Wouldn't it be remarkable if a magic square could remain magic not only when upside down but also when viewed in a mirror? Astonishingly, there is one such square. It has digits which when rotated and reflected still stay as legitimate digits. To achieve this, the numbers have to be written in the style of those found on a calculator display. This multi-symmetrical magic square is four-by-four like the one above, with an identical pattern but with some of the digits changed. I'm not going to reveal it, because part of the magic is discovering it for yourself.

I started with an example of a think-of-a-number trick which a child regards as magic but an adult normally regards as a "so what?". Curiously, it can sometimes work the other way around. Adults can be surprised by things that children regard as unexceptional.

Here is an example. Let's suppose that the world is a perfect sphere and you have tied a piece of string tightly around it, so tightly that you can't even squeeze a razor blade underneath. Now cut the string and add in an extra metre to it. Compared to the enormous length of string around the earth, you have only inserted a tiny bit of slack. So the question is, how much slack is there? If millions of people spread out all along the string now tried to lift up the string at the same time, would there be enough slack for them all to squeeze a razor blade underneath? Could they possibly even get their fingers under it?

An adult's intuition usually says that even the razor blades would struggle to get through. Which makes the real answer gobsmacking. It turns out that around the earth there would now be enough slack to let millions of rabbits get under the string without even having to squeeze. The answer is so surprising (if you haven't heard it before) that it seems impossible - or magical, depending on your point of view.

To work out why it is true, you just need some simple algebra.

Let’s call the diameter of the earth , so its circumference is .

We add in a metre of string, to make the new circumference , where is the extra diameter (or slack) in the string. But we know that , so .

Cancel out the to give , or , which is roughly 32cm. So the extra diameter is about 32cm, meaning the extra radius is 16cm. In other words, the circle of string will now clear the earth by 16cm all the way round. That’s more than enough space for the all rabbits to crawl through.

But young children don't have the same reaction to this "trick", mainly because their sense of the "right" sort of answer to expect is not well enough developed. In fact to them it would be disappointing if the rabbits couldn't squeeze under the string!

It reminds me of a story told in the book Sophie's World. Mum, Dad and two year old Thomas are at breakfast. Suddenly, Dad flies up and floats around the ceiling. Thomas smiles as he points and says "Look, Daddy's flying". Mum screams and drops the jam.

This simple example demonstrates something that happens throughout the world of maths. Something is only magic if it goes against what your experience tells you to expect. What the two-year-old Thomas saw was exciting, but no more magical than countless other new experiences he saw every day (like the fact that when you drop a bottle it smashes into hundreds of pieces), whereas what his mother saw went against everything she thought she knew.

In the same way, many maths tricks are only surprising to mathematicians who have spent years encountering results that have led them to expect something else. That's why sometimes clever people can be the easiest to fool.

So magical maths isn't just limited to the minds of primary school children. However far you go in the exploration of this subject, you can be certain that there will be things around the corner waiting to surprise you.

About the author

Rob Eastaway is an independent lecturer, and a consultant to the Millennium Maths Project. He specialises in the everyday applications of mathematics. His books include "Why do buses come in threes?", "Guinness Book of Mindbenders" and "The Memory Kit".