Let us indulge in the topic of Magic Squares today – simply put, it is a square grid into which whole numbers are placed. The whole numbers themselves need not follow any order but they must be distinct, and placed in such a way that each horizontal row, vertical column and diagonal add up to the same number.

Let us illustrate by means of an example:

A 3 x 3 'Lo Shu' Square |

Observe:

**1st Row:**8 + 1 + 6 = 15

**2nd Row:**3 + 5 + 7 = 15

**3rd Row:**4 + 9 + 2 = 15

**1st Column:**8 + 5 + 2 = 15

**2nd Column:**1 + 5 + 9 = 15

**3rd Column:**6 + 7 + 2 = 15

**1st Diagonal:**8 + 5 + 2 = 15

**2nd Diagonal:**6 + 7 + 2 = 15

This magic square is known as the 'Lo Shu' square and was known in China around 3000 BC. Legend says that it was first seen on the back of a turtle emerging from the Lo river - the natives then took it as a sign from the gods that they would not be freed of pestilence unless they increased their offerings.

But really, is there a systematic way of generating such magic squares? Indeed there is! There are several methods, of which the likes of

*trial and error*I shall not mention, haha. Suppose we go by a logical algebraic method:
1) For a 3 x 3 square, there will be 9 numbers, whose sum is given by:

*= 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45*

**S**
Since each row must add up to the same number, dividing this by 3 means that each row/column/diagonal must add up to 15.

2) Let us now consider the central cell and label it

*:***x**The Blank Square |

We know that each row, column and diagonal must add up to 15, and so if we add up the middle row, middle column and both diagonals, we have them adding up to 60:

15 + 15 + 15 + 15 = 60

Now, pause for a moment - if you take the sum of the middle row, middle column and both the diagonals, that's equivalent to taking

*+ 3***S***= 60 because you're adding all the numbers from 1 through 9 once, and then adding them to 3***x****.***x*
Since

*= 45, then surely:***S**
3

*= 15 and therefore***x****x****=**5
And of course, we can carry on

*ad infinitum*,*ad nausea*, via a system of simultaneous equations that can be solved for every single element in the grid we see above.
But surely, surely there

*be an easier method!***must**
Well, guess what? There is one! Simon de la Loubere, the French ambassador to the King of Siam in the late 17th century, wrote down an algorithm for constructing magic squares that have an odd number of rows and columns:

1) Place a '1' in the middle of the first row.

3) If the cell is blocked, the successive number should be placed beneath the current number.

Let's illustrate this awesome rule:

The 'Loubere' Algorithm |

And there you have it:

A 3 x 3 'Lo Shu' Square |

Using this algorithm, you can easily create any magic square that has an odd number of rows and columns. :)

## No comments:

Post a Comment