Saturday, May 24, 2014

1.2: Magic Squares

Magic Squares
A magic square is an \(n \times n\) grid of numbers 1, 2, all the way up to \(n^2\). The numbers are placed in such a way that each row, column, and diagonal has the same sum \(s\), which is called its magic sum. Here's a magic square of order 4 (\(n = 4\)):


The magic sum for the square is 34.

The sum of all integers in a magic square follows this formula:

$$1 + 2 + 3 + \cdots + n^2 = \frac{n^2(n^{2} + 1)}{2}$$

Each row has the same magic sum \(s\). Since there are \(n\) rows, you can equate it with \(1 + 2 + 3 + \cdots + n^2\) to get:

$$ns = \frac{n^2(n^{2} + 1)}{2}$$

Or, cancelling \(n\),

$$s = \frac{n(n^{2} + 1)}{2}$$

The challenge is to find what values of \(n\) have a magic square, and then find general methods for making them. For \(n = 2\) there is no magic square, since \(s\) would equal 5, violating the rules set up for the squares. For the rest of the values, a square can be made.

de la Loubère's Method
There is a method devised by de la Loubère for finding magic squares when \(n\) is odd. You start from 1 then go all the way to \(n^2\) following this pattern:

  • Put 1 in the middle square of the top row.
  • For each successive number, put it in the square that is up and to the right of the previous square.
  • When you reach the top row, put the next integer in the bottom row.
  • When you reach the rightmost column, put the next integer in the left row.
  • When you're placing numbers in the upper-right square and it's filled, place the number instead in the square immediately below the last square that was filled.
Here's a magic square of order 5 that follows these rules. See if you can follow along with it.



There are, of course, other methods, but they won't be mentioned here.

Magic Cubes
As always, let's take it to the next step. Define a magic cube of order \(n\) as an \(n \times n \times n\) cubical array made of the numbers \(1, 2, 3, \cdots, n^3\) such that for all lines parallel to the edge of a cube, the two diagonals of each cross section of the cube, and the four space diagonals, the sum of the numbers comes out to magic sum \(s\).

The value of \(s\) is \(\frac{n^{4} + n}{2}\). 

It is known that there's no magic cube of order 3. Let's see why. First, suppose we have a magic cube of order 3. Its magic sum would be 42. Take any 3x3 slice (plane) of it. You get a matrix of numbers of this style:

$$\begin{bmatrix}a\ b\ c\\x\ y\ z\\d\ e\ f\end{bmatrix}$$

With it being a magic square, each of the following sums equal 42. They follow the rules laid out in the definition for a magic square.

$$a + y + f\\b + y + e\\c + y + d\\a + b + c\\d + e + f$$

If you subtract the sum of the last two equations from the sum of the first three, everything but the \(y\) cancels out. You're left with \(3y = 42\) or, if you reduce, \(y = 14\). But this means 14 would have to appear in the cube seven times - in the dead center of the cube and in the middle of each face. But a number can only appear once in a magic cube, therefore there is a contradiction. From this we conclude, you can't have a magic cube of order 3.

There is more to it but, with this just being an introductory example, we'll stop here.

No comments:

Post a Comment