1. What are magic squares?
・What are magic squares?
A magic square is an n by n grid, whose cells contain numbers ranging from 1 to n2 and in which the sum of numbers in any row, column, or diagonal is the same. We consider cases with n>= 3. The simplest example is shown below. This is a 3 by 3 magic square, or a magic square of 3rd order. This is made by arranging each number from 1 to 9 so that any row, column, or diagonal has the same sum.
Rows 2+9+4=15 7+5+3=15 6+1+8=15 Columns 2+7+6=15 9+5+1=15 4+3+8=15 Diagonals 2+5+8=15 4+5+6=15
As one can see, the sums are indeed the same.
Similarly, there are magic squares of 4th, 5th, 6th orders, and so on. Try verifying that the sum of any row, column, or diagonal is all the same in the example below. The sum of a row, column, or diagonal is called the magic constant. Once n is chosen, the magic constant is also determined. It is 15 for n = 3, 34 for n = 4, 65 for n = 5, and so on. The magic constant of a magic square of nth order can be found by dividing the sum of 1 to n2 by n; namely, the magic constant = n (n2+1)/2.
Magic squares are called “magic squares” in English. The mysterious nature of magic squares has fascinated people from both Europe and China since antiquity. Many people are studying magic squares even today. Unlike in the past, computers have helped us understand many things, but there remain more mysteries that cannot be solved by computers.
・How many solutions are there for magic squares?
How do we construct such magic squares? Magic squares of 3rd order can be made with a little thought, but those of 4th order or more are difficult to construct. If we want to find just one such square, there are many methods explained in sources such as Wikipedia. However, finding just one square is not enough; it is also interesting to think about how many magic squares exist. When thinking about the number of solutions, we need to clarify rotations and reverses. For example, we can take a magic square of 3rd order and rotate it by 90° and obtain another magic square (make sure to fix the orientations of numbers). Similarly, we can obtain magic squares after rotating 180° and 270°. A reversed magic square is also a magic square. Then, we can easily obtain 7 more magic squares from one magic square. Therefore, we take rotated and reversed squares as identical when counting the number of magic squares.
One might think that there is a formula for the number of magic squares of nth order. However, no such formula has been found, and the number of squares can only be found by calculating them one by one, making it a troublesome problem. The numbers of magic squares known today are as follows.
3rd order 1
4th order 880
5th order 275, 305, 224
6th order about 1.8 × 1019
・Magic square of 3rd order
There is only one magic square of 3rd order. With 9 variables, there are 8 (essentially 7) conditions satisfying the same sum, yet there exists a square using each number from 1 to 9. This is a miracle in a sense.
・Magic squares of 4th order
There are 880 magic squares of 4th order. These squares were found even before the invention of computers. Today, a computer can show all the squares very quickly. This would be a handy programming practice.
→ Characteristics of magic squares of 4th order → Special magic squares of 4th order → All Solutions of magic squares of 4th order → Program for finding magic squares of 4th order
・Magic squares of 5th order
Believe it or not, there are 275,305,224 magic squares of 5th order. This was discovered, with the help of computers, in 1973 by Richard Schroeppel from the United States*1. Unfortunately, however, his work did not attract much attention, and there even was a book written 20 years later that stated that the solution for magic squares of 5th order had not been found. The calculation was a tremendous task for computers in the 1970's. It required a lot of calculation time. Today, though there is some wait time, the calculation can be done by a personal computer. However, it may not be so easy to write the code. In our research group, all the calculations were made as graduation projects.
→ Special magic squares of 5th order
・Magic squares of 6th order
If the number of magic squares of 5th order is so large, how many magic squares of 6th order are there? The exact number is not known. This is because even the latest super computers are not up to the task. However, there are some estimates. Our research group came up with an estimate in 1992 by using "estimation by random sampling"*2. The number was about 1.8 × 1019. In 1998, K. Pinn and C. Wieczerkowski in Germany, also reached a similar estimate (1.775 × 1019).
→ Special magic squares of 6th order
・Pan diagonal magic squares
Pan diagonal magic squares are magic squares in which, in addition to the rows, columns and diagonals, the pan diagonals also share the same sum. As shown in the figure to the right, pan diagonals run diagonally and wrap round at the edges of the square. They can be considered diagonals where the right and left edges of the magic square are connected. Similarly, the top and bottom edges can be considered connected.
If the sums of the pan diagonals are also same, it means that one can get a magic square by switching rows or columns. In other words, one pan diagonal magic square can give rise to n2 magic squares.
Pan diagonal magic squares have more requirements than magic squares; thus, their occurrence is less frequent, or sometimes null, depending on the order. For the number of pan diagonal magic squares of different orders, refer to the following links: → Special magic squares of 4th order, → Special magic squares of 5th order, and → Special magic squares of 6th order
・Magic squares with numbers other than 1 to n2
There exist magic squares that restrict the numbers used.
* Prime magic squares
The most famous of such magic squares are those that only use prime numbers. An example of a prime magic square of 3rd order is shown on the right. Even though it is of 3rd order, it is not an easy task to find such a combination of prime numbers. It is difficult to construct a magic square with small prime numbers, and one with only the prime numbers smaller than 100 does not seem to exist. However, since there are infinitely many prime numbers, some believe there are an infinite number of prime magic squares of 3rd order. In older literature, the number 1 is sometimes treated as a prime number, but that is not accurate; 1 is not a prime number.
→ Prime magic squares of 3rd order
Similarly, it is possible to construct prime magic squares of 4th order. To the right are the prime magic squares of 4th order, which have the smallest magic constant (120). It is interesting that its magic constant is smaller than the magic constants of prime magic squares of 3rd order. Among the prime magic squares of 4th order, some of them are pan diagonal magic squares.
→ Prime magic squares of 4th order
Next is 5th order. It is cumbersome to look for such a square randomly, so let us find the ones with smaller magic constants. It is obvious that the prime numbers used do not include 2. Now, it is impossible to make a magic square with only the first 25 prime numbers starting from 3 (3, 5, …, 101). This is because the sum of such numbers is 1,159, which is not a multiple of 5. Since 1159 ÷ 5 ＝ 231.8, the magic constant has to be at least 233.
Surprisingly, once we look for prime magic squares with the magic constant of 233, we find there are many of them (more than 100,000). Two examples of such magic squares are shown on the right.
→ Prime magic squares of 5th order
How about 6th order? Similar to the case of 5th order, the smallest possible magic constant is 432. By hypothesizing the magic constant to be 432, one can find many such squares.Two examples are shown on the right.
→ Prime magic squares of 6th order
Similar to the case of lower order, many prime magic squares of 7th, 8th and 9th order are found.
→ Prime magic squares of 7th order → Prime magic squares of 8th order → Prime magic squares of 9th order
* Magic squares of squares
Next are magic squares with only square numbers. Since square numbers have increasing intervals like 1, 4, 9, 16, 25, and so on, the magic constant necessarily becomes large. I first saw a 4th order magic square of squares introduced by Mr. Kobayashi at the Puzzling Amusement Club, Kansai. There are actually many such squares for 4th and 5th orders, yet there appears to be no 3rd order magic square of squares. It probably does not exist, but I have not seen a proof that it does not exist.
There are many 4th order magic squares of squares. Yet, the smallest magic constant of such squares is (as large as) 2,823. It is similar for the 5th order, but the smallest magic constant is 1,375, which is smaller than that of 4th order.
6th order magic squares of squares are not so easy to find as 5th order or lower. The smallest magic constant of 6th order is 2775 (by T.Kobayashi,1994).
→ 4th order magic squares of squares → 5th order magic squares of squares → 6th order magic squares of squares
・Mystery of magic squares？
In old ages, it was believed that magic squares have mysterious power. A mysterious magic square of 4th order is found in Albrecht Durer's Melencolia. The work and the magic square in the red square are shown on the right. What is mysterious? Look at the middle two cells in the bottom row. 1514 is the date he finished this work.
Did he calculate the magic square? If he did, was it easy or hard?
* Your birthday in a magic square of 4th order
Isn't it interesting to find paticular date in a magic square like Melancolia? Is it possible to embed your birthday (month and day) in a magic square of 4th order? It is obvious that dates of numbers more tan 16 and doublets(repdigits) are impossible. Other dates can be included in magic square of 4th order with only four exceptions. They are
July 8th, August 7th, september 10th, October 9th
* Your birthday in a magic square of 6th order
We can use all the numbers of date (1-31) in magic squares of 6th order. Is it possible to embed your birthday in a magic squares of 6th order?
If your birthday is not a doublet the answer is Yes! How can I assert it? The way I proved is not smart. I calculated all the combinations of months and days. You can find your birthday in the following links.
→ Birthdays in a magic square of 6th order（Jan.-Jun.）
→ Birthdays in a magic square of 6th order（Jul.-Dec.）
・ Minimum clues of magic square problem
How many clues are necessary at least to render a SUDOKU solution unique? It was solved in 2012 and the number is 17.*3
Similarly, I found the minimum number of clues in magic square problems with unique solution.
* 2-clue problem of 3rd order
The minimum is two. An example is shown on the right. Some other combinations of 2 numbers are also possible.
* 3-clue problems of 4th order
There are no 2-clue problems that make a unique solution. Three clues are necessary to fix other cells. 3-clue problems are shown on the right. There are some other problems.
* 3-clue problems of 5th order
There are no 2-clue problems that make a unique solution. All the combinations of two numbers in all cells are tested.
The least number of clues that make unique solution is 3. Two examples are shown. They are very rare and are only two fundamental patterns. All other combinations are derived from these two samples by simple transformations. The calculations to find these two are cumbersome a little bit.
References ： "Hojin no kenkyu", Osaka Kyoiku Tosho, by Hirayama & Abe, 1983
*1Scientific American 1/1976, by Martin Gardner
*2"Estimation of number of solutions of 6th order magic square by random sampling",Sugei Puzzle No.177, 1992 Apr. pp13-20 By Yasaki Oishi → PDF
*3"Mathematicians Solve Minimum Sudoku Problem"
Yasaki Oishi, Department of Information Systems, Daido University