Magic square
In recreational mathematics and combinatorial design, a magic square is a square grid filled with distinct positive integers in the range such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal. The sum is called the magic constant or magic sum of the magic square. A square grid with cells on each side is said to have order n.
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 method, 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. The magic squares are generally classified according to their order n as: odd if n is odd, evenly even if n = 4k, oddly even if n = 4k + 2. 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.
In regard to magic sum, the problem of magic squares only requires the sum of each row, column and diagonal to be equal, it does not require the sum to be a particular value. Thus, although magic squares may contain negative integers, they are just variations by adding or multiplying a negative number to every positive integer in the original square. Magic squares composed of integers are also called normal magic squares, in the sense that there are non-normal magic squares whose integers are not restricted to. However, in some places, "magic squares" is used as a general term to cover both the normal and non-normal ones, especially when non-normal ones are under discussion. Moreover, the term "magic squares" is sometimes also used to refer to various types of word squares.
Magic squares have a long history, dating back to at least 190 BCE in China. At various times they have acquired magical 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.
's Melancholia 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 datable instance of the fourth-order magic square occur 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 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.China and Japan
While ancient references to the pattern of even and odd numbers in the 3×3 magic square appears 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 on the systematic methods for constructing larger magic squares 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.
The Japanese interest in magic square began after the dissemination of Yang Hui's Suanfa and Cheng Dawei's Suanfa tongzong in the 17th century, and 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 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, Sato Seiko in Kongenki, and Hosino Sanenobu in Ko-ko-gen Sho. One of Seki Takakazu's Seven Books 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 in Rakusho-kikan. 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 Yamaji.
India
The 3×3 magic square first appears in India in Gargasamhita by Garga, who recommends its use to pacify the nine planets. The oldest version of this text dates from 100 CE; however passage on planets could not have been written earlier than 400 CE. The first datable 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 datable fourth order magic square in the world is found in an encyclopaedic work written by Varahamihira around 587 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.
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 |
The square of Varahamihira as given above has sum of 18. Here the numbers 1 to 8 appear twice in the square. It is a pan-diagonal magic square. It is also an instance of most perfect magic square. Four different magic squares can be obtained by adding 8 to one of the two sets of 1 to 8 sequence. The sequence is selected such that the number 8 is added exactly twice in each row, each column and each of the main diagonals. One of the possible magic squares shown in the right side. This magic square is remarkable in that it is a 90 degree rotation of a magic square that appears in the 13th century Islamic world as one of the most popular magic squares.
The construction of 4th-order magic square is detailed in a work titled Kaksaputa, composed by the alchemist Nagarjuna around 10th century CE. All of the squares given by Nagarjuna are 4×4 magic squares, and one of them is called Nagarjuniya after him. Nagarjuna gave a method of constructing 4×4 magic square using a primary skeleton square, given an odd or even magic sum. Incidentally, the special Nagarjuniya square cannot be constructed from the method he expounds. The Nagarjuniya square is given below, and has the sum total of 100.
30 | 16 | 18 | 36 |
10 | 44 | 22 | 24 |
32 | 14 | 20 | 34 |
28 | 26 | 40 | 6 |
7 | 1 | 4 | 6 |
2 | 8 | 5 | 3 |
5 | 3 | 2 | 8 |
4 | 6 | 7 | 1 |
The Nagarjuniya square is a pan-diagonal magic square. The Nagarjuniya square is made up of two arithmetic progressions starting from 6 and 16 with eight terms each, with a common difference between successive terms as 4. When these two progressions are reduced to the normal progression of 1 to 8, we obtain the adjacent square.
Around 12th-century, a 4×4 magic square was inscribed on the wall of Parshvanath temple in Khajuraho, India. Several Jain hymns teach how to make magic squares, although they are undatable.
As far as is known, the first systematic study of magic squares in India was conducted by Thakkar Pheru, a Jain scholar, in his Ganitasara Kaumudi. This work contains a small section on magic squares which consists of nine verses. Here he gives a square of order four, and alludes to its rearrangement; classifies magic squares into three according to its order; gives a square of order six; and prescribes one method each for constructing even and odd squares. For the even squares, Pheru divides the square into component squares of order four, and puts the numbers into cells according to the pattern of a standard square of order four. For odd squares, Pheru gives the method using horse move or knight's move. Although algorithmically different, it gives the same square as the De la Loubere's method.
The next comprehensive work on magic squares was taken up by Narayana Pandit, who in the fourteenth chapter of his Ganita Kaumudi gives general methods for their construction, along with the principles governing such constructions. It consists of 55 verses for rules and 17 verses for examples. Narayana gives a method to construct all the pan-magic squares of fourth order using knight's move; enumerates the number of pan-diagonal magic squares of order four, 384, including every variation made by rotation and reflection; three general methods for squares having any order and constant sum when a standard square of the same order is known; two methods each for constructing evenly even, oddly even, and odd squares when the sum is given. While Narayana describes one older method for each species of square, he claims the method of superposition for evenly even and odd squares and a method of interchange for oddly even squares to be his own invention. The superposition method was later re-discovered by De la Hire in Europe. In the last section, he conceives of other figures, such as circles, rectangles, and hexagons, in which the numbers may be arranged to possess properties similar to those of magic squares. Below are some of the magic squares constructed by Narayana:
8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |
1 | 14 | 4 | 15 |
8 | 11 | 5 | 10 |
13 | 2 | 16 | 3 |
12 | 7 | 9 | 6 |
16 | 14 | 7 | 30 | 23 |
24 | 17 | 10 | 8 | 31 |
32 | 25 | 18 | 11 | 4 |
5 | 28 | 26 | 19 | 12 |
13 | 6 | 29 | 22 | 20 |
1 | 35 | 4 | 33 | 32 | 6 |
25 | 11 | 9 | 28 | 8 | 30 |
24 | 14 | 18 | 16 | 17 | 22 |
13 | 23 | 19 | 21 | 20 | 15 |
12 | 26 | 27 | 10 | 29 | 7 |
36 | 2 | 34 | 3 | 5 | 31 |
35 | 26 | 17 | 1 | 62 | 53 | 44 |
46 | 37 | 21 | 12 | 3 | 64 | 55 |
57 | 41 | 32 | 23 | 14 | 5 | 66 |
61 | 52 | 43 | 34 | 25 | 16 | 7 |
2 | 63 | 54 | 45 | 36 | 27 | 11 |
13 | 4 | 65 | 56 | 47 | 31 | 22 |
24 | 15 | 6 | 67 | 51 | 42 | 33 |
60 | 53 | 44 | 37 | 4 | 13 | 20 | 29 |
3 | 14 | 19 | 30 | 59 | 54 | 43 | 38 |
58 | 55 | 42 | 39 | 2 | 15 | 18 | 31 |
1 | 16 | 17 | 32 | 57 | 56 | 41 | 40 |
61 | 52 | 45 | 36 | 5 | 12 | 21 | 28 |
6 | 11 | 22 | 27 | 62 | 51 | 46 | 35 |
63 | 50 | 47 | 34 | 7 | 10 | 23 | 26 |
8 | 9 | 24 | 25 | 64 | 49 | 48 | 33 |
The order 8 square is interesting in itself since it is an instance of the most-perfect magic square. Incidentally, Narayana states that the purpose of studying magic squares is to construct yantra, to destroy the ego of bad mathematicians, and for the pleasure of good mathematicians. The subject of magic squares is referred to as bhadraganita and Narayana states that it was first taught to men by god Shiva.
Middle East: Persia, Arabia, North Africa, Muslim Iberia
Although the early history of magic squares in Persia and Arabia is not known, it has been suggested that they were known in pre-Islamic times. It is clear, however, that the study of magic squares was common in medieval Islam, and it was thought to have begun after the introduction of chess into the region. The first datable appearance of magic square of order 3 occur in Jābir ibn Hayyān's Kitab al-mawazin al-Saghir where the magic square and its related numerology is associated with alchemy. While it is known that treatises on magic squares were written in the 9th century, the earliest extant treaties we have date from the 10th-century: one by Abu'l-Wafa al-Buzjani and another by Ali b. Ahmad al-Antaki. These early treatise were purely mathematical, and the Arabic designation for magic squares used is wafq al-a'dad, which translates as harmonious disposition of the numbers. By the end of 10th century, the two treatises by Buzjani and Antaki makes it clear that the Middle Eastern mathematicians had understood how to construct bordered squares of any order as well as simple magic squares of small orders which were used to make composite magic squares. A specimen of magic squares of orders 3 to 9 devised by Middle Eastern mathematicians appear in an encyclopedia from Baghdad, the Rasa'il Ikhwan al-Safa. The squares of order 3 to 7 from Rasa'il are given below:2 | 7 | 6 |
9 | 5 | 1 |
4 | 3 | 8 |
4 | 14 | 15 | 1 |
9 | 7 | 6 | 12 |
5 | 11 | 10 | 8 |
16 | 2 | 3 | 13 |
21 | 3 | 4 | 12 | 25 |
15 | 17 | 6 | 19 | 8 |
10 | 24 | 13 | 2 | 16 |
18 | 7 | 20 | 9 | 11 |
1 | 14 | 22 | 23 | 5 |
11 | 22 | 32 | 5 | 23 | 18 |
25 | 16 | 7 | 30 | 13 | 20 |
27 | 6 | 35 | 36 | 4 | 3 |
10 | 31 | 1 | 2 | 33 | 34 |
14 | 19 | 8 | 29 | 26 | 15 |
24 | 17 | 28 | 9 | 12 | 21 |
47 | 11 | 8 | 9 | 6 | 45 | 49 |
4 | 37 | 20 | 17 | 16 | 35 | 46 |
2 | 18 | 26 | 21 | 28 | 32 | 48 |
43 | 19 | 27 | 25 | 23 | 31 | 7 |
38 | 36 | 22 | 29 | 24 | 14 | 12 |
40 | 15 | 30 | 33 | 34 | 13 | 10 |
1 | 39 | 42 | 41 | 44 | 5 | 3 |
The 11th century saw the finding of several ways to construct simple magic squares for odd and evenly-even orders; the more difficult case of evenly-odd case was solved by Ibn al-Haytham with k even, and completely by the beginning of 12th century, if not already in the latter half of the 11th century. Around the same time, pandiagonal squares were being constructed. Treaties on magic squares were numerous in the 11th and 12th century. These later developments tended to be improvements on or simplifications of existing methods. From the 13th century on wards, magic squares were increasingly put to occult purposes. However, much of these later texts written for occult purposes merely depict certain magic squares and mention their attributes, without describing their principle of construction, with only some authors keeping the general theory alive. One such occultist was the Egyptian Ahmad al-Buni, who gave general methods on constructing bordered magic squares; some others were the 17th century Egyptian Shabramallisi and the 18th century Nigerian al-Kishnawi.
The magic square of order three was described as a child-bearing charm since its first literary appearances in the alchemical works of Jābir ibn Hayyān and al-Ghazālī and it was preserved in the tradition of the planetary tables. The earliest occurrence of the association of seven magic squares to the virtues of the seven heavenly bodies appear in Andalusian scholar Ibn Zarkali's Kitāb tadbīrāt al-kawākib. A century later, the Egyptian scholar Ahmad al-Buni attributed mystical properties to magic squares in his highly influential book Shams al-Ma'arif, which also describes their construction. This tradition about a series of magic squares from order three to nine, which are associated with the seven planets, survives in Greek, Arabic, and Latin versions. There are also references to the use of magic squares in astrological calculations, a practice that seems to have originated with the Arabs.
Latin Europe
Unlike in Persia and Arabia, we have better documentation of how the magic squares were transmitted to Europe. Around 1315, influenced by Arab sources, the Greek Byzantine scholar Manuel Moschopoulos wrote a mathematical treatise on the subject of magic squares, leaving out the mysticism of his Middle Eastern predecessors, where he gave two methods for odd squares and two methods for evenly even squares. Moschopoulos was essentially unknown to the Latin Europe until the late 17th century, when Philippe de la Hire rediscovered his treatise in the Royal Library of Paris. However, he was not the first European to have written on magic squares; and the magic squares were disseminated to rest of Europe through Spain and Italy as occult objects. The early occult treaties that displayed the squares did not describe how they were constructed. Thus the entire theory had to be rediscovered.Magic squares had first appeared in Europe in Kitāb tadbīrāt al-kawākib written by Ibn Zarkali of Toledo, Al-Andalus, as planetary squares by 11th century. The magic square of three was discussed in numerological manner in early 12th century by Jewish scholar Abraham ibn Ezra of Toledo, which influenced later Kabbalists. Ibn Zarkali's work was translated as Libro de Astromagia in the 1280s, due to Alfonso X of Castille. In the Alfonsine text, magic squares of different orders are assigned to the respective planets, as in the Islamic literature; unfortunately, of all the squares discussed, the Mars magic square of order five is the only square exhibited in the manuscript.
Magic squares surface again in Florence, Italy in the 14th century. A 6×6 and a 9×9 square are exhibited in a manuscript of the Trattato d'Abbaco by Paolo Dagomari. It is interesting to observe that Paolo Dagomari, like Pacioli after him, refers to the squares as a useful basis for inventing mathematical questions and games, and does not mention any magical use. Incidentally, though, he also refers to them as being respectively the Sun's and the Moon's squares, and mentions that they enter astrological calculations that are not better specified. As said, the same point of view seems to motivate the fellow Florentine Luca Pacioli, who describes 3×3 to 9×9 squares in his work De Viribus Quantitatis by the end of 15th century.
Europe after 15th century
The planetary squares had disseminated into northern Europe by the end of 15th century. For instance, the Cracow manuscript of Picatrix from Poland displays magic squares of orders 3 to 9. The same set of squares as in the Cracow manuscript later appears in the writings of Paracelsus in Archidoxa Magica, although in highly garbled form. In 1514 Albrecht Dürer immortalized a 4×4 square in his famous engraving Melencolia I. Paracelsus' contemporary Heinrich Cornelius Agrippa von Nettesheim published his famous three volume book De occulta philosophia in 1531, where he devoted Chapter 22 of Book II to the planetary squares shown below. The same set of squares given by Agrippa reappear in 1539 in Practica Arithmetice by Girolamo Cardano. The tradition of planetary squares was continued into the 17th century by Athanasius Kircher in Oedipi Aegyptici. In Germany, mathematical treaties concerning magic squares were written in 1544 by Michael Stifel in Arithmetica Integra, who rediscovered the bordered squares, and Adam Riese, who rediscovered the continuous numbering method to construct odd ordered squares published by Agrippa. However, due to the religious upheavals of that time, these work were unknown to the rest of Europe.4 | 9 | 2 |
3 | 5 | 7 |
8 | 1 | 6 |
4 | 14 | 15 | 1 |
9 | 7 | 6 | 12 |
5 | 11 | 10 | 8 |
16 | 2 | 3 | 13 |
11 | 24 | 7 | 20 | 3 |
4 | 12 | 25 | 8 | 16 |
17 | 5 | 13 | 21 | 9 |
10 | 18 | 1 | 14 | 22 |
23 | 6 | 19 | 2 | 15 |
6 | 32 | 3 | 34 | 35 | 1 |
7 | 11 | 27 | 28 | 8 | 30 |
19 | 14 | 16 | 15 | 23 | 24 |
18 | 20 | 22 | 21 | 17 | 13 |
25 | 29 | 10 | 9 | 26 | 12 |
36 | 5 | 33 | 4 | 2 | 31 |
22 | 47 | 16 | 41 | 10 | 35 | 4 |
5 | 23 | 48 | 17 | 42 | 11 | 29 |
30 | 6 | 24 | 49 | 18 | 36 | 12 |
13 | 31 | 7 | 25 | 43 | 19 | 37 |
38 | 14 | 32 | 1 | 26 | 44 | 20 |
21 | 39 | 8 | 33 | 2 | 27 | 45 |
46 | 15 | 40 | 9 | 34 | 3 | 28 |
8 | 58 | 59 | 5 | 4 | 62 | 63 | 1 |
49 | 15 | 14 | 52 | 53 | 11 | 10 | 56 |
41 | 23 | 22 | 44 | 45 | 19 | 18 | 48 |
32 | 34 | 35 | 29 | 28 | 38 | 39 | 25 |
40 | 26 | 27 | 37 | 36 | 30 | 31 | 33 |
17 | 47 | 46 | 20 | 21 | 43 | 42 | 24 |
9 | 55 | 54 | 12 | 13 | 51 | 50 | 16 |
64 | 2 | 3 | 61 | 60 | 6 | 7 | 57 |
37 | 78 | 29 | 70 | 21 | 62 | 13 | 54 | 5 |
6 | 38 | 79 | 30 | 71 | 22 | 63 | 14 | 46 |
47 | 7 | 39 | 80 | 31 | 72 | 23 | 55 | 15 |
16 | 48 | 8 | 40 | 81 | 32 | 64 | 24 | 56 |
57 | 17 | 49 | 9 | 41 | 73 | 33 | 65 | 25 |
26 | 58 | 18 | 50 | 1 | 42 | 74 | 34 | 66 |
67 | 27 | 59 | 10 | 51 | 2 | 43 | 75 | 35 |
36 | 68 | 19 | 60 | 11 | 52 | 3 | 44 | 76 |
77 | 28 | 69 | 20 | 61 | 12 | 53 | 4 | 45 |
In 1624 France, Claude Gaspard Bachet described the "diamond method" for constructing Agrippa's odd ordered squares in his book Problèmes Plaisants. Blaise Pascal, Bernard Frenicle de Bessy and Pierre Fermat are also known to have constructed concentric bordered magic squares, while an early account of their method was given by Antoine Arnauld in his Nouveaux éléments de géométrie. In the two treatise Des quarrez magiques and Table générale des quarrez magiques de quatre de côté, published posthumously in 1693, twenty years after his death, Bernard Frenicle de Bessy demonstrated that there were exactly 880 distinct magic squares of order four and also gave methods to find magic squares of any even order. In 1691, Simon de la Loubère described the Indian continuous method of constructing odd ordered magic squares in his book Du Royaume de Siam, which he had learned while returning from a diplomatic mission to Siam, which was faster than Bachet's method. In an attempt to explain its working, de la Loubere used the primary numbers and root numbers, and rediscovered the method of adding two preliminary squares. This method was further investigated by Abbe Poignard in Traité des quarrés sublimes, by Philippe de La Hire in Mémoires de l’Académie des Sciences for the Royal Academy, and by Joseph Sauveur in Construction des quarrés magiques. Concentric bordered squares were also studied by De la Hire in 1705, while Sauveur introduced magic cubes and lettered squares, which was taken up later by Euler in 1776, who is often credited for devising them. In 1750 d'Ons-le-Bray rediscovered the method of constructing doubly even and singly even squares using bordering technique; while in 1767 Benjamin Franklin published a semi-magic square which had the properties of eponymous Franklin square. By this time the earlier mysticism attached to the magic squares had completely vanished, and the subject was treated as a part of recreational mathematics.
In the 19th century, Bernard Violle gave a comprehensive treatment of magic squares in his three volume Traité complet des carrés magiques, which also described magic cubes, parallelograms, parallelopipeds, and circles. Pandiagonal squares were extensively studied by Andrew Hollingworth Frost, who learned it while in the town of Nasik, India, in a series of articles: On the knight's path, On the General Properties of Nasik Squares, On the General Properties of Nasik Cubes, On the construction of Nasik Squares of any order. He showed that it is impossible to have normal singly-even pandiagonal magic square. Frederick A.P. Barnard constructed inlaid magic squares and other three dimensional magic figures like magic spheres and magic cylinders in Theory of magic squares and of magic cubes. In 1897, Emroy McClintock published On the most perfect form of magic squares, coining the words pandiagonal square and most perfect square, which had previously been referred to as perfect, or diabolic, or Nasik.
Some famous magic squares
Luo Shu magic square
Legends dating from as early as 650 BCE tell the story of the Lo Shu or "scroll of the river Lo". According to the legend, there was at one time in ancient China a huge flood. While the great king Yu was trying to channel the water out to sea, a turtle emerged from it with a curious pattern on its shell: a 3×3 grid in which circular dots of numbers were arranged, such that the sum of the numbers in each row, column and diagonal was the same: 15. According to the legend, thereafter people were able to use this pattern in a certain way to control the river and protect themselves from floods. The Lo Shu Square, as the magic square on the turtle shell is called, is the unique normal magic square of order three in which 1 is at the bottom and 2 is in the upper right corner. Every normal magic square of order three is obtained from the Lo Shu by rotation or reflection.Magic square in Parshavnath temple
There is a well-known 12th-century 4×4 magic square inscribed on the wall of the Parshvanath temple in Khajuraho, India.7 | 12 | 1 | 14 |
2 | 13 | 8 | 11 |
16 | 3 | 10 | 5 |
9 | 6 | 15 | 4 |
This is known as the Chautisa Yantra since its magic sum is 34. It is one of the three 4×4 pandiagonal magic squares and is also an instance of the most-perfect magic square. The study of this square led to the appreciation of pandiagonal squares by European mathematicians in the late 19th century. Pandiagonal squares were referred to as Nasik squares or Jain squares in older English literature.
Albrecht Dürer's magic square
The order four magic square Albrecht Dürer immortalized in his 1514 engraving Melencolia I, referred to above, is believed to be the first seen in European art. The square associated with Jupiter appears as a talisman used to drive away melancholy. It is very similar to Yang Hui's square, which was created in China about 250 years before Dürer's time. The sum 34 can be found in the rows, columns, diagonals, each of the quadrants, the center four squares, and the corner squares. This sum can also be found in the four outer numbers clockwise from the corners and likewise the four counter-clockwise, the two sets of four symmetrical numbers, the sum of the middle two entries of the two outer columns and rows, and in four kite or cross shaped quartets. The two numbers in the middle of the bottom row give the date of the engraving: 1514. The numbers 1 and 4 at either side of the date correspond respectively to the letters "A" and "D," which are the initials of the artist.16 | 3 | 2 | 13 |
5 | 10 | 11 | 8 |
9 | 6 | 7 | 12 |
4 | 15 | 14 | 1 |
Dürer's magic square can also be extended to a magic cube.
Sagrada Família magic square
The Passion façade of the Sagrada Família church in Barcelona, conceptualized by Antoni Gaudí and designed by sculptor Josep Subirachs, features a 4×4 magic square: The magic constant of the square is 33, the age of Jesus at the time of the Passion. Structurally, it is very similar to the Melancholia magic square, but it has had the numbers in four of the cells reduced by 1.1 | 14 | 14 | 4 |
11 | 7 | 6 | 9 |
8 | 10 | 10 | 5 |
13 | 2 | 3 | 15 |
While having the same pattern of summation, this is not a normal magic square because two numbers are duplicated and two are absent, failing the rule that an n x n magic square must contain each of the positive integers 1 through n 2. Such squares are not generally mathematically interesting and may be described, in a slightly deprecative sense, as trivial. Lee Sallows has pointed out that, due to Subirachs's ignorance of magic square theory, the renowned sculptor made a needless blunder, and supports this assertion by giving several examples of non-trivial 4 x 4 magic squares showing the desired magic constant of 33.
Similarly to Dürer's magic square, the Sagrada Familia's magic square can also be extended to a magic cube.
Parker's magic square
Parker's square is an attempt to create the 3x3 magic square of squares. Parker's Square is not a magic square: it uses some numbers more than once, and the diagonal -- sums to, not as for all the other rows, columns, or diagonal. Parker's Square became a "mascot for people who give it a go, but ultimately fall short". It is also a metaphor for something that is almost right, but is a little off.Properties of magic squares
Magic constant
The constant that is the sum of any row, or column, or diagonal is called the magic constant or magic sum, M. Every normal magic square has a constant dependent on the order, calculated by the formula. This can be demonstrated by noting that the sum of is. Since the sum of each row is, the sum of rows is, which when divided by the order yields the magic constant. For normal magic squares of orders n = 3, 4, 5, 6, 7, and 8, the magic constants are, respectively: 15, 34, 65, 111, 175, and 260.For example, a normal 6x6 square will always equate to 111 for each row, column, or diagonal.
Magic square of order 1 is trivial
The 1×1 magic square, with only one cell containing the number 1, is called trivial, because it is typically not under consideration when discussing magic squares; but it is indeed a magic square by definition, if we regard a single cell as a square of order one.Magic square of order 2 cannot be constructed
Normal magic squares of all sizes can be constructed except 2×2.Number of magic squares of a given order
Excluding rotations and reflections, there is exactly one 3×3 magic square, there are exactly 880 4×4 magic squares, and there are exactly 275,305,224 5×5 magic squares. For the 6×6 case, there are estimated to be approximately 1.8 × 1019 squares.Center of mass
If we think of the numbers in the magic square as masses located in various cells, then the center of mass of a magic square coincides with its geometric center.Moment of inertia
The moment of inertia of a magic square has been defined as the sum over all cells of the number in the cell times the squared distance from the center of the cell to the center of the square; here the unit of measurement is the width of one cell. Then all magic squares of a given order have the same moment of inertia as each other. For the order-3 case the moment of inertia is always 60, while for the order-4 case the moment of inertia is always 340. In general, for the n×n case the moment of inertia isBirkhoff–von Neumann decomposition
Dividing each number of the magic square by the magic constant will yield a doubly stochastic matrix, whose row sums and column sums equal to unity. However, unlike the doubly stochastic matrix, the diagonal sums of such matrices will also equal to unity. Thus, such matrices constitute a subset of doubly stochastic matrix. The Birkhoff–von Neumann theorem states that for any doubly stochastic matrix, there exists real numbers, where and permutation matrices such thatThis representation may not be unique in general. By Marcus-Ree theorem, however, there need not be more than terms in any decomposition. Clearly, this decomposition carries over to magic squares as well, since we can recover a magic square from a doubly stochastic matrix by multiplying it by the magic constant.
Classification of magic squares
While the classification of magic squares can be done in many ways, some useful categories are given below. An n×n square array of integers 1, 2,..., n2 is called:- Semi-magic square when its rows and columns sum to give the magic constant.
- Simple magic square when its rows, columns, and two diagonals sum to give magic constant and no more. They are also known as ordinary magic squares or normal magic squares.
- Self-complementary magic square when it is a magic square which when complemented will give a rotated or reflected version of the original magic square.
- Associative magic square when it is a magic square with a further property that every number added to the number equidistant, in a straight line, from the center gives n2 + 1. They are also called symmetric magic squares. Associated magic squares do not exist for squares of singly even order. All associated magic square are self-complementary magic squares as well.
- Pandiagonal magic square when it is a magic square with a further property that the broken diagonals sum to the magic constant. They are also called panmagic squares, perfect squares, diabolic squares, Jain squares, or Nasik squares. Panmagic squares do not exist for singly even orders. However, singly even non-normal squares can be panmagic.
- Ultra magic square when it is both associative and pandiagonal magic square. Ultra magic square exist only for orders n ≥ 5.
- Bordered magic square when it is a magic square and it remains magic when the rows and columns at the outer edge is removed. They are also called concentric bordered magic squares if removing a border of a square successively gives another smaller bordered magic square. Bordered magic square do not exist for order 4.
- Composite magic square when it is a magic square that is created by "multiplying" smaller magic squares. Such squares can usually be partitioned into smaller non-overlapping magic sub-squares.
- Inlaid magic square when it is a magic square inside which a magic sub-square is embedded, regardless of construction technique. The embedded magic sub-squares are themselves referred to as inlays.
- Most-perfect magic square when it is a pandiagonal magic square with two further properties each 2×2 subsquare add to 1/k of the magic constant where n = 4k, and all pairs of integers distant n/2 along any diagonal are complementary. The first property is referred to as compactness, while the second property is referred to as completeness. Most perfect magic squares exist only for squares of doubly even order. All the pandiagonal squares of order 4 are also most perfect.
- Franklin magic square when it is a doubly even magic square with three further properties every bent diagonal adds to the magic constant, every half row and half column starting at an outside edge adds to half the magic constant, and the square is compact.
- Multimagic square when it is a magic square that remains magic even if all its numbers are replaced by their k-th power for 1 ≤ k ≤ P. They are also known as P-multimagic square or satanic squares. They are also referred to as bimagic squares, trimagic squares, tetramagic squares, pentamagic squares when the value of P is 2, 3, 4, and 5 respectively.
Transformations that preserve the magic property
For any magic square
- A magic square remains magic when its numbers are multiplied by any constant.
- A magic square remains magic when a constant is added or subtracted to its numbers, or if its numbers are subtracted from a constant. In particular, if every element in a normal magic square is subtracted from n2 + 1, we obtain the complement of the original square. In the example below, elements of 4×4 square on the left is subtracted from 17 to obtain the complement of the square on the right.
10 | 3 | 13 | 8 |
5 | 16 | 2 | 11 |
4 | 9 | 7 | 14 |
15 | 6 | 12 | 1 |
7 | 14 | 4 | 9 |
12 | 1 | 15 | 6 |
13 | 8 | 10 | 3 |
2 | 11 | 5 | 16 |
- Any magic square can be rotated and reflected to produce 8 trivially distinct squares. In magic square theory, all of these are generally deemed equivalent and the eight such squares are said to make up a single equivalence class. In discussing magic squares, equivalent squares are usually not considered as distinct. The 8 equivalent squares is given for the 3×3 magic square below:
8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |
6 | 1 | 8 |
7 | 5 | 3 |
2 | 9 | 4 |
2 | 7 | 6 |
9 | 5 | 1 |
4 | 3 | 8 |
4 | 3 | 8 |
9 | 5 | 1 |
2 | 7 | 6 |
2 | 9 | 4 |
7 | 5 | 3 |
6 | 1 | 8 |
4 | 9 | 2 |
3 | 5 | 7 |
8 | 1 | 6 |
8 | 3 | 4 |
1 | 5 | 9 |
6 | 7 | 2 |
6 | 7 | 2 |
1 | 5 | 9 |
8 | 3 | 4 |
- Given any magic square, another magic square of the same order can be formed by interchanging the row and the column which intersect in a cell on a diagonal with the row and the column which intersect in the complementary cell of the same diagonal. For an even square, there are n/2 pairs of rows and columns that can be interchanged; thus we can obtain 2n/2 equivalent magic squares by combining such interchanges. For odd square, there are /2 pairs of rows and columns that can be interchanged; and 2/2 equivalent magic squares obtained by combining such interchanges. Interchanging all the rows and columns rotates the square by 180 degree. In the example using a 4×4 magic square, the left square is the original square, while the right square is the new square obtained by interchanging the 1st and 4th rows and columns.
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
16 | 3 | 2 | 13 |
9 | 6 | 7 | 12 |
5 | 10 | 11 | 8 |
4 | 15 | 14 | 1 |
- Given any magic square, another magic square of the same order can be formed by interchanging two rows on one side of the center line, and then interchanging the corresponding two rows on the other side of the center line; then interchanging like columns. For an even square, since there are n/2 same sided rows and columns, there are n/8 pairs of such rows and columns that can be interchanged. Thus we can obtain 2n/8 equivalent magic squares by combining such interchanges. For odd square, since there are /2 same sided rows and columns, there are /8 pairs of such rows and columns that can be interchanged. Thus, there are 2/8 equivalent magic squares obtained by combining such interchanges. Interchanging every possible pairs of rows and columns rotates each quadrant of the square by 180 degree. In the example using a 4×4 magic square, the left square is the original square, while the right square is the new square obtained by this transformation. In the middle square, row 1 has been interchanged with row 2; and row 3 and 4 has been interchanged. The final square on the right is obtained by interchanging columns 1 and 2, and columns 3 and 4 of the middle square. In this particular example, this transform amounts to rotating the quadrants by 180 degree. The middle square is also a magic square, since the original square is an associative magic square.
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
12 | 6 | 7 | 9 |
1 | 15 | 14 | 4 |
13 | 3 | 2 | 16 |
8 | 10 | 11 | 5 |
6 | 12 | 9 | 7 |
15 | 1 | 4 | 14 |
3 | 13 | 16 | 2 |
10 | 8 | 5 | 11 |
- A magic square remains magic when any of its non-central rows x and y are interchanged, along with the interchange of their complementary rows n - x + 1 and n - y + 1; and then interchanging like columns. This is a generalization of the above two transforms. When y = n - x + 1, this transform reduces to the first of the above two transforms. When x and y are on the same side of the center line, this transform reduces to the second of the above two transforms. In the example below, the original square is on the left side, while the final square on the right. The middle square has been obtained by interchanging rows 1 and 3, and rows 2 and 4 of the original square. The final square on the right is obtained by interchanging columns 1 and 3, and columns 2 and 4 of the middle square. In this example, this transform amounts to interchanging the quadrants diagonally. Since the original square is associative, the middle square also happens to be magic.
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
11 | 5 | 8 | 10 |
2 | 16 | 13 | 3 |
14 | 4 | 1 | 15 |
7 | 9 | 12 | 6 |
- A magic square remains magic when its quadrants are diagonally interchanged. This is exact for even ordered squares. For odd ordered square, the halves of the central row and central column also needs to be interchanged. Examples for even and odd squares are given below:
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
11 | 5 | 8 | 10 |
2 | 16 | 13 | 3 |
14 | 4 | 1 | 15 |
7 | 9 | 12 | 6 |
17 | 24 | 1 | 8 | 15 |
23 | 5 | 7 | 14 | 16 |
4 | 6 | 13 | 20 | 22 |
10 | 12 | 19 | 21 | 3 |
11 | 18 | 25 | 2 | 9 |
21 | 3 | 19 | 10 | 12 |
2 | 9 | 25 | 11 | 18 |
20 | 22 | 13 | 4 | 6 |
8 | 15 | 1 | 17 | 24 |
14 | 16 | 7 | 23 | 5 |
For associative magic squares
- An associative magic square remains associative when two rows or columns equidistant from the center are interchanged. For an even square, there are n/2 pairs of rows or columns that can be interchanged; thus we can obtain 2n/2 × 2n/2 = 2n equivalent magic squares by combining such interchanges. For odd square, there are /2 pairs of rows or columns that can be interchanged; and 2n-1 equivalent magic squares obtained by combining such interchanges. Interchanging all the rows flips the square vertically, while interchanging all the columns flips the square horizontally. In the example below, a 4×4 associative magic square on the left is transformed into a square on the right by interchanging the second and third row, yielding the famous Durer's magic square.
16 | 3 | 2 | 13 |
9 | 6 | 7 | 12 |
5 | 10 | 11 | 8 |
4 | 15 | 14 | 1 |
16 | 3 | 2 | 13 |
5 | 10 | 11 | 8 |
9 | 6 | 7 | 12 |
4 | 15 | 14 | 1 |
- An associative magic square remains associative when two same sided rows are interchanged along with corresponding other sided rows. For an even square, since there are n/2 same sided rows, there are n/8 pairs of such rows that can be interchanged. Thus, we can obtain 2n/8 × 2n/8 = 2n/4 equivalent magic squares by combining such interchanges. For odd square, since there are /2 same sided rows or columns, there are /8 pairs of such rows or columns that can be interchanged. Thus, there are 2/8 × 2/8 = 2/4 equivalent magic squares obtained by combining such interchanges. Interchanging all the same sided rows flips each quadrants of the square vertically, while interchanging all the same sided columns flips each quadrant of the square horizontally. In the example below, the original square is on the left, whose rows 1 and 2 are interchanged with each other, along with rows 3 and 4, to obtain the transformed square on the right.
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
12 | 6 | 7 | 9 |
1 | 15 | 14 | 4 |
13 | 3 | 2 | 16 |
8 | 10 | 11 | 5 |
For pan-diagonal magic squares
- A pan-diagonal magic square remains a pan-diagonal magic square under cyclic shifting of rows or of columns or both. This allows us to position a given number in any one of the n2 cells of an n order square. Thus, for a given pan-magic square, there are n2 equivalent pan-magic squares. In the example below, the original square on the left is transformed by shifting the first row to the bottom to obtain a new pan-magic square in the middle. Next, the 1st and 2nd column of the middle pan-magic square is circularly shifted to the right to obtain a new pan-magic square on the right.
10 | 3 | 13 | 8 |
5 | 16 | 2 | 11 |
4 | 9 | 7 | 14 |
15 | 6 | 12 | 1 |
5 | 16 | 2 | 11 |
4 | 9 | 7 | 14 |
15 | 6 | 12 | 1 |
10 | 3 | 13 | 8 |
2 | 11 | 5 | 16 |
7 | 14 | 4 | 9 |
12 | 1 | 15 | 6 |
13 | 8 | 10 | 3 |
For bordered magic squares
- A bordered magic square remains a bordered magic square after permuting the border cells in the rows or columns, together with their corresponding complementary terms, keeping the corner cells fixed. Since the cells in each row and column of every concentric border can be permuted independently, when the order n ≥ 5 is odd, there are ! × 2 equivalent bordered squares. When n ≥ 6 is even, there are ! × 2 equivalent bordered squares. In the example below, a square of order 5 is given whose border row has been permuted. We can obtain 2 = 36 such equivalent squares.
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 |
1 | 16 | 23 | 4 | 21 |
15 | 14 | 7 | 18 | 11 |
24 | 17 | 13 | 9 | 2 |
20 | 8 | 19 | 12 | 6 |
5 | 10 | 3 | 22 | 25 |
- A bordered magic square remains a bordered magic square after each of its concentric borders are independently rotated or reflected with respect to the central core magic square. If there are b borders, then this transform will yield 8b equivalent squares. In the example below of the 5×5 magic square, the border has been rotated 90 degrees anti-clockwise.
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 |
21 | 11 | 2 | 6 | 25 |
4 | 14 | 7 | 18 | 22 |
16 | 17 | 13 | 9 | 10 |
23 | 8 | 19 | 12 | 3 |
1 | 15 | 24 | 20 | 5 |
For composite magic squares
- A composite magic square remains a composite magic square when the embedded magic squares undergo transformations that do not disturb the magic property.
Specific methods of 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 according to their order: odd, doubly even and singly even. Odd and doubly even magic squares are easy to generate; the construction of singly even magic squares is more difficult but several methods exist, including the LUX method for magic squares and the Strachey method for magic squares.
Group theory was also used for constructing new magic squares of a given order from one of them.
The numbers of different n×n magic squares for n from 1 to 5, not counting rotations and reflections are: 1, 0, 1, 880, 275305224. The number for n = 6 has been estimated to be
Cross-referenced to the above sequence, a new classification enumerates the magic tori that display these magic squares. The numbers of magic tori of order n from 1 to 5, are: 1, 0, 1, 255, 251449712.
Method for constructing a magic square of order 3
In the 19th century, Édouard Lucas devised the general formula for order 3 magic squares. Consider the following table made up of positive integers a, b and c:c − b | c + | c − a |
c − | c | c + |
c + a | c − | c + b |
These nine numbers will be distinct positive integers forming a magic square so long as 0 < a < b < c − a and b ≠ 2a. Moreover, every 3×3 square of distinct positive integers is of this form.
In 1997 Lee Sallows discovered that leaving aside rotations and reflections, then every distinct parallelogram drawn on the Argand diagram defines a unique 3×3 magic square, and vice versa, a result that had never previously been noted.
A method for constructing a magic square of odd order
A method for constructing magic squares of odd order was published by the French diplomat de la Loubère in his book, A new historical relation of the kingdom of Siam, in the chapter entitled The problem of the magical square according to the Indians. The method operates as follows:The method prescribes starting in the central column of the first row with the number 1. After that, the fundamental movement for filling the squares is diagonally up and right, one step at a time. If a filled square is encountered, one moves vertically down one square instead, then continues as before. When an "up and to the right" move would leave the square, it is wrapped around to the last row or first column, respectively.
1 | ||
1 | ||
2 |
1 | ||
3 | ||
2 |
1 | ||
3 | ||
4 | 2 |
1 | ||
3 | 5 | |
4 | 2 |
1 | 6 | |
3 | 5 | |
4 | 2 |
1 | 6 | |
3 | 5 | 7 |
4 | 2 |
8 | 1 | 6 |
3 | 5 | 7 |
4 | 2 |
8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |
Starting from other squares rather than the central column of the first row is possible, but then only the row and column sums will be identical and result in a magic sum, whereas the diagonal sums will differ. The result will thus be a semimagic square and not a true magic square. Moving in directions other than north east can also result in magic squares.
8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |
17 | 24 | 1 | 8 | 15 |
23 | 5 | 7 | 14 | 16 |
4 | 6 | 13 | 20 | 22 |
10 | 12 | 19 | 21 | 3 |
11 | 18 | 25 | 2 | 9 |
47 | 58 | 69 | 80 | 1 | 12 | 23 | 34 | 45 |
57 | 68 | 79 | 9 | 11 | 22 | 33 | 44 | 46 |
67 | 78 | 8 | 10 | 21 | 32 | 43 | 54 | 56 |
77 | 7 | 18 | 20 | 31 | 42 | 53 | 55 | 66 |
6 | 17 | 19 | 30 | 41 | 52 | 63 | 65 | 76 |
16 | 27 | 29 | 40 | 51 | 62 | 64 | 75 | 5 |
26 | 28 | 39 | 50 | 61 | 72 | 74 | 4 | 15 |
36 | 38 | 49 | 60 | 71 | 73 | 3 | 14 | 25 |
37 | 48 | 59 | 70 | 81 | 2 | 13 | 24 | 35 |
A method of constructing a magic square of doubly even order
means that n is an even multiple of an even integer; or 4p, where p is an integer.Generic pattern
All the numbers are written in order from left to right across each row in turn, starting from the top left 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.
A construction of a magic square of order 4
Starting from top left, go left to right through each row of the square, counting each cell from 1 to 16 and filling the cells along the diagonals with its corresponding number. Once the bottom right cell is reached, continue by going right to left, starting from the bottom right of the table through each row, and fill in the non-diagonal cells counting up from 1 to 16 with its corresponding number. As shown below:
1 | 4 | ||
6 | 7 | ||
10 | 11 | ||
13 | 16 |
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
An extension of the above example for Orders 8 and 12
First generate a pattern table, where a '1' indicates selecting from the square where the numbers are written in order 1 to n2, and a '0' indicates selecting from the square where the numbers are written in reverse order n2 to 1. For M = 4, the pattern table is as shown below. When we shade the unaltered cells, we get a criss-cross pattern.
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 |
16 | 15 | 14 | 13 |
12 | 11 | 10 | 9 |
8 | 7 | 6 | 5 |
4 | 3 | 2 | 1 |
1 | 0 | 0 | 1 |
0 | 1 | 1 | 0 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 |
1 | 15 | 14 | 4 |
12 | 6 | 7 | 9 |
8 | 10 | 11 | 5 |
13 | 3 | 2 | 16 |
The patterns are a) there are equal number of '1's and '0's in each row and column; b) each row and each column are "palindromic"; c) the left- and right-halves are mirror images; and d) the top- and bottom-halves are mirror images. The pattern table can be denoted using hexadecimals as for simplicity. The simplest method of generating the required pattern for higher ordered doubly even squares is to copy the generic pattern for the fourth-order square in each four-by-four sub-squares.
For M = 8, possible choices for the pattern are ; ; .
1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 |
0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 |
0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
1 | 4 | 5 | 8 | ||||
10 | 11 | 14 | 15 | ||||
18 | 19 | 22 | 23 | ||||
25 | 28 | 29 | 32 | ||||
33 | 36 | 37 | 40 | ||||
42 | 43 | 46 | 47 | ||||
50 | 51 | 54 | 55 | ||||
57 | 60 | 61 | 64 |
1 | 63 | 62 | 4 | 5 | 59 | 58 | 8 |
56 | 10 | 11 | 53 | 52 | 14 | 15 | 49 |
48 | 18 | 19 | 45 | 44 | 22 | 23 | 41 |
25 | 39 | 38 | 28 | 29 | 35 | 34 | 32 |
33 | 31 | 30 | 36 | 37 | 27 | 26 | 40 |
24 | 42 | 43 | 21 | 20 | 46 | 47 | 17 |
16 | 50 | 51 | 13 | 12 | 54 | 55 | 9 |
57 | 7 | 6 | 60 | 61 | 3 | 2 | 64 |
For M = 12, the pattern table yields a magic square It is possible to count the number of choices one has based on the pattern table, taking rotational symmetries into account.
Method of superposition
The earliest discovery of the superposition method was made by the Indian mathematician Narayana in the 14th century. The same method was later re-discovered and studied in early 18th century Europe by de la Loubere, Poignard, de La Hire, and Sauveur; and the method is usually referred to as de la Hire's method. Although Euler's work on magic square was unoriginal, he famously conjectured the impossibility of constructing the evenly odd ordered mutually orthogonal Graeco-Latin squares. This conjecture was disproved in the mid 20th century. For clarity of exposition, we have distinguished two important variations of this method.Euler's method
This method consists in constructing two preliminary squares, which when added together gives the magic square. As a running example, we will consider a 3×3 magic square. We can uniquely label each number of the 3×3 natural square by a pair of numbers as1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
αa | αb | αc |
βa | βb | βc |
γa | γb | γc |
where every pair of Greek and Latin alphabets, e.g. αa, are meant to be added together, i.e. αa = α + a. Here, = and =. The numbers 0, 3, and 6 are referred to as the root numbers while the numbers 1, 2, and 3 are referred to as the primary numbers. An important general constraint here is
- a Greek letter is paired with a Latin letter only once.
α | α | α |
β | β | β |
γ | γ | γ |
a | b | c |
a | b | c |
a | b | c |
The lettered squares are referred to as Greek square or Latin square if they are filled with Greek or Latin letters, respectively. A magic square can be constructed by ensuring that the Greek and Latin squares are magic squares too. The converse of this statement is also often, but not always, true: A magic square can be decomposed into a Greek and a Latin square, which are themselves magic squares. Thus the method is useful for both synthesis as well as analysis of a magic square. Lastly, by examining the pattern in which the numbers are laid out in the finished square, it is often possible to come up with a faster algorithm to construct higher order squares that replicate the given pattern, without the necessity of creating the preliminary Greek and Latin squares.
During the construction of the 3×3 magic square, the Greek and Latin squares with just three unique terms are much easier to deal with than the original square with nine different terms. The row sum and the column sum of the Greek square will be the same, α + β + γ, if
- each letter appears exactly once in a given column or a row.
In order to construct a magic square, we should also ensure that the diagonals sum to magic constant. For this, we have a third condition:
- either all the letters should appear exactly once in both the diagonals; or in case of odd ordered squares, one of the diagonals should consist entirely of the middle term, while the other diagonal should have all the letters exactly once.
Odd squares: For the 3×3 odd square, since α, β, and γ are in arithmetic progression, their sum is equal to the product of the square's order and the middle term, i.e. α + β + γ = 3 β. Thus, the diagonal sums will be equal if we have βs in the main diagonal and α, β, γ in the skew diagonal. Similarly, for the Latin square. The resulting Greek and Latin squares and their combination will be as below. The Latin square is just a 90 degree anti-clockwise rotation of the Greek square with the corresponding letters interchanged. Substituting the values of the Greek and Latin letters will give the 3×3 magic square.
β | α | γ |
γ | β | α |
α | γ | β |
c | a | b |
a | b | c |
b | c | a |
βc | αa | γb |
γa | βb | αc |
αb | γc | βa |
6 | 1 | 8 |
7 | 5 | 3 |
2 | 9 | 4 |
For the odd squares, this method explains why the Siamese method and its variants work. This basic method can be used to construct odd ordered magic squares of higher orders. To summarise:
- For odd ordered squares, to construct Greek square, place the middle term along the main diagonal, and place the rest of the terms along the skew diagonal. The remaining empty cells are filled by diagonal moves. The Latin square can be constructed by rotating or flipping the Greek square, and replacing the corresponding alphabets. The magic square is obtained by adding the Greek and Latin squares.
As another example, the construction of 5×5 magic square is given. Numbers are directly written in place of alphabets. The numbered squares are referred to as primary square or root square if they are filled with primary numbers or root numbers, respectively. The numbers are placed about the skew diagonal in the root square such that the middle column of the resulting root square has 0, 5, 10, 15, 20. The primary square is obtained by rotating the root square counter-clockwise by 90 degrees, and replacing the numbers. The resulting square is an associative magic square, in which every pair of numbers symmetrically opposite to the center sum up to the same value, 26. For e.g., 16+10, 3+23, 6+20, etc. In the finished square, 1 is placed at center cell of bottom row, and successive numbers are placed via elongated knight's move, or equivalently, bishop's move. When a collision occurs, the break move is to move one cell up. All the odd numbers occur inside the central diamond formed by 1, 5, 25 and 21, while the even numbers are placed at the corners. The occurrence of the even numbers can be deduced by copying the square to the adjacent sides. The even numbers from four adjacent squares will form a cross.
10 | 5 | |||
10 | 20 | |||
10 | ||||
0 | 10 | |||
15 | 10 |
10 | 0 | 5 | ||
10 | 20 | 0 | ||
0 | 10 | |||
0 | 10 | |||
15 | 0 | 10 |
10 | 15 | 20 | 0 | 5 |
5 | 10 | 15 | 20 | 0 |
0 | 5 | 10 | 15 | 20 |
20 | 0 | 5 | 10 | 15 |
15 | 20 | 0 | 5 | 10 |
2 | 1 | 5 | 4 | 3 |
1 | 5 | 4 | 3 | 2 |
5 | 4 | 3 | 2 | 1 |
4 | 3 | 2 | 1 | 5 |
3 | 2 | 1 | 5 | 4 |
12 | 16 | 25 | 4 | 8 | - | - |
6 | 15 | 19 | 23 | 2 | - | - |
5 | 9 | 13 | 17 | 21 | - | - |
24 | 3 | 7 | 11 | 20 | 24 | - |
18 | 22 | 1 | 10 | 14 | 18 | 22 |
4 | 8 | 12 | 16 | |||
2 | 6 | - |
A variation of the above example, where the skew diagonal sequence is taken in different order, is given below. The resulting magic square is the flipped version of the famous Agrippa's Mars magic square. It is an associative magic square and is the same as that produced by Moschopoulos's method. Here the resulting square starts with 1 placed in the cell which is to the right of the centre cell, and proceeds as De la Loubere's method, with downwards-right move. When a collision occurs, the break move is to shift two cells to the right.
10 | 20 | |||
10 | 15 | |||
10 | ||||
5 | 10 | |||
0 | 10 |
10 | 0 | 15 | 5 | 20 |
20 | 10 | 0 | 15 | 5 |
5 | 20 | 10 | 0 | 15 |
15 | 5 | 20 | 10 | 0 |
0 | 15 | 5 | 20 | 10 |
1 | 4 | 2 | 5 | 3 |
4 | 2 | 5 | 3 | 1 |
2 | 5 | 3 | 1 | 4 |
5 | 3 | 1 | 4 | 2 |
3 | 1 | 4 | 2 | 5 |
11 | 4 | 17 | 10 | 23 |
24 | 12 | 5 | 18 | 6 |
7 | 25 | 13 | 1 | 19 |
20 | 8 | 21 | 14 | 2 |
3 | 16 | 9 | 22 | 15 |
In the previous examples, for the Greek square, the second row can be obtained from the first row by circularly shifting it to the right by one cell. Similarly, the third row is a circularly shifted version of the second row by one cell to the right; and so on. Likewise, the rows of the Latin square is circularly shifted to the left by one cell. The row shifts for the Greek and Latin squares are in mutually opposite direction. It is possible to circularly shift the rows by more than one cell to create the Greek and Latin square.
- For odd ordered squares, whose order is not divisible by three, we can create the Greek squares by shifting a row by two places to the left or to the right to form the next row. The Latin square is made by flipping the Greek square along the main diagonal and interchanging the corresponding letters. This gives us a Latin square whose rows are created by shifting the row in the direction opposite to that of the Greek square. A Greek square and a Latin square should be paired such that their row shifts are in mutually opposite direction. The magic square is obtained by adding the Greek and Latin squares. When the order also happens to be a prime number, this method always creates pandiagonal magic square.
In the example below, the square has been constructed such that 1 is at the center cell. In the finished square, the numbers can be continuously enumerated by the knight's move. When collision occurs, the break move is to move one cell up, one cell left.The resulting square is a pandiagonal magic square. This square also has a further diabolical property that any five cells in quincunx pattern formed by any odd sub-square, including wrap around, sum to the magic constant, 65. For e.g., 13+7+1+20+24, 23+1+9+15+17, 13+21+10+19+2 etc. Also the four corners of any 5×5 square and the central cell, as well as the middle cells of each side together with the central cell, including wrap around, give the magic sum: 13+10+19+22+1 and 20+24+12+8+1. Lastly the four rhomboids that form elongated crosses also give the magic sum: 23+1+9+24+8, 15+1+17+20+12, 14+1+18+13+19, 7+1+25+22+10.
10 | 15 | 20 | 0 | 5 |
0 | 5 | 10 | 15 | 20 |
15 | 20 | 0 | 5 | 10 |
5 | 10 | 15 | 20 | 0 |
20 | 0 | 5 | 10 | 15 |
3 | 1 | 4 | 2 | 5 |
4 | 2 | 5 | 3 | 1 |
5 | 3 | 1 | 4 | 2 |
1 | 4 | 2 | 5 | 3 |
2 | 5 | 3 | 1 | 4 |
13 | 16 | 24 | 2 | 10 |
4 | 7 | 15 | 18 | 21 |
20 | 23 | 1 | 9 | 12 |
6 | 14 | 17 | 25 | 3 |
22 | 5 | 8 | 11 | 19 |
We can also combine the Greek and Latin squares constructed by different methods. In the example below, the primary square is made using knight's move. We have re-created the magic square obtained by De la Loubere's method. As before, we can form 8 × ! × n! magic squares by this combination. For n = 5 and 7, this will create 23,040 and 29,030,400 magic squares. After dividing by 8 in order to neglect equivalent squares due to rotation and reflection, we get 2,880 and 3,628,800 squares.
15 | 20 | 0 | 5 | 10 |
20 | 0 | 5 | 10 | 15 |
0 | 5 | 10 | 15 | 20 |
5 | 10 | 15 | 20 | 0 |
10 | 15 | 20 | 0 | 5 |
2 | 4 | 1 | 3 | 5 |
3 | 5 | 2 | 4 | 1 |
4 | 1 | 3 | 5 | 2 |
5 | 2 | 4 | 1 | 3 |
1 | 3 | 5 | 2 | 4 |
17 | 24 | 1 | 8 | 15 |
23 | 5 | 7 | 14 | 16 |
4 | 6 | 13 | 20 | 22 |
10 | 12 | 19 | 21 | 3 |
11 | 18 | 25 | 2 | 9 |
For order 5 squares, these three methods give a complete census of the number of magic squares that can be constructed by the method of superposition. Neglecting the rotation and reflections, the total number of magic squares of order 5 produced by the superposition method is 144 + 3,600 + 2,880 = 6,624.
Even squares: We can also construct even ordered squares in this fashion. Since there is no middle term among the Greek and Latin alphabets for even ordered squares, in addition to the first two constraint, for the diagonal sums to yield the magic constant, all the letters in the alphabet should appear in the main diagonal and in the skew diagonal.
An example of a 4×4 square is given below. For the given diagonal and skew diagonal in the Greek square, the rest of the cells can be filled using the condition that each letter appear only once in a row and a column.
α | δ | ||
δ | α | ||
γ | β | ||
β | γ |
α | β | γ | δ |
γ | δ | α | β |
δ | γ | β | α |
β | α | δ | γ |
a | b | c | d |
d | c | b | a |
b | a | d | c |
c | d | a | b |
αa | βb | γc | δd |
γd | δc | αb | βa |
δb | γa | βd | αc |
βc | αd | δa | γb |
1 | 6 | 11 | 16 |
12 | 15 | 2 | 5 |
14 | 9 | 8 | 3 |
7 | 4 | 13 | 10 |
Using these two Graeco-Latin squares, we can construct 2 × 4! × 4! = 1,152 magic squares. Dividing by 8 to eliminate equivalent squares due to rotation and reflections, we get 144 essentially different magic squares of order 4. These are the only magic squares constructible by the Euler method, since there are only two mutually orthogonal doubly diagonal Graeco-Latin squares of order 4.
Similarly, an 8×8 magic square can be constructed as below. Here the order of appearance of the numbers is not important; however the quadrants imitate the layout pattern of the 4×4 Graeco-Latin squares.
0 | 8 | 16 | 24 | 32 | 40 | 48 | 56 |
24 | 16 | 8 | 0 | 56 | 48 | 40 | 32 |
48 | 56 | 32 | 40 | 16 | 24 | 0 | 8 |
40 | 32 | 56 | 48 | 8 | 0 | 24 | 16 |
56 | 48 | 40 | 32 | 24 | 16 | 8 | 0 |
32 | 40 | 48 | 56 | 0 | 8 | 16 | 24 |
8 | 0 | 24 | 16 | 40 | 32 | 56 | 48 |
16 | 24 | 0 | 8 | 48 | 56 | 32 | 40 |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
3 | 4 | 1 | 2 | 7 | 8 | 5 | 6 |
5 | 6 | 7 | 8 | 1 | 2 | 3 | 4 |
7 | 8 | 5 | 6 | 3 | 4 | 1 | 2 |
4 | 3 | 2 | 1 | 8 | 7 | 6 | 5 |
2 | 1 | 4 | 3 | 6 | 5 | 8 | 7 |
8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
6 | 5 | 8 | 7 | 2 | 1 | 4 | 3 |
1 | 10 | 19 | 28 | 37 | 46 | 55 | 64 |
27 | 20 | 9 | 2 | 63 | 56 | 45 | 38 |
53 | 62 | 39 | 48 | 17 | 26 | 3 | 12 |
47 | 40 | 61 | 54 | 11 | 4 | 25 | 18 |
60 | 51 | 42 | 33 | 32 | 23 | 14 | 5 |
34 | 41 | 52 | 59 | 6 | 13 | 24 | 31 |
16 | 7 | 30 | 21 | 44 | 35 | 58 | 49 |
22 | 29 | 8 | 15 | 50 | 57 | 36 | 43 |
Euler's method has given rise to the study of Graeco-Latin squares. Euler's method for constructing magic squares is valid for any order except 2 and 6.
Variations: Magic squares constructed from mutually orthogonal doubly diagonal Graeco-Latin squares are interesting in themselves since the magic property emerges from the relative position of the alphabets in the square, and not due to any arithmetic property of the value assigned to them. This means that we can assign any value to the alphabets of such squares and still obtain a magic square. This is the basis for constructing squares that display some information in the square and for creating "reversible squares". For example, we can display the number π ≈ 3·141592 at the bottom row of a 4×4 magic square using the Graeco-Latin square given above by assigning = and =. We will obtain the following non-normal magic square with the magic sum 124:
10 | 2 | 93 | 19 |
94 | 18 | 12 | 0 |
17 | 90 | 4 | 13 |
3 | 14 | 15 | 92 |
Narayana-De la Hire's method for even orders
Narayana-De la Hire's method for odd square is the same as that of Euler's. However, for even squares, we drop the second requirement that each Greek and Latin letter appear only once in a given row or column. This allows us to take advantage of the fact that the sum of an arithmetic progression with an even number of terms is equal to the sum of two opposite symmetric terms multiplied by half the total number of terms. Thus, when constructing the Greek or Latin squares,- for even ordered squares, a letter can appear n/2 times in a column but only once in a row, or vice versa.
- For even ordered squares, the Greek magic square is made by first placing the Greek alphabets along the main diagonal in some order. The skew diagonal is then filled in the same order or by picking the terms that are complementary to the terms in the main diagonal. Finally, the remaining cells are filled column wise. Given a column, we use the complementary terms in the diagonal cells intersected by that column, making sure that they appear only once in a given row but n/2 times in the given column. The Latin square is obtained by flipping or rotating the Greek square and interchanging the corresponding alphabets. The final magic square is obtained by adding the Greek and Latin squares.
α | δ | ||
β | γ | ||
β | γ | ||
α | δ |
α | γ | β | δ |
δ | β | γ | α |
δ | β | γ | α |
α | γ | β | δ |
a | d | d | a |
c | b | b | c |
b | c | c | b |
d | a | a | d |
αa | γd | βd | δa |
δc | βb | γb | αc |
δb | βc | γc | αb |
αd | γa | βa | δd |
1 | 12 | 8 | 13 |
15 | 6 | 10 | 3 |
14 | 7 | 11 | 2 |
4 | 9 | 5 | 16 |
The above example explains why the "criss-cross" method for doubly even magic square works. Another possible 4×4 magic square, which is also pan-diagonal as well as most-perfect, is constructed below using the same rule. However, the diagonal sequence is chosen such that all four letters α, β, γ, δ appear inside the central 2×2 sub-square. Remaining cells are filled column wise such that each letter appears only once within a row. In the 1st column, the empty cells need to be filled with one of the letters selected from the complementary pair α and δ. Given the 1st column, the entry in the 2nd row can only be δ since α is already there in the 2nd row; while, in the 3rd row the entry can only be α since δ is already present in the 3rd row. We proceed similarly until all cells are filled. The Latin square given below has been obtained by flipping the Greek square along the main diagonal and replacing the Greek alphabets with corresponding Latin alphabets.
α | γ | ||
γ | α | ||
β | δ | ||
δ | β |
α | β | δ | γ |
δ | γ | α | β |
α | β | δ | γ |
δ | γ | α | β |
a | d | a | d |
b | c | b | c |
d | a | d | a |
c | b | c | b |
αa | βd | δa | γd |
δb | γc | αb | βc |
αd | βa | δd | γa |
δc | γb | αc | βb |
1 | 8 | 13 | 12 |
14 | 11 | 2 | 7 |
4 | 5 | 16 | 9 |
15 | 10 | 3 | 6 |
We can use this approach to construct singly even magic squares as well. However, we have to be more careful in this case since the criteria of pairing the Greek and Latin alphabets uniquely is not automatically satisfied. Violation of this condition leads to some missing numbers in the final square, while duplicating others. Thus, here is an important proviso:
- For singly even squares, in the Greek square, check the cells of the columns which is vertically paired to its complement. In such a case, the corresponding cell of the Latin square must contain the same letter as its horizontally paired cell.
0 | 24 | 18 | 12 | 6 | 30 |
30 | 6 | 12 | 18 | 24 | 0 |
0 | 24 | 12 | 18 | 6 | 30 |
30 | 24 | 12 | 18 | 6 | 0 |
30 | 6 | 18 | 12 | 24 | 0 |
0 | 6 | 18 | 12 | 24 | 30 |
1 | 6 | 1 | 6 | 6 | 1 |
5 | 2 | 5 | 5 | 2 | 2 |
4 | 3 | 3 | 3 | 4 | 4 |
3 | 4 | 4 | 4 | 3 | 3 |
2 | 5 | 2 | 2 | 5 | 5 |
6 | 1 | 6 | 1 | 1 | 6 |
1 | 30 | 19 | 18 | 12 | 31 |
35 | 8 | 17 | 23 | 26 | 2 |
4 | 27 | 15 | 21 | 10 | 34 |
33 | 28 | 16 | 22 | 9 | 3 |
32 | 11 | 20 | 14 | 29 | 5 |
6 | 7 | 24 | 13 | 25 | 36 |
As another example of a 6×6 magic square constructed this way is given below. Here the diagonal entries are arranged differently. The primary square is constructed by flipping the root square about the main diagonal. In the second square the proviso for singly even square is not satisfied, leading to a non-normal magic square where the numbers 3, 13, 24, and 34 are duplicated while missing the numbers 4, 18, 19, and 33.
6 | 30 | 12 | 18 | 0 | 24 |
24 | 0 | 12 | 18 | 30 | 6 |
24 | 0 | 18 | 12 | 30 | 6 |
6 | 30 | 18 | 12 | 0 | 24 |
24 | 0 | 18 | 12 | 30 | 6 |
6 | 30 | 12 | 18 | 0 | 24 |
2 | 5 | 5 | 2 | 5 | 2 |
6 | 1 | 1 | 6 | 1 | 6 |
3 | 3 | 4 | 4 | 4 | 3 |
4 | 4 | 3 | 3 | 3 | 4 |
1 | 6 | 6 | 1 | 6 | 1 |
5 | 2 | 2 | 5 | 2 | 5 |
8 | 35 | 17 | 20 | 5 | 26 |
30 | 1 | 13 | 24 | 31 | 12 |
27 | 3 | 22 | 16 | 34 | 9 |
10 | 34 | 21 | 15 | 3 | 28 |
25 | 6 | 24 | 13 | 36 | 7 |
11 | 32 | 14 | 23 | 2 | 29 |
The last condition is a bit arbitrary and may not always need to be invoked, as in this example:
6 | 30 | 12 | 24 | 18 | 0 |
6 | 0 | 18 | 24 | 12 | 30 |
24 | 0 | 12 | 6 | 18 | 30 |
6 | 30 | 18 | 24 | 12 | 0 |
24 | 30 | 12 | 6 | 18 | 0 |
24 | 0 | 18 | 6 | 12 | 30 |
2 | 2 | 5 | 2 | 5 | 5 |
6 | 1 | 1 | 6 | 6 | 1 |
3 | 4 | 3 | 4 | 3 | 4 |
5 | 5 | 2 | 5 | 2 | 2 |
4 | 3 | 4 | 3 | 4 | 3 |
1 | 6 | 6 | 1 | 1 | 6 |
8 | 32 | 17 | 26 | 23 | 5 |
12 | 1 | 19 | 30 | 18 | 31 |
27 | 4 | 15 | 10 | 21 | 34 |
11 | 35 | 20 | 29 | 14 | 2 |
28 | 33 | 16 | 9 | 22 | 3 |
25 | 6 | 24 | 7 | 13 | 36 |
As one more example, we have generated an 8×8 magic square. Unlike the criss-cross pattern of the earlier section for evenly even square, here we have a checkered pattern for the altered and unaltered cells. Also, in each quadrant the odd and even numbers appear in alternating columns.
0 | 48 | 16 | 32 | 24 | 40 | 8 | 56 |
56 | 8 | 40 | 24 | 32 | 16 | 48 | 0 |
0 | 48 | 16 | 32 | 24 | 40 | 8 | 56 |
56 | 8 | 40 | 24 | 32 | 16 | 48 | 0 |
56 | 8 | 40 | 24 | 32 | 16 | 48 | 0 |
0 | 48 | 16 | 32 | 24 | 40 | 8 | 56 |
56 | 8 | 40 | 24 | 32 | 16 | 48 | 0 |
0 | 48 | 16 | 32 | 24 | 40 | 8 | 56 |
1 | 8 | 1 | 8 | 8 | 1 | 8 | 1 |
7 | 2 | 7 | 2 | 2 | 7 | 2 | 7 |
3 | 6 | 3 | 6 | 6 | 3 | 6 | 3 |
5 | 4 | 5 | 4 | 4 | 5 | 4 | 5 |
4 | 5 | 4 | 5 | 5 | 4 | 5 | 4 |
6 | 3 | 6 | 3 | 3 | 6 | 3 | 6 |
2 | 7 | 2 | 7 | 7 | 2 | 7 | 2 |
8 | 1 | 8 | 1 | 1 | 8 | 1 | 8 |
1 | 56 | 17 | 40 | 32 | 41 | 16 | 57 |
63 | 10 | 47 | 26 | 34 | 23 | 50 | 7 |
3 | 54 | 19 | 38 | 30 | 43 | 14 | 59 |
61 | 12 | 45 | 28 | 36 | 21 | 42 | 5 |
60 | 13 | 44 | 29 | 37 | 20 | 53 | 4 |
6 | 51 | 22 | 35 | 27 | 46 | 11 | 62 |
58 | 15 | 42 | 31 | 39 | 18 | 55 | 2 |
8 | 47 | 24 | 33 | 25 | 48 | 9 | 64 |
Variations: A number of variations of the basic idea are possible: a complementary pair can appear n/2 times or less in a column. That is, a column of a Greek square can be constructed using more than one complementary pair. This method allows us to imbue the magic square with far richer properties. The idea can also be extended to the diagonals too. An example of an 8×8 magic square is given below. In the finished square each of four quadrants are pan-magic squares as well, each quadrant with same magic constant 130.
0 | 48 | 56 | 8 | 16 | 32 | 40 | 24 |
56 | 8 | 0 | 48 | 40 | 24 | 16 | 32 |
0 | 48 | 56 | 8 | 16 | 32 | 40 | 24 |
56 | 8 | 0 | 48 | 40 | 24 | 16 | 32 |
48 | 0 | 8 | 56 | 32 | 16 | 24 | 40 |
8 | 56 | 48 | 0 | 24 | 40 | 32 | 16 |
48 | 0 | 8 | 56 | 32 | 16 | 24 | 40 |
8 | 56 | 48 | 0 | 24 | 40 | 32 | 16 |
1 | 8 | 1 | 8 | 7 | 2 | 7 | 2 |
7 | 2 | 7 | 2 | 1 | 8 | 1 | 8 |
8 | 1 | 8 | 1 | 2 | 7 | 2 | 7 |
2 | 7 | 2 | 7 | 8 | 1 | 8 | 1 |
3 | 6 | 3 | 6 | 5 | 4 | 5 | 4 |
5 | 4 | 5 | 4 | 3 | 6 | 3 | 6 |
6 | 3 | 6 | 3 | 4 | 5 | 4 | 5 |
4 | 5 | 4 | 5 | 6 | 3 | 6 | 3 |
1 | 56 | 57 | 16 | 23 | 34 | 47 | 26 |
63 | 10 | 7 | 50 | 41 | 32 | 17 | 40 |
8 | 49 | 64 | 9 | 18 | 39 | 42 | 31 |
58 | 15 | 2 | 55 | 48 | 25 | 24 | 33 |
51 | 6 | 11 | 62 | 37 | 20 | 29 | 44 |
13 | 60 | 53 | 4 | 27 | 46 | 35 | 22 |
54 | 3 | 14 | 59 | 36 | 21 | 28 | 45 |
12 | 61 | 52 | 5 | 30 | 43 | 38 | 19 |
Method of borders
Bordering method for order 3
In this method, the objective is to wrap a border around a smaller magic square which serves as a core. Consider the 3×3 square for example. Subtracting the middle number 5 from each number 1, 2,..., 9, we obtain 0, ± 1, ± 2, ± 3, and ± 4, which we will, for lack of better words, following Harry S. White, refer to as bone numbers. The magic constant of a magic square, which we will refer to as the skeleton square, made by these bone numbers will be zero since adding all the rows of a magic square will give nM = Σ k = 0; thus M = 0.It is not difficult to argue that the middle number should be placed at the center cell: let x be the number placed in the middle cell, then the sum of the middle column, middle row, and the two diagonals give Σ k + 3 x = 4 M. Since Σ k = 3 M, we have x = M / 3. Here M = 0, so x = 0.
Putting the middle number 0 in the center cell, we want to construct a border such that the resulting square is magic. Let the border be given by:
u | a | v |
b* | 0 | b |
v* | a* | u* |
Since the sum of each row, column, and diagonals must be a constant, we have
Now, if we have chosen a, b, u, and v, then we have a* = - a, b* = - b, u* = - u, and v* = - v. This means that if we assign a given number to a variable, say a = 1, then its complement will be assigned to a*, i.e. a* = - 1. Thus out of eight unknown variables, it is sufficient to specify the value of only four variables. We will consider a, b, u, and v as independent variables, while a*, b*, u*, and v* as dependent variables. This allows us to consider a bone number ± x as a single number regardless of sign because its assignment to a given variable, say a, will automatically imply that the same number of opposite sign will be shared with its complement a*, and two independent variables, say a and b, cannot be assigned the same bone number. But how should we choose a, b, u, and v? We have the sum of the top row and the sum of the right column as
Since 0 is an even number, there are only two ways that the sum of three integers will yield an even number: 1) if all three were even, or 2) if two were odd and one was even. Since in our choice of numbers we only have two even non-zero number, the first statement is false. Hence, it must be the case that the second statement is true: that two of the numbers are odd and one even.
The only way that both the above two equations can satisfy this parity condition simultaneously, and still be consistent with the set of numbers we have, is when u and v are odd. For on the contrary, if we had assumed u and a to be odd and v to be even in the first equation, then u* = - u will be odd in the second equation, making b odd as well, in order to satisfy the parity condition. But this requires three odd numbers, contradicting the fact that we only have two odd numbers which we can use. This proves that the odd bone numbers occupy the corners cells. When converted to normal numbers by adding 5, this implies that the corners of a 3×3 magic square are all occupied by even numbers.
Thus, taking u = 1 and v = 3, we have a = - 4 and b = - 2. Hence, the finished skeleton square will be as in the left. Adding 5 to each number, we get the finished magic square.
1 | -4 | 3 |
2 | 0 | -2 |
-3 | 4 | -1 |
6 | 1 | 8 |
7 | 5 | 3 |
2 | 9 | 4 |
Similar argument can be used to construct larger squares. Since there does not exist a 2×2 magic square around which we can wrap a border to construct a 4×4 magic square, the next smallest order for which we can construct bordered square is the order 5.
Bordering method for order 5
Consider the fifth-order square. For this, we have a 3×3 magic core, around which we will wrap a magic border. The bone numbers to be used will be ± 5, ± 6, ± 7, ± 8, ± 9, ± 10, ± 11, and ± 12. Disregarding the signs, we have 8 bone numbers, 4 of which are even and 4 of which are odd. In general, for a square of any order n, there will be 4 border cells, which are to be filled using 2 bone numbers. Let the magic border be given asu | a | b | c | v |
d* | d | |||
e* | e | |||
f* | f | |||
v* | a* | b* | c* | u* |
As before, we should
- place a bone number and its complement opposite to each other, so that the magic sum will be zero.
Multiple solutions are possible. The standard procedure is to
- first try to determine the corner cells, after which we will try to determine the rest of the border.
We can prove that the corner cells u and v cannot have an even and an odd number. This is because if this were so, then the sums u + v and v + u* will be odd, and since 0 is an even number, the sums a + b + c and d + e + f should be odd as well. The only way that the sum of three integers will result in an odd number is when 1) two of them are even and one is odd, or 2) when all three are odd. Since the corner cells are assumed to be odd and even, neither of these two statements are compatible with the fact that we only have 3 even and 3 odd bone numbers at our disposal. This proves that u and v cannot have different parity. This eliminates 16 possibilities.
Using similar type reasoning we can also draw some conclusions about the sets and. If u and v are both even, then both the sets should have two odd numbers and one even number. If u and v are both odd, then one of the sets should have three even numbers while the other set should have one even number and two odd numbers.
As a running example, consider the case when both u and v are even. The 6 possible pairs are:,,,,, and two of them are odd and one is even, or 2) when all three are even. The fact that the two corner cells are even means that we have only 2 even numbers at our disposal. Thus, the second statement is not compatible with this fact. Hence, it must be the case that the first statement is true: two of the three numbers should be odd, while one be even.
Now let a, b, d, e be odd numbers while c and f be even numbers. Given the odd bone numbers at our disposal: ± 5, ± 7, ± 9, and ± 11, their differences range from D = while their sums range from S =. It is also useful to have a table of their sum and differences for later reference. Now, given the corner cells, we can check its admissibility by checking if the sums u + v + c and v + u* + f fall within the set D or S. The admissibility of the corner numbers is a necessary but not a sufficient condition for the solution to exist.
For example, if we consider the pair =, then u + v = 20 and v + u* = 6; and we will have ± 6 and ± 10 even bone numbers at our disposal. Taking c = ± 6, we have the sum u + v + c to be 26 and 14, depending on the sign of ± 6 taken, both of which do not fall within the sets D or S. Likewise, taking c = ± 10, we have the sum u + v + c to be 30 and 10, both of which again do not fall within the sets D or S. Thus, the pair is not admissible. By similar process of reasoning, we can also rule out the pair.
As another example, if we consider the pair =, then u + v = 22 and v + u* = 2; and we will have ± 6 and ± 8 even bone numbers at our disposal. Taking c = ± 6, we have the sum u + v + c to be 28 and 16. While 28 does not fall within the sets D or S, 16 falls in set S. By inspection, we find that if =, then a + b = -16; and it will satisfy the first constraint equation. Also, taking f = ± 8, we have the sum v + u* + f to be 10 and -6. While 10 does not fall within the sets D or S, -6 falls in set D. Since -7 and -9 have already been assigned to a and b, clearly = so that d + e = 6; and it will satisfy the second constraint equation.
Likewise, taking c = ± 8, we have the sum u + v + c to be 30 and 14. While 30 does not fall within the sets D or S, 14 falls in set S. By inspection, we find that if =, then a + b = -14. Also, taking f = ± 6, we have the sum v + u* + f to be 8 and -4. While 8 does not fall within the sets D or S, -4 falls in set D. Clearly, = so that d + e = 4, and the second constraint equation will be satisfied.
Hence the corner pair = is admissible; and it admits two solutions: = and =. The finished skeleton squares are given below. The magic square is obtained by adding 13 to each cells.
10 | -7 | -9 | -6 | 12 |
5 | -5 | |||
-11 | 11 | |||
8 | -8 | |||
-12 | 7 | 9 | 6 | -10 |
23 | 6 | 4 | 7 | 25 |
18 | 8 | |||
2 | 24 | |||
21 | 5 | |||
1 | 20 | 22 | 19 | 3 |
10 | -5 | -9 | -8 | 12 |
7 | -7 | |||
-11 | 11 | |||
6 | -6 | |||
-12 | 5 | 9 | 8 | -10 |
23 | 8 | 4 | 5 | 25 |
20 | 6 | |||
2 | 24 | |||
19 | 7 | |||
1 | 18 | 22 | 21 | 3 |
Using similar process of reasoning, we can construct the following table for the values of u, v, a, b, c, d, e, f expressed as bone numbers as given below. There are only 6 possible choices for the corner cells, which leads to 10 possible border solutions.
u, v | a, b, c | d, e, f |
12, 10 | -6, -7, -9 | -11, 5, 8 |
12, 10 | -5, -8, -9 | -11, 6, 7 |
11, 5 | 6, -10, -12 | -9, 7, 8 |
10, 6 | 5, -9, -12 | -11, 7, 8 |
10, 6 | 7, -11, -12 | -9, 5, 8 |
9, 7 | 5, -10, -11 | -12, 6, 8 |
9, 7 | 6, -10, -12 | -11, 5, 8 |
8, 6 | 7, -10, -11 | -12, 5, 9 |
8, 6 | 9, -11, -12 | -10, 5, 7 |
7, 5 | 9, -10, -11 | -12, 6, 8 |
Given this group of 10 borders, we can construct 10×8×2 = 2880 essentially different bordered magic squares. Here the bone numbers ± 5,..., ± 12 were consecutive. More bordered squares can be constructed if the numbers are not consecutive. If non-consecutive bone numbers were also used, then there are a total of 605 magic borders. Thus, the total number of order 5 essentially different bordered magic squares is 174,240. See history. It is worth noting that the number of fifth-order magic squares constructible via the bordering method is about 26 times larger than via the superposition method.
Continuous enumeration methods
Exhaustive enumeration of all the borders of a magic square of a given order, as done previously, is very tedious. As such a structured solution is often desirable, which allows us to construct a border for a square of any order. Below we give three algorithms for constructing border for odd, doubly even, and singly even squares. These continuous enumeration algorithms were discovered in 10th century by Arab scholars; and their earliest surviving exposition comes from the two treatises by al-Buzjani and al-Antaki, although they themselves were not the discoverers. Since then many more such algorithms have been discovered.Odd ordered squares: The following is the algorithm given by al-Buzjani to construct a border for odd squares. A peculiarity of this method is that for order n square, the two adjacent corners are numbers n - 1 and n + 1.
Starting from the cell above the lower left corner, we put the numbers alternately in left column and bottom row until we arrive at the middle cell. The next number is written in the middle cell of the bottom row just reached, after which we fill the cell in the upper left corner, then the middle cell of the right column, then the upper right corner. After this, starting from the cell above middle cell of the right column already filled, we resume the alternate placement of the numbers in the right column and the top row. Once half of the border cells are filled, the other half are filled by numbers complementary to opposite cells. The subsequent inner borders is filled in the same manner, until the square of order 3 is filled.
Below is an example for 9th-order square.
8 | 80 | 78 | 76 | 75 | 12 | 14 | 16 | 10 |
67 | 22 | 64 | 62 | 61 | 26 | 28 | 24 | 15 |
69 | 55 | 32 | 52 | 51 | 36 | 34 | 27 | 13 |
71 | 57 | 47 | 38 | 45 | 40 | 35 | 25 | 11 |
73 | 59 | 49 | 43 | 41 | 39 | 33 | 23 | 9 |
5 | 19 | 29 | 42 | 37 | 44 | 53 | 63 | 77 |
3 | 17 | 48 | 30 | 31 | 46 | 50 | 65 | 79 |
1 | 58 | 18 | 20 | 21 | 56 | 54 | 60 | 81 |
72 | 2 | 4 | 6 | 7 | 70 | 68 | 66 | 74 |
Doubly even order: The following is the method given by al-Antaki. Consider an empty border of order n = 4k with k ≥ 3. The peculiarity of this algorithm is that the adjacent corner cells are occupied by numbers n and n - 1.
Starting at the upper left corner cell, we put the successive numbers by groups of four, the first one next to the corner, the second and the third on the bottom, and the fourth at the top, and so on until there remains in the top row six empty cells. We then write the next two numbers above and the next four below. We then fill the upper corners, first left then right. We place the next number below the upper right corner in the right column, the next number on the other side in the left column. We then resume placing groups of four consecutive numbers in the two columns as before. Once half of the border cells are filled, the other half are filled by numbers complementary to opposite cells.
The example below gives the border for order 16 square.
15 | 1 | 255 | 254 | 4 | 5 | 251 | 250 | 8 | 9 | 10 | 246 | 245 | 244 | 243 | 16 |
240 | 17 | ||||||||||||||
18 | 239 | ||||||||||||||
19 | 238 | ||||||||||||||
237 | 20 | ||||||||||||||
236 | 21 | ||||||||||||||
22 | 235 | ||||||||||||||
23 | 234 | ||||||||||||||
233 | 24 | ||||||||||||||
232 | 25 | ||||||||||||||
26 | 231 | ||||||||||||||
27 | 230 | ||||||||||||||
229 | 28 | ||||||||||||||
228 | 29 | ||||||||||||||
30 | 227 | ||||||||||||||
241 | 256 | 2 | 3 | 253 | 252 | 6 | 7 | 249 | 248 | 247 | 11 | 12 | 13 | 14 | 242 |
For order 8 square, we just begin directly with the six cells.
7 | 1 | 2 | 62 | 61 | 60 | 59 | 8 |
56 | 9 | ||||||
10 | 55 | ||||||
11 | 54 | ||||||
53 | 12 | ||||||
52 | 13 | ||||||
14 | 51 | ||||||
57 | 64 | 63 | 3 | 4 | 5 | 6 | 58 |
Singly even order: For singly even order, we have the algorithm given by al-Antaki. Here the corner cells are occupied by n and n - 1. Below is an example of 10th-order square.
Start by placing 1 at the bottom row next to the left corner cell, then place 2 in the top row. After this, place 3 at the bottom row and turn around the border in anti-clockwise direction placing the next numbers, until n - 2 is reached on the right column. The next two numbers are placed in the upper corners. Then, the next two numbers are placed on the left column, then we resume the cyclic placement of the numbers until half of all the border cells are filled. Once half of the border cells are filled, the other half are filled by numbers complementary to opposite cells.
9 | 100 | 2 | 98 | 5 | 94 | 88 | 15 | 84 | 10 |
83 | 18 | ||||||||
16 | 85 | ||||||||
87 | 14 | ||||||||
12 | 89 | ||||||||
11 | 90 | ||||||||
93 | 8 | ||||||||
6 | 95 | ||||||||
97 | 4 | ||||||||
91 | 1 | 99 | 3 | 96 | 7 | 13 | 86 | 17 | 92 |
Method of composition
For squares of order ''m × n'' where ''m'', ''n'' > 2
This is a method reminiscent of the Kronecker product of two matrices, that builds an nm × nm magic square from an n × n magic square and an m × m magic square. The "product" of two magic squares creates a magic square of higher order than the two multiplicands. Let the two magic squares be of orders m and n. The final square will be of order m × n. Divide the square of order m × n into m × m sub-squares, such that there are a total of n2 such sub-squares. In the square of order n, reduce by 1 the value of all the numbers. Multiply these reduced values by m2, and place the results in the corresponding sub-squares of the m × n whole square. The squares of order m are added n2 times to the sub-squares of the final square. The peculiarity of this construction method is that each magic subsquare will have different magic sums. The square made of such magic sums from each magic subsquare will again be a magic square. The smallest composite magic square of order 9, composed of two order 3 squares is given below.8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |
63 | 63 | 63 | 0 | 0 | 0 | 45 | 45 | 45 |
63 | 63 | 63 | 0 | 0 | 0 | 45 | 45 | 45 |
63 | 63 | 63 | 0 | 0 | 0 | 45 | 45 | 45 |
18 | 18 | 18 | 36 | 36 | 36 | 54 | 54 | 54 |
18 | 18 | 18 | 36 | 36 | 36 | 54 | 54 | 54 |
18 | 18 | 18 | 36 | 36 | 36 | 54 | 54 | 54 |
27 | 27 | 27 | 72 | 72 | 72 | 9 | 9 | 9 |
27 | 27 | 27 | 72 | 72 | 72 | 9 | 9 | 9 |
27 | 27 | 27 | 72 | 72 | 72 | 9 | 9 | 9 |
71 | 64 | 69 | 8 | 1 | 6 | 53 | 46 | 51 |
66 | 68 | 70 | 3 | 5 | 7 | 48 | 50 | 52 |
67 | 72 | 65 | 4 | 9 | 2 | 49 | 54 | 47 |
26 | 19 | 24 | 44 | 37 | 42 | 62 | 55 | 60 |
21 | 23 | 25 | 39 | 41 | 43 | 57 | 59 | 61 |
22 | 27 | 20 | 40 | 45 | 38 | 58 | 63 | 56 |
35 | 28 | 33 | 80 | 73 | 78 | 17 | 10 | 15 |
30 | 32 | 34 | 75 | 77 | 79 | 12 | 14 | 16 |
31 | 36 | 29 | 76 | 81 | 74 | 13 | 18 | 11 |
Since each of the 3×3 sub-squares can be independently rotated and reflected into 8 different squares, from this single 9×9 composite square we can derive 89 = 134,217,728 essentially different 9×9 composite squares. Plenty more composite magic squares can also be derived if we select non-consecutive numbers in the magic sub-squares, like in Yang Hui's version of the 9×9 composite magic square. The next smallest composite magic squares of order 12, composed of magic squares of order 3 and 4 are given below.
2 | 9 | 4 |
7 | 5 | 3 |
6 | 1 | 8 |
1 | 14 | 11 | 8 |
12 | 7 | 2 | 13 |
6 | 9 | 16 | 3 |
15 | 4 | 5 | 10 |
2 | 9 | 4 | 119 | 126 | 121 | 92 | 99 | 94 | 65 | 72 | 67 |
7 | 5 | 3 | 124 | 122 | 120 | 97 | 95 | 93 | 70 | 68 | 66 |
6 | 1 | 8 | 123 | 118 | 125 | 96 | 91 | 98 | 69 | 64 | 71 |
101 | 108 | 103 | 56 | 63 | 58 | 11 | 18 | 13 | 110 | 117 | 112 |
106 | 104 | 102 | 61 | 59 | 57 | 16 | 14 | 12 | 115 | 113 | 111 |
105 | 100 | 107 | 60 | 55 | 62 | 15 | 10 | 17 | 114 | 109 | 116 |
47 | 54 | 49 | 74 | 81 | 76 | 137 | 144 | 139 | 20 | 27 | 22 |
52 | 50 | 48 | 79 | 77 | 75 | 142 | 140 | 138 | 25 | 23 | 21 |
51 | 46 | 53 | 78 | 73 | 80 | 141 | 136 | 143 | 24 | 19 | 26 |
128 | 135 | 130 | 29 | 36 | 31 | 38 | 45 | 40 | 83 | 90 | 85 |
133 | 131 | 129 | 34 | 32 | 30 | 43 | 41 | 39 | 88 | 86 | 84 |
132 | 127 | 134 | 33 | 28 | 35 | 42 | 37 | 44 | 87 | 82 | 89 |
17 | 30 | 27 | 24 | 129 | 142 | 139 | 136 | 49 | 62 | 59 | 56 |
28 | 23 | 18 | 29 | 140 | 135 | 130 | 141 | 60 | 55 | 50 | 61 |
22 | 25 | 32 | 19 | 134 | 137 | 144 | 131 | 54 | 57 | 64 | 51 |
31 | 20 | 21 | 26 | 143 | 132 | 133 | 138 | 63 | 52 | 53 | 58 |
97 | 110 | 107 | 104 | 65 | 78 | 75 | 72 | 33 | 46 | 43 | 40 |
108 | 103 | 98 | 109 | 76 | 71 | 66 | 77 | 44 | 39 | 34 | 45 |
102 | 105 | 112 | 99 | 70 | 73 | 80 | 67 | 38 | 41 | 48 | 35 |
111 | 100 | 101 | 106 | 79 | 68 | 69 | 74 | 47 | 36 | 37 | 42 |
81 | 94 | 91 | 88 | 1 | 14 | 11 | 8 | 113 | 126 | 123 | 120 |
92 | 87 | 82 | 93 | 12 | 7 | 2 | 13 | 124 | 119 | 114 | 125 |
86 | 89 | 96 | 83 | 6 | 9 | 16 | 3 | 118 | 121 | 128 | 115 |
95 | 84 | 85 | 90 | 15 | 4 | 5 | 10 | 127 | 116 | 117 | 122 |
For the base squares, there is only one essentially different 3rd order square, while there 880 essentially different 4th-order squares that we can choose from. Each pairing can produce two different composite squares. Since each magic sub-squares in each composite square can be expressed in 8 different forms due to rotations and reflections, there can be 1×880×89 + 880×1×816 ≈ 2.476×1017 essentially different 12×12 composite magic squares created this way, with consecutive numbers in each sub-square. In general, if there are cm and cn essentially different magic squares of order m and n, then we can form cm × cn × composite squares of order mn, provided m ≠ n. If m = n, then we can form 2 × 8m2 composite squares of order m2.
For squares of doubly even order
When the squares are of doubly even order, we can construct a composite magic square in a manner more elegant than the above process, in the sense that every magic subsquare will have the same magic constant. Let n be the order of the main square and m the order of the equal subsquares. The subsquares are filled one by one, in any order, with a continuous sequence of m2/2 smaller numbers together with their complements to n2 + 1. Each subsquare as a whole will yield the same magic sum. The advantage of this type of composite square is that each subsquare is filled in the same way and their arrangement is arbitrary. Thus, the knowledge of a single construction of even order will suffice to fill the whole square. Furthermore, if the subsquares are filled in the natural sequence, then the resulting square will be pandiagonal. The magic sum of the subsquares is related to the magic sum of the whole square by where k = n/m.In the examples below, we have divided the order 12 square into nine subsquares of order 4 filled each with eight smaller numbers and, in the corresponding bishop's cells, their complements to n2 + 1 = 145. Each subsquare is pandiagonal with magic constant 290; while the whole square on the left is also pandiagonal with magic constant 870.
1 | 142 | 139 | 8 | 9 | 134 | 131 | 16 | 17 | 126 | 123 | 24 |
140 | 7 | 2 | 141 | 132 | 15 | 10 | 133 | 124 | 23 | 18 | 125 |
6 | 137 | 144 | 3 | 14 | 129 | 136 | 11 | 22 | 121 | 128 | 19 |
143 | 4 | 5 | 138 | 135 | 12 | 13 | 130 | 127 | 20 | 21 | 122 |
25 | 118 | 115 | 32 | 33 | 110 | 107 | 40 | 41 | 102 | 99 | 48 |
116 | 31 | 26 | 117 | 108 | 39 | 34 | 109 | 100 | 47 | 42 | 101 |
30 | 113 | 120 | 27 | 38 | 105 | 112 | 35 | 46 | 97 | 104 | 43 |
119 | 28 | 29 | 114 | 111 | 36 | 37 | 106 | 103 | 44 | 45 | 98 |
49 | 94 | 91 | 56 | 57 | 86 | 83 | 64 | 65 | 78 | 75 | 72 |
92 | 55 | 50 | 93 | 84 | 63 | 58 | 85 | 76 | 71 | 66 | 77 |
54 | 89 | 96 | 51 | 62 | 81 | 88 | 59 | 70 | 73 | 80 | 67 |
95 | 52 | 53 | 90 | 87 | 60 | 61 | 82 | 79 | 68 | 69 | 74 |
69 | 74 | 79 | 68 | 29 | 114 | 119 | 28 | 61 | 82 | 87 | 60 |
75 | 72 | 65 | 78 | 115 | 32 | 25 | 118 | 83 | 64 | 57 | 86 |
66 | 77 | 76 | 71 | 26 | 117 | 116 | 31 | 58 | 85 | 84 | 63 |
80 | 67 | 70 | 73 | 120 | 27 | 30 | 113 | 88 | 59 | 62 | 81 |
21 | 122 | 127 | 20 | 53 | 90 | 95 | 52 | 13 | 130 | 135 | 12 |
123 | 24 | 17 | 126 | 91 | 56 | 49 | 94 | 131 | 16 | 9 | 134 |
18 | 125 | 124 | 23 | 50 | 93 | 92 | 55 | 10 | 133 | 132 | 15 |
128 | 19 | 22 | 121 | 96 | 51 | 54 | 89 | 136 | 11 | 14 | 129 |
45 | 98 | 103 | 44 | 5 | 138 | 143 | 4 | 37 | 106 | 111 | 36 |
99 | 48 | 41 | 102 | 139 | 8 | 1 | 142 | 107 | 40 | 33 | 110 |
42 | 101 | 100 | 47 | 2 | 141 | 140 | 7 | 34 | 109 | 108 | 39 |
104 | 43 | 46 | 97 | 144 | 3 | 6 | 137 | 112 | 35 | 38 | 105 |
In another example below, we have divided the order 12 square into four order 6 squares. Each of the order 6 squares are filled with eighteen small numbers and their complements using bordering technique given by al-Antaki. If we remove the shaded borders of the order 6 subsquares and form an order 8 square, then this order 8 square is again a magic square. In its full generality, we can take any m2/2 smaller numbers together with their complements to n2 + 1 to fill the subsquares, not necessarily in continuous sequence.
60 | 82 | 88 | 56 | 90 | 59 | 24 | 118 | 124 | 20 | 126 | 23 |
64 | 69 | 74 | 79 | 68 | 81 | 28 | 33 | 110 | 115 | 32 | 117 |
83 | 75 | 72 | 65 | 78 | 62 | 119 | 111 | 36 | 29 | 114 | 26 |
84 | 66 | 77 | 76 | 71 | 61 | 120 | 30 | 113 | 112 | 35 | 25 |
58 | 80 | 67 | 70 | 73 | 87 | 22 | 116 | 31 | 34 | 109 | 123 |
86 | 63 | 57 | 89 | 55 | 85 | 122 | 27 | 21 | 125 | 19 | 121 |
6 | 136 | 142 | 2 | 144 | 5 | 42 | 100 | 106 | 38 | 108 | 41 |
10 | 15 | 128 | 133 | 14 | 135 | 46 | 51 | 92 | 97 | 50 | 99 |
137 | 129 | 18 | 11 | 132 | 8 | 101 | 93 | 54 | 47 | 96 | 44 |
138 | 12 | 131 | 130 | 17 | 7 | 102 | 48 | 95 | 94 | 53 | 43 |
4 | 134 | 13 | 16 | 127 | 141 | 40 | 98 | 49 | 52 | 91 | 105 |
140 | 9 | 3 | 143 | 1 | 139 | 104 | 45 | 39 | 107 | 37 | 103 |
Medjig-method for squares of even order 2''n'', where ''n'' > 2
In this method a magic square is "multiplied" with a medjig square to create a larger magic square. The namesake of this method derives from mathematical game called medjig created by Willem Barink in 2006, although the method itself is much older. An early instance of a magic square constructed using this method occurs in Yang Hui's text for order 6 magic square. The LUX method to construct singly even magic squares is a special case of the medjig method, where only 3 out of 24 patterns are used to construct the medjig square.The pieces of the medjig puzzle are 2×2 squares on which the numbers 0, 1, 2 and 3 are placed. There are three basic patterns by which the numbers 0, 1, 2 and 3 can be placed in a 2×2 square, where 0 is at the top left corner:
0 | 1 |
2 | 3 |
0 | 1 |
3 | 2 |
0 | 2 |
3 | 1 |
Each pattern can be reflected and rotated to obtain 8 equivalent patterns, giving us a total of 3×8 = 24 patterns. The aim of the puzzle is to take n2 medjig pieces and arrange them in an n × n medjig square in such a way that each row, column, along with the two long diagonals, formed by the medjig square sums to 3n, the magic constant of the medjig square. An n × n medjig square can create a 2n × 2n magic square where n > 2.
Given an n×n medjig square and an n×n magic square base, a magic square of order 2n×2n can be constructed as follows:
- Each cell of an n×n magic square is associated with a corresponding 2×2 subsquare of the medjig square
- Fill each 2×2 subsquares of the medjig square with the four numbers from 1 to 4n2 that equal the original number modulo n2, i.e. x+n2y where x is the corresponding number from the magic square and y is a number from 0 to 3 in the 2×2 subsquares.
1 | 0 | 1 | - |
5 | 2 | 3 | - |
3 | 2 | 4 | 3 |
1 | 0 | 1 | - |
5 | 3 | 2 | - |
4 | 3 | 3 | 2 |
2 | 0 | 2 | - |
4 | 3 | 1 | - |
5 | 3 | 3 | 1 |
Doubly even squares: The smallest even ordered medjig square is of order 2 with magic constant 6. While it is possible to construct a 2×2 medjig square, we cannot construct a 4×4 magic square from it since 2×2 magic squares required to "multiply" it does not exist. Nevertheless, it is worth constructing these 2×2 medjig squares. There exists 96 such 2×2 medjig squares. In the examples below, each 2×2 medjig square is made by combining different orientations of a single medjig piece.
0 | 1 | 3 | 2 |
2 | 3 | 1 | 0 |
3 | 2 | 0 | 1 |
1 | 0 | 2 | 3 |
0 | 1 | 2 | 3 |
3 | 2 | 1 | 0 |
1 | 0 | 3 | 2 |
2 | 3 | 0 | 1 |
0 | 2 | 3 | 1 |
3 | 1 | 0 | 2 |
0 | 2 | 3 | 1 |
3 | 1 | 0 | 2 |
We can use the 2×2 medjig squares to construct larger even ordered medjig squares. One possible approach is to simply combine the 2×2 medjig squares together. Another possibility is to wrap a smaller medjig square core with a medjig border. The pieces of a 2×2 medjig square can form the corner pieces of the border. An example of an 8×8 magic square is constructed below by combining four copies of the left most 2×2 medjig square given above:
1 | 14 | 4 | 15 |
8 | 11 | 5 | 10 |
13 | 2 | 16 | 3 |
12 | 7 | 9 | 6 |
0 | 1 | 3 | 2 | 0 | 1 | 3 | 2 |
2 | 3 | 1 | 0 | 2 | 3 | 1 | 0 |
3 | 2 | 0 | 1 | 3 | 2 | 0 | 1 |
1 | 0 | 2 | 3 | 1 | 0 | 2 | 3 |
0 | 1 | 3 | 2 | 0 | 1 | 3 | 2 |
2 | 3 | 1 | 0 | 2 | 3 | 1 | 0 |
3 | 2 | 0 | 1 | 3 | 2 | 0 | 1 |
1 | 0 | 2 | 3 | 1 | 0 | 2 | 3 |
1 | 17 | 62 | 46 | 4 | 20 | 63 | 47 |
33 | 49 | 30 | 14 | 36 | 52 | 31 | 15 |
56 | 40 | 11 | 27 | 53 | 37 | 10 | 26 |
24 | 8 | 43 | 59 | 21 | 5 | 42 | 58 |
13 | 29 | 50 | 34 | 16 | 32 | 51 | 35 |
45 | 61 | 18 | 2 | 48 | 64 | 19 | 3 |
60 | 44 | 7 | 23 | 57 | 41 | 6 | 22 |
28 | 12 | 39 | 55 | 25 | 9 | 38 | 54 |
The next example is constructed by bordering a 2×2 medjig square core.
1 | 14 | 4 | 15 |
8 | 11 | 5 | 10 |
13 | 2 | 16 | 3 |
12 | 7 | 9 | 6 |
0 | 1 | 0 | 1 | 2 | 3 | 3 | 2 |
2 | 3 | 3 | 2 | 1 | 0 | 1 | 0 |
0 | 3 | 0 | 2 | 3 | 1 | 0 | 3 |
1 | 2 | 3 | 1 | 0 | 2 | 1 | 2 |
2 | 1 | 0 | 2 | 3 | 1 | 2 | 1 |
3 | 0 | 3 | 1 | 0 | 2 | 3 | 0 |
3 | 2 | 0 | 1 | 2 | 3 | 0 | 1 |
1 | 0 | 3 | 2 | 1 | 0 | 2 | 3 |
1 | 17 | 14 | 30 | 36 | 52 | 63 | 47 |
33 | 49 | 62 | 46 | 20 | 4 | 31 | 15 |
8 | 56 | 11 | 43 | 53 | 21 | 10 | 58 |
24 | 40 | 59 | 27 | 5 | 37 | 26 | 42 |
45 | 29 | 2 | 34 | 64 | 32 | 35 | 19 |
61 | 13 | 50 | 18 | 16 | 48 | 51 | 3 |
60 | 44 | 7 | 23 | 41 | 57 | 6 | 22 |
28 | 12 | 55 | 39 | 25 | 9 | 38 | 54 |
Singly even squares: Medjig square of order 1 does not exist. As such, the smallest odd ordered medjig square is of order 3, with magic constant 9. There are only 7 ways of partitioning the integer 9, our magic constant, into three parts. If these three parts correspond to three of the medjig pieces in a row, column or diagonal, then the relevant partitions for us are
Once a 3×3 medjig square has been constructed, we can convert it into a 6×6 magic square. For example:
8 | 1 | 6 |
3 | 5 | 7 |
4 | 9 | 2 |
2 | 3 | 0 | 2 | 0 | 2 |
1 | 0 | 3 | 1 | 3 | 1 |
3 | 1 | 1 | 2 | 2 | 0 |
0 | 2 | 0 | 3 | 3 | 1 |
3 | 2 | 2 | 0 | 0 | 2 |
0 | 1 | 3 | 1 | 1 | 3 |
26 | 35 | 1 | 19 | 6 | 24 |
17 | 8 | 28 | 10 | 33 | 15 |
30 | 12 | 14 | 23 | 25 | 7 |
3 | 21 | 5 | 32 | 34 | 16 |
31 | 22 | 27 | 9 | 2 | 20 |
4 | 13 | 36 | 18 | 11 | 29 |
There are 1,740,800 such 3×3 medjig squares. An easy approach to construct higher order odd medjig square is by wrapping an smaller odd ordered medjig square with a medjig border, just as with even ordered medjig squares. Approaches such as the LUX method can also be used. In the example below, a 5×5 medjig square is created by wrapping a medjig border around a 3×3 medjig square given previously:
17 | 24 | 1 | 8 | 15 |
23 | 5 | 7 | 14 | 16 |
4 | 6 | 13 | 20 | 22 |
10 | 12 | 19 | 21 | 3 |
11 | 18 | 25 | 2 | 9 |
0 | 1 | 3 | 1 | 0 | 1 | 3 | 1 | 3 | 2 |
2 | 3 | 0 | 2 | 2 | 3 | 0 | 2 | 1 | 0 |
3 | 0 | 2 | 3 | 0 | 2 | 0 | 2 | 1 | 2 |
1 | 2 | 1 | 0 | 3 | 1 | 3 | 1 | 3 | 0 |
0 | 2 | 3 | 1 | 1 | 2 | 2 | 0 | 1 | 3 |
1 | 3 | 0 | 2 | 0 | 3 | 3 | 1 | 0 | 2 |
3 | 0 | 3 | 2 | 2 | 0 | 0 | 2 | 1 | 2 |
1 | 2 | 0 | 1 | 3 | 1 | 1 | 3 | 3 | 0 |
3 | 2 | 1 | 3 | 1 | 0 | 1 | 3 | 0 | 1 |
1 | 0 | 2 | 0 | 3 | 2 | 2 | 0 | 2 | 3 |
17 | 42 | 99 | 49 | 1 | 26 | 83 | 33 | 90 | 65 |
67 | 92 | 24 | 74 | 51 | 76 | 8 | 58 | 40 | 15 |
98 | 23 | 55 | 80 | 7 | 57 | 14 | 64 | 41 | 66 |
48 | 73 | 30 | 5 | 82 | 32 | 89 | 39 | 91 | 16 |
4 | 54 | 81 | 31 | 38 | 63 | 70 | 20 | 47 | 97 |
29 | 79 | 6 | 56 | 13 | 88 | 95 | 45 | 22 | 72 |
85 | 10 | 87 | 62 | 69 | 19 | 21 | 71 | 28 | 53 |
35 | 60 | 12 | 37 | 94 | 44 | 46 | 96 | 78 | 3 |
86 | 61 | 43 | 93 | 100 | 25 | 27 | 77 | 9 | 34 |
36 | 11 | 68 | 18 | 95 | 75 | 52 | 2 | 59 | 84 |
Solving partially completed magic squares
Similar to the Sudoku and KenKen puzzles, solving partially completed magic squares has become a popular mathematical puzzle. Puzzle-solving centers on analyzing the initial given values and possible values of the empty squares. One or more solutions arise as the participant uses logic and permutation group theory to rule out all unsuitable number combinations.Variations of the magic square
Extra constraints
Certain extra restrictions can be imposed on magic squares.If raising each number to the nth power yields another magic square, the result is a bimagic, a trimagic, or, in general, a multimagic square.
A magic square in which the number of letters in the name of each number in the square generates another magic square is called an alphamagic square.
There are magic squares consisting entirely of primes. Rudolf Ondrejka discovered the following 3×3 magic square of primes, in this case nine Chen primes:
17 | 89 | 71 |
113 | 59 | 5 |
47 | 29 | 101 |
The Green–Tao theorem implies that there are arbitrarily large magic squares consisting of primes.
The following "reversible magic square" has a magic constant of 264 both upside down and right way up:
96 | 11 | 89 | 68 |
88 | 69 | 91 | 16 |
61 | 86 | 18 | 99 |
19 | 98 | 66 | 81 |
When the extra constraint is to display some date, especially a birth date, then such magic squares are called birthday magic square. An early instance of such birthday magic square was created by Srinivasa Ramanujan. He created a 4×4 square in which he entered his date of birth in DD-MM-CC-YY format in the top row and the magic happened with additions and subtractions of numbers in squares. Not only do the rows, columns, and diagonals add up to the same number, but the four corners, the four middle squares, the first and last rows two middle numbers, and the first and last columns two middle numbers all add up to the sum of 139.
Different constraints
Sometimes the rules for magic squares are relaxed, so that only the rows and columns but not necessarily the diagonals sum to the magic constant.In heterosquares and antimagic squares, the 2n + 2 sums must all be different.
Multiplicative magic squares
Instead of adding the numbers in each row, column and diagonal, one can apply some other operation. For example, a multiplicative magic square has a constant product of numbers. A multiplicative magic square can be derived from an additive magic square by raising 2 to the power of each element, because the logarithm of the product of 2 numbers is the sum of logarithm of each. Alternatively, if any 3 numbers in a line are 2a, 2b and 2c, their product is 2a+b+c, which is constant if a+b+c is constant, as they would be if a, b and c were taken from ordinary magic square. For example, the original Lo-Shu magic square becomes:16 | 512 | 4 |
8 | 32 | 128 |
256 | 2 | 64 |
Other examples of multiplicative magic squares include:
2 | 9 | 12 |
36 | 6 | 1 |
3 | 4 | 18 |
1 | 6 | 20 | 56 |
40 | 28 | 2 | 3 |
14 | 5 | 24 | 4 |
12 | 8 | 7 | 10 |
27 | 50 | 66 | 84 | 13 | 2 | 32 |
24 | 52 | 3 | 40 | 54 | 70 | 11 |
56 | 9 | 20 | 44 | 36 | 65 | 6 |
55 | 72 | 91 | 1 | 16 | 36 | 30 |
4 | 24 | 45 | 60 | 77 | 12 | 26 |
10 | 22 | 48 | 39 | 5 | 48 | 63 |
78 | 7 | 8 | 18 | 40 | 33 | 60 |
Multiplicative magic squares of complex numbers
Still using Ali Skalli's non iterative method, it is possible to produce an infinity of multiplicative magic squares of complex numbers belonging to set. On the example below, the real and imaginary parts are integer numbers, but they can also belong to the entire set of real numbers.The product is: −352,507,340,640 − 400,599,719,520 i.
21 | +14i | −70 | +30i | −93 | −9i | −105 | −217i | 16 | +50i | 4 | −14i | 14 | −8i |
63 | −35i | 28 | +114i | −14i | 2 | +6i | 3 | −11i | 211 | +357i | −123 | −87i | |
31 | −15i | 13 | −13i | −103 | +69i | −261 | −213i | 49 | −49i | −46 | +2i | −6 | +2i |
102 | −84i | −28 | −14i | 43 | +247i | −10 | −2i | 5 | +9i | 31 | −27i | −77 | +91i |
−22 | −6i | 7 | +7i | 8 | +14i | 50 | +20i | −525 | −492i | −28 | −42i | −73 | +17i |
54 | +68i | 138 | −165i | −56 | −98i | −63 | +35i | 4 | −8i | 2 | −4i | 70 | −53i |
24 | +22i | −46 | −16i | 6 | −4i | 17 | +20i | 110 | +160i | 84 | −189i | 42 | −14i |
Additive-multiplicative magic and semimagic squares
Additive-multiplicative magic squares and semimagic squares satisfy properties of both ordinary and multiplicative magic squares and semimagic squares, respectively.It is unknown if any additive-multiplicative magic squares smaller than 8×8 exist, but it has been proven that no 3×3 or 4×4 additive-multiplicative magic squares and no 3×3 additive-multiplicative semimagic squares exist. Geometric magic squaresMagic squares may be constructed which contain geometric shapes instead of numbers. Such squares, known as geometric magic squares, were invented and named by Lee Sallows in 2001.In the example shown the shapes appearing are two dimensional. It was Sallows' discovery that all magic squares are geometric, the numbers that appear in numerical magic squares can be interpreted as a shorthand notation which indicates the lengths of straight line segments that are the geometric 'shapes' occurring in the square. That is, numerical magic squares are that special case of a geometric magic square using one dimensional shapes. Area magic squaresIn 2017, following initial ideas of and , the first linear area magic square was constructed by Walter Trump.Other magic shapesOther two dimensional shapes than squares can be considered. The general case is to consider a design with N parts to be magic if the N parts are labeled with the numbers 1 through N and a number of identical sub-designs give the same sum. Examples include magic circles, magic rectangles, magic triangles magic stars, magic hexagons, magic diamonds. Going up in dimension results in magic spheres, magic cylinders, magic cubes, magic parallelepiped, magic solids, and other magic hypercubes.Possible magic shapes are constrained by the number of equal-sized, equal-sum subsets of the chosen set of labels. For example, if one proposes to form a magic shape labeling the parts with, the sub-designs will have to be labeled with and. Related problemsOver the years, many mathematicians, including Euler, Cayley and Benjamin Franklin have worked on magic squares, and discovered fascinating relations.''n''-Queens problemIn 1992, Demirörs, Rafraf, and Tanik published a method for converting some magic squares into n-queens solutions, and vice versa.Enumeration of magic squaresAs mentioned above, the set of normal squares of order three constitutes a single equivalence class-all equivalent to the Lo Shu square. Thus there is basically just one normal magic square of order 3. But the number of distinct normal magic squares rapidly increases for higher orders. There are 880 distinct magic squares of order 4 and 275,305,224 of order 5. These squares are respectively displayed on 255 magic tori of order 4, and 251,449,712 of order 5. The number of magic tori and distinct normal squares is not yet known for any higher order.Algorithms tend to only generate magic squares of a certain type or classification, making counting all possible magic squares quite difficult. Traditional counting methods have proven unsuccessful, statistical analysis using the Monte Carlo method has been applied. The basic principle applied to magic squares is to randomly generate n × n matrices of elements 1 to n2 and check if the result is a magic square. The probability that a randomly generated matrix of numbers is a magic square is then used to approximate the number of magic squares. More intricate versions of the Monte Carlo method, such as the exchange Monte Carlo, and Monte Carlo backtracking have produced even more accurate estimations. Using these methods it has been shown that the probability of magic squares decreases rapidly as n increases. Using fitting functions give the curves seen to the right. Magic squares in occultismMagic squares of order 3 through 9, assigned to the seven planets, and described as means to attract the influence of planets and their angels during magical practices, can be found in several manuscripts all around Europe starting at least since the 15th century. Among the best known, the Liber de Angelis, a magical handbook written around 1440, is included in Cambridge Univ. Lib. MS Dd.xi.45. The text of the Liber de Angelis is very close to that of De septem quadraturis planetarum seu quadrati magici, another handbook of planetary image magic contained in the Codex 793 of the Biblioteka Jagiellońska. The magical operations involve engraving the appropriate square on a plate made with the metal assigned to the corresponding planet, as well as performing a variety of rituals. For instance, the 3×3 square, that belongs to Saturn, has to be inscribed on a lead plate. It will, in particular, help women during a difficult childbirth.In about 1510 Heinrich Cornelius Agrippa wrote De Occulta Philosophia, drawing on the Hermetic and magical works of Marsilio Ficino and Pico della Mirandola. In its 1531 edition, he expounded on the magical virtues of the seven magical squares of orders 3 to 9, each associated with one of the astrological planets, much in the same way as the older texts did. This book was very influential throughout Europe until the counter-reformation, and Agrippa's magic squares, sometimes called kameas, continue to be used within modern ceremonial magic in much the same way as he first prescribed. of Venus, drawn on the magic square of Venus. Each Hebrew letter provides a numerical value, giving the vertices of the sigil. The most common use for these kameas is to provide a pattern upon which to construct the sigils of spirits, angels or demons; the letters of the entity's name are converted into numbers, and lines are traced through the pattern that these successive numbers make on the kamea. In a magical context, the term magic square is also applied to a variety of word squares or number squares found in magical grimoires, including some that do not follow any obvious pattern, and even those with differing numbers of rows and columns. They are generally intended for use as talismans. For instance the following squares are: The Sator square, one of the most famous magic squares found in a number of grimoires including the Key of Solomon; a square "to overcome envy", from The Book of Power; and two squares from The Book of the Sacred Magic of Abramelin the Mage, the first to cause the illusion of a superb palace to appear, and the second to be worn on the head of a child during an angelic invocation:
Magic squares in popular culture
|