Friday, November 17, 2017

What is the fewest number of filled-in squares required to uniquely define a magic square?


The magic square is a well-known grid of the numbers from 1 to 9 in which every row, column, and diagonal adds up to 15:


4 9 2
3 5 7

8 1 6

But it is also possible to create magic squares using other numbers:


24 87 45
73 52 31
59 17 80

It's also known that given just a few filled-in squares, you can determine the rest logically. For example, given the partially filled-in grid:


8 9 .
. 6 .

. 3 .

you can immediately infer that the rows, columns, and diagonals add up to 18, and so the bottom-right square is 4 and the top-right square is 1:


8 9 1
. 6 .
. 3 4

Then the right square is 13 and the bottom-left square is 11:


 8 9  1
. 6 13

11 3 4

And finally, in a slightly uncouth twist, the left square is -1.


 8  9  1
-1 6 13
11 3 4

But in fact, it's possible to create a set of filled-in numbers that don't have any completed rows at all and still be able to fill the rest of the numbers in:


12 .. 27
.. .. 6

.. 18 ..

This, as it turns out, has a (unique) solution of:


12 24 27
36 21 6
15 18 30

So what is the fewest number of filled-in squares that are actually possible to derive the whole square from, and what arrangement are they in? And what about the case of higher-order magic squares?



Answer



It turns out that the magic squares form a vector space. You can add them (by adding each corresponding entry), multiply them by scalars (by multiplying every entry by the same number), and invert them (take the negative of each entry) around a zero element (the magic square where everything is zero), and they will still stay magic squares.



And this vector space has a basis of size three, as follows:


 0 -3  0     0  2  1     1  2  0
-1 -1 -1 , 2 1 0 , 0 1 2
-2 1 -2 1 0 2 2 0 1

This means that given any three constants a, b and c, you can define the following magic square:


          c,   2b + 2c - 3a,             b
2b - a, b + c - a, 2c - a
b + 2c - 2a, a, 2b + c - 2a


where the magic constant is 3b + 3c - 3a.


The classical (Lo Shu) magic square has a = 1, b = 2, and c = 4.


So if you are given three numbers in the V shape (or its reflections and rotations):


xx .. ..
.. .. xx
xx .. ..

then you can make a magic square out of it. In fact, as long as you're given any three positions so that for each position, when you take the number in that position from each square in the basis and form a vector out of it, you end up with three linearly independent vectors, then you can still uniquely determine a magic square out of it by solving a system of linear equations.




I don't know anything about the higher-order squares, though. That can be left for another answer.



No comments:

Post a Comment

classical mechanics - Moment of a force about a given axis (Torque) - Scalar or vectorial?

I am studying Statics and saw that: The moment of a force about a given axis (or Torque) is defined by the equation: $M_X = (\vec r \times \...