In mathematics, especially historical and recreational mathematics, a magic square is a square array of numbers, usually positive integers, where the sums of the numbers in each row, each column, and both main diagonals are the same. The order of a magic square is the number of integers along one side (n), and the constant sum is called the magic constant or magic sum. 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 (sometimes called orthomagic 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 (also referred to as "doubly even") if n is a multiple of 4, oddly even (also known as "singly 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.
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 550 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 (Rasa'il Ikhwan al-Safa). 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.The most famous Arabic book on magic, named "Shams Al-ma'arif (), for Ahmed bin Ali Al-boni, who died about 1225 (622 AH). Reprinted in Beirut in 1985 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 (see the photograph of the work). 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.Veronica Simpson. (Sept. 14, 2016). The EY Exhibition: Wifredo Lam Studio International
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 (Bright Hall) of a 1st-century book Da Dai Liji (Record of Rites by the Elder Dai), which purported to describe ancient Chinese rites of the Zhou dynasty. These numbers also occur in a possibly earlier mathematical text called Shushu jiyi (Memoir on Some Traditions of Mathematical Art), 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 (Continuation of Ancient Mathematical Methods for Elucidating the Strange) 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 2031 4 36 9 29 2 12 21 14 23 16 25 30 3 5 32 34 717 26 10 19 15 24 8 35 28 1 6 33
46 8 16 20 29 7 493 40 35 36 18 41 244 12 33 23 19 38 6 28 26 11 25 39 24 225 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 3629 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 1122 40 58 27 45 63 20 38 5667 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 5235 80 17 28 73 10 33 78 1526 44 62 19 37 55 24 42 6071 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 (1593), Fang Zhongtong's Shuduyan (1661) 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.
Japan Japan and China have similar mathematical traditions and have repeatedly influenced each other in the history of magic squares.The Influence of Chinese Mathematical Arts on Seki Kowa by Shigeru Jochi, MA, School of Oriental and African Studies, University of London, 1993 The Japanese interest in magic squares began after the dissemination of Chinese works—Yang Hui's Suanfa and Cheng Dawei's Suanfa tongzong—in the 17th century, and as a result, almost all the wasans devoted their time to its study.
In the 1660 edition of Ketsugi-sho, Isomura Kittoku gave both odd and even ordered bordered magic squares as well as magic circles; while the 1684 edition of the same book contained a large section on magic squares, demonstrating that he had a general method for constructing bordered magic squares. In Jinko-ki (1665) by Muramatsu Kudayu Mosei, both magic squares and magic circles are displayed. The largest square Mosei constructs is of 19th order. Various magic squares and magic circles were also published by Nozawa Teicho in Dokai-sho (1666), Sato Seiko in Kongenki (1666), and Hosino Sanenobu in Ko-ko-gen Sho (1673). One of Seki Takakazu's Seven Books (Hojin Yensan) (1683) is devoted completely to magic squares and circles. This is the first Japanese book to give a general treatment of magic squares in which the algorithms for constructing odd, singly even and doubly even bordered magic squares are clearly described. In 1694 and 1695, Yueki Ando gave different methods to create the magic squares and displayed squares of order 3 to 30. A fourth-order magic cube was constructed by Yoshizane Tanaka (1651–1719) in Rakusho-kikan (1683). The study of magic squares was continued by Seki's pupils, notably by Katahiro Takebe, whose squares were displayed in the fourth volume of Ichigen Kappo by Shukei Irie, Yoshisuke Matsunaga in Hojin-Shin-jutsu, Yoshihiro Kurushima in Kyushi Iko who rediscovered a method to produce the odd squares given by Agrippa, and Naonobu Ajima. Thus by the beginning of the 18th century, the Japanese mathematicians were in possession of methods to construct magic squares of arbitrary order. After this, attempts at enumerating the magic squares was initiated by Nushizumi Yamaji.
India
The 3×3 magic square first appears in India in Gargasamhita by Garga, who recommends its use to pacify the nine planets (navagraha). The oldest version of this text dates from 100 CE, but the passage on planets could not have been written earlier than 400 CE. The first dateable instance of 3×3 magic square in India occur in a medical text Siddhayog () by Vrnda, which was prescribed to women in labor in order to have easy delivery.
The oldest dateable fourth order magic square in the world is found in an encyclopaedic work written by Varahamihira around 550 CE called Brhat Samhita. The magic square is constructed for the purpose of making perfumes using 4 substances selected from 16 different substances. Each cell of the square represents a particular ingredient, while the number in the cell represents the proportion of the associated ingredient, such that the mixture of any four combination of ingredients along the columns, rows, diagonals, and so on, gives the total volume of the mixture to be 18. Although the book is mostly about divination, the magic square is given as a matter of combinatorial design, and no magical properties are attributed to it. The special features of this magic square were commented on by Bhattotpala ()
2 3 5 8 5 8 2 3 4 1 7 6 7 6 4 1
10 3 13 8 5 16 2 11 4 9 7 14 15 6 12 1