8 1 6 3 5 7 4 9 2

Order-3 Magic Squares are simple enough to allow an
algebraic
treatment yet interesting enough to still be fun. A magic square is a
square grid filled with numbers (usually consecutive integers) in
such a way that every row and column and the two main diagonals all
sum to the same number. There is only one solution for the order-3
magic square (ignoring reflections and rotations), and it is pictured
to the right. Its rows, columns, and diagonals all sum to 15. It is
easy to show that no other solution is possible just by looking at
all the possible ways three different numbers from 1 to 9 can sum to
15. There are eight in all:

From this list it is obvious that 5 appears in four different expressions; 2, 4, 6, and 8 each appear in three different expressions; and 1, 3, 7, and 9 each appear in two different expressions. The only cell that appears in four sums is the center cell. Likewise, the corner cells each appear in three sums, and the side cells each appear in two sums. Therefore, 5 must go in the center cell; 2, 4, 6, and 8 in the corner cells; and 1, 3, 7, and 9 in the side cells. Placing the 1 in any side cell uniquely determines the placement of the 9. Placing any other digit uniquely determines all the rest. A little experimentation will serve to show that all the solutions are reflections or rotations of the one shown.

*a*
*b*
*c*
*d*
*e*
*f*
*g*
*h*
*i*

From this list a number of interesting relationships can be
discovered that make it easy to generate an order-3 magic square
using any three numbers. For example, lets add together all the
equations containing *e*.

Rearranging and combining terms gives:

Thus for any order-3 magic square, the magic constant of the square is three times the center cell. Now consider the sum of equations 6 and 7 above:

Substituting from equations 1 and 2, we get:

12 7 20 21 13 5 6 19 14

Now we can use any three numbers to generate several order-3 magic
squares. For example, let *a*=12,
*b*=7,
and *c*=20.
It immediately follows that *j*=39
and *e*=13. With *j*
and *e* known, the rest
of the square is easy to fill in, as shown at the right. Notice how
all the relationships we discovered hold true. Every corner cell is
half the sum of the two opposite side cells, and the center cell is
half the sum of opposite cells. If I were a programmer, I could write
a computer program that would generate a magic square by filling in
any three appropriate cells. (Of course, if someone filled in, say, *a*
and *e*, the program
would automatically fill in *i*,
leaving the person to select another letter).