Magic square

From Wikipedia, the free encyclopedia
Jump to: navigation, search
The smallest (and unique up to rotation and reflection) non-trivial case of a magic square, measuring 3×3

In recreational mathematics, a magic square[1] is a square grid (where is the number of cells on each side) filled with distinct positive integers in the range such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal.[2] The sum is called the magic constant or magic sum of the magic square. A square grid with cells on each side is said to have order n.

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 non-normal magic squares[5] which integers are not restricted in . However, in some places, "magic squares" is used as a general term to cover both the normal and non-normal ones, especially when non-normal ones are under discussion. Moreover, the term "magic squares" is sometimes also used to refer to various types of word squares.

Magic squares have a long history, dating back to at least 650 BC 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.

Properties of magic squares[edit]

Magic constant[edit]

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 , calculated by the formula , since the sum of is which when divided by the order 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[edit]

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[edit]

Normal magic squares of all sizes can be constructed except 2×2 (that is, where order n = 2).[6]

Equivalent magic squares[edit]

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.[7][8]

Number of magic squares of a given order[edit]

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 × 1019 squares.[9]

An invariant[edit]

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.[9] (Thus for example a corner cell of a 3×3 square has a distance of a non-corner 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 order-3 case the moment of inertia is always 60, while for the order-4 case the moment of inertia is always 340; in general, for the n×n case the moment of inertia is [9]


Iron plate with an order 6 magic square in Eastern Arabic Numerals from China, dating to the Yuan Dynasty (1271–1368).

Magic squares were known to Chinese mathematicians as early as 650 BC, and explicitly given since 570 AD,[10] and to Islamic mathematicians possibly as early as the seventh century AD, the first magic squares of order 5 and 6 appear in an encyclopedia from Baghdad circa 983, the Encyclopedia of the Brethren of Purity (Rasa'il Ihkwan al-Safa); simpler magic squares were known to several earlier Arab mathematicians.[10] Some of these squares were later used in conjunction with magic letters, as in Shams Al-ma'arif, to assist Arab illusionists and magicians.[11]

China (Lo Shu square, 3×3 magic square)[edit]

Ancient references to the pattern of even and odd numbers in the Lo Shu appear in the I Ching; however, the earliest unequivocal appearance of the Lo Shu in the form of a magic square dates to the early 12th century.[12] Legends dating from as early as 650 BC tell the story of the Lo Shu (洛書) or "scroll of the river Lo".[10] 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.

4 9 2
3 5 7
8 1 6

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.


Original script from the Shams al-Ma'arif.
Printed version of the previous manuscript. Eastern Arabic numerals were used.

Although the early history of magic squares in Persia is not known, it has been suggested that they were known in pre-Islamic times,[13] it is clear, however, that the study of magic squares was common in medieval Islam in Persia, and it was thought to have begun after the introduction of chess into the region.[14] The 10th-century Persian mathematician Buzjani, for example, left a manuscript that on page 33 contains a series of magic squares, filled by numbers in arithmetical progression, in such a way that the sums of each row, column and diagonal are equal.[15]


Magic squares were known to Islamic mathematicians in Arabia as early as the seventh century, they may have learned about them when the Arabs came into contact with Indian culture and learned Indian astronomy and mathematics – including other aspects of combinatorial mathematics. Alternatively, the idea may have come to them from China, the first magic squares of order 5 and 6 known to have been devised by Arab mathematicians appear in an encyclopedia from Baghdad circa 983, the Rasa'il Ikhwan al-Safa (the Encyclopedia of the Brethren of Purity); simpler magic squares were known to several earlier Arab mathematicians.[10]

The magic square of order three was described as a child-bearing charm[16] since its first literary appearances in the works of Jābir ibn Hayyān (fl. c. 721– c. 815)[17] and al-Ghazālī (1058–1111)[18] and it was preserved in the tradition of the planetary tables, known from H.C.Agrippa's work,[19] too.

The Arab mathematician Ahmad al-Buni, who worked on magic squares around 1250, attributed mystical properties to them, although no details of these supposed properties are known. There are also references to the use of magic squares in astrological calculations, a practice that seems to have originated with the Arabs.[10]


Magic Square at the Parshvanatha temple, in Khajuraho India

The 3×3 magic square has been a part of rituals in India since Vedic times, and still is today, the Ganesh yantra is a 3×3 magic square. There is a well-known 10th-century 4×4 magic square on display in the Parshvanath temple in Khajuraho, India.[20]

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

This is known as the Chautisa Yantra, each row, column, and diagonal, as well as each 2×2 sub-square, the corners of each 3×3 and 4×4 square, the corners of each 2×4 and 4×2 rectangle, and the offset diagonals (12+8+5+9, 1+11+16+6, 14+2+3+15 and 7+11+10+6, 12+2+5+15, 1+13+16+4) sum to 34.

In this square, every second diagonal number adds to 17 (the same applies to offset diagonals); in addition to squares and rectangles, there are eight trapeziums – two in one direction, and the others at a rotation of 90 degrees, such as (12, 1, 16, 5) and (13, 8, 9, 4).

These characteristics (which identify it as one of the three 4×4 pandiagonal magic squares and as a most-perfect magic square) mean that the rows or columns can be rotated and maintain the same characteristics - for example:

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

The Kubera-Kolam, 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.

23 28 21
22 24 26
27 20 25


This page from Athanasius Kircher's Oedipus Aegyptiacus (1653) belongs to a treatise on magic squares and shows the Sigillum Iovis associated with Jupiter

In 1300, building on the work of the Arab Al-Buni, Greek Byzantine scholar Manuel Moschopoulos wrote a mathematical treatise on the subject of magic squares, leaving out the mysticism of his predecessors.[21] Moschopoulos was essentially unknown to the Latin west, he was not, either, the first Westerner to have written on magic squares. They appear in a Spanish manuscript written in the 1280s, presently in the Biblioteca Vaticana (cod. Reg. Lat. 1283a) due to Alfonso X of Castille.[22] In that text, each magic square is assigned to the respective planet, as in the Islamic literature.[23] Magic squares surface again in Italy in the 14th century, and specifically in Florence; in fact, a 6×6 and a 9×9 square are exhibited in a manuscript of the Trattato d'Abbaco (Treatise of the Abacus) by Paolo dell'Abbaco, aka Paolo Dagomari, a mathematician, astronomer and astrologer who was, among other things, in close contact with Jacopo Alighieri, a son of Dante. 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,[24] 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.[25] 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.

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.[26] 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).[27] The magical operations involve engraving the appropriate square on a plate made with the metal assigned to the corresponding planet,[28] 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 1514 Albrecht Dürer immortalized a 4×4 square, of order four, in his famous engraving Melencolia I. It is described in more detail below.

In about 1510 Heinrich Cornelius Agrippa wrote De Occulta Philosophia, drawing on the Hermetic and magical works of Marsilio Ficino and Pico della Mirandola. In its 1531 edition, he expounded on the magical virtues of the seven magical squares of orders 3 to 9, each associated with one of the astrological planets, much in the same way as the older texts did, this book was very influential throughout Europe until the counter-reformation, and Agrippa's magic squares, sometimes called kameas, continue to be used within modern ceremonial magic in much the same way as he first prescribed.[10][29]

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;[30] 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:

Albrecht Dürer's magic square[edit]

Detail of Melencolia I

The order-4 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. 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 counter-clockwise (the locations of four queens in the two solutions of the 4 queens puzzle[31]), 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.[32]

Dürer's magic square and his Melencolia I both also played large roles in Dan Brown's 2009 novel, The Lost Symbol.

Sagrada Família magic square[edit]

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. 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→n2 rule.

Similarly to Dürer's magic square, the Sagrada Familia's magic square can also be extended to a magic cube.[33]

This magic square has 24 groups of four fields with the sum of 139 and in the first row - shown at bottom-right - Ramanujan's date of birth.

Srinivasa Ramanujan's magic square[edit]

The Indian mathematician Srinivasa Ramanujan created a square where - in addition to several groups of four squares - the first row shows his date of birth, 22nd Dec. 1887.

Magic Square using calculator digit shapes

Professor Roger Bowley has shown a fascinating 4x4 magic square using calculator digits shapes. All rows, columns and diagonals total 176. Then the whole paper is turned upside down and still all rows, columns, diagonal of new numbers formed by turning paper upside down is 176. Next reflection of this magic square also displays the same property.

Types of construction[edit]

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.[34]

Question dropshade.png Unsolved problem in mathematics:
How many n×n magic squares, and how many magic tori of order n, are there for n>5?
(more unsolved problems 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 A006052 in the OEIS). The number for n = 6 has been estimated to be (1.7745 ± 0.0016) × 1019.[35][36]

Cross-referenced to the above sequence, a new classification enumerates the magic tori that display these magic squares, the numbers of magic tori of order n from 1 to 5, are: 1, 0, 1, 255, 251449712 (sequence A270876 in the OEIS).

Method for constructing a magic square of order 3[edit]

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:

cb c + (a + b) ca
c − (ab) c c + (ab)
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 < ca 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[edit]

Yang Hui's construction method

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.[37] 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.

The following formulae help construct magic squares of odd order

Squares (n) Last no. Middle no. Sum (M) Ith row and Jth column no.


Order 5
Squares (n) Last no. Middle no. Sum (M)
5 25 13 65

The "middle number" is always in the diagonal bottom left to top right.
The "last number" is always opposite the number 1 in an outside column or row.

A method of constructing a magic square of doubly even order[edit]

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.

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 n2 (left-to-right, top-to-bottom), and a '0' indicates selecting from the square where the numbers are written in reverse order n2 to 1. For M = 4, the "truth" table is as shown below, (third matrix from left.)

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 right-halves are mirror images; and d) the top- and bottom-halves are mirror images (c & d imply b.) The truth table can be denoted as (9, 6, 6, 9) for simplicity (1-nibble 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) (2-nibbles 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 (3-nibbles 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.

Medjig-method of constructing magic squares of even number of rows[edit]

This method is based on a 2006 published mathematical game called medjig (author: Willem Barink, editor: Philos-Spiele), 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 "medjig-square" 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 medjig-square (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 medjig-square.


Similarly, for any larger integer N, a magic square of order 2N can be constructed from any N × N medjig-square with each row, column, and long diagonal summing to 3N, and any N × N magic square (using the four numbers from 1 to 4N2 that equal the original number modulo N2).

Construction of panmagic squares[edit]

Any number p in the order-n 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 a-numbers (0,..., n−1), and one for the r-numbers (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 (1706–1790) 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.

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 Time–Life Science Library Series, magic squares by Euler and Franklin are shown. Franklin designed this one so that any four-square 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 L-shaped moves on the square, can touch all 64 boxes in consecutive numerical order.

Construction similar to the Kronecker Product[edit]

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.[38]

The construction of a magic square using genetic algorithms[edit]

A magic square can be constructed using genetic algorithms;[39] in this process an initial population of squares with random values is generated. The fitness scores of these individual squares are calculated based on the degree of deviation in the sums of the rows, columns, and diagonals, the population of squares reproduce by exchanging values, together with some random mutations. Those squares with a higher fitness score are more likely to reproduce, the fitness scores of the next generation squares are calculated, and this process continues until a magic square is found or a time limit is reached.

Solving partially completed magic squares[edit]

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[edit]

Extra constraints[edit]

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 most-perfect 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.

Certain extra restrictions can be imposed on magic squares. If not only the main diagonals but also the broken diagonals sum to the magic constant, the result is a panmagic square.

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[edit]

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[edit]

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 2a, 2b and 2c, their product is 2a+b+c, which is constant if a+b+c is constant, as they would be if a, b and c were taken from ordinary (additive) magic square.[40] For example, the original Lo-Shu magic square becomes:

M = 32768
16 512 4
8 32 128
256 2 64

Other examples of multiplicative magic squares include:

Multiplicative magic squares of complex numbers[edit]

Still using Ali Skalli's non iterative method, it is possible to produce an infinity of multiplicative magic squares of complex numbers[41] belonging to set. On the example below, the real and imaginary parts are integer numbers, but they can also belong to the entire set of real numbers . The product is: −352,507,340,640 − 400,599,719,520 i.

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

Additive-multiplicative magic and semimagic squares[edit]

Additive-multiplicative magic squares and semimagic squares satisfy properties of both ordinary and multiplicative magic squares and semimagic squares, respectively.[42]

First known additive-multiplicative 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 additive-multiplicative 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 additive-multiplicative magic squares smaller than 8×8 exist, but it has been proven that no 3×3 or 4×4 additive-multiplicative magic squares and no 3×3 additive-multiplicative semimagic squares exist.[43]

Other magic shapes[edit]

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 sub-designs give the same sum. Examples include magic dodecahedrons, magic triangles[44] 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 equal-sized, equal-sum subsets of the chosen set of labels, for example, if one proposes to form a magic shape labeling the parts with {1, 2, 3, 4}, the sub-designs will have to be labeled with {1,4} and {2,3}.[44]

A geometric magic square.

Other component elements[edit]

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.[45]

Combined extensions[edit]

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[edit]

In 2017, following initial ideas of William Walkington and Inder Taneja, the first linear area magic square (L-AMS) was constructed by Walter Trump.[46]

Related problems[edit]

Over the years, many mathematicians, including Euler, Cayley and Benjamin Franklin have worked on magic squares, and discovered fascinating relations.

Magic square of primes[edit]

Rudolf Ondrejka (1928–2001) discovered the following 3×3 magic square of primes, in this case nine Chen primes:

17 89 71
113 59 5
47 29 101

The Green–Tao theorem implies that there are arbitrarily large magic squares consisting of primes.

n-Queens problem[edit]

In 1992, Demirörs, Rafraf, and Tanik published a method for converting some magic squares into n-queens solutions, and vice versa.[47]

Enumeration of magic squares[edit]

Semi-log 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 class-all equivalent to the Lo Shu square, thus there is basically just one normal magic square of order 3. But the number of distinct normal magic squares rapidly increases for higher orders.[48] There are 880 distinct magic squares of order 4 and 275,305,224 of order 5,[49] these squares are respectively displayed on 255 magic tori of order 4, and 251,449,712 of order 5.[50] The number of magic tori and distinct normal squares is not yet known for any higher order.[51]

Algorithms tend to only generate magic squares of a certain type or classification, making counting all possible magic squares quite difficult. Traditional counting methods have proven unsuccessful, statistical analysis using the Monte Carlo method has been applied, the basic principle applied to magic squares is to randomly generate n × n matrices of elements 1 to n2 and check if the result is a magic square. The probability that a randomly generated matrix of numbers is a magic square is then used to approximate the number of magic squares.[52]

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 popular culture[edit]

In Goethe's Faust, the witch's spell used to make a youth elixir for Faust, the Hexen-Einmal-Eins (de), has been interpreted as a construction of a magic square.

Macau stamps featuring magic squares

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,[53] the figure below shows the stamps featuring the nine magic squares chosen to be in this collection.[54]

The metallic artifact at the center of The X-Files episode "Biogenesis" is alleged by Chuck Burks to be a magic square.[55] [56]

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[edit]


  1. ^ Miller, Jeff (September 3, 2016). "Earliest Known Uses of Some of the Words of Mathematics (M)". 
  2. ^ Schwartzman, Steven (1994). The Words of Mathematics: An Etymological Dictionary of Mathematical Terms Used in English. MAA. p. 130. 
  3. ^ Hawley, Del (February 2011) [September 1998]. "Magic Squares II". NRICH. 
  4. ^ Allenby, R. B. J. T. (1995). Linear Algebra. p. 97. 
  5. ^ Richardson, William H. "Non-Normal Magic Squares". Wichita State University. 
  6. ^ Adler, Allan; Alejandre, Suzanne. "Why there are no 2x2 magic squares". 
  7. ^ Sallows, Lee (Fall 1997) [09 January 2009]. "The lost theorem". The Mathematical Intelligencer. 19 (4): 51–54. doi:10.1007/BF03024415. 
  8. ^ Swetz, Frank (2008). Legacy of the Luoshu: The 4,000 Year Search for the Meaning of the Magic Square of Order Three. CRC Press. p. 67. 
  9. ^ 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): 151–153. doi:10.1017/S002555720017456X. 
  10. ^ a b c d e f Swaney, Mark. "Mark Swaney on the History of Magic Squares". Archived from the original on 2004-08-07. 
  11. ^ The most famous Arabic book on magic, named "Shams Al-ma'arif (Arabic: كتاب شمس المعارف‎), for Ahmed bin Ali Al-boni, who died about 1225 (622 AH). Reprinted in Beirut in 1985
  12. ^ Andrews, William Symes (1917). Magic Squares and Cubes (2nd ed.). Open Court Publishing Company. p. 122. 
  13. ^ J. P. Hogendijk, A. I. Sabra, The Enterprise of Science in Islam: New Perspectives, Published by MIT Press, 2003, ISBN 0-262-19482-1, p. xv.
  14. ^ Helaine Selin, Ubiratan D'Ambrosio, Mathematics Across Cultures: The History of Non-Western Mathematics, Published by Springer, 2001, ISBN 1-4020-0260-2, p. 160.
  15. ^ Sesiano, J., Abūal-Wafā\rasp's treatise on magic squares (French), Z. Gesch. Arab.-Islam. Wiss. 12 (1998), 121–244.
  16. ^ Peter, J. Barta, The Seal-Ring of Proportion and the magic rings (2016), pp. 6–9.
  17. ^ Jābir ibn Hayyān, Book of the Scales. French translation in: Marcelin Berthelot (1827-1907), Histoire de sciences. La chimie au moyen âge, Tom. III: L'alchimie arabe. Paris, 1893. [rprt.. Osnabruck: O. Zeller, 1967], pp. 139–162, in particular: pp. 150–151
  18. ^ al-Ghazālī, Deliverance From Error (al-munqidh min al-ḍalāl ) ch. 145. Arabic: al-Munkidh min al-dalal. ed. J. Saliba – K. Ayyad. Damascus: Maktab al-Nashr al-'Arabi, 1934, p. 79. English tr.: Richard Joseph McCarthy, Freedom and Fulfillment: An annotated translation of al-Ghazali's al-Munkidh min al-Dalal an other relevant works of al-Ghazali. 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.
  19. ^ 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. 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 Seal-Ring of Proportion and the magic rings (2016), pp. 8–9, n. 10
  20. ^ Andrews, William Symes (1917). Magic Squares and Cubes (2nd ed.). Open Court Publishing Company. pp. 124–126. 
  21. ^ Manuel Moschopoulos – Mathematics and the Liberal Arts
  22. ^ See Alfonso X el Sabio, Astromagia (Ms. Reg. lat. 1283a), a cura di A.D'Agostino, Napoli, Liguori, 1992
  23. ^ 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)
  24. ^ 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. 313–338) 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. 20v-21r; 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. 37v-38r; Florenz, Bibl. Naz., II. IX. 57, f. 86r, und Targioni 9, f. 77r; Florenz, Bibl. Riccard., Ms. 1169, f. 94-95."
  25. ^ This manuscript text (circa 1496–1508) is also at the Biblioteca Universitaria in Bologna. It can be seen in full at the address
  26. ^ 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)
  27. ^ 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)
  28. ^ 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.
  29. ^ Drury, Nevill (1992). Dictionary of Mysticism and the Esoteric Traditions. Bridport, Dorset: Prism Press. ISBN 1-85327-075-X. 
  30. ^ "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. 
  31. ^
  32. ^ "Magic cube with Dürer's square" Ali Skalli's magic squares and magic cubes
  33. ^ "Magic cube with Gaudi's square" Ali Skalli's magic squares and magic cubes
  34. ^ Structure of Magic and Semi-Magic Squares, Methods and Tools for Enumeration
  35. ^ Pinn, K.; Wieczerkowski, C. (1998). "Number of Magic Squares From Parallel Tempering Monte Carlo". Int. J. Mod. Phys. C. 9: 541. arXiv:cond-mat/9804109Freely accessible. doi:10.1142/s0129183198000443. 
  36. ^ "Number of Magic Squares From Parallel Tempering Monte Carlo,, April 9, 1998. Retrieved November 2, 2013.
  37. ^ Mathematical Circles Squared By Phillip E. Johnson, Howard Whitley Eves, p.22
  38. ^ Hartley, M. "Making Big Magic Squares".
  39. ^ Evolving a Magic Square using Genetic Algorithms
  40. ^ Stifel, Michael (1544), Arithmetica integra (in Latin), pp. 29–30 .
  41. ^ "8x8 multiplicative magic square of complex numbers" Ali Skalli's magic squares and magic cubes
  42. ^ "MULTIMAGIE.COM - Additive-Multiplicative magic squares, 8th and 9th-order". Retrieved 26 August 2015. 
  43. ^ "MULTIMAGIE.COM - Smallest additive-multiplicative magic square". Retrieved 26 August 2015. 
  44. ^ a b Magic Designs, Robert B. Ely III, Journal of Recreational Mathematics volume 1 number 1, January 1968
  45. ^ Magic squares are given a whole new dimension, The Observer, April 3, 2011
  46. ^ "Area Magic Squares". Futility Closet. 2017-01-19. Retrieved 2017-06-12. 
  47. ^ Demirörs, O.; Rafraf, N.; Tanik, M. M. "Obtaining n-queens solutions from magic squares and constructing magic squares from n-queens solutions". Journal of Recreational Mathematics. 24 (272–280): 1992. 
  48. ^ How many magic squares are there? by Walter Trump, Nürnberg, January 11, 2001
  49. ^ A006052 in the on-line encyclopedia of integer sequences
  50. ^ A270876 in the on-line encyclopedia of integer sequences
  51. ^ Anything but square: from magic squares to Sudoku by Hardeep Aiden, Plus Magazine, March 1, 2006
  52. ^ 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 4431883Freely accessible. PMID 25973764. 
  53. ^ Macau Post Office web site
  54. ^ Macau's magic square stamps just made philately even more nerdy The Guardian Science, November 3, 2014
  55. ^ Michelle Erica Green (June 15, 1997). "Biogenesis on The X-Files". The Little Review. Retrieved March 25, 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. 
  56. ^ Zack Handlen (November 17, 2012). "The X-Files: "Biogenesis" / Millennium: "Goodbye To All That"". The A.V. Club. The Onion, Inc. Retrieved March 25, 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. 


Further reading[edit]

  • 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: 674–78. 
  • Ollerenshaw, Kathleen; Bree, David (October 1998). Most perfect pandiagonal magic squares: their construction and enumeration. The Institute of Mathematics and its Applications. ISBN 978-0905091068. 
  • Semanisinova, Ingrid; Trenkler, Marian (August 2007). "Discovering the Magic of Magic Squares". Mathematics Teacher. 101 (1): 32–39. 
  • King, J. R. (1963). "Magic Square Numbers". 

External links[edit]