# Reverse engineering a math magic trick involving matrices.

This problem was brought up by my mother from a corporate party along with a question on how that worked.

There was a showman who asked to tell him a number from $$10$$ to $$99$$ (If i'm not mistaken). The number $$83$$ was named after which he took a piece of paper and quickly put down a matrix (note he did that fast):

$$\begin{bmatrix} 8 & 11 & 63 & 1\\ 62 & 2 & 7 & 12\\ 3 & 65 & 9 & 6 \\ 10 & 5 & 4 & 64 \end{bmatrix}$$

If you take a closer look every row, column and diagonal has the sum of $$83$$. Moreover consider the corners of the matrix also have the sum of $$83$$. For example: $$\begin{bmatrix} \color\red{8} & \color\red{11} & 63 & 1\\ \color\red{62} & \color\red{2} & 7 & 12\\ 3 & 65 & 9 & 6 \\ 10 & 5 & 4 & 64 \end{bmatrix}$$

Also the central square is $$83$$ in sum as well: $$\begin{bmatrix} 8 & 11 & 63 & 1\\ 62 & \color\red{2} & \color\red{7} & 12\\ 3 & \color\red{65} & \color\red{9} & 6 \\ 10 & 5 & 4 & 64 \end{bmatrix}$$

Clearly numbers $$1,2,3,4,5,6,7,8,9,10,11,12$$ are filled in in a circular manner. And then consequent $$62, 63, 64, 65$$ are as well. I'm not very familial with linear algebra so my question is:

What was that rule he used to build it? Can we construct a matrix with the same properties given a random number in some range? Is it possible to build a similar one but for $$5\times 5$$, $$6\times 6$$ or $$N\times N$$ matrix?

• What kind of show was that?
– lcv
Commented Dec 22, 2018 at 13:32
• It’s hard to imagine a less geeky show :-)
– lcv
Commented Dec 22, 2018 at 13:38
• This feels more like recreational mathematics than linear algebra. Commented Dec 22, 2018 at 16:50
• Reminds me of a paper I read before about constructing magic squares. Have a look at this: researchgate.net/publication/…
– Theo
Commented Dec 22, 2018 at 20:00
• To show that you can get any sum on the rows, columns, and two main diagonals for any $N \times N$ magic square ($N \ge 4$), see my Answer here: math.stackexchange.com/questions/1992336/… Commented Dec 23, 2018 at 15:40

This is all based on the amazing matrix $$\pmatrix{8&11&14&1\\13&2&7&12\\3&16&9&6\\10&5&4&15}$$ Note that this works for $$34$$. For $$34+n$$ you just replace $$13,14,15,16$$ with $$13+n,14+n,15+n,16+n$$. I do not know what the showman's backup plan for numbers below $$34$$ is.

EDIT: There is a Numberphile video on YouTube on this exact trick.

• I also believe it was not 10, but rather some larger two digit number Commented Dec 22, 2018 at 13:19
• Thanks for sharing a link to the video! Also it looks like magic does not exist after all :) Commented Dec 22, 2018 at 15:30
• It's possible that his backup plan was to subtract some number from those four. Commented Dec 23, 2018 at 18:36
• @JarredAllen Or perhaps use a smaller matrix? Subtract all numbers from 100, effectively inverting the trick? No clue, but there are possibilities indeed.
– Mast
Commented Dec 24, 2018 at 6:45

He did not write down 'a matrix'. He wrote down a magic square.

There are various algorithms for constructing them, the easiest to do mentally is to start with a generic starter matrix you memoize:

 A  1 12  7
11  8  B  2
5 10  3  C
4  D  6  9


And solve for A, B, C, D for your target number. With some practice you can do this super fast.

• Of course it is a matrix as well. Commented Dec 22, 2018 at 13:27
• @JannikPitt Of course. I just remarked on it as if someone arriving by private helicopter to do grocery shopping is described as "arriving by vehicle".
– orlp
Commented Dec 22, 2018 at 17:16

Observe that the numbers in the sixties lie on different rows, different columns and different quadrants. If you increase them simultaneously, all the twelve sums increase by the same amount.

In the pure magic square (numbers $$1$$ to $$16$$), the sum is $$34$$, hence if suffices to add $$83-34=49$$ to these four elements.

It would be more logical to request a sum in the range $$[34,83]$$ so that all elements are at most two-digit naturals.

For stronger mystification, you can split the required increment in two or more and adjust on the other possible groups.