The smallest (and unique
up to rotation and reflection) nontrivial case of a magic square, measuring 3×3
In recreational mathematics and combinatorial design, a magic square^{[1]} is a $n\times n$ square grid (where n is the number of cells on each side) filled with distinct positive integers in the range $1,2,...,n^{2}$ such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal.^{[2]} The sum is called the magic constant or magic sum of the magic square. A square grid with n 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 (also referred to as doubly even) if n = 4k (e.g. 4, 8, 12, and so on), oddly even (also known as singly even) if n = 4k + 2 (e.g. 6, 10, 14, and so on). 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 associated magic squares, pandiagonal magic squares, mostperfect magic square, 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
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.^{[3]}^{[4]} Magic squares are also called normal magic squares, in the sense that there are nonnormal magic squares^{[5]} which integers are not restricted in $1,2,...,n^{2}$. However, in some places, "magic squares" is used as a general term to cover both the normal and nonnormal ones, especially when nonnormal 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.
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 circa 983, the Encyclopedia of the Brethren of Purity (Rasa'il Ihkwan alSafa). 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 Alma'arif, for occult purposes.^{[6]} 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 rediscovered 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 PreColumbian Americans.
China
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 a 1st century book Da Dai Liji (Record of Rites by the Elder Dai).^{[7]}^{[8]}^{[9]} These numbers also occur in a possibly earlier mathematical text called Shushu jiyi (Memoir on Some Traditions of Mathematical Art), said to be written in 190 BCE. This is the earliest appearance of a magic square on record; and it was mainly used for divination and astrology.^{[7]} The 3×3 magic square was referred to as the "Nine Halls" by earlier Chinese mathematicians.^{[9]} 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.^{[7]}^{[9]} The oldest surviving Chinese treatise on the systematic methods for constructing larger magic squares is Yang Hui's Xugu zheqi suanfa (Continuation of Ancient Mathematical Methods for Elucidating the Strange) written in 1275.^{[7]}^{[9]} 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.^{[9]} He gives a magic square of order 3, two squares for each order of 4 to 8, one of order nine, and one semimagic square of order 10. He also gives six magic circles of varying complexity.^{[10]}

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 

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, 4, 5, 6, and 9 are taken from Yang Hui's treatise, in which the Luo Shu principle is clearly evident.^{[9]}^{[11]} 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.^{[9]} After Yang Hui, magic squares frequently occur in Chinese mathematics such as in Ding Yidong's Dayan suoyin (circa 1300), Chen Dawei's Suanfa tongzong (1593), Fang Zhongtong's Shuduyan (1661) which contains magic circles, cubes and spheres, Zhang Chao's Xinzhai zazu (circa 1650), who published China's the first magic square of order ten, and lastly Bao Qishou's Binaishanfang ji (circa 1880), who gave various three dimensional magic configurations.^{[7]}^{[11]} 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 Islamic, the Indian, or the 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.^{[9]} 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.^{[9]}
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 preIslamic times.^{[12]} 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.^{[13]}^{[14]}^{[15]} The first datable appearance of magic square of order 3 occur in the alchemical works of J?bir ibn Hayy?n (fl. c. 721 c. 815). While it is known that treatises on magic squares were written in the 9th century, the earliest extant treaties we have date from the 10thcentury: one by Abu'lWafa alBuzjani (circa 998) and another by Ali b. Ahmad alAntaki (circa 987).^{[14]}^{[16]}^{[17]} These early treatise were purely mathematical, and the Arabic designation for magic squares is wafq ala'dad which translates as harmonious disposition of the numbers.^{[15]} By the end of 10th century, the Islamic mathematicians had understood how to construct bordered squares of any order as well as simple magic squares of small orders (n [14] A specimen of magic squares of orders 3 to 9 devised by Islamic mathematicians appear in an encyclopedia from Baghdad circa 983, the Rasa'il Ikhwan alSafa (the Encyclopedia of the Brethren of Purity).^{[18]} The squares of order 3 to 7 from Rasa'il are given below:^{[18]}

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 evenlyeven orders; the more difficult case of evenlyodd case (n = 4k + 2) was solved by Ibn alHaytham with k even (circa 1040), and completely by the beginning of 12th century, if not already in the latter half of the 11th century.^{[14]} 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.^{[14]} 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.^{[14]} One such occultist was the Egyptian Ahmad alBuni (circa 1225), who gave general methods on constructing bordered magic squares; another one was the 18th century Nigerian alKishnawi.^{[19]}
The magic square of order three was described as a childbearing charm^{[20]}^{[21]} since its first literary appearances in the alchemical works of J?bir ibn Hayy?n (fl. c. 721 c. 815)^{[21]}^{[22]} and alGhaz?l? (10581111)^{[23]} 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 (known as Azarquiel in Europe) (10291087) Kit?b tadb?r?t alkaw?kib (Book on the Influences of the Planets).^{[24]} A century later, the Egyptian scholar Ahmad alBuni attributed mystical properties to magic squares in his highly influential book Shams alMa'arif (The Book of the Sun of Gnosis and the Subtleties of Elevated Things), 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.^{[25]} There are also references to the use of magic squares in astrological calculations, a practice that seems to have originated with the Arabs.^{[26]}^{[27]}
India
The 3×3 magic square has been a part of rituals in India since ancient times, and still is today. For instance, the KuberaKolam, a magic square of order three, is commonly painted on floors in India. It is essentially the same as the Lo Shu Square, but with 19 added to each number, giving a magic constant of 72 (below, square on the left). The 3×3 magic square first appears in India in Gargasamhita by Garga, who recommends its use to pacify the nine planets (navagraha). The oldest version of this text dates from 100 CE; 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 (ca. 900 CE) by Vrnda, which was prescribed to women in labor in order to have easy delivery.^{[28]} Vrnda's square is given below (square on the right), which sum to 30.
23 
28 
21 
22 
24 
26 
27 
20 
25 


The earliest unequivocal occurrence of magic square is found in a work called Kaksaputa, composed by the alchemist Nagarjuna around 1st 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.^{[29]} 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 pandiagonal magic square, where the broken diagonals (e.g. 16+22+34+28, 18+24+32+26, etc) sum to 100. It is also an instance of a most perfect magic square, where every 2×2 subsquare, four corners of any 3×3 subsquare, four corners of the 4×4 square, the four corners of any 2×4 or 4×2 subrectangle, and the four corners of oblong diagonals (18+24+32+26 and 10+16+34+40) all sum to 100. Furthermore, the corners of eight trapezoids (16+18+32+34, 44+22+28+6, etc) all sum to 100. 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.
The oldest datable 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.^{[29]}^{[28]}
2 
3 
5 
8 
5 
8 
2 
3 
4 
1 
7 
6 
7 
6 
4 
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 pandiagonal 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.^{[30]} One of the possible magic squares is given below:
10 
3 
13 
8 
5 
16 
2 
11 
4 
9 
7 
14 
15 
6 
12 
1 
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.^{[30]} His book also contains a method for constructing a magic square of order four when a constant sum is given. It also contains the Nagarjuniya square.^{[28]}
Around 12thcentury, a 4×4 magic square was inscribed on the wall of Parshvanath temple in Khajuraho, India. Several Jain hyms teach how to make magic squares, although they are undatable.^{[28]}
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 (ca. 1315). 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 (odd, evenly even, and oddly even) according to its order; gives a square of order six; and prescribes one method each for constructing even and odd squares.^{[28]} 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.^{[28]} 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.^{[28]} Below is Pheru's square of order six.^{[28]}
1 
32 
34 
33 
5 
6 
30 
8 
28 
27 
11 
7 
24 
23 
15 
16 
14 
19 
13 
20 
21 
22 
17 
18 
12 
26 
9 
10 
29 
25 
31 
2 
4 
3 
35 
36 
The next comprehensive work on magic figures was taken up by Narayana Pandit, who in the fourteenth chapter of his Ganita Kaumudi (1356) gives general methods for the constructions of all sorts of magic squares with the principles governing such constructions. It consists of 55 verses for rules and 17 verses for examples. Narayana gives the method to make a magic squares of order four using knight's move; enumerates the number of pandiagonal magic squares of order four, 384, including every variation made by rotation and inversion; 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 recounts some older methods of construction, his folding method seems to be his own invention, which was later rediscovered by De la Hire. 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.^{[29]}^{[28]} Below is an example of 4×4 magic square constructed by knight's move as given by Narayana. This is also a pandiagonal as well as a mostperfect magic square.
1 
14 
4 
15 
8 
11 
5 
10 
13 
2 
16 
3 
12 
7 
9 
6 
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.^{[28]}
Latin Europe
This page from
Athanasius Kircher's
Oedipus Aegyptiacus (1653) belongs to a treatise on magic squares and shows the
Sigillum Iovis associated with Jupiter
Unlike in Persia and Arabia, we have better documentation of how the magic squares were transmitted to Europe. Around 1315, influenced by Islamic sources, the Greek Byzantine scholar Manuel Moschopoulos wrote a mathematical treatise on the subject of magic squares, leaving out the mysticism of his Muslim 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.^{[31]} 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 alkaw?kib (Book on the Influences of the Planets) written by Ibn Zarkali of Toledo, AlAndalus, as planetary squares by 11th century.^{[24]} 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.^{[32]} Ibn Zarkali's work was translated as Libro de Astromagia in the 1280s,^{[33]} due to Alfonso X of Castille.^{[34]}^{[24]} 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.^{[35]}^{[24]}
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 (Treatise of the Abacus) by Paolo Dagomari.^{[36]}^{[37]} 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.^{[38]}^{[39]}
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 (1567), 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 book De occulta philosophia in 1531, where he devoted a chapter to the planetary squares. 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 (1653). 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.^{[32]}
In 1624 France, Claude Gaspard Bachet described the "diamond method" for constructing Agrippa's odd ordered squares in his book Problèmes Plaisants. 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 (1704), and then later by Philippe de La Hire in Mémoires de l'Académie des Sciences for the Royal Academy (1705), and by Joseph Sauveur in Construction des quarrés magiques (1710). In Divers ouvrages de mathematique et de physique published posthumously in 1693, Bernard Frenicle de Bessy demonstrated that there were exactly 880 distinct magic squares of order four. De la Hire also introduced concentric bordered square 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'OnsleBray rediscovered the method of constructing doubly even and singly even squares using bordering technique. 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.^{[32]}^{[40]}
In the 19th century, Bernard Violle gave the most comprehensive treatment of magic squares in his three volume Traité complet des carrés magiques (18371838), 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, (thus calling them Nasik squares) in a series of articles: On the knight's path (1877), On the General Properties of Nasik Squares (1878), On the General Properties of Nasik Cubes (1878), On the construction of Nasik Squares of any order (1896). He showed that it is impossible to have normal singlyeven 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 (1888).^{[40]} 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
Lo Shu from "The Astronomical Phenomena" (
Tien Yuan Fa Wei). Compiled by Bao Yunlong in 13th century, published during the
Ming dynasty, 14571463.
Luo Shu magic square
Legends dating from as early as 650 BC tell the story of the Lo Shu () or "scroll of the river Lo".^{[11]} 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 wellknown 12thcentury 4×4 magic square inscribed on the wall of the Parshvanath temple in Khajuraho, India.^{[29]}^{[28]}^{[41]}
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 mostperfect 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 (of the 4×4 as well as the four contained 3×3 grids). This sum can also be found in the four outer numbers clockwise from the corners (3+8+14+9) and likewise the four counterclockwise (the locations of four queens in the two solutions of the 4 queens puzzle^{[42]}), the two sets of four symmetrical numbers (2+8+9+15 and 3+5+12+14), the sum of the middle two entries of the two outer columns and rows (5+9+8+12 and 3+2+15+14), and in four kite or cross shaped quartets (3+5+11+15, 2+10+8+14, 3+9+7+15, and 2+6+12+14). 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.^{[43]}
Sagrada Família magic square
A magic square on the Sagrada Família church façade
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.^{[44]} 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 as above, as two numbers (10 and 14) are duplicated and two (12 and 16) are absent, failing the 1>n^{2} rule. Similarly to Dürer's magic square, the Sagrada Familia's magic square can also be extended to a magic cube.^{[45]}
Properties of magic squares
Magic constant
The constant that is the sum of every row, column and diagonal is called the magic constant or magic sum, M. Every normal magic square has a constant dependent on the order n, calculated by the formula $M=n(n^{2}+1)/2$, since the sum of $1,2,...,n^{2}$ is $n^{2}(n^{2}+1)/2$ which when divided by the order n is 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 (sequence A006003 in the OEIS).
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 (that is, where order n = 2).^{[46]}
Number of magic squares of a given order
Excluding rotations and reflections, there is exactly one 3×3 magic square, exactly 880 4×4 magic squares, and exactly 275,305,224 5×5 magic squares. For the 6×6 case, there are estimated to be approximately 1.8 × 10^{19} squares.^{[47]}
An invariant
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.^{[47]} (Thus for example a corner cell of a 3×3 square has a distance of ${\sqrt {2}},$ a noncorner edge cell has a distance of 1, and the center cell has a distance of 0.) Then all magic squares of a given order have the same moment of inertia as each other. For the order3 case the moment of inertia is always 60, while for the order4 case the moment of inertia is always 340. In general, for the n×n case the moment of inertia is $n^{2}(n^{4}1)/12.$^{[47]}
Classification of magic squares
Euler diagram of requirements of some types of 4×4 magic squares. Cells of the same colour sum to the magic constant. * In 4×4 mostperfect magic squares, any 2 cells that are 2 cells diagonally apart (including wraparound) sum to half the magic constant, hence any 2 such pairs also sum to the magic constant.
While the classification of magic squares can be done in many way, some useful categories are given below. An n×n square array of integers is called:
 Semimagic 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.
 Associated 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 n^{2} + 1. They are also called symmetric magic squares.
 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. Normal panmagic squares exist only for squares of odd and doubly even order.
 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.
 Composite magic square when it is a magic square that has smaller magic squares embedded in them.
 Most perfect magic square when it is a pandiagonal magic square with two further properties (i) each 2×2 subsquare add to 1/k of the magic constant where n = 4k, and (ii) all pairs of integers distant n/2 along any diagonal (major or broken) are complementary (i.e. they sum to n^{2} + 1). Most perfect magic squares exist only for squares of doubly even order.
Transformations that preserve the magic property
 A magic square remains magic when its numbers are multiplied by any fixed number.^{[48]}
 A magic square remains magic when its numbers are added to or subtracted from any fixed number. In particular, if every element is subtracted from n^{2} + 1, we obtain the complement of the original square.^{[48]} In the example below, a 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.^{[49]}^{[48]} 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:
 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 (i.e. cell symmetrically opposite from the center) of the same diagonal.^{[48]}^{[40]} For an even square, there are n/2 pairs of rows and columns that can be interchanged; thus we can obtain 2^{n/2} equivalent magic squares by combining such interchanges. For odd square, there are (n  1)/2 pairs of rows and columns that can be interchanged; and 2^{(n1)/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 

 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.^{[48]} 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 

 An associated magic square remains an associated magic square 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 2^{n/2} × 2^{n/2} = 2^{n} equivalent magic squares by combining such interchanges. For odd square, there are (n  1)/2 pairs of rows or columns that can be interchanged; and 2^{n1} equivalent magic squares obtained by combining such interchanges. Interchanging all the rows flips the square vertically (i.e. reflected along the horizontal axis), while interchanging all the columns flips the square horizontally (i.e. reflected along the vertical axis). In the example below, a 4×4 associated magic square on the left is transformed into a square on the right by interchanging the 2nd and 3rd 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 

 A pandiagonal magic square remains a pandiagonal magic square under cyclic shifting of rows or of columns or both.^{[48]} This allows us to position a given number in any one of the n^{2} cells of an n order square. Thus, for a given panmagic square, there are n^{2} equivalent panmagic squares. In the example below, the original square on the left is transformed by shifting the 1st row to the bottom to obtain a new panmagic square in the middle. Next, the 1st and 2nd column of the middle panmagic square is circularly shifted to the right to obtain a new panmagic 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 

 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 ((n2)! × (n4)! × ··· × 3!)^{2} equivalent bordered squares. When n >= 6 is even, there are ((n2)! × (n4)! × ··· × 4!)^{2} equivalent bordered squares. In the example below, a square of order 5 is given whose border row has been permuted. We can obtain (3!)^{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 composite magic square remains a composite magic square when the embedded magic squares undergo transformations that do not disturb the magic property (e.g. rotation, reflection, shifting of rows and columns, and so on).
Specific methods of construction
There are many ways to construct magic squares, but the standard (and most simple) way is to follow certain configurations/formulas which generate regular patterns. Magic squares exist for all values of n, with only one exception: it is impossible to construct a magic square of order 2. Magic squares can be classified into three types: odd, doubly even (n divisible by four) and singly even (n even, but not divisible by four). Odd and doubly even magic squares are easy to generate; the construction of singly even magic squares is more difficult but several methods exist, including the LUX method for magic squares (due to John Horton Conway) 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.^{[50]}

Unsolved problem in mathematics:

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 (sequence in the OEIS). The number for n = 6 has been estimated to be ^{[51]}^{[52]}
Crossreferenced 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 (sequence in the OEIS).
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 + (a + b) 
c  a 
c  (a  b) 
c 
c + (a  b) 
c + a 
c  (a + b) 
c + b 
These 9 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.
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 (Du Royaume de Siam, 1693), in the chapter entitled The problem of the magical square according to the Indians.^{[53]} 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.
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.
Order 3
8 
1 
6 
3 
5 
7 
4 
9 
2 

Order 5
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 

Order 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
Doubly even means that n is an even multiple of an even integer; or 4p (e.g. 4, 8, 12), 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. The resulting square is also known as a mystic square. 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 (This is reflection of Albrecht Dürer's square.) Go left to right through the square counting and filling in on the diagonals only. Then continue by going left to right from the top left of the table and fill in counting down from 16 to 1. As shown below.
M = Order 4
1 


4 

6 
7 


10 
11 

13 


16 

M = Order 4
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 "truth" table, where a '1' indicates selecting from the square where the numbers are written in order 1 to n^{2} (lefttoright, toptobottom), and a '0' indicates selecting from the square where the numbers are written in reverse order n^{2} to 1. For M = 4, the "truth" table is as shown below, (third matrix from left.)
M = Order 4
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 

M = Order 4
16 
15 
14 
13 
12 
11 
10 
9 
8 
7 
6 
5 
4 
3 
2 
1 

M = Order 4
1 
0 
0 
1 
0 
1 
1 
0 
0 
1 
1 
0 
1 
0 
0 
1 

M = Order 4
1 
15 
14 
4 
12 
6 
7 
9 
8 
10 
11 
5 
13 
3 
2 
16 

Note that a) there are equal number of '1's and '0's; b) each row and each column are "palindromic"; c) the left and righthalves are mirror images; and d) the top and bottomhalves are mirror images (c & d imply b.) The truth table can be denoted as (9, 6, 6, 9) for simplicity (1nibble per row, 4 rows.) Similarly, for M=8, two choices for the truth table are (A5, 5A, A5, 5A, 5A, A5, 5A, A5) or (99, 66, 66, 99, 99, 66, 66, 99) (2nibbles per row, 8 rows.) For M=12, the truth table (E07, E07, E07, 1F8, 1F8, 1F8, 1F8, 1F8, 1F8, E07, E07, E07) yields a magic square (3nibbles per row, 12 rows.) It is possible to count the number of choices one has based on the truth table, taking rotational symmetries into account.
General methods of construction
Euler's method
Euler's method for constructing the magic square is similar to NarayanaDe la Hire's method. It consists of breaking the magic square into two primary squares, which when added 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 square by a pair of numbers as

?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, (?, ?, ?) = (0, 3, 6) and (a, b, c) = (1, 2, 3). 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 to note here is that
 a Greek letter is paired with a Latin letter only once.
Thus, the original square can now be split into two simpler squares:
The lettered squares are referred to as Greek square or Latin square if the 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, provided that the Greek and Latin alphabets are paired with each other only once. The converse of this statement is also often, but not always (e.g. bordered magic squares), 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 only once in a given column and a row.
This can be achieved by cyclic permutation of ?, ?, and ?. Satisfaction of these two conditions ensures that the resulting square is a semimagic square; and such Greek and Latin squares are said to be orthogonal to each other. To construct a magic square, we should also ensure that the diagonals sum to magic constant.
For the 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. Note that the Latin square is just a 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 


For the odd squares, this method explains why the Siamese method (method of De la Loubere) 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.
A peculiarity of the construction method given above for the odd magic squares is that the middle number (n^{2} + 1)/2 will always appear at the center cell of the magic square. Since there are (n  1)! ways to arrange the skew diagonal terms, we can obtain (n  1)! Greek squares this way; same with the Latin squares. Also, since each Greek square can be paired with (n  1)! Latin squares, and since for each of Greek square the middle term may be arbitrarily placed in the main diagonal or the skew diagonal (and correspondingly along the skew diagonal or the main diagonal for the Latin squares), we can construct a total of 2 × (n  1)! × (n  1)! magic squares using this method. For n = 3, 5, and 7, this will give 8, 1152, and 1,036,800 different magic squares, respectively. Dividing by 8 to neglect equivalent squares due to rotation and reflections, we obtain 1, 144, and 129,600 essentially different magic squares, respectively.
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 (from bottom to top). The primary square is obtained by rotating the root square counterclockwise 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 (two cells right, two cells down). When a collision occurs, the break move is to move one cell up. Also note that 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. We have recreated the so called lozenge method.

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 
18 
22 
1 
10 
14 

A variation of the above example, where the skew diagonal sequence is taken in different order, is given below. The resulting magic square 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 downwardsright move. When a collision occurs, the break move is to shift two cells to the right.

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 

Another possible method of creating the root squares is to shift a row by two places to form the next row. The primary square is made by flipping the root square along the main diagonal and interchanging the corresponding numbers. This essentially recreates the knight's move (two cells up, one cell right). The break move is to move one cell up, one cell left. In this particular case, the square has been constructed such that 1 is at the center cell. The resulting square is a pandiagonal magic square. The central 3×3 square is also a magic square with constant 33. This square also has a further diabolical property that any five cells in quincunx pattern 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 as well as the middle cells of each side together with the central cell 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. The knight's move method to create a pandiagonal magic square is valid for all orders that are prime numbers greater than three.
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 recreated the magic square obtained by De la Loubere's method.
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 

We can also construct even ordered squares in this fashion, although it takes a bit of trial and error. An example of a 4×4 square is given below, which is also a pandiagonal magic square:
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 

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 

Euler's method has given rise to the study of GraecoLatin squares. Euler's method is valid for squares of any order except 2 and 6.
NarayanaDe la Hire's method
NarayanaDe 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.
As a running example, if we take a 4×4 square, where the Greek and Latin terms have the values (?, ?, ?, ?) = (0, 4, 8, 12) and (a, b, c, d) = (1, 2, 3, 4), respectively, then we have ? + ? + ? + ? = 2 (? + ?) = 2 (? + ?). Similarly, a + b + c + d = 2 (a + d) = 2 (b + c). This means that the complementary pair ? and ? (or ? and ?) can appear twice in a column (or a row) and still give the desired magic sum. Thus, we can construct:
 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.
In the example given below, the main diagonal (from top left to bottom right) is filled with sequence ordered as ?, ?, ?, ?, while the skew diagonal (from bottom left to top right) filled in the same order. The remaining cells are then filled column wise such that the complementary letters appears only once within a row, but twice within a column. In the first column, since ? appears on the 1st and 4th row, the remaining cells are filled with its complementary term ?. Similarly, the empty cells in the 2nd column are filled with ?; in 3rd column ?; and 4th column ?. Each Greek letter appears only once along the rows, but twice along the columns. As such, the row sums are ? + ? + ? + ? while the column sums are either 2 (? + ?) or 2 (? + ?). Likewise for the Latin square, which is obtained by flipping the Greek square along the main diagonal and interchanging the corresponding letters.

? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 
? 

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 "crisscross" method for doubly even magic square works. Another possible 4×4 magic square, which is also pandiagonal as well as mostperfect, is constructed below using the same rule. However, the diagonal sequence is chosen such that all four letters ?, ?, ?, ? appear inside the central 2×2 subsquare. 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.
Below is a construction of a 6×6 magic square, where the numbers are directly given, rather than the alphabets. The second square is constructed by flipping the first square along the main diagonal. Here in the first column of the root square the 3rd cell is paired with its complement in the 4th cells. Thus, in the primary square, the numbers in the 1st and 6th cell of the 3rd row are same. Likewise, with other columns and rows. In this example the flipped version of the root square satisfies this proviso.
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 nonnormal magic square (third 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 crisscross pattern of the earlier section for evenly even square, here we have a checkered pattern for the altered and unaltered cells. Also, for each 4×4 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 

Medjigmethod of constructing magic squares of even number of rows
This method is based on a 2006 published mathematical game called medjig (author: Willem Barink, editor: PhilosSpiele). The pieces of the medjig puzzle are squares divided in four quadrants on which the numbers 0, 1, 2 and 3 are dotted in all sequences. There are 18 squares, with each sequence occurring 3 times. The aim of the puzzle is to take 9 squares out of the collection and arrange them in a 3×3 "medjigsquare" in such a way that each row and column formed by the quadrants sums to 9, along with the two long diagonals.
The medjig method of constructing a magic square of order 6 is as follows:
 Construct any 3×3 medjigsquare (ignoring the original game's limit on the number of times that a given sequence is used).
 Take the 3×3 magic square and divide each of its squares into four quadrants.
 Fill these quadrants with the four numbers from 1 to 36 that equal the original number modulo 9, i.e. x+9y where x is the original number and y is a number from 0 to 3, following the pattern of the medjigsquare.
Example:
Order 3
8 
1 
6 
3 
5 
7 
4 
9 
2 

Medjig 3 × 3
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 

Order 6
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 

Similarly, for any larger integer N, a magic square of order 2N can be constructed from any N × N medjigsquare with each row, column, and long diagonal summing to 3N, and any N × N magic square (using the four numbers from 1 to 4N^{2} that equal the original number modulo N^{2}).
Construction of panmagic squares
Any number p in the ordern square can be uniquely written in the form p = an + r, with r chosen from {1,...,n}. Note that due to this restriction, a and r are not the usual quotient and remainder of dividing p by n. Consequently, the problem of constructing can be split in two problems easier to solve. So, construct two matching square grids of order n satisfying panmagic properties, one for the anumbers (0,..., n1), and one for the rnumbers (1,...,n). This requires a lot of puzzling, but can be done. When successful, combine them into one panmagic square. Van den Essen and many others supposed this was also the way Benjamin Franklin (17061790) constructed his famous Franklin squares. Three panmagic squares are shown below. The first two squares have been constructed April 2007 by Barink, the third one is some years older, and comes from Donald Morris, who used, as he supposes, the Franklin way of construction.
Order 8, sum 260
62 
4 
13 
51 
46 
20 
29 
35 
5 
59 
54 
12 
21 
43 
38 
28 
52 
14 
3 
61 
36 
30 
19 
45 
11 
53 
60 
6 
27 
37 
44 
22 
64 
2 
15 
49 
48 
18 
31 
33 
7 
57 
56 
10 
23 
41 
40 
26 
50 
16 
1 
63 
34 
32 
17 
47 
9 
55 
58 
8 
25 
39 
42 
24 

Order 12, sum 870
138 
8 
17 
127 
114 
32 
41 
103 
90 
56 
65 
79 
19 
125 
140 
6 
43 
101 
116 
30 
67 
77 
92 
54 
128 
18 
7 
137 
104 
42 
31 
113 
80 
66 
55 
89 
5 
139 
126 
20 
29 
115 
102 
44 
53 
91 
78 
68 
136 
10 
15 
129 
112 
34 
39 
105 
88 
58 
63 
81 
21 
123 
142 
4 
45 
99 
118 
28 
69 
75 
94 
52 
130 
16 
9 
135 
106 
40 
33 
111 
82 
64 
57 
87 
3 
141 
124 
22 
27 
117 
100 
46 
51 
93 
76 
70 
134 
12 
13 
131 
110 
36 
37 
107 
86 
60 
61 
83 
23 
121 
144 
2 
47 
97 
120 
26 
71 
73 
96 
50 
132 
14 
11 
133 
108 
38 
35 
109 
84 
62 
59 
85 
1 
143 
122 
24 
25 
119 
98 
48 
49 
95 
74 
72 

Order 12, sum 870
1 
120 
121 
48 
85 
72 
73 
60 
97 
24 
25 
144 
142 
27 
22 
99 
58 
75 
70 
87 
46 
123 
118 
3 
11 
110 
131 
38 
95 
62 
83 
50 
107 
14 
35 
134 
136 
33 
16 
105 
52 
81 
64 
93 
40 
129 
112 
9 
8 
113 
128 
41 
92 
65 
80 
53 
104 
17 
32 
137 
138 
31 
18 
103 
54 
79 
66 
91 
42 
127 
114 
7 
5 
116 
125 
44 
89 
68 
77 
56 
101 
20 
29 
140 
139 
30 
19 
102 
55 
78 
67 
90 
43 
126 
115 
6 
12 
109 
132 
37 
96 
61 
84 
49 
108 
13 
36 
133 
135 
34 
15 
106 
51 
82 
63 
94 
39 
130 
111 
10 
2 
119 
122 
47 
86 
71 
74 
59 
98 
23 
26 
143 
141 
28 
21 
100 
57 
76 
69 
88 
45 
124 
117 
4 

The order 8 square satisfies all panmagic properties, including the Franklin ones. It consists of 4 perfectly panmagic 4×4 units. Note that both order 12 squares show the property that any row or column can be divided in three parts having a sum of 290 (= 1/3 of the total sum of a row or column). This property compensates the absence of the more standard panmagic Franklin property that any 1/2 row or column shows the sum of 1/2 of the total. For the rest the order 12 squares differ a lot. The Barink 12×12 square is composed of 9 perfectly panmagic 4×4 units, moreover any 4 consecutive numbers starting on any odd place in a row or column show a sum of 290. The Morris 12×12 square lacks these properties, but on the contrary shows constant Franklin diagonals. For a better understanding of the constructing decompose the squares as described above, and see how it was done. And note the difference between the Barink constructions on the one hand, and the Morris/Franklin construction on the other hand.
In the book Mathematics in the TimeLife Science Library Series, magic squares by Euler and Franklin are shown. Franklin designed this one so that any foursquare subset (any four contiguous squares that form a larger square, or any four squares equidistant from the center) total 130. The square attributed to Euler is in fact due to William Beverley, published in the Philosophical Magazine 1848. In this square, the rows and columns each total 260, and halfway they total 130  and a chess knight, making its Lshaped moves on the square, can touch all 64 boxes in consecutive numerical order.
Composite magic squares
There 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.^{[54]}
Solving partially completed magic squares
Similar to the Sudoku and KenKen puzzles, solving partially completed 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 solution arises as the participant uses logic and permutation group theory to rule out all unsuitable number combinations.
Variations of the magic square
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 (n = 2), a trimagic (n = 3), 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.
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 (this is usually called a semimagic square).
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 (or any other integer) 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 2^{a}, 2^{b} and 2^{c}, their product is 2^{a+b+c}, which is constant if a+b+c is constant, as they would be if a, b and c were taken from ordinary (additive) magic square.^{[55]} For example, the original LoShu magic square becomes:
M = 32768
16 
512 
4 
8 
32 
128 
256 
2 
64 
Other examples of multiplicative magic squares include:
M = 216
2 
9 
12 
36 
6 
1 
3 
4 
18 

M = 6720
1 
6 
20 
56 
40 
28 
2 
3 
14 
5 
24 
4 
12 
8 
7 
10 

M = 6,227,020,800
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^{[56]} belonging to $\mathbb {C}$ 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 $\mathbb {R}$. The product is: 352,507,340,640  400,599,719,520 i.
Skalli multiplicative 7×7 of complex numbers
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 
Additivemultiplicative magic and semimagic squares
Additivemultiplicative magic squares and semimagic squares satisfy properties of both ordinary and multiplicative magic squares and semimagic squares, respectively.^{[57]}
First known
additivemultiplicative magic square 8×8 found by W. W. Horner in 1955
Sum = 840
Product = 2 058 068 231 856 000
162 
207 
51 
26 
133 
120 
116 
25 
105 
152 
100 
29 
138 
243 
39 
34 
92 
27 
91 
136 
45 
38 
150 
261 
57 
30 
174 
225 
108 
23 
119 
104 
58 
75 
171 
90 
17 
52 
216 
161 
13 
68 
184 
189 
50 
87 
135 
114 
200 
203 
15 
76 
117 
102 
46 
81 
153 
78 
54 
69 
232 
175 
19 
60 

Smallest known additivemultiplicative semimagic square 4×4 found by L. Morgenstern in 2007
Sum = 247
Product = 3 369 600
156 
18 
48 
25 
30 
144 
60 
13 
16 
20 
130 
81 
45 
65 
9 
128 

It is unknown if any additivemultiplicative magic squares smaller than 8×8 exist, but it has been proven that no 3×3 or 4×4 additivemultiplicative magic squares and no 3×3 additivemultiplicative semimagic squares exist.^{[58]}
Other magic shapes
Other 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 subdesigns give the same sum. Examples include magic dodecahedrons, magic triangles^{[59]}magic stars, and magic hexagons. Going up in dimension results in magic cubes and other magic hypercubes.
Edward Shineman has developed yet another design in the shape of magic diamonds.
Possible magic shapes are constrained by the number of equalsized, equalsum subsets of the chosen set of labels. For example, if one proposes to form a magic shape labeling the parts with {1, 2, 3, 4}, the subdesigns will have to be labeled with {1,4} and {2,3}.^{[59]}
A geometric magic square.
Other component elements
Magic 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.^{[60]}
Combined extensions
One can combine two or more of the above extensions, resulting in such objects as multiplicative multimagic hypercubes. Little seems to be known about this subject.
The first linear area magic square
Area Magic Squares
In 2017, following initial ideas of William Walkington and Inder Taneja, the first linear area magic square (LAMS) was constructed by Walter Trump.^{[61]}
Related problems
Over the years, many mathematicians, including Euler, Cayley and Benjamin Franklin have worked on magic squares, and discovered fascinating relations.
Magic square of primes
Rudolf Ondrejka (19282001) 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 GreenTao theorem implies that there are arbitrarily large magic squares consisting of primes.
nQueens problem
In 1992, Demirörs, Rafraf, and Tanik published a method for converting some magic squares into nqueens solutions, and vice versa.^{[62]}
Enumeration of magic squares
Semilog plot of Pn, the probability of magic squares of dimension n
As mentioned above, the set of normal squares of order three constitutes a single equivalence classall 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.^{[63]} There are 880 distinct magic squares of order 4 and 275,305,224 of order 5.^{[64]} These squares are respectively displayed on 255 magic tori of order 4, and 251,449,712 of order 5.^{[65]} The number of magic tori and distinct normal squares is not yet known for any higher order.^{[66]}
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 n^{2} 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.^{[67]}
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 occultism
Magic squares of order 3 through 9, assigned to the seven planets, and described as means to attract the influence of planets and their angels (or demons) 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.^{[68]} 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 (Ms BJ 793).^{[69]} The magical operations involve engraving the appropriate square on a plate made with the metal assigned to the corresponding planet,^{[70]} 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 counterreformation, 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.^{[71]}

Jupiter=34
4 
14 
15 
1 
9 
7 
6 
12 
5 
11 
10 
8 
16 
2 
3 
13 

Mars=65
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 

Sol=111
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 

Venus=175
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 

Mercury=260
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 

Luna=369
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 

The derivation of the
sigil of Hagiel, the
planetary intelligence 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;^{[72]} 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:
S 
A 
T 
O 
R 
A 
R 
E 
P 
O 
T 
E 
N 
E 
T 
O 
P 
E 
R 
A 
R 
O 
T 
A 
S 

6 
66 
848 
938 
8 
11 
544 
839 
1 
11 
383 
839 
2 
73 
774 
447 

H 
E 
S 
E 
B 
E 
Q 
A 
L 

S 




E 

G 


B 





A 
D 
A 
M 
D 
A 
R 
A 
A 
R 
A 
D 
M 
A 
D 
A 

Magic squares in popular culture
Macau stamps featuring magic squares
 In Goethe's Faust, the witch's spell used to make a youth elixir for Faust, the HexenEinmalEins (de), has been interpreted as a construction of a magic square.
 Dürer's magic square and his Melencolia I both also played large roles in Dan Brown's 2009 novel, The Lost Symbol.
 On October 9, 2014 the post office of Macao in the People's Republic of China issued a series of stamps based on magic squares.^{[73]} The figure below shows the stamps featuring the nine magic squares chosen to be in this collection.^{[74]}
 The metallic artifact at the center of The XFiles episode "Biogenesis" is alleged by Chuck Burks to be a magic square.^{[75]}^{[76]}
 Mathematician Matt Parker attempted to create a 3x3 magic square using square numbers in a YouTube video on the Numberphile channel. His failed attempt is known as the Parker Square.
 The first season Stargate Atlantis episode "Brotherhood" involves completing a magic square as part of a puzzle guarding a powerful Ancient artefact.
See also
Notes
 ^ Miller, Jeff (September 3, 2016). "Earlier Known Uses of Some of the Words of Mathematics (M)".
 ^ Schwartzman, Steven (1994). The Words of Mathematics: An Etymological Dictionary of Mathematical Terms Used in English. MAA. p. 130.
 ^ Hawley, Del (February 2011) [September 1998]. "Magic Squares II". NRICH.
 ^ Allenby, R. B. J. T. (1995). Linear Algebra. p. 97.
 ^ Richardson, William H. "NonNormal Magic Squares". Wichita State University.
 ^ The most famous Arabic book on magic, named "Shams Alma'arif (Arabic: ? ??), for Ahmed bin Ali Alboni, who died about 1225 (622 AH). Reprinted in Beirut in 1985
 ^ ^{a} ^{b} ^{c} ^{d} ^{e} Yoke, Ho Peng (2008). Magic Squares in China. Encyopaedia of the History of Science, Technology, and Medicine in NonWestern Cultures (2 ed.). Springer. pp. 12521259.
 ^ Andrews, William Symes (1917). Magic Squares and Cubes (2nd ed.). Open Court Publishing Company. p. 122.
 ^ ^{a} ^{b} ^{c} ^{d} ^{e} ^{f} ^{g} ^{h} ^{i} Cammann, Schuyler (April 1960). "The Evolution of Magic Squares in China" (PDF). Journal of the American Oriental Society. 80 (2): 116124.
 ^ O'Connor, J.J.; Robertson, E.F. "Yang Hui". MacTutor History of Mathematics Archive. Retrieved 2018.
 ^ ^{a} ^{b} ^{c} Swetz, Frank J. (2008). The Legacy of the Luoshu (2nd ed.). A.K. Peters/CRC Press.
 ^ J. P. Hogendijk, A. I. Sabra, The Enterprise of Science in Islam: New Perspectives, Published by MIT Press, 2003, ISBN 0262194821, p. xv.
 ^ Helaine Selin, Ubiratan D'Ambrosio, Mathematics Across Cultures: The History of NonWestern Mathematics, Published by Springer, 2001, ISBN 1402002602, p. 160.
 ^ ^{a} ^{b} ^{c} ^{d} ^{e} ^{f} Sesiano, Jacques (November 2003). "Construction of magic squares using the knight's move in Islamic mathematics". Archive for History of Exact Sciences. 58 (1): 120.
 ^ ^{a} ^{b} Sesiano, Jacques (1997). "Magic squares in Islamic mathematics". Encyclopaedia of the History of Science, Technology, and Medicine in NonWestern Cultures. pp. 12591260.
 ^ Sesiano, Jacques (2007). Magic squares in the tenth century: Two Arabic treatises by Antaki and Buzjani. Springer. pp. 12591260.
 ^ Sesiano, J., Ab?alWaf?\rasp's treatise on magic squares (French), Z. Gesch. Arab.Islam. Wiss. 12 (1998), 121244.
 ^ ^{a} ^{b} Cammann, Schuyler (February 1969). "Islamic and Indian Magic Squares, Part I". History of Religions. 8 (3): 181209.
 ^ Sesiano, Jacques (2004). "Quelques methodes arabes de construction des carres magiques impairs (some Arabic construction methods of odd magical squares)". Bulletin de la Societe Vaudoise des Sciences Naturelles (in French). 83 (1): 5176.
 ^ Peter, J. Barta, The SealRing of Proportion and the magic rings (2016), pp. 69.
 ^ ^{a} ^{b} Needham, Joseph (1987). Theoretical Influences of China on Arabic Alchemy. UC Biblioteca Geral 1.
 ^ J?bir ibn Hayy?n, Book of the Scales. French translation in: Marcelin Berthelot (18271907), Histoire de sciences. La chimie au moyen âge, Tom. III: L'alchimie arabe. Paris, 1893. [rprt.. Osnabruck: O. Zeller, 1967], pp. 139162, in particular: pp. 150151
 ^ alGhaz?l?, Deliverance From Error (almunqidh min al?al?l ) ch. 145. Arabic: alMunkidh min aldalal. ed. J. Saliba  K. Ayyad. Damascus: Maktab alNashr al'Arabi, 1934, p. 79. English tr.: Richard Joseph McCarthy, Freedom and Fulfillment: An annotated translation of alGhazali's alMunkidh min alDalal an other relevant works of alGhazali. Boston, Twayer, 1980. He refers a book titled 'The Marvels of Special Properties' as his source. This square was named in the Orient as the Seal of Ghazali after him.
 ^ ^{a} ^{b} ^{c} ^{d} Comes, Rosa. "The Transmission of Azarquiel's Magic Squares in Latin Europe". Medieval Textual Cultures: Agents of Transmission, Translation and Transformation. Judaism, Christianity, and Islam  Tension, Transmission, Transformation. Walter de Gruyter GmbH & Co KG. 6: 159198. ISBN 9783110467307.
 ^ The Latin version is Liber de septem figuris septem planetarum figurarum Geberi regis Indorum. This treatise is the identified source of Dürer and Heinrich Cornelius Agrippa von Nettesheim. Cf. Peter, J. Barta, The SealRing of Proportion and the magic rings (2016), pp. 89, n. 10
 ^ Sesiano, Jacques (2004). Les carrés magiques dans les pays islamiques (in French). PPUR presses polytechniques.
 ^ Schimmel, Annemarie (1993). The mystery of numbers. New York: Oxford University Press.
 ^ ^{a} ^{b} ^{c} ^{d} ^{e} ^{f} ^{g} ^{h} ^{i} ^{j} ^{k} Hayashi, Takao (2008). Magic Squares in Indian Mathematics. Encyclopaedia of the History of Science, Technology, and Medicine in NonWestern Cultures (2 ed.). Springer. pp. 12521259.
 ^ ^{a} ^{b} ^{c} ^{d} Datta, Bibhutibhusan; Singh, Awadhesh Narayan (1992). Magic Squares in India (PDF). Indian Journal of History of Science. 27. pp. 51120.
 ^ ^{a} ^{b} Hayashi, Takao (1987). "Varahamihira's Pandiagonal Magic Square of the Order Four" (PDF). Historia Mathematica. 14 (2): 159166.
 ^ Magic Squares of Manuel Moschopoulos
 ^ ^{a} ^{b} ^{c} Cammann, Schuyler (May 1969). "Islamic and Indian Magic Squares, part II". History of Religions. 8 (4): 271299. JSTOR 1062018.
 ^ presently in the Biblioteca Vaticana (cod. Reg. Lat. 1283a)
 ^ See Alfonso X el Sabio, Astromagia (Ms. Reg. lat. 1283a), a cura di A.D'Agostino, Napoli, Liguori, 1992
 ^ Mars magic square appears in figure 1 of "Saturn and Melancholy: Studies in the History of Natural Philosophy, Religion, and Art" by Raymond Klibansky, Erwin Panofsky and Fritz Saxl, Basic Books (1964)
 ^ The squares can be seen on folios 20 and 21 of MS. 2433, at the Biblioteca Universitaria of Bologna. They also appear on folio 69rv of Plimpton 167, a manuscript copy of the Trattato dell'Abbaco from the 15th century in the Library of Columbia University.
 ^ In a 1981 article ("Zur Frühgeschichte der magischen Quadrate in Westeuropa" i.e. "Prehistory of Magic Squares in Western Europe", Sudhoffs Archiv Kiel (1981) vol. 65, pp. 313338) German scholar Menso Folkerts lists several manuscripts in which the "Trattato d'Abbaco" by Dagomari contains the two magic square. Folkerts quotes a 1923 article by Amedeo Agostini in the Bollettino dell'Unione Matematica Italiana: "A. Agostini in der Handschrift Bologna, Biblioteca Universitaria, Ms. 2433, f. 20v21r; siehe Bollettino della Unione Matematica Italiana 2 (1923), 77f. Agostini bemerkte nicht, dass die Quadrate zur Abhandlung des Paolo dell'Abbaco gehören und auch in anderen Handschriften dieses Werks vorkommen, z. B. New York, Columbia University, Plimpton 167, f. 69rv; Paris, BN, ital. 946, f. 37v38r; Florenz, Bibl. Naz., II. IX. 57, f. 86r, und Targioni 9, f. 77r; Florenz, Bibl. Riccard., Ms. 1169, f. 9495."
 ^ This manuscript text (circa 14961508) is also at the Biblioteca Universitaria in Bologna. It can be seen in full at the address http://www.uriland.it/matematica/DeViribus/Presentazione.html
 ^ Pacioli states: A lastronomia summamente hanno mostrato li supremi di quella commo Ptolomeo, al bumasar ali, al fragano, Geber et gli altri tutti La forza et virtu de numeri eserli necessaria (Masters of astronomy, such as Ptolemy, Albumasar, Alfraganus, Jabir and all the others, have shown that the force and the virtue of numbers are necessary to that science) and then goes on to describe the seven planetary squares, with no mention of magical applications.
 ^ ^{a} ^{b} ^{c} Rouse Ball, W.W. "Magic Squares". Mathematical Recreations and Essays (4 ed.). London: Mac Millan and Co., Limited. pp. 122142.
 ^ Andrews, William Symes (1917). Magic Squares and Cubes (2nd ed.). Open Court Publishing Company. pp. 124126.
 ^ "Archived copy". Archived from the original on 20051109. Retrieved .
 ^ "Magic cube with Dürer's square" Ali Skalli's magic squares and magic cubes
 ^ "The magic square on the Passion façade: keys to understanding it". 7 February 2018.
 ^ "Magic cube with Gaudi's square" Ali Skalli's magic squares and magic cubes
 ^ Adler, Allan; Alejandre, Suzanne. "Why there are no 2x2 magic squares". mathforum.org.
 ^ ^{a} ^{b} ^{c} Loly, Peter (March 2004) [1 August 2016]. "The invariance of the moment of inertia of magic squares" (PDF). Mathematical Gazette. 88 (511): 151153. doi:10.1017/S002555720017456X.
 ^ ^{a} ^{b} ^{c} ^{d} ^{e} ^{f} Kraitchik, Maurice (1953). "Magic Squares". Mathematical Recreations (2nd ed.). New York: Dover Publications, Inc. pp. 142192.
 ^ Sallows, Lee (Fall 1997) [09 January 2009]. "The lost theorem". The Mathematical Intelligencer. 19 (4): 5154. doi:10.1007/BF03024415.
 ^ Structure of Magic and SemiMagic Squares, Methods and Tools for Enumeration
 ^ Pinn, K.; Wieczerkowski, C. (1998). "Number of Magic Squares From Parallel Tempering Monte Carlo". Int. J. Mod. Phys. C. 9: 541. arXiv:condmat/9804109 . Bibcode:1998IJMPC...9..541P. doi:10.1142/s0129183198000443.
 ^ "Number of Magic Squares From Parallel Tempering Monte Carlo, arxiv.org, April 9, 1998. Retrieved November 2, 2013.
 ^ Mathematical Circles Squared By Phillip E. Johnson, Howard Whitley Eves, p.22
 ^ Hartley, M. "Making Big Magic Squares".
 ^ Stifel, Michael (1544), Arithmetica integra (in Latin), pp. 2930 .
 ^ "8x8 multiplicative magic square of complex numbers" Ali Skalli's magic squares and magic cubes
 ^ "MULTIMAGIE.COM  AdditiveMultiplicative magic squares, 8th and 9thorder". Retrieved 2015.
 ^ "MULTIMAGIE.COM  Smallest additivemultiplicative magic square". Retrieved 2015.
 ^ ^{a} ^{b} Magic Designs, Robert B. Ely III, Journal of Recreational Mathematics volume 1 number 1, January 1968
 ^ Magic squares are given a whole new dimension, The Observer, April 3, 2011
 ^ "Area Magic Squares". Futility Closet. 20170119. Retrieved .
 ^ Demirörs, O.; Rafraf, N.; Tanik, M. M. "Obtaining nqueens solutions from magic squares and constructing magic squares from nqueens solutions". Journal of Recreational Mathematics. 24 (272280): 1992.
 ^ How many magic squares are there? by Walter Trump, Nürnberg, January 11, 2001
 ^ A006052 in the online encyclopedia of integer sequences
 ^ A270876 in the online encyclopedia of integer sequences
 ^ Anything but square: from magic squares to Sudoku by Hardeep Aiden, Plus Magazine, March 1, 2006
 ^ Kitajima, Akimasa; Kikuchi, Macoto; Altmann, Eduardo G. (14 May 2015). "Numerous but Rare: An Exploration of Magic Squares". PLOS ONE. 10 (5): e0125062. doi:10.1371/journal.pone.0125062. PMC 4431883 . PMID 25973764.
 ^ See Juris Lidaka, The Book of Angels, Rings, Characters and Images of the Planets in Conjuring Spirits, C. Fangier ed. (Pennsylvania State University Press, 1994)
 ^ Benedek Láng, Demons in Krakow, and Image Magic in a Magical Handbook, in Christian Demonology and Popular Mythology, Gábor Klaniczay and Éva Pócs eds. (Central European University Press, 2006)
 ^ According to the correspondence principle, each of the seven planets is associated to a given metal: lead to Saturn, iron to Mars, gold to the Sun, etc.
 ^ Drury, Nevill (1992). Dictionary of Mysticism and the Esoteric Traditions. Bridport, Dorset: Prism Press. ISBN 185327075X.
 ^ "The Book of Power: Cabbalistic Secrets of Master Aptolcater, Mage of Adrianople", transl. 1724. In Shah, Idries (1957). The Secret Lore of Magic. London: Frederick Muller Ltd.
 ^ Macau Post Office web site Archived 20141111 at the Wayback Machine.
 ^ Macau's magic square stamps just made philately even more nerdy The Guardian Science, November 3, 2014
 ^ Michelle Erica Green (June 15, 1997). "Biogenesis on The XFiles". littlereview.com. The Little Review. Retrieved 2017.
Moreover, it's a magic square, a pattern in which God supposedly instructed the early Hebrews to gain power from names or their numeric equivalents.
 ^ Zack Handlen (November 17, 2012). "The XFiles: "Biogenesis" / Millennium: "Goodbye To All That"". The A.V. Club. The Onion, Inc. Retrieved 2017.
I love when they bring the nerdy FBI guy in to explain the concept of "the magic square," which he does by telling us that magic squares have been around for a while, and then nothing else. Unless I missed something, all I have at this point is that magic squares are squares that people once thought were magic.
References
 John Lee Fults, Magic Squares. (La Salle, Illinois: Open Court, 1974).
 Cliff Pickover, The Zen of Magic Squares, Circles, and Stars (Princeton, New Jersey: Princeton University Press)
 Leonhard Euler, On magic squares
 Asker Ali Abiyev, The Natural Code of Numbered Magic Squares (1996)
 William H. Benson and Oswald Jacoby, "New Recreations with Magic Squares". (New York: Dover, 1976).
 A 'perfect' magic square presented as a magic trick (Online Generator  Magic Square 4×4 using Javascript)
 Magic Squares of Order 4,5,6, and some theory, hbmeyer.de
 Evolving a Magic Square using Genetic Algorithms, dcs.napier.ac.uk
Further reading
 Block, Seymour (2009). Before Sudoku: The World of Magic Squares. Oxford University Press. ISBN 0195367901.
 McCranie, Judson (November 1988). "Magic Squares of All Orders". Mathematics Teacher: 67478.
 Ollerenshaw, Kathleen; Bree, David (October 1998). Most perfect pandiagonal magic squares: their construction and enumeration. The Institute of Mathematics and its Applications. ISBN 9780905091068.
 Semanisinova, Ingrid; Trenkler, Marian (August 2007). "Discovering the Magic of Magic Squares". Mathematics Teacher. 101 (1): 3239.
 King, J. R. (1963). "Magic Square Numbers".
External links