Over the millennia, many ways to construct magic squares have been discovered. These methods can be classified as general methods and special methods, in the sense that general methods allow us to construct more than a single magic square of a given order, whereas special methods allow us to construct just one magic square of a given order. Special methods are specific algorithms whereas general methods may require some trial-and-error.

Special methods are the most simple ways to construct magic squares. They follow certain algorithms which generate regular patterns of numbers in a square. The correctness of these special methods can be proved using one of the general methods given in later sections. After a magic square has been constructed using a special method, the transformations described in the previous section can be applied to yield further magic squares. Special methods are usually referred to using the name of the author(s) (if known) who described the method, for e.g. De la Loubere's method, Starchey's method, Bachet's method, etc.

Magic squares exist for all orders except for order 2, as they can trivially be seen as a homogeneous system of linear equations consisting of (at most) equations and variables. Magic squares can be classified according to their order as odd, doubly even (n divisible by four), and singly even (n even, but not divisible by four). This classification is based on the fact that entirely different techniques need to be employed to construct these different species of squares. 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 John Horton Conway's LUX method for magic squares and the Strachey method for magic squares.

Special methods of construction

A 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 nine numbers will be distinct positive integers forming a magic square with the magic constant 3c so long as 0 < a < b < c − a and b ≠ 2a. Moreover, every 3×3 magic square of distinct positive integers is of this form.

In 1997 Lee Sallows discovered that leaving aside rotations and reflections, then every distinct parallelogram drawn on the Argand diagram defines a unique 3×3 magic square, and vice versa, a result that had never previously been noted.

A method for constructing a magic square of odd order

A method for constructing magic squares of odd order was published by the French diplomat de la Loubère in his book, A new historical relation of the kingdom of Siam (Du Royaume de Siam, 1693), in the chapter entitled The problem of the magical square according to the Indians.Mathematical Circles Squared By Phillip E. Johnson, Howard Whitley Eves, p. 22 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 square is filled with a multiple of the order n, 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.

+ step 1 1      

+ step 2 1   2

+ step 3 1 3 2

+ step 4 1 3 4 2

+ step 5 1 3 5 4 2

+ step 6 1 6 3 5 4 2

+ step 7 1 6 3 5 7 4 2

+ step 8 8 1 6 3 5 7 4 2

+ step 9 8 1 6 3 5 7 4 9 2

Starting from other squares rather than the central column of the first row is possible, but then only the row and column sums will be identical and result in a magic sum, whereas the diagonal sums will differ. The result will thus be a semimagic square and not a true magic square. Moving in directions other than north east can also result in magic squares.

+ 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. Numbers are then either retained in the same place or interchanged with their diametrically opposite numbers in a certain regular pattern. In the magic square of order four, the numbers in the four central squares and one square at each corner are retained in the same place and the others are interchanged with their diametrically opposite numbers.

A construction of a magic square of order 4 Starting from top left, go left to right through each row of the square, counting each cell from 1 to 16 and filling the cells along the diagonals with its corresponding number. Once the bottom right cell is reached, continue by going right to left, starting from the bottom right of the table through each row, and fill in the non-diagonal cells counting up from 1 to 16 with its corresponding number. As shown below:

+ M = Order 41 4 6 7 10 11 13 16

+ M = Order 41 15 14 412 6 7 9 8 10 11 513 3 2 16

An extension of the above example for Orders 8 and 12 First generate a pattern table, where a '1' indicates selecting from the square where the numbers are written in order 1 to n2 (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 pattern table is as shown below (third matrix from left). With the unaltered cells (cells with '1') shaded, a criss-cross pattern is obtained.

+ 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 1312 11 10 9 8 7 6 5 4 3 2 1

+ M = Order 41 0 0 1 0 1 1 0 0 1 1 01 0 0 1

+ M = Order 41 15 14 412 6 7 9 8 10 11 513 3 2 16

The patterns are a) there are equal number of '1's and '0's in each row and column; b) each row and each column are "palindromic"; c) the left- and right-halves are mirror images; and d) the top- and bottom-halves are mirror images (c and d imply b). The pattern table can be denoted using hexadecimals as (9, 6, 6, 9) for simplicity (1-nibble per row, 4 rows). The simplest method of generating the required pattern for higher ordered doubly even squares is to copy the generic pattern for the fourth-order square in each four-by-four sub-squares.

For M = 8, possible choices for the pattern are (99, 66, 66, 99, 99, 66, 66, 99); (3C, 3C, C3, C3, C3, C3, 3C, 3C); (A5, 5A, A5, 5A, 5A, A5, 5A, A5) (2-nibbles per row, 8 rows).

+ M = Order 81 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 0 0 1 1 0 0 11 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 01 0 0 1 1 0 0 1

+ M = Order 81 4 5 8 10 11 14 15 18 19 22 23 25 28 29 3233 36 37 40 42 43 46 47 50 51 54 55 57 60 61 64

+ M = Order 81 63 62 4 5 59 58 8 56 10 11 53 52 14 15 49 48 18 19 45 44 22 23 4125 39 38 28 29 35 34 3233 31 30 36 37 27 26 40 24 42 43 21 20 46 47 17 16 50 51 13 12 54 55 957 7 6 60 61 3 2 64

For M = 12, the pattern 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 pattern table, taking rotational symmetries into account.

Method of superposition The earliest discovery of the superposition method was made by the Indian mathematician Narayana in the 14th century. The same method was later re-discovered and studied in early 18th century Europe by de la Loubere, Poignard, de La Hire, and Sauveur; and the method is usually referred to as de la Hire's method. Although Euler's work on magic square was unoriginal, he famously conjectured the impossibility of constructing the evenly odd ordered mutually orthogonal Graeco-Latin squares. This conjecture was disproved in the mid 20th century. For clarity of exposition, two important variations of this method can be distinguished.

Euler's method This method consists in constructing two preliminary squares, which when added together gives the magic square. As a running example, a 3×3 magic square is considered. Each number of the 3×3 natural square by a pair of numbers can be labeled as

1 2 3 4 5 6 7 8 9

αa αb αc βa βb βc γa γb γc

where every pair of Greek and Latin alphabets, e.g. , are meant to be added together, i.e. . Here, . The numbers 0, 3, and 6 are referred to as the root numbers while the numbers 1, 2, and 3 are referred to as the primary numbers. An important general constraint here is

a Greek letter is paired with a Latin letter only once.

Thus, the original square can now be split into two simpler squares:

α α α β β β γ γ γ

a b c a b c a b c

The lettered squares are referred to as Greek square or Latin square if they are filled with Greek or Latin letters, respectively. A magic square can be constructed by ensuring that the Greek and Latin squares are magic squares too. The converse of this statement is also often, but not always (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 exactly once in a given column or a row.

This can be achieved by cyclic permutation of α, β, and γ. Satisfaction of these two conditions ensures that the resulting square is a semi-magic square; and such Greek and Latin squares are said to be mutually orthogonal to each other. For a given order n, there are at most squares in a set of mutually orthogonal squares, not counting the variations due to permutation of the symbols. This upper bound is exact when n is a prime number.

In order to construct a magic square, we should also ensure that the diagonals sum to magic constant. For this, we have a third condition:

either all the letters should appear exactly once in both the diagonals; or in case of odd ordered squares, one of the diagonals should consist entirely of the middle term, while the other diagonal should have all the letters exactly once.

The mutually orthogonal Greek and Latin squares that satisfy the first part of the third condition (that all letters appear in both the diagonals) are said to be mutually orthogonal doubly diagonal Graeco-Latin squares.

Odd squares: For the 3×3 odd square, since α, β, and γ are in arithmetic progression, their sum is equal to the product of the square's order and the middle term, i.e. α + β + γ = 3 β. Thus, the diagonal sums will be equal if we have βs in the main diagonal and α, β, γ in the skew diagonal. Similarly, for the Latin square. The resulting Greek and Latin squares and their combination will be as below. The Latin square is just a 90 degree anti-clockwise rotation of the Greek square (or equivalently, flipping about the vertical axis) 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