What Is a Magic Square? Numbers Arranged So Every Line Agrees
By the BrainSnail editorial team. How these articles are written and checked, and how to tell us when one is wrong.
A magic square is a grid of different numbers in which every row, every column and both diagonals add to the same total. The arrangement has no practical use, which has not stopped it appearing on Chinese scrolls, Islamic amulets, a Durer engraving and the facade of a Barcelona basilica, because a pattern that shouldn't be possible is extremely attractive.
How they work
In the standard version, a square of side n contains the numbers from one to n squared, each used once, and the constant that every line sums to is fixed by arithmetic rather than by choice: the total of all the numbers divided by the number of rows, which gives a formula depending only on n. For a three by three square the constant is fifteen, and there is exactly one solution up to rotation and reflection, a fact that can be proved by hand. For four by four there are 880 distinct solutions, for five by five there are more than thirteen million, and for six by six the number is not known exactly and has been estimated by simulation. Construction methods exist and differ by whether the side is odd, singly even or doubly even, with the Siamese method placing consecutive numbers diagonally and wrapping around the edges producing an odd-order square straightforwardly, which makes what looks like a puzzle into a procedure.
Where they appear
The same object surfaces independently across cultures, almost always with significance attached:
- •The Lo Shu square of Chinese tradition, the unique three by three arrangement, associated with a legend about markings on a turtle's shell emerging from a river and embedded in cosmological and divinatory schemes
- •Indian mathematical texts describing construction methods, with a notable fourth-order square at a temple in Khajuraho
- •Islamic mathematics, which developed general construction methods, and Islamic talismanic practice, where squares were inscribed on amulets and associated with planets
- •Durer's engraving Melencolia of 1514, containing a four by four square whose bottom row includes the numbers fifteen and fourteen, giving the date
- •The Sagrada Familia in Barcelona, whose passion facade carries a four by four square summing to thirty-three, achieved by repeating two numbers, which makes it not a true magic square and is deliberate
- •The Sator square, a Latin word square rather than a numerical one, found at Pompeii and readable in four directions, which is a related fascination with symmetric completeness
The variants
Mathematicians have pushed the idea in several directions, and the constraints make the problems hard rather than decorative. A panmagic or diabolic square requires the broken diagonals to sum correctly as well, which is possible for some orders and impossible for others. A bimagic square remains magic when every entry is squared, which is far more restrictive and was long thought impossible at small orders. A magic square of distinct squares, meaning every entry is itself a perfect square, remains an open problem for the three by three case and has been a well-publicised challenge with a prize attached. Magic cubes extend the idea to three dimensions, requiring every line through the structure to sum equally. Latin squares, where each symbol appears once per row and column, are a related family with genuine practical use in experimental design, since they allow treatments to be arranged so that two sources of variation are balanced, and sudoku is a constrained Latin square with additional block conditions.
Why they keep attracting attention
Magic squares occupy an unusual position between mathematics, art and superstition. They have essentially no applications, which is why professional mathematicians historically paid them limited attention while amateurs produced a great deal of work on them, and that division is itself a recurring feature of recreational mathematics. What sustains the interest is the combination of a completely explicit rule with a solution space that is enormous and irregular, so constructing one feels like discovery rather than calculation. The cultural attachment appears to follow the same logic as other numerical fascinations: an arrangement in which everything balances suggests an underlying order, and that suggestion has been read as cosmological in several traditions independently. The practical descendants are real though indirect, since the constraint-satisfaction techniques used to enumerate and construct such squares are the same ones used for scheduling, circuit layout and experimental design, which is a common pattern in which a useless problem trains tools that turn out to be useful.
The takeaway
A magic square places distinct numbers so that every row, column and diagonal sums to the same constant, which is fixed by arithmetic rather than chosen. The three by three case has exactly one solution up to symmetry, four by four has 880, and counts beyond six are unknown. It appears independently in Chinese, Indian and Islamic traditions, in Durer's Melencolia and on the Sagrada Familia, where the square is deliberately not a true one. Latin squares, its relatives, are genuinely used in experimental design.