The Search for Magic Squares

If we place the digits 1, 2, 3 all the way up to 9 in the nine “boxes” shown in Figure 1 with no digits being repeated, such that the horizontal, vertical and diagonal sums equal 15, then we have a 3×3 magic square.  Not many people know, but there is a systematic way of locating the positions of the digits to construct the 3×3 magic square.

Figure 1

Looking at problem above, we know two facts:

1.)    The sum of all the digits from 1 through 9 is equal to 45. It follows that

a + b + c + d + e + f + g + h + i = 45.

2.)    The sum of the three digits horizontally, vertically and diagonally is equal to 15. Hence, c + e + g = 15, b + e + h = 15 and g + h + i = 15, etc.

With these two facts, we can use four equations containing e.

(a + e + i) + (b  + e + h) + (c + e + g) + (d + e + f) = 15 + 15 + 15 + 15 = 60.

Rearranging and regrouping, we have

(a + b + c + d + e + f + g + h + i) + 3e = 60

45 + 3e =  60

3e = 15

e = 5.

Therefore, the value of our center box is 5.  We now put 5 in place of e as shown in Figure 2.

Figure 2

The best that we can do is to find the square where we will put the largest or the smallest number (Why?).  Suppose, we let a = 9. It follows that i = 1 as shown in Figure 3.

Figure 3

Notice that we could not put 8 in boxes with red letters, since having 9 on the same row or column would already add up to 17. Therefore, the only boxes that we could put 8 are in box f or box h.

Let us place 8 in square f. That would make d = 2 and g = 6 as shown in Figure 4.

Figure 4

Since the sum of each row is equal to 15 that makes our h = 10, which is not allowed. If we put 8 in h, then g = 6 which makes the sum of the first column 15 with no number in g.

Hence, we have two 8’s.  Therefore, our choice of letting a = 9 is wrong.

Question: Can we put 9 in the other three corner squares? Explain your answer.

It is not possible to put 9 in square a, so let us place it in square b.  In doing so, we come up with the magic square shown in Figure 5.

Figure 5

It is reasonable to put the smaller integers in the first row where 9 is placed, since putting larger integers, would make the sum greater than 15. The next smallest integer is 2.  Now, let a = 2. This makes c = 4, h = 8*. With the given numbers, it is now possible to fill in all the squares as shown in Figure 6.

Figure 6

Question: Try letting a = 3, or g = 7 and see if you can create a magic square.

Searching for Bigger Magic Squares

In creating bigger magic squares, more “guess and check” strategy is needed.  However, the strategies that we have used in this discussion can also be useful. Generalizing our solution above, we can use the following facts:

1.) The sum s of the numbers of the an n x n magic square is described by

s = 1 + 2 + 3 + 4 + 5 + … + n2

2.) Since each magic square can be divided by n groups with the same sum s, therefore each row (or column or diagonal), has the sum s/n.

NOTE: This post was adapted from the book of Oystein Ore entitled Invitation to Number Theory

Related Posts Plugin for WordPress, Blogger...

3 thoughts on “The Search for Magic Squares

Leave a Reply