Magic squares
Tonight's idea
A magic square puts the numbers 1 to 9 in a \(3 \times 3\) grid so that every row, column and diagonal has the same magic sum. The oldest known one is Chinese; legend puts it on the back of a turtle.
Two facts follow from nothing but adding. First, the nine numbers total \(1 + 2 + \cdots + 9 = 45\), shared equally by three rows, so each row sums to \(45 \div 3 = 15\). Second, the four lines through the middle cell (middle row, middle column, two diagonals) cover the centre four times and every other cell exactly once.
Four lines: \(4 \times 15 = 60\). Also \(60 = 45 + 3c\), where \(c\) is the centre. So \(3c = 15\) and \(c = 5\).
The same count shows that opposite cells through the centre add to \(15 - 5 = 10\).
For any odd size use the Siamese method, brought to Europe from Siam in the 1680s. Put 1 in the middle of the top row, then place each next number one cell up and to the right. Off the grid? Wrap to the opposite edge. Cell taken? Go one cell down from the number just placed instead.
Watch one: a \(5 \times 5\) by the Siamese method
1 goes in the middle of the top row. Up-right wraps to the bottom row: 2 goes in the bottom row, fourth column. Then 3, 4 (wrapping off the right edge), 5. Up-right of 5 is where 1 sits, so 6 drops below 5. Keep going to 25:
| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
The numbers 1 to 25 total \(\tfrac{25 \times 26}{2} = 325\), shared by five rows, so the magic sum should be 65. Top row: \(17 + 24 + 1 + 8 + 15 = 65\). Main diagonal: \(17 + 5 + 13 + 21 + 9 = 65\). It works.
Your turn
- Complete this magic square using 1 to 9, and check all eight lines.
2 6 5 4 - Show that 1 cannot be in a corner. Hint: a corner lies on three lines, and the diagonal through it also passes through 5. Which pairs of numbers from 2 to 9 add to 14?
- Build the \(3 \times 3\) square by the Siamese method and check all eight lines. How is it related to the square in question 1?
- A \(3 \times 3\) magic square uses nine different whole numbers, not necessarily 1 to 9, and its centre is 12. Find the magic sum and the total of the four corners. Hint: the four lines through the centre still work, and so do the three rows.
Stretch: how many magic squares are there?
Extend question 2: show that every corner of a 1-to-9 magic square must be even. Then count the magic squares that use 1 to 9. How many are there, and how are they related to each other?
Answers
- Top middle \(15 - 2 - 6 = 7\); left column needs 9; then right column 1, bottom 3 and 8. Rows: \(2, 7, 6 \mid 9, 5, 1 \mid 4, 3, 8\). All eight lines give 15.
- A corner sits on a row, a column and a diagonal. The diagonal through 1 and the centre 5 needs 9 at the opposite corner. The row and the column through 1 each need two numbers adding to 14, chosen from 2 to 9 without 5 or 9. The pairs adding to 14 are \(5 + 9\) and \(6 + 8\), so both the row and the column need 6 and 8, which can only be used once. Contradiction: 1 is in the middle of a side, and so is 9, opposite it.
- \(8, 1, 6 \mid 3, 5, 7 \mid 4, 9, 2\). All lines sum to 15. It is the question-1 square reflected in the diagonal from bottom-left to top-right (the 2 and 8 swap corners, the 6 and 4 stay put).
- Call the magic sum \(S\) and the centre \(c\). Three rows: the nine numbers total \(3S\). Four lines through the centre: \(4S = 3S + 3c\), so \(S = 3c = 36\). Each pair of opposite corners adds to \(S - c = 24\), so the four corners total 48.
Stretch. Repeat question 2 for 3, 7 and 9. If 3 is in a corner, 7 is opposite; the row and column through 3 each need two unused numbers adding to 12, and only \(4 + 8\) is left. The same clash happens for 7 (only \(2 + 6\)) and for 9 (only \(2 + 4\)). So the corners are 2, 4, 6, 8. Place 2 in any of 4 corners; 8 goes opposite; 4 and 6 fill the other two corners in 2 ways; the middles of the sides are then forced. That gives \(4 \times 2 = 8\) squares, and they are one square rotated or reflected.