Magic Square Solver |
Home | Your Feedback |
(Or click Generate Random Square ... to do just that!) Another site's take on the problem
Patterns marked with * are restricted: the sum of the 3 numbers must equal (3 × the second number), so in those cases, the third number might be changed to make the solution possible.
The last pattern, marked #, is also restricted: the third number must equal twice the first minus the second, and so it too might need to be adjusted.
Those three are also "wildcard" patterns ... one of the other numbers can chosen at will and the rest filled in. As such, those will have random solutions generated, and repeatedly selecting the pattern will produce different solutions.
The sum of each row, called the Magic Sum, is the same, so the sum of all the numbers equals 3 times that.
There are four pairs of opposite numbers, comprising eight
of the numbers, each with the same sum, which is Magic Sum - Middle Number.
Hence,
Total Sum = 4 * (Magic Sum - Middle Number) + Middle Number.
3 * Magic Sum = 4 * Magic Sum - 3 * Middle Number, and
Magic Sum = 3 * Middle Number.
Then each opposite pair sums to twice the middle number,
and the opposite pairs all consist of two numbers of the same parity,
equidistant from the middle number.
Every corner is half the sum of the two squares which are "knight's move" away (the middle squares of the opposite sides), and falls halfway between them.
From all that, we see that the nine numbers always form eight arithmetic
progressions:
The middle row and column(2), the main diagonals(2),
and 4 are "broken diagonals",
consisting of each corner square and the two opposite middle edge
squares, just mentioned above.
If all 9 numbers form a single arithmetic progression, then the magic square can be derived from the basic 816-357-492 square by a linear transformation: A * x + B, where A and B are constants, and x is value in a square.
For example: 5 8 11 14 17 20 23 26 29, which becomes:
26 5 20 8 1 6 11 17 23 = (3x+2) * 3 5 7 14 29 8 4 9 2
Others are not quite so simple to reduce, but there is always some
regularity.
Take 4 7 8 10 11 12 14 15 18 for example:
This forms a set of arithmetic progressions:
4 7 10 ... 8 11 14 ... 12 15 18
all with constant difference 3.
Also 4 8 12 ... 7 11 15 ... 10 14 18
all with constant different 4.
The remaining ones are:
10 11 12 ... 4 11 18 (the middle row/column);
Note the differences between this one and the previous:
26 5 20 15 4 14 11 1 6 which is itself 11 17 23 - 10 11 12 = 1 6 11 a magic square! 14 29 8 8 18 7 6 11 1
It is always the case that the sum or difference of two magic squares is another magic square.
Or start with (a progression of) arithmetic progressions:
0 3 6 ... 11 14 17 ... 22 25 28
3 .. .. .. 28 .. .. .. 11 3 28 11 .. .. 6 + 22 .. .. + .. 14 .. = 22 14 6 .. 0 .. .. .. 25 17 .. .. 17 0 25
Starting with 0 11 22 ... 3 14 25 ... 6 17 28 also works.
The two sets of progressions are complementary.