How To Do Magic Squares | A Clear Guide

Magic squares are square grids of numbers where the sum of numbers in each row, column, and main diagonal is the same, known as the magic constant.

Understanding magic squares offers a wonderful opportunity to appreciate the elegance of number theory and systematic problem-solving. These mathematical puzzles have fascinated thinkers for millennia, providing a tangible way to engage with arithmetic patterns and logical construction. Learning how to construct them reveals underlying mathematical principles that are both accessible and profound.

Understanding Magic Squares

A magic square is a square grid where each cell contains a distinct positive integer, and the sum of the integers in each row, column, and both main diagonals is identical. This consistent sum is referred to as the “magic constant” or “magic sum,” often denoted by M.

The “order” of a magic square refers to the number of cells along one side, represented by ‘n’. Thus, an n x n grid is a magic square of order n. For a normal magic square, the integers used are typically from 1 to n2.

The magic constant M for any normal magic square of order n can be calculated using the formula: M = n (n2 + 1) / 2. This formula ensures that the sum remains consistent regardless of the specific arrangement of numbers, as long as the square adheres to the definition.

Historically, magic squares trace their roots back to ancient China, with the 3×3 Lo Shu square being one of the earliest known examples, dating back possibly to 650 BC. Their study continued through India, the Islamic world, and medieval Europe, often associated with mystical or astrological significance before their mathematical properties gained prominence.

Constructing Odd Order Magic Squares (n is odd)

Magic squares of odd order (e.g., 3×3, 5×5, 7×7) are constructed using a relatively straightforward method known as the Siamese method, also sometimes called De la Loubère’s method. This method systematically places numbers in a diagonal pattern with specific rules for wrapping around the grid and handling occupied cells.

  1. Begin by placing the number 1 in the middle cell of the top row.
  2. For subsequent numbers, move one cell diagonally up and to the right.
  3. If this move takes you off the top row, wrap around to the bottom row of the same column.
  4. If this move takes you off the rightmost column, wrap around to the leftmost column of the same row.
  5. If the cell determined by the diagonal up-right move is already occupied, or if the move takes you off the top-right corner (where both wrap-around conditions would apply simultaneously), instead place the number directly below the current number’s position.
  6. Continue this process until all numbers from 1 to n2 are placed.

Example: A 3×3 Magic Square

Let’s apply the Siamese method to construct a 3×3 magic square. For n=3, the magic constant M = 3 (32 + 1) / 2 = 3 (9 + 1) / 2 = 3 10 / 2 = 15. Each row, column, and main diagonal must sum to 15.

Following the steps:

  • Place 1 in the middle of the top row (row 0, col 1).
  • Move up-right from 1: This is off the top row and off the right column. Wrap around to the bottom row, leftmost column (row 2, col 0) and place 2.
  • Move up-right from 2: This is row 1, col 1. Place 3.
  • Move up-right from 3: This is row 0, col 2. Place 4.
  • Move up-right from 4: This is off the top row. Wrap around to the bottom row (row 2, col 2). Place 5.
  • Move up-right from 5: This is off the right column. Wrap around to the leftmost column (row 2, col 0). This cell is occupied by 2. So, place 6 directly below 5 (row 0, col 2 becomes row 1, col 2).
  • Move up-right from 6: This is row 0, col 0. Place 7.
  • Move up-right from 7: This is off the top row. Wrap around to the bottom row (row 2, col 0). This cell is occupied by 2. So, place 8 directly below 7 (row 1, col 0).
  • Move up-right from 8: This is row 0, col 1. This cell is occupied by 1. So, place 9 directly below 8 (row 2, col 1).
Resulting 3×3 Magic Square
Row/Col Col 0 Col 1 Col 2
Row 0 8 1 6
Row 1 3 5 7
Row 2 4 9 2

Verifying the sums: Each row (8+1+6=15, 3+5+7=15, 4+9+2=15), each column (8+3+4=15, 1+5+9=15, 6+7+2=15), and both main diagonals (8+5+2=15, 6+5+4=15) all sum to 15.

Constructing Singly Even Magic Squares (n = 4k + 2)

Singly even magic squares are those where the order ‘n’ is an even number, but not a multiple of 4 (e.g., 6×6, 10×10, 14×14). These are generally more complex to construct than odd order squares. A common method involves dividing the large square into smaller sub-squares and applying modifications.

One prominent method, often attributed to Strachey, involves these general steps:

  1. Divide the `n x n` square into four `(n/2) x (n/2)` sub-squares. Label them A (top-left), B (top-right), C (bottom-left), and D (bottom-right).
  2. Fill each of these `(n/2) x (n/2)` sub-squares as an odd order magic square using the Siamese method. However, each sub-square uses a different range of numbers:
    • Sub-square A uses numbers from 1 to `(n/2)^2`.
    • Sub-square B uses numbers from `(n/2)^2 + 1` to `2 (n/2)^2`.
    • Sub-square C uses numbers from `2 (n/2)^2 + 1` to `3 (n/2)^2`.
    • Sub-square D uses numbers from `3 (n/2)^2 + 1` to `4 (n/2)^2`.
  3. After filling, specific elements are swapped between sub-squares A and C, and between B and D. The exact pattern of these swaps depends on the order ‘n’ and involves identifying specific columns on the left and right sides of the sub-squares, along with a middle column. These swaps are crucial for ensuring the overall `n x n` square becomes a magic square.

This method builds upon the odd-order construction but introduces a layer of complexity through the division and element swapping. For a 6×6 square, for instance, `n/2` is 3, so four 3×3 sub-squares are filled, and then specific numbers are exchanged. Further details on these specific swap patterns can be found in advanced number theory resources.

Constructing Doubly Even Magic Squares (n = 4k)

Doubly even magic squares are those where the order ‘n’ is a multiple of 4 (e.g., 4×4, 8×8, 12×12). These squares have a distinct construction method that often involves marking or reversing number sequences. A popular method is the “continuous counting” or “crossed-out” method.

  1. Draw an `n x n` grid.
  2. Divide the entire grid into smaller 2×2 blocks. Identify all cells that lie on either of the two main diagonals of the entire `n x n` square. Also, identify all cells that lie within 2×2 blocks that are themselves on the main diagonals of the larger square. Mark these cells.
  3. Fill the numbers from 1 to n2 sequentially, moving from left to right, row by row. However, only write down the numbers in the unmarked cells.
  4. Now, starting from n2 and counting downwards to 1, fill the marked cells. Place these numbers in the marked cells in reverse order of how you would normally fill them (i.e., from right to left, bottom to top, or by simply identifying the marked cells that were skipped and filling them from n2 down to 1).

Example: A 4×4 Magic Square

Let’s construct a 4×4 magic square. For n=4, the magic constant M = 4 (42 + 1) / 2 = 4 (16 + 1) / 2 = 4 17 / 2 = 34. All rows, columns, and main diagonals must sum to 34.

Following the “crossed-out” method:

  • Draw a 4×4 grid.
  • Mark the cells along the main diagonals. For a 4×4, these are (0,0), (1,1), (2,2), (3,3) and (0,3), (1,2), (2,1), (3,0).
  • Fill 1 to 16 sequentially, but only write numbers in the unmarked cells.
  • Then, fill the marked cells by counting backwards from 16 to 1.
Resulting 4×4 Magic Square
Row/Col Col 0 Col 1 Col 2 Col 3
Row 0 16 2 3 13
Row 1 5 11 10 8
Row 2 9 7 6 12
Row 3 4 14 15 1

Verifying the sums: Each row (16+2+3+13=34, 5+11+10+8=34, 9+7+6+12=34, 4+14+15+1=34), each column (16+5+9+4=34, 2+11+7+14=34, 3+10+6+15=34, 13+8+12+1=34), and both main diagonals (16+11+6+1=34, 13+10+7+4=34) all sum to 34.

Properties and Significance of Magic Squares

Beyond their construction, magic squares possess several interesting mathematical properties. The magic constant M is uniquely determined by the order n. This means that for any given order, there is only one possible magic sum for a normal magic square. Understanding this constant provides a fundamental check for any constructed square.

Some magic squares exhibit additional properties, such as being “associative” or “pandiagonal” (also known as “panmagic”). An associative magic square is one where every pair of numbers symmetrically opposite to the center sums to n2 + 1. A pandiagonal magic square maintains the magic sum not only in its main diagonals but also in all broken diagonals (diagonals that wrap around the edges of the square).

The study of magic squares extends into areas of combinatorics and computational mathematics, with researchers exploring the number of possible magic squares for higher orders and developing algorithms for their generation. They serve as excellent tools for teaching logical thinking, arithmetic practice, and pattern recognition in educational settings, making abstract mathematical concepts more tangible and engaging. Their historical journey from mystical symbols to mathematical objects highlights humanity’s evolving understanding of numbers and patterns. For a deeper dive into their mathematical properties and variations, resources like Wolfram MathWorld offer extensive information.

Beyond Basic Construction

The field of magic squares extends far beyond the basic square grid. Researchers and enthusiasts explore more complex variations, such as magic cubes, which are three-dimensional arrays where sums along rows, columns, pillars, and main space diagonals are constant. There are also magic spheres, magic stars, and other geometric arrangements that adhere to similar summing principles.

The challenge of constructing higher-order magic squares, especially those with additional properties like being pandiagonal, continues to engage mathematicians. The computational generation and enumeration of magic squares, particularly for orders greater than 5, remain areas of active interest, often requiring sophisticated algorithms and significant computing power. These explorations help us appreciate the vastness of number theory and the intricate ways numbers can be arranged to reveal elegant structures.

The American Mathematical Society provides resources that delve into various aspects of recreational mathematics, including magic squares, illustrating their enduring appeal as both puzzles and subjects of serious mathematical inquiry. Their work showcases how such seemingly simple concepts can lead to profound mathematical questions and discoveries, inspiring new generations of learners to explore the beauty of numbers and patterns. You can find more insights into mathematical exploration at the American Mathematical Society website.

References & Sources

  • Wolfram MathWorld. “Magic Square” Provides comprehensive definitions and properties of magic squares.
  • American Mathematical Society. “American Mathematical Society” Offers resources and publications on various mathematical topics, including recreational mathematics.