[Math] Reverse engineering a math magic trick involving matrices.

magic squarerecreational-mathematics

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?

Best Answer

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.

Related Question