## Recreational Math II : Even-Ordered Magic Squares: 4×4 part 2

Hits: 203

Much of the work from that article came from an Excel spreadsheet, which I forgot to save. No big deal, I re-constructed the 24 squares again using Grogono’s magic carpets. But as I was doing this I was finding to my horror that these new magic squares – all proven to be pan-magic — were different from the 24 squares in the previous article. What was notably absent was the number 16 in the upper left and the 1 in row 3, column 3, which occured in all 24 of the squares generated yesterday. In fact, what had happened instead is that the 1 and the 16 switched places. Weird.

So, I took a closer look. And I found out that in the last article, I based my carpets on a scheme I found on the internet. Again, it looks like this:

This was not what I got from the Grogono site. The Grogono site had a scheme more like this:

Every placeholder and zero are switched. What had a zero now has a placeholder, and what was a placeholder now has a zero. While the “pan-magicness” was not affected, we appeared to obtain new magic squares.

But what if I picked and chose which carpets to invert, and which to leave as-is. Would the result still be magic? That is, could I still get pan-magic if I chose to invert only one random carpet, or two, or three random carpets?

From what I have investigated, it appears that in all cases, yes, that is what will happen. And when I did that, I began to notice squares which were rotated or flipped versions of other existing squares. Below are the 16 squares generated from square “1248” from the previous day’s posting, by inverting one, two, three or all four magic carpets in all possible permutations, never changing the ordering of the carpets. All of these are pan-magic.

 1 15 4 14 Original 12 6 9 7 13 3 16 2 8 10 5 11 1 2 3 4 2 16 3 13 4 14 1 15 8 10 5 11 16 2 13 3 11 5 10 8 9 7 12 6 13 3 16 2 5 11 8 10 14 4 15 1 16 2 13 3 12 6 9 7 4 14 1 15 7 9 6 12 5 11 8 10 1 15 4 14 9 7 12 6 5 6 7 8 3 13 2 16 5 11 8 10 7 9 6 12 15 1 14 4 10 8 11 5 16 2 13 3 14 4 15 1 6 12 7 9 15 1 14 4 9 7 12 6 11 5 10 8 3 13 2 16 6 12 7 9 4 14 1 15 2 16 3 13 10 8 11 5 9 10 11 12 11 5 10 8 13 3 16 2 9 7 12 6 6 12 7 9 2 16 3 13 8 10 5 11 4 14 1 15 15 1 14 4 7 9 6 12 1 15 4 14 5 11 8 10 10 8 11 5 14 4 15 1 12 6 9 7 16 2 13 3 3 13 2 16 13 14 15 10 8 11 5 12 6 9 7 14 4 15 1 3 13 2 16 1 15 4 14 7 9 6 12 6 12 7 9 8 10 5 11 2 16 3 13 15 1 14 4 13 3 16 2 11 5 10 8

Changing the ordering of the carpets makes no difference in the resulting magic square, as addition is commutative. Throughout these past two postings, I have always kept the carpets in one order while trying out all possible substitutions of the numbers 1, 2, 4, and 8 on them. The above set are variations on 1248 with each new variant labelled from 1 to 16, which labels are highlighted in yellow.

Keeping the ordering of the carpets the same as in the two illustrations at the start of this article, let a “1” represent an inverted, Grogono carpet, and a “0” represent a member from the first set of carpets. So, a “1111” would repsent the fact that all Grogono carpets were used, and “0000” represent the idea that all carpets were used as per the first illustration, or as seen in the last posting. Something like “0100” would tell you that only the second carpet was the inverted Grogono carpet, and the rest were the original carpets I used. I wish I could say that the 16 magic squares illustrated above went with the ordering of the binary numbers, but instead I began my spreadsheet experimentally with some random choices, then proceeded to fill out the missing combinations as I went. What follows is the actual ordering of those squares.

(the original 1248 square from the last post, not numbered)

I count magic squares, while being aware that many of them are rotations or reflections, possibly of the first 24. For example, squares 1 and 7 is a reflection; 2 and 13 is a rotation, as is 3 and 15. So, I am quite sure that 384 will not be anywhere close to the count when rotations and reflections are taken into consideration.

The new magic squares I have obtained are thus, using the Grogono carpets:

 1248 1284 1248 1482 1 15 4 14 1 15 4 14 1 15 6 12 1 15 6 12 12 6 9 7 8 10 5 11 14 4 9 7 8 10 3 13 13 3 16 2 13 3 16 2 11 5 16 2 11 5 16 2 8 10 5 11 12 6 9 7 8 10 3 13 14 4 9 7 1824 1842 2148 2184 1 15 10 8 1 15 10 8 1 14 4 15 1 14 4 15 14 4 5 11 12 6 3 13 12 7 9 6 8 11 5 10 7 9 16 2 7 9 16 2 13 2 16 3 13 2 16 3 12 6 3 13 14 4 5 11 8 11 5 10 12 7 9 6 2418 2481 2814 2841 1 14 7 12 1 14 7 12 1 14 11 8 1 14 11 8 15 4 9 6 8 11 2 13 15 4 5 10 12 7 2 13 10 5 16 3 10 5 16 3 6 9 16 3 6 9 16 3 8 11 2 13 15 4 9 6 12 7 2 13 15 4 5 10 4128 4182 4218 4281 1 12 6 15 1 12 6 15 1 12 7 14 1 12 7 14 14 7 9 4 8 13 3 10 15 6 9 4 8 13 2 11 11 2 16 5 11 2 16 5 10 3 16 5 10 3 16 5 8 13 3 10 14 7 9 4 8 13 2 11 15 6 9 4 4812 4821 8124 8142 1 12 13 8 1 12 13 8 1 8 10 15 1 8 10 15 15 6 3 10 14 7 2 11 14 11 5 4 12 13 3 6 4 9 16 5 4 9 16 5 7 2 16 9 7 2 16 9 14 7 2 11 15 6 3 10 12 13 3 6 14 11 5 4 8214 8241 8412 8421 1 8 11 14 1 8 11 14 1 8 13 12 1 8 13 12 15 10 5 4 12 13 2 7 15 10 3 6 14 11 2 7 6 3 16 9 6 3 16 9 4 5 16 9 4 5 16 9 12 13 2 7 15 10 5 4 14 11 2 7 15 10 3 6
##### How many 4×4 magic squares are there?

In 1933, a mathematician who taught at UC Berkeley named Derrick Norman Lehmer published a short paper in the October 1933 edition of the Bulletin of the American Mathematical Society, entitled “A Complete Census of 4×4 Magic Squares”. In this paper, he deals with magic squares generally, not just the pan-magic ones. He asserted that there are 539,136 magic squares of order 4 in total.

His way of counting involves the ability to normalize them by rearranging the numbers in a methodical way which shows that squares showing a different normalization cannot be transformed by shuffling columns or rows. It turns out that there are 468 normalized squares of order 4. Each of these 468 normalized squares has possible shufflings of its rows and columns to produce different squares. And thus, .

As for order-4 pan-magic squares, there are 52 ways to obtain a total of 34. The diagram below came from a Ted Talk by mathematician Michael Daniels, and illustrates the 52 ways to obtain the total.

Grogono also offers a diagram where you can see the effects of changing the numbers on a 4×4 magic square, the inversion of the carpets, and so on. You just have to remember that for his squares, the numbering starts from 0 and the magic number is 30. So, that to get the magic number 34, you need to add 1 to each position in the magic square.

## Recreational Math II: Even-ordered Magic Squares: 4×4

Hits: 267

I had been going on now for quite a while about magic squares of odd-order, particlularly those magic squares whose order is a prime number of 5 or more. The algorithm for creating 5×5, 7,7, 11×11, 13,13 and other prime-ordered magic squares are all pretty similar, based on a sum of two squares and what might be called a “knight’s tour” to the right for the first one, and to the left for the second one.

The pattern breaks when you get to squares of even order, or of composite order. So, 4×4 has many pan-magic squares, but most methods I have observed appear to be brute force. And even after I have read about a method for constructing such squares, I have been often disappointed by the low-yielding nature of the algorithms they suggest.

The methods I have described for a 7×7 construction, for example, can yield possible magic squares. And the larger the prime-ordered square, the greater the possibilities. By the time we get to 13×13, the number of squares becomes or over 38 quintillion. Counting to such a number would take more than 1.2 trillion years, hundreds of times longer than the age of the universe. And we are just getting warmed up. After all, 13×13 isn’t really that big. But I think by now I can impress on you what a “high-yielding” algorithm can do. It must be stated that there appear to be no magic squares beyond 5×5 that are pan-magic. The rest appear to be normal magic, which I will distinguish shortly.

The methods I will now describe in the coming articles, those of composite order of 4 or more, are generally low-yielding. We will start with order 4. The one I learned about for a 4×4 square was by visiting Grogono.com, a site created and run by Alan Grogono, a professor of anesthesiology at the Tulane University School of Medicine, located in New Orleans, Louisiana. His foray into this branch of mathematics is proof that non-mathematicians are as capable as anyone of spending more time in recreational math than they or their spouses will care to admit.

Grogono states that all 4×4 squares are variations of the same three squares. This is probably uncharitable, since he only refers to pan-magic squares, and that is quite a high bar. He does not appear to count the possibility of squares that are fully magic (or a normal level of magic), but not pan-magic. Normal magic in a 4×4 square will have unique digits from 1 to 16 in some randomized order, which nevertheless add to 34 in each of its rows, columns and diagonals. Pan-magic goes beyond this and offers multiple symmetrical ways of getting the total, in addition to normal magic.

So, I have a strong hunch that if we ignore pan-magic and stick with normal magic, I think I can state cautiously that we will obtain a number of unique magic squares greater than 3.

### The Magic Carpet Method

But first, I wll mention the “magic carpet” technique that Grogono describes for the creation of his randomized 4×4 pan-magic squares. The magic carpet method has been around possibly for centuries, probably as long as magic squares have been around. And if we count China, it would have been for at least a millenia. But “magic carpet” for me conjures up images of Arabic lore and mythology. Indeed, magic squares have been known to Middle Eastern and South Asian culture for centuries as well. For all of its renown worldwide, no one has yet thought of a use for magic squares. It remains a staple of recreational mathematics.

A 4×4 pan-magic square requires four 4×4 magic carpets, or numbers patterned in a 4×4 matrix which resemble the weave of a carpet. Each of the carpets have a different “weave”:

Each of , , , and represents a specific number, namely a power of 2. We get to decide which of , , , or gets to be the numbers 1, 2, 4, or 8. Once filled out, we add all four matrices to obtain the 4×4 magic square we want. But this gets us a magic number of 30, not 34, and the numbers will go from 0 to 15 rather than 1 to 16. If we add 1 to each number, or rather, add a matrix filled with 1’s, that fixes the problem, and the numbers 1 to 16 are restored, and 34 becomes the magic number.

The fact that the 4×4 magic squares depends on the ordering of four numbers means that potentially there are , or 24 possible magic squares. So, it is not a great yield. Grogono tells us that even these squares boil down to the rotations or reflections of the same 3 pan-magic squares.

This caused me to have a look at the magic squares in question to see if there was any truth to this. For your edification, here are the 24 magic squares below:

 8421 8412 8241 8214 16 9 6 3 16 9 7 2 16 9 4 5 16 9 7 2 5 4 15 10 5 4 14 11 3 6 15 10 3 6 12 13 11 14 1 8 10 15 1 8 13 12 1 8 10 15 1 8 2 7 12 13 3 6 12 13 2 7 14 11 5 4 14 11 8142 8124 4821 4812 16 9 4 5 16 9 6 3 16 5 10 3 16 5 11 2 2 7 14 11 2 7 12 13 9 4 15 6 9 4 14 7 13 12 1 8 11 14 1 8 7 14 1 12 6 15 1 12 3 6 15 10 5 4 15 10 2 11 8 13 3 10 8 13 4281 4218 4182 4128 16 5 4 9 16 5 11 2 16 5 4 9 16 5 10 3 3 10 15 6 3 10 8 13 2 11 14 7 2 11 8 13 13 8 1 12 6 15 1 12 13 8 1 12 7 14 1 12 2 11 14 7 9 4 14 7 3 10 15 6 9 4 15 6 2841 2814 2481 2418 16 3 10 5 16 3 13 2 16 3 6 9 16 3 13 2 9 6 15 4 9 6 12 7 5 10 15 4 5 10 8 11 7 12 1 14 4 15 1 14 11 8 1 14 4 15 1 14 2 13 8 11 5 10 8 11 2 13 12 7 9 6 12 7 2184 2148 1842 1824 16 3 6 9 16 3 10 5 16 2 11 5 16 2 13 3 2 13 12 7 2 13 8 11 9 7 14 4 9 7 12 6 11 8 1 14 7 12 1 14 6 12 1 15 4 14 1 15 5 10 15 4 9 6 15 4 3 13 8 10 5 11 8 10 1482 1428 1284 1248 16 2 7 9 16 2 13 3 16 2 7 9 16 2 11 5 5 11 14 4 5 11 8 10 3 13 12 6 3 13 8 10 10 8 1 15 4 14 1 15 10 8 1 15 6 12 1 15 3 13 12 6 9 7 12 6 5 11 14 4 9 7 14 4

Each square is labelled with a 4-digit number denoting, in order, the values of , , , and used in the magic carpets in constructing each square. I was able to order the squares from the highest 4-digit number to the lowest, to show there are no duplicates.

### Asside: The missing square: The Dürer Square

Click here for a previous article I wrote on the Dürer Square.

On a side note, I found that the 4×4 magic square created by Albrecht Dürer and engraved on his 1514 Melancholia carving does not appear to be included in the above set of 24. This is one example of a square that is not pan-magic. Here is the Dürer square:

 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1

The Dürer square is fully magic (all rows, columns and both diagonals add to 34), and in addition, you can obtain 34 by adding the four corner squares, and again by adding the four central squares. But there is no other way to obtain a total of 34 that uses a pattern with any kind of symmetry that would cause us to group it among the pan-magic squares.

The above square follows the pattern of having 16 on  the upper left, but in addition has the year of the engraving, “1514” at the centre squares of the bottom row. It is sort of like the 2418 square in the above series, but just sort of, and without the distinctive “1514”. It also bears some resemblance to the square 2814. But you will find there will be numbers that break symmetry, and so you can’t just shuffle a column or two to get the Dürer square. If you follow the numbers 1 to 16 in the Dürer square, they appear to follow a magic carpet pattern of some kind, but it doesn’t seem quite like what we did.

In the above series of 24 squares, we can see right away that the squares are unique, since a “16” consistently appears on the upper left corner, precluding the idea that any of these squares are mere rotations or reflections of each other. The only reflection I would imagine to be the case might be reflections along the main diagonal, which extends from the upper left to the lower right. There is another consistency in all of these squares in that they also possess a “1” in the third row, third column.

I can make out adjacent pairs of squares with the same main diagonal, where the other diagonal in the second is the reversal of the first. This is seen throughout the 24 squares, for example the first two squares 8421 and 8412 have 16, 4, 1, and 13 as their main diagonal, while the opposing diagonal in 8421 is 3, 15, 14, 2, which is the reversal of the square 8412. Since I have not seen a pair of squares where the rest of the number follow suit to produce such a reflection (known as a “transposition” in matrix math), this just remains an interesting quirk.

However, Grogono went to the extent of defining any magic square with identical columns as “the same”, even if their ordering of those columns are different. This might be justified from the thinking of matrices as vector systems. Thus, shifting columns is merely just shuffling vectors around, and if these were indeed vector systems, all shufflings of four equations (which these vectors would represent) in four unknowns would yield the same solutions. Thus, it can be argued, matrices with shifted columns are “the same”. Examples I have been able to spot are 4281 and 2481. If you look, you begin to find them everywhere, which is why Grogono was able to reason that there were only 3 squares whose columns are truly unique and “non-shufflable”, if there is such a phrase. All the rest are shufflings of these three.

But I have a problem with this in that, objectively speaking, these are not vector systems. This is just a number game where numbers are distributed in a grid of some kind. It might be helpful to think of this as a matrix, or a table, but the fact remains that this is just a number game, and no one is trying to say these are vector systems or linear systems in four dimensions. I find matrix terminology helpful as well, but we can’t get carried away into the recesses of linear algebra, since that is not what this is about.

What most people who dabble in magic squares mean when they say two squares are “the same” is that if you rotate or reflect the magic square and get the same as another square, then they are the same. I offer a quick  example with 3×3 squares:

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

The middle square is a rotation of the left square. The right square is a reflection of the left square. If we simply either rotate or reflect the other two squares we always get the square on the left. This is why it has been widely stated that only one unique 3×3 magic square exists. According to Grogono, there are 8 variations of this one square, all being rotations or reflections of each other. I will leave it to the reader to find the other five.

So, when someone who knows about magic squares says that squares are the same, they are referring to something “visual” done to it, so that the arrangements of numbers will always be the same relative to each other.

The above 3×3 squares can’t be shuffled, since “9 5 1” and “7 5 3” will always have the immutable property of being either the middle row or the middle column, with “5” always occupying the center square. So, any “shuffling” in a 3×3 is really a reflection, since the outer rows or columns are the only things you are allowed to shuffle. Also notice that the diagonal numbers are immutable as well: “6 5 4” and “8 5 2” are the only game in town for these diagonals. Indeed, rotations and reflections of squares shouldn’t be counted as different, because addition is commutative: , for example. Adding the same 3 numbers will get the same total.

In larger squares, if shuffling is observed, I would argue that the squares can be seen as different. The center number, if there is one, can change, and there are no immutable rows or columns that we saw in the 3×3 squares. It still must be conceded that the rows and columns are “the same” due to addition’s commutative property. If you shuffle the columns, then the numbers in the rows are merely in a different order, and so you are still adding the same four numbers. However, the shuffling changes the diagonals, and any other symmetric arrangements which can add up to the magic number, which exist in the above 4×4 pan-magic squares.