[AMOF] [GENERATE] [Schoolnet Icon]


Information on Magic Squares

[Description | Example | History | Applications | Implementation | Classroom | Links]


Description of the Problem

Draw a 3 by 3 grid on a piece of paper. Now try to place the numbers 1 through 9 into the squares in such a way that all columns, all rows and both diagonals add up to the same amount. The result is known as a magic square.

In general, a magic square is an n x n matrix of numbers where each row, each column and both diagonals add up to n(n2 + 1)/2

The simplest magic square is the 1 by 1. This is simply a 1. There are no 2 by 2 magic squares, but there are for 3 by 3, 4 by 4, 5 by 5, and so on.


Example

For example, all the magic squares of size 3 by 3 are shown below:

276
951
438
294
753
618
618
753
294
672
159
834
834
159
672
816
357
492
492
357
816
438
951
276

Notice that all of these squares can be obtained from the first one through flips and turns (rotations) of the first magic square. AMOF will only generate one of these 8 squares.


A Brief History

Magic Squares are claimed to go back as far as 2200 BC when the Chinese called them lo-shu. According to legend, the pattern was first revealed on the shell of a turtle that crawled out of the Lo River in the twenty-third century B.C.

Here is the lo-shu magic square:

492
357
816

The first indication of any mathematical investigation into magic squares was from Cornelius Agrippa. In the early part of the 15th century in Europe, he constructed magic squares from orders 3 to 9. He associated these squares with the planets then known, including the sun and moon.

In 1514, Albrecht Dürer, a famous artist of the 16th century, made a woodcut called "Melancholia" which contained a 4 by 4 magic square. It is shown below.

163213
510118
96712
415141

In 1908, a mathematician named Veblen used matrix methods to study magic squares.

It has long been known that the number of magic squares of size 4 is 880. In recent decades, a computer was used to count the number of magic squares of size 5, getting a result of 275305224. However, no one has ever reported a count of the number of magic squares of size 6.


Applications to Mathematics and other Areas

The magic squares problem is an example of a problem which is easy to understand, yet hard to solve in general. In fact, the problem of determining how many magic squares there are of size n has not been solved. This remains an open question in mathematics.

There are many varieties of magic squares which are studied in mathematics. Some simply satisfy the row, column and diagonal sum rules, and are called simple. Others also possess a great deal of symmetry and are called Nasik magic squares.

The magic squares problem leads to work into areas of mathematics such as theories of groups, lattices, Latin squares, determinants, partitions, matrices and congruence arithmetic.

Computer scientists are also perplexed by the difficulty of generating all magic squares of larger sizes. More realistic is the idea of generating only certain kinds of magic squares of a large size, such as what AMOF does with sizes 6 through 10.


Explanation of AMOF Implementation

In AMOF, you must specify n, the size of magic squares which you want generated. The maximum size is 10, the minimum is 1, and there is no result for 2. There are no output options because AMOF will automatically output an n x n grid.

Magic Squares of the larger sizes used in AMOF can be constructed in a fairly simple way. A Magic Border can be constructed and then a Magic Square can be placed inside this border. A Magic Border is a rectangle of numbers in which each row and column adds to the appropriate number and all pairs of numbers which are on opposite ends of the border add to the same value.


In the Classroom

Given in this section are a number of different activities which are relevant to the magic squares problem.

Students can try to generate magic squares and compare their own constructions to those which AMOF produces.

The method of using Magic Borders to generate Magic Squares can be used in the classroom. Secondary school students can practice this technique .

Students can be given a partially completed magic square where the totals are not as low as in the original problem. For example, a magic square with rows, columns and diagonals adding to 24 can be created.

Magic triangles activity: The numbers 1 through 6 are arranged on a triangle with 3 numbers per side so that each side adds to the same amount, in this case 10. Variations: try 1, 2, 3, 5, 6, 7 or 1, 2, 3, 4, 6, 7

Magic Circles activity: Put the numbers 1 through 6 into the squares in such a way that the four numbers on each circle add up to the same amount. A diagram of this is given below.

Numbers wheels are another related actvity. One number wheel is shown below. Each group of three circles that are in a line must add to the same value . The lines which add to this value must contain a value from the outside. In other words, the long diagonals within the circle count as two lines.

A Magic Cube extension of the problem is to create a magic cube of the numbers 1 through 27 where each row and column adds to the same amount. The diagonal on the faces of the cube need not add to this amount, but the diagonals of opposite corners in the cube should.


Links to Other Relevant Sites and Sources of Information


[AMOF] [GENERATE] [Schoolnet Icon]


This page created by Frank Ruskey and Scott Lausch, March 1998. ©Frank Ruskey and Scott Lausch, 1998.