Main Page | See live article | Alphabetical index

# Magic square

In mathematics, magic squares consist of a number of integers arranged in the form of a square in such a way that the sum of the numbers in every row, column and diagonal are the same. A magic square may have odd or even number of rows and columns. Usually the magic square is filled up by consecutive numbers from one to N2 where N is the number of rows or columns. A magic square is designated with reference to this. Thus a magic square of order N will have N number of rows and columns and will be filled by numbers ranging from one to N2.

More formally, a magic square can be defined as an n-by-n matrix such that the sum of any row, column or main diagonal yields the same result (the square's magic constant, denoted M2(n)); if these numbers are 1, 2,..., n², then

There are many ways to construct magic squares, but the standard (and most simple) way is to follow certain configurations / formulas which generate regular patterns. Certain other restrictions can be imposed on magical squares, resulting, for example, in bimagic, trimagic and multimagic squares, and there are also other forms displaying similar characteristics, including magic circles, magic polygons, and magic cubes.

## Brief history of magic squares

### The Lo Shu Square

Magic Squares have fascinated humanity throughout the ages, and have been around for over 4,000 years.

Chinese literature dating from as early as 2800 BC tells the legend of Lo Shu or 'scroll of the river Lo': in ancient China, there was a huge flood. The people tried to offer some sacrifice to the river god of one of the flooding rivers, the Lo river, to calm his anger. Then, there emerged from the water a turtle with a curious figure/pattern on its shell; there were circular dots of numbers that were arranged in a three by three nine-grid pattern such that the sum of the numbers in each row, column and diagonal was the same - 15. This number is also equal to the 15 days in each of the 24 cycles of the Chinese solar year. This pattern, in a certain way, helped in controlling the river.

The Lo Shu Square, as the magic square on the turtle shell is called, is an important part of Feng Shui, the ancient Chinese art of geomancy. Traditional Chinese cities and temples were laid out in a square broken into nine sections; the odd numbers in the Lo Shu Square are male or yang, while the even numbers are female or yin. The numbers 1, the beginning of all things, and 9, representing completion, are considered most auspicious, while the number 5 at the centre is the most powerful. The Lo Shu square, in the form of a trigram, gives the basis for determining the orientation of buildings, and is also a diagrammatic representation of the seasons showing the ratio of yin and yang in the annual cycle.

The magic square figures in Greek writings dating from about 1300 BC and was used by Arabian astrologers in the ninth century when drawing up horoscopes.

### The earliest square of order four

The earliest magic square of order four was found inscribed Khajuraho, India, dating from the eleventh or twelfth century; it is also a so-called diabolic or pandiagonal magic square where, in addition to the rows, columsn and main diagonals, the broken diagonals also have the same sum.

### Cultural significance of magic squares

Magic squares were frequently found in a number of cultures, including Egypt and India, engraved on stone or metal and worn as talismans, the belief being that magic squares had astrological and divinatory qualities, their usage ensuring longevity, prevention against diseases etc.. The Kubera-Kolam is a floor painting used in India which is in the form of a magic square of order three. It begins with the number twenty and ends with the number twenty-eight.

### Albrecht Dürer's magic square

The 4x4 magic square in Albrecht Dürer's engraving Melancholia I is believed to be the first seen in European art. The sum 34 can be found in the rows, columns, diagonals, any 2x2 block of numbers, the sum of the four corners, the sums of the four outer numbers clockwise from the corners (3 + 8 + 14 + 9) and likewise the four counter-clockwise, and the sum of the middle two entries of the two outer columns and rows (eg 5 + 9 + 8 + 12), as well as several kite-shaped quartets, eg 3 + 5 + 11 + 15; the two numbers in the middle of the bottom row give the date of the engraving: 1514.

It has been known since 1693 that there exist 880 basic (excluding those obtained by rotation and reflection) 4x4 magic squares and 275305224 basic 5x5 magic squares. The number of basic magic squares of any higher degreee is not yet known but it was estimated by Klaus Pinn and C. Wieczerkowski (1998) using Monte Carlo simulation and methods from statistical mechanics to be (1.7745 ± 0.0016) × 1019 in the 6x6 case squares and (3.7982 ± 0.0004) × 1034 in the 7x7 case.

## Types of magic squares and their construction

Magic squares exist for all values of n, with only one exception - it is impossible to construct a magic square of order 2. Magic squares can be classified into three types: odd, doubly even (n divisible by four) and singly even (n even, but not divisible by four). Odd and doubly even magic squares are easy to generate; however, the construction of singly even magic squares is more difficult. Only odd and doubly even magic squares are discussed below.

### A method for constructing a magic square of odd order

Starting from the central column of the last row with the number 1, the fundamental movement for filling the squares is diagonally down and right, one step at a time. If a filled square is encountered, one moves vertically up one square, then continuing as before. When a move would leave the square, it is wrapped around to the first row or column, respectively.

The same pattern can be achieved starting from the central column of the first row; In this case the fundamental movement is diagonally up and left, one step at a time, and if a filled square is encountered, one moves vertically down one square, then continuing as before. When a move would leave the square, it is wrapped around the last row or column, respectively.

Similar patterns can also be obtained by starting from other squares.

 Order 3 Order 5 Order 9

### A method of constructing a magic square of doubly even order

This should be rewritten for clarity and generality.

All the numbers are written in order from right to left across each row in turn, starting from the top right hand corner. Numbers are then either retained in the same place or interchanged with their diametrically opposite numbers in a certain regular pattern. In the magic square of order four, the numbers in the four central squares and one square at each corner are retained in the same place and the others are interchanged with their diametrically opposite numbers. In the magic square of order eight, the same is done; the 16 central squares and 4 squares at each corner are retained in their places and the rest are switched.

Order 8