Magic square
In mathematics, especially historical and recreational mathematics, a square array of numbers, usually positive integers, is called a magic square if the sums of the numbers in each row, each column, and both main diagonals are the same. The order of the magic square is the number of integers along one side, and the constant sum is called the magic constant. If the array includes just the positive integers, the magic square is said to be normal. Many authors take magic square to mean normal magic square.
Magic squares that include repeated entries do not fall under this definition and are referred to as trivial. Some well-known examples, including the [|Sagrada Família magic square] are trivial in this sense. When all the rows and columns but not both diagonals sum to the magic constant, this gives a semimagic square.
The mathematical study of magic squares typically deals with its construction, classification, and enumeration. Although completely general methods for producing all the magic squares of all orders do not exist, historically three general techniques have been discovered: by bordering, by making composite magic squares, and by adding two preliminary squares. There are also more specific strategies like the continuous enumeration method that reproduces specific patterns. Magic squares are generally classified according to their order n as: odd if n is odd, evenly even if n is a multiple of 4, oddly even if n is any other even number. This classification is based on different techniques required to construct odd, evenly even, and oddly even squares. Beside this, depending on further properties, magic squares are also classified as associative magic squares, pandiagonal magic squares, most-perfect magic squares, and so on. More challengingly, attempts have also been made to classify all the magic squares of a given order as transformations of a smaller set of squares. Except for n ≤ 5, the enumeration of higher-order magic squares is still an open challenge. The enumeration of most-perfect magic squares of any order was only accomplished in the late 20th century.
Magic squares have a long history, dating back to at least 190 BCE in China. At various times they have acquired occult or mythical significance, and have appeared as symbols in works of art. In modern times they have been generalized a number of ways, including using extra or different constraints, multiplying instead of adding cells, using alternate shapes or more than two dimensions, and replacing numbers with shapes and addition with geometric operations.
File:Dürer Melancholia I.jpg|thumb|Melencolia I includes an order 4 square with magic sum 34
History
The third-order magic square was known to Chinese mathematicians as early as 190 BCE, and explicitly given by the first century of the common era. The first dateable instance of the fourth-order magic square occurred in 587 CE in India. Specimens of magic squares of order 3 to 9 appear in an encyclopedia from Baghdad, the Encyclopedia of the Brethren of Purity. By the end of the 12th century, the general methods for constructing magic squares were well established. Around this time, some of these squares were increasingly used in conjunction with magic letters, as in Shams Al-ma'arif, for occult purposes. In India, all the fourth-order pandiagonal magic squares were enumerated by Narayana in 1356. Magic squares were made known to Europe through translation of Arabic sources as occult objects during the Renaissance, and the general theory had to be re-discovered independent of prior developments in China, India, and Middle East. Also notable are the ancient cultures with a tradition of mathematics and numerology that did not discover the magic squares: Greeks, Babylonians, Egyptians, and Pre-Columbian Americans.Magic squares also appear in art. For example, a magic square appears in Albrecht Dürer's Melencolia. Another one appears in Wilfredo Lam's Bélial, Emperor of the Flies, a magic square is seen in the lower left quadrant of the painting.
China
While ancient references to the pattern of even and odd numbers in the 3×3 magic square appear in the I Ching, the first unequivocal instance of this magic square appears in the chapter called Mingtang of a 1st-century book Da Dai Liji, which purported to describe ancient Chinese rites of the Zhou dynasty.These numbers also occur in a possibly earlier mathematical text called Shushu jiyi, said to be written in 190 BCE. This is the earliest appearance of a magic square on record; and it was mainly used for divination and astrology. The 3×3 magic square was referred to as the "Nine Halls" by earlier Chinese mathematicians. The identification of the 3×3 magic square to the legendary Luoshu chart was only made in the 12th century, after which it was referred to as the Luoshu square. The oldest surviving Chinese treatise that displays magic squares of order larger than 3 is Yang Hui's Xugu zheqi suanfa written in 1275. The contents of Yang Hui's treatise were collected from older works, both native and foreign; and he only explains the construction of third and fourth-order magic squares, while merely passing on the finished diagrams of larger squares. He gives a magic square of order 3, two squares for each order of 4 to 8, one of order nine, and one semi-magic square of order 10. He also gives six magic circles of varying complexity.
| 4 | 9 | 2 |
| 3 | 5 | 7 |
| 8 | 1 | 6 |
| 2 | 16 | 13 | 3 |
| 11 | 5 | 8 | 10 |
| 7 | 9 | 12 | 6 |
| 14 | 4 | 1 | 15 |
| 1 | 23 | 16 | 4 | 21 |
| 15 | 14 | 7 | 18 | 11 |
| 24 | 17 | 13 | 9 | 2 |
| 20 | 8 | 19 | 12 | 6 |
| 5 | 3 | 10 | 22 | 25 |
| 13 | 22 | 18 | 27 | 11 | 20 |
| 31 | 4 | 36 | 9 | 29 | 2 |
| 12 | 21 | 14 | 23 | 16 | 25 |
| 30 | 3 | 5 | 32 | 34 | 7 |
| 17 | 26 | 10 | 19 | 15 | 24 |
| 8 | 35 | 28 | 1 | 6 | 33 |
| 46 | 8 | 16 | 20 | 29 | 7 | 49 |
| 3 | 40 | 35 | 36 | 18 | 41 | 2 |
| 44 | 12 | 33 | 23 | 19 | 38 | 6 |
| 28 | 26 | 11 | 25 | 39 | 24 | 22 |
| 5 | 37 | 31 | 27 | 17 | 13 | 45 |
| 48 | 9 | 15 | 14 | 32 | 10 | 47 |
| 1 | 43 | 34 | 30 | 21 | 42 | 4 |
| 61 | 3 | 2 | 64 | 57 | 7 | 6 | 60 |
| 12 | 54 | 55 | 9 | 16 | 50 | 51 | 13 |
| 20 | 46 | 47 | 17 | 24 | 42 | 43 | 21 |
| 37 | 27 | 26 | 40 | 33 | 31 | 30 | 36 |
| 29 | 35 | 34 | 32 | 25 | 39 | 38 | 28 |
| 44 | 22 | 23 | 41 | 48 | 18 | 19 | 45 |
| 52 | 14 | 15 | 49 | 56 | 10 | 11 | 53 |
| 5 | 59 | 58 | 8 | 1 | 63 | 62 | 4 |
| 31 | 76 | 13 | 36 | 81 | 18 | 29 | 74 | 11 |
| 22 | 40 | 58 | 27 | 45 | 63 | 20 | 38 | 56 |
| 67 | 4 | 49 | 72 | 9 | 54 | 65 | 2 | 47 |
| 30 | 75 | 12 | 32 | 77 | 14 | 34 | 79 | 16 |
| 21 | 39 | 57 | 23 | 41 | 59 | 25 | 43 | 61 |
| 66 | 3 | 48 | 68 | 5 | 50 | 70 | 7 | 52 |
| 35 | 80 | 17 | 28 | 73 | 10 | 33 | 78 | 15 |
| 26 | 44 | 62 | 19 | 37 | 55 | 24 | 42 | 60 |
| 71 | 8 | 53 | 64 | 1 | 46 | 69 | 6 | 51 |
The above magic squares of orders 3 to 9 are taken from Yang Hui's treatise, in which the Luo Shu principle is clearly evident. The order 5 square is a bordered magic square, with central 3×3 square formed according to Luo Shu principle. The order 9 square is a composite magic square, in which the nine 3×3 sub squares are also magic. After Yang Hui, magic squares frequently occur in Chinese mathematics such as in Ding Yidong's Dayan suoyin, Cheng Dawei's Suanfa tongzong, Fang Zhongtong's Shuduyan which contains magic circles, cubes and spheres, Zhang Chao's Xinzhai zazu, who published China's first magic square of order ten, and lastly Bao Qishou's Binaishanfang ji, who gave various three dimensional magic configurations. However, despite being the first to discover the magic squares and getting a head start by several centuries, the Chinese development of the magic squares are much inferior compared to the Indian, Middle Eastern, or European developments. The high point of Chinese mathematics that deals with the magic squares seems to be contained in the work of Yang Hui; but even as a collection of older methods, this work is much more primitive, lacking general methods for constructing magic squares of any order, compared to a similar collection written around the same time by the Byzantine scholar Manuel Moschopoulos. This is possibly because of the Chinese scholars' enthralment with the Lo Shu principle, which they tried to adapt to solve higher squares; and after Yang Hui and the fall of Yuan dynasty, their systematic purging of the foreign influences in Chinese mathematics.