Recreational Math II: Magic Squares of Composite Order

Hits: 55

The 3×3 and 4×4 squares have been used in the past as building blocks for larger magic squares. To use these as building blocks, the order of the resulting square must be some multiple of 3 or 4. In fact, you can say the same thing about building larger squares from any smaller squares of prime order as well.

The Fundamental Theorem of Arithmetic states that all N\in\mathbb{N}, or all numbers N from 0 to infinity have a prime factorization. If it doesn’t have prime factors, then N is itself prime.

Numbers that are not prime have more factors than just 1 and itself. Those numbers are called composite. There is an exception: the number 1, which is not prime (primes have 2 factors: 1 and itself, while 1 just has 1 as a factor), nor is it composite. Yes, I guess you can say there are infinitely many “order-1” (or 1×1) magic squares. For example, the magic square

                                   21

is magic, since it “adds” to 21 in “all directions”. But that is getting philosophical and does not yield much helpful information for building larger squares. You can say that for any single number.

I bring this up, because I have mentioned high-yielding methods of producing prime-ordered magic squares in the past. Orders that are not prime are multiples of a smaller number. Since no order-2 squares exist, we can’t use order-2 as a building block, so we must divide by 2 and use a different factor as a building block. Sometimes order 4 can be used, as they are for making 8×8, 12×12 or 16×16 squares. It’s a little bit dodgy because every 2nd even number is a multiple of 2 and not 4, like 6 or 14. For order 6 then, we turn to order 3 as a building block; for order 14, we must use order-7 as a building block. Since 2 divides all even numbers, higher even numbers can be just divided by 2, with the other factor being used as the building block, so it looks as though one can say that for all nonprime numbers greater than 3, there will exist a number that has a factor apart from 2. A statement like this requires a proof, but I will just state it here for now.

Investigations into 9×9 squares

Odd composite orders like 9 have 3 as a prime factor. And such squares have often been composed of 3×3 tiles via the Lo Shu Method. Squares of order-15 have prime factors 3 and 5, so that such squares can be composed of tiles of fifteen 3×3 squares or nine 5×5 squares.

I tried a little experiment where I attempt to make a 9×9 square out of these same numbers shown above, but using the numbers above also as scalar multiples of the matrix. Let S be the Lo Shu square, expressed as a matrix. Then, each position becomes another Lo Shu square multiplied by a scalar multiple, as follows:

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

The result is the following 9×9 matrix which has magic properties:

16 36 8 36 81 18 8 18 4
12 20 28 27 45 63 6 10 14
32 4 24 72 9 54 16 2 12
12 27 6 20 45 10 28 63 14
9 15 21 15 25 35 21 35 49
24 3 18 40 5 30 56 7 42
32 72 16 4 9 2 24 54 12
24 40 56 3 5 7 18 30 42
64 8 48 8 1 6 48 6 36

While the total of 225 is indeed the same in all rows, columns and diagonals, there are a lot of repeated numbers here. Because the 3×3 sections here are based on multiples, most of the prime numbers p where 9 \leq p \leq 81 are missing (except those less than 9: 2, 3, 5, and 7). But there are a lot of repeated numbers, particularly the highly composite numbers 4, 6, 12, 24, 36, 48 as a consequence of how it was constructed. It would not past muster as magic in the way we have been expecting for this article series.

I was more successful following the same algorithm as was successful for 5×5 squares where you would fill out sequential numbers from 1 to 81 along a diagonal, and obtained the magic sum 369 along all of its rows, columns and both diagonals:

47 58 69 80 1 12 23 34 45
57 68 79 9 11 22 33 44 46
67 78 8 10 21 32 43 54 56
77 7 18 20 31 42 53 55 66
6 17 19 30 41 52 63 65 76
16 27 29 40 51 62 64 75 5
26 28 39 50 61 72 74 4 15
36 38 49 60 71 73 3 14 25
37 48 59 70 81 2 13 24 35

Of course, the disadvantage here is that this is the only square you can produce by this method.

9×9 Squares by the Lo Shu Method

An artist’s impression of the Lo Shu Turtle.

The Lo Shu square refers to the famous 3×3 square discovered some time in the 13th century (some accounts have this as early as the 2nd millenia BCE) by Yang Hui in China. He saw a turtle with an odd arrangement of spots on its back. I could go into the relationship of this particular arrangement of numbers of spots to Chinese mysticism and Feng Shui, but that would be too much of a digression. You can refer to this article in a Feng Shui blog for more detail on its mysticism. But among the things he noticed is that the numbers of spots added to 15 in all directions. The number of dots in each section became known as the famous 3×3 Lo Shu square.

                           4  9  2
                           3  5  7
                           8  1  6

There is another well-known way of producing 9×9 squares, and that is what has earned the name the Lo Shu Method. Unfortunately, you still obtain only one square from this. You begin with an arrangement of 81 numbers in this way, in numerical order by column from right to left:

73 64 55 46 37 28 19 10 1
74 65 56 47 38 29 20 11 2
75 66 57 48 39 30 21 12 3
76 67 58 49 40 31 22 13 4
77 68 59 50 41 32 23 14 5
78 69 60 51 42 33 24 15 6
79 70 61 52 43 34 25 16 7
80 71 62 53 44 35 26 17 8
81 72 63 54 45 36 27 18 9

Then, you take the first row (73, 64, 55, 46, 37, 28, 19, 10, and 1), and arrange them in order analogous to the 3×3 magic square (shown for comparison):

             4  9  2          28 73 10
             3  5  7          19 37 55
             8  1  6          64  1 46

This creates a 3×3 sub-square that is used as a building block for the 9×9 square. You can see that 1, being the lowest number, remains in the bottom center; the 10, being the second lowest, occupies the same position as 2 for the original square. One then proceeds in numerical order for the remaining squares so that the new square has an arrangement analogous to the old arrangement, by ordering of the numbers. The number 73, the largest of this set of numbers, occupies the position held by 9 in the old square, the largest number in that square.

The second row, consisting of the numbers 74, 65, 56, 47, 38, 29, 20, 11, and 2, forms a 3×3 sub-square with the identical arrangement of numbers. In fact, you might notice that this new set is just the old set with 1 added to each element. Taking the small square we just made, we can add 1 and make the next sub-square:

28 73 10                                            29 74 11
19 37 55    --- Add 1 to each element to make: ---> 20 38 56
64  1 46                                            65  2 47

Similarly, we form new 3×3 sub-squares by adding 3, then 4, then 5, until we have nine 3×3 sub-squares to arrange.

28 73 10   29 74 11   30 75 12    31 76 13    32 77 14
19 37 55   20 38 56   21 39 57    22 40 58    23 41 59
64  1 46   65  2 47   66  3 48    67  4 49    68  5 50

33 78 15   34 79 16   35 80 17    36 81 18
24 42 60   25 43 61   26 44 62    27 45 63
69  6 51   70  7 52   71  8 53    72  9 54

You should notice that the bottom center of each sub-square is a single-digit number from 1 to 9. These are identifying marks which tell us where these sub-squares go. And they are arranged according to the positioning of those same numbers in the original 3×3 Lo Shu square. This is what you end up with:

31 76 13 36 81 18 29 74 11
22 40 58 27 45 63 20 38 56
67 4 49 72 9 54 65 2 47
30 75 12 32 77 14 34 79 16
21 39 57 23 41 59 25 43 61
66 3 48 68 5 50 70 7 52
35 80 17 28 73 10 33 78 15
26 44 62 19 37 55 24 42 60
71 8 53 64 1 46 69 6 51

Some squares are highlighted to illustrate the identifying marks I am referring to, and their attached sub-squares relative to each other. This is a fully magic square, with unique numbers from 1 to 81, and a magic total of 369.

We are still hobbled by the disadvantage that this is the only 9×9 square we can make using Lo Shu. There are more ways to make these squares, and Grogono claims that they can even be pan-magic.

 

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

Hits: 74

Click here for my previous article on 4×4 Magic Squares.
Click here for an even earlier article on 4×4 Magic Squares.

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.

0000 \rightarrow 0 (the original 1248 square from the last post, not numbered)
1000 \rightarrow 1
1100 \rightarrow 2
1110 \rightarrow 3
1111 \rightarrow 4
1000 \rightarrow 5
0100 \rightarrow 6
0110 \rightarrow 7
0111 \rightarrow 8
0101 \rightarrow 9
0011 \rightarrow 10
0001 \rightarrow 11
1010 \rightarrow 12
1001 \rightarrow 13
1100 \rightarrow 14
1011 \rightarrow 15

I count 24 \times 16 = 384 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 2(4!)^2 = 1152 possible shufflings of its rows and columns to produce different squares. And thus, 468 \times 1152 = 539,136.

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: 73

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 (71)^2 = (5040)^2 = 25,401,600 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 (13!)^2 = (6,227,020,800)^2 = 38,775,788,043,632,640,000 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”:

The four magic carpets, expressed as matrices.

Each of a, b, c, and d represents a specific number, namely a power of 2. We get to decide which of a, b, c, or d 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 4!, 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 a, b, c, and d 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: 6+5+4 = 4+5+6, 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.

The Virtual Existence of Advameg

Hits: 31

Advameg.org is a toy of Lech Mazur. The Illinios-based website is a throwback to “World-Wide-Web one-point-oh”, which has recently had some CSS3 applied to it. But, it still doesn’t take away from the underlying design of the site, which are rooted in a bygone web architecture. One person said the site looked like throwback from the days of Windows 95.

Many parts of the site appear to be somewhat up-to-date, due to their pulling of public data from whatever outside agencies collect them and make free and public. I have noticed that their RFCs are also pretty much up-to-date also. When I say “up-to-date”, is that everywhere I looked, the latest data, updates, and RFCs are from 2019. To me, this is much more up-to-date than expected (but still not really). All of this free data is curated over 72 of their websites such as City-data, Nonprofit Facts, Photo Dictionary, and one website with the ambitious name “Website Encyclopedia“. There is probably nothing in these sites that you couldn’t look up with Google and get more updated and more reliable information.  It would also be naive to think that all 200 million websites and 400 million registered domains which are currently active would be listed under Website Encyclopedia. Pile on to that the fact that there are a half million websites being added to their number each day.

What has not kept up with the times is their FAQ archive. It is a graveyard of FAQs that have not been updated in almost 20 years. This could once have been easily updated by checking the MIT FAQ archive. But since that is no longer in existence and USENET is pretty much dead in North America, most FAQ maintainers have found better ways of making their FAQs public, usually through making a web page. The founder of Advameg, Lech Mazur, was elusive and seemingly impossible to reach even prior to 2010, and by all accounts, even more difficult to reach today. It is one thing to remove a FAQ that is no longer topical or has links to other internet sites that are no longer working; it is another thing if you once posted opnions you thought were worthwhile 20 years ago, but no longer support.

A website called Ripoff Report indicates that they have resisted requests to update or remove information that is no longer useable, sometimes in a way that appears intimidating, or in a way that uses their access to information about the complainants to reveal names, addresses and identities of anyone who complains about their services.

Also, it appears as though even a 200-word Wikipedia article about city-data.com was unusually difficult to maintain. There were vandals who posted content on the article accusing the discussion board of tolerating racism (this content was quickly taken down). In the Talk section there was extensive discussion about the site, including one posting in 2015 from an Lech Mazur himself who went on in excess of 500 words (more then double the word count of the original article itself) in great detail how to “bring the article up to Wikipedia standards”. He seemed mostly to be self-advocating, rather than bending Wikipedia to his will. He was posting his views on how it should be written, and the Wikipedia writers responded with their own review of how articles get written and sourced.

city-data.com has been cited a few times over the years by other websites like the New York Times as a reference to stats about things like housing prices, or in one case, their city-data discussion forum has been mentioned once when the topic of commuting from New York City to Scranton, Pennsylvania (120 miles away) came up. There was no comment on this, just a link. Therefore, it is puzzling to stumble into the review of this site from complainants to the Better Business Bureau, with various kinds of racism. The kinds appear inconsistent, with some complaining of the site becoming a hotbed for hate groups and trolls of various persuasions. The data side of this site is out of date by several years, and not that useable, as many other commenters to the BBB had noticed.

It looks as though, apart from being on LinkedIn these days, Mazur is also posting tweets about tech and science on Twitter. He is trying to position his company, it appears, in the area of artificial intelligence and natural language processing. He does not accept tech support questions on his Twitter feed. I would guess that also means no complaints about city-data or faqs.org.

My take on the “Math Test” problem

Hits: 37

I have no desire to further pollute YouTube with yet another video on the “3 = ?” so-called “controversy”, so I seem to feel better trolling my own blog about it.

If you have a mindless social media account, like Instagram, Facebook, or Twitter, you would have seen this “Math Test” being spread around over the past few years:

From Vi Hart’s video (https://youtu.be/Twik7wqdwZU)

I don’t wish to pick on Victoria Hart, as she was the second person I have noticed embarking on this trend to make something profound out of this poorly-worded, poorly-conceived “Math Test”. This was similarly done by Hank Green of Vlog Brothers fame.

The person formulating the question didn’t seem to care enough about forming their question properly enough to articulate what they really meant. I don’t think I would be making any controversial statement to say that 7 and 56 are not equal, not even for large values of 7 ☺. In fact, none of the numbers are equal. The vloggers have attempted to  ascribe genius to the author of the question and attempt to look past the abused equal signs, but there is no consensus, meaning you can make any nonsense up that you like. The author of this “test” has never come forward, so we will never know what they meant by these tortured equations.

It means that the ambiguity in the question is just left for everyone else to waste their time arguing over. Hart and Green appear to be playing a part similar to interpreters of ancient manuscripts whose authors have vanished over thousands of years without a trace of their existence. Both engage in a kind of exegesis of the work with nothing really to go on, since there is no time or place for this “test”. But they have to find something to say because this “test” has gone so viral, and they have to score engagement points with their viewers and with YouTube.

While Hart and Green make heroic efforts at making such dodgy questions seem profound and serious (in my opionon, Vi Hart wins top honors here), their profundity carries too many assumptions about the author (whom no one has met, remember), to take anything seriously. Too many what-if’s. The only thing that comes out of both videos is that they have been thinking about this way too much. Hank Green tries to turn it into a statement on the state of humanity; while Vi Hart tries to use it to comment on how logic is usad to carry forward various social and cultural biases made by imaginary scholarly people who sit in their armchairs and rationalize all day, whom it is implied we should all hate.

If there was no internet, and this was written on a piece of paper, no one would think twice about dismissing it. It relies on a certain number sense, yet, also relies on a certain functional illiteracy toward math symbols so that people reading this question engage with it. It shouldn’t take an Einstein to see there is something wrong by saying that “9 = 90“. But there is also a number pattern. It would have been better to use function notation. If f(x) represented an unknown formula, I would feel better if it were written this way:

f(9) = 90

This first equation says that if you plug 9 into the formula, you get 90. Other numbers are thus plugged in to get numerical results that hopefully bear some kind of relationship:

f(8) = 72
f(7) = 56
f(6) = 42

Finally, you jump to f(3), and if you know the pattern, you know the answer. Or do you?

f(3) = y

I am not promoting f(x) as “the correct interpretation,” and I can’t be bothered to propose a solution that hasn’t already been seen countless times in discussions over many parts of the Internet. There have been passionate arguments over what f(3) is (12? 18?), because more than one pattern has been proposed. Because the question is so sketchy, and the writer of the question is AWOL, and can’t be held to account, there really isn’t going to be any consensus possible.

The question is easy to dismiss, since the writer of the question has given us much to be dismissive of. The real question to ask here is: is it a productive use of our time to engage in math questions where we are forced to make assumptions based on information we don’t have (and will likely never have)? I think everyone knows the answer to that.

More things for you to worry about: Buying a used car these days

Hits: 75

Ian_FloodI have heard from the most recent Consumer Reports that if you choose to buy a used car in the coming months, it is quite possible that you could obtain a car that was a write-off in the Florida floods after Hurricane Ian.

What dealers would do is repair these cars, and while they might be in driveable condition when sold, their lives are greatly shortened by the effects of the prior flood damage: rust, corrosion, and electrical malfunctions. Water can also wreak havoc on lubricants and the car’s internal mechanics. Some state laws require the flooded cars to be re-branded as “totalled” or as “salvage”. Most places will only allow resale of a revived flood-damaged car if it is sold as “rebuilt” (assuming any needed repairs were actually done to make the flood-damaged car roadworthy). Sellers can dodge this regulation by saying the car was “lost” and not traceable to an owner, or if there was only a bill of sale attached to it.

wsl and VcXsrv (and Cygwin)

Hits: 118

wsl is the Windows Subsystem for Linux, a nice way to get apps from X-Windows to work in MS-Windows.

Here you can see the MS-Windows taskbar and icons in the desktop. The terminal in the foreground is running wsl in one of its tabs, but the tab for Cygwin is the one that is open. The X applications that comprise the other windows are all Cygwin.

The way it is supposed to work, is that I configure and run wsl so that both Windows and Linux kernels cooperate together, and then install VcXsrv so that I have a way of running X applications on Windows through my MS-Windows installation. For the record, I am running Windows 10, and WSL 2.

I am still in the process of learning how to configure it. Above you see a screenshot of my desktop running the apps you would expect to have run on a properly-configured wsl/VcXsrv installation: you see xcalc, xterm, and xload. You even get xfig. In the foreground is Windows Terminal, so that doesn’t count. VcXsrv is running with the root window hidden so you can see my Windows Desktop along with the attendant X-Windows applications.

So what’s the problem, you ask? It looks like I have gotten it do do whatever I need it to do, so there is little else to learn. And that, my dear reader is where you are mistaken. Yes, VcXsrv is running X-Windows as it should, but the applications are coming from my Cygwin installation, not from wsl. Setting $DISPLAY to 127.0.0.1:0.0 in Cygwin is enough configuration in Cygwin to get it to send apps to VcXsrv directly from Windows Terminal, over the BASH command line.

I have been trying for the past week to get this to work in wsl without success, but I appear to be succeeding in running Cygwin’s X apps without Cygwin’s X-windows.

Have I gained anything by stumbling on this? Well, I have to say that the X server offered by VcXsrv is faster than Cygwin/X. Cygwin’s X-windows server takes nearly a minute to load, while VcXsrv loads in under a second. One thing that is lost is the ability to launch X running one of the window managers, like mint, KDE or Gnome. With the X desktop as given under VcXsrv, there are no window commands or menus apart from the one that appears in the Windows 10 taskbar icon tray on the right. It is nearly identical to the Cygwin/X menu.

But as it is, it has no commands, and would work better if it wasn’t there at all. So, yes you can hide the desktop, just like you can under Cygwin, and have your X-apps mingle with your Windows 10 apps. They can all be accessed by using Alt+TAB just like any windows 10 application.

I have noticed that the “top” command does something different under an X-based terminal than it does in a Windows 10 terminal. Apart from the usual information, it shows a text-based bar graph of the usage of each core on the CPU, as well as the memory and swap used.

This is Cygwin’s rxvt window running under Windows 10 and X-Windows. Unlike normal “top” on wsl and Linux generally, this one also uses bars to indicate cpu loads and other information. Color is toggled with a keypress on both OS’s, but color is default on Cygwin.

The PRIMM approach to computer science teaching

Hits: 69

With research from Sue Sentance’s blog and primmportal.com.

The stages of PRIMM make out its acronym:

  • Predict
  • Run
  • Investigate
  • Modify
  • Make

In the Predict stage, students are given code, and asked to predict its output. This can be done in pairs, and can also be a whole day’s lesson. The code is written by the teacher, and has to be tested ahead of time to eliminate student doubts about syntax or runtime errors. The goal here is to get students to determine the function of a piece of code by looking for clues.

Run is the stage where students test their prediction by running the code. This might involve downloading it to their programming environment. It is meant as a confidence booster, and to take away ownership of errors away from the teacher. While it is possible to copy the code, it is not adviseable, due to typos and time spent typing, especially if the code goes on for dozens of lines.

Investigate could mean code tracing, commenting, flowcharting, labelling concepts or special algorithms, or just answering questions. Working in pairs can help students to work out the details of the code.

The first 3 stages, predict, run, and investigate, could be done many times before students understand the underlying concepts in a secure way. It is not necessarily true that students understand if-else statements or loops after only being shown it once.

In the modify stage, students take a working piece of code and are asked to modify it to do something different. At the start of a course or unit, you should start simply, and progress so that students modify ever larger chunks of code. Transfer of ownership of the code now moves from “not mine” to “partly mine”.

In the make stage, students write the program from scratch. The new program can bear similarites to previous programs. The new program can have similarities to previous programs, but should differ in function, context or problem to solve.

What this allows is scaffolding of learning. Mutual support is had through students working in pairs. This also helps students to articulate particular problems that are going on in the code.

A new 2048-style challenge

Hits: 79

Yes, the game 2048 is one of those tablet/cellphone games which also run on a desktop browser which have fascinated numerically-inclined people such as myself. It is a wonderful waste of time, something to do while you are doing something else and actually need to pull yourself away for a few moments and clear your mind by diverting your attention to something else for a bit.

As many of you know, it is normally played on a 4×4 grid. When you search for “2048 game” on the Duck Duck Go search engine, at the top of the selection is a game Duck Duck Go has provided:

Duck Duck Go’s attempt to replicate the “classic” game of 2048

My cellphone app offers me a variety of grid dimensions to play on: 4×4, 5×5, 6×6, and 8×8. The bigger the grid size, the easier it gets to obtain the total 2048. Once you obtain that tile, you win, although you can continue playing. You can play until you have no more room to move or merge your tieles. If you run out of room before you reach 2048, you lose.

The 8×8 tileset is so easy, you can have a mess on the grid and still reach 2048 eventually, with plenty of room left on the board to move your tiles around. So if you are just starting out, you might find it easier to play with the larger boards, eventually graduating to the 4×4 board once you have a clear idea what is going on, and have built a sense of intuition. My version of the game allows you to undo your last turn (but no more than that) in case your last move was less than ideal. It is also useful because sometimes I could swipe right and the tiles move in the wrong direction for some reason. They are supposed to move in the direction of the swipe.

Out of curiosity, I went one size down and tried out the 6×6 mode of the app, and so far, I have two 4096 tiles, and a 16384 tile with no end in sight:

A bit blurry, but there are always a ton of empty squares in this game, and the game board, as you can see is less than ideal for tile distribution. But I’m still getting 16384 and beyond. This same game has been played and stored off and on for the past week.

So, since 2048 is fairly easy on grids beyond 6×6, I began to wonder what numbers could pose a challenge on these larger squares. For 8×8, I think I found what might be a suggestion:

Uhhh, woah.

By the title of this game, they appear to be suggesting that I try to reach a tile labelled “2,147,483,648”, a 10-digit number just over 2 billion. I would be curious to see how they achieved fitting such a number on a tile once it is obtained. But how long would that take? On a 4×4 grid, getting that tile could take a couple of hours, if you get there at all.

The original 2048 suggests that 2048 be the winning tile, which is a power of 2, namely 2^{10}. Taking the base-2 log of 2,147,483,648 on my calculator, I find that this new number is equal to 2^{31}. I am beginning to think that I will need to pass this on to my children in my will, assuming I haven’t lost the game yet.

2147483648 is a game offered currently on GitHub, so it is likely the side project of a professional programmer or a pet project for a hobbyist and could still contain bugs (imagine the nightmare in testing and debugging this game into the high numbers). It appears that the only one developing the project is an anonymous, nameless, faceless programmer going by the handle “jiangtyd”. That said, it seems to come with clever innovations, such as allowing the program to auto-move the tiles on its own to create interesting combinations. You can also change base to something like 3, or increase the tiles by way of the Fibonacci sequence. The “3” selection is a bit lame, in that the successive tiles that need to be formed are really 3\times 2^n, so you are really dealing with powers of 2 again, except in a different way.

A Pet Peeve About the Internet

Hits: 63

I have said this several times before in many ways, and I will say it again: there is too much importance placed on the internet. It wouldn’t be so bad if the internet was run by the government, since that would make it more accountable. But instead, it is mostly in the hands of large private companies, who are largely unaccountable, and would not be truthful unless regulators, or the threat of regulation, forces their hand.

This was brought out in all its glory yesterday, as the Canadian telecommunications conglomerate, Rogers, experienced a denial of service nationwide, affecting all internet services. It wasn’t just that families were denied Netflix or YouTube, or that you couldn’t receive email or text messages, it was that the entire economy slowed considerably. Interac stopped working, and that meant that people couldn’t make transactions unless they had cash or credit. All major banks and credit unions use Interac, and thus experienced this problem. But in addition, customers were also not able to do e-transfers or pay bills through their bank.

Many vending machines are hooked up to the internet, and some of them were disabled if they had to connect with a Rogers service. Municipal parking, now dependent on the internet as many cities abandon parking meters, were hobbled as municipalities were not able to accept payment for parking. Toronto’s BikeShareTO service, whcih depends on the internet to distribute bikes to users, had to declare their bikes inaccessible for all stations in Toronto. Vancouver had a similar problem with its bike share program. School boards with summer online programs had to go asynchronous and move its deadlines back another day. Public libraries had a stoppage of WiFi service at many locations, as well as self-checkout machines, and book kiosks.

Many retail stores had to close altogether for the day, as was seen in Mississauga’s Square One Mall and Toronto’s Yorkdale Mall. Many condos and apartments experienced a disabling of their buzzer systems due to the outage.

That wasn’t all. 911 services also stopped working in many areas where the 911 services were managed by Rogers. Chatr Mobile and Fido, offshoot services owned by Rogers, also stopped working. Downstream internet service providers (ISPs) also experienced downtime as a consequence.

It caused the phone lines at the CRTC to go down, since they were using IP telephony provided by Rogers. Of course, this would also be true for any IP telephone, which includes all cell phones served by Rogers or its subsidiaries. These IP telephones also went down in passport offices provided by Service Canada. Rogers also manages the multi-factor authentication systems used by the Canada Revenue Agency, so anyone attempting to log in to the CRA website yesterday could not log in.

One way the internet is oversold is in how we market and use IoT (Interent of Things) devices. Imagine for example, the many forms of digital signage you see around you. A good number of them are connected to the internet, and programmed remotely. Examples are digital highway signs which warn of dangers ahead. So are a good number of household appliances, including televisions and tablets. IoT can also centrally link home security systems, allowing a monotoring service to provide surveillance at low cost as if a security guard was on site. IoT has medical applications, such as providing a way to aid medical professionals to monitor someone who has cardiovascular disease. Some of these things seem pretty essential, but others, such as IoT stoves or refrigerators which are sold to households, not so much. All these would stop working if internet providers had a service stoppage the same way Rogers had done, and these effects would have been already felt with the Rogers denial of service.

Too much is riding on the internet, and too much is riding on only a small handful of service providers. So much so, that we appear to take the internet for granted the way we take water, electricity and sewage for granted. We just assume it works and people are doing their jobs.

But the internet is very different from these other public utilities, in that there are too many variables involved in providing people with decent service. Networks can get hacked, and DDOS attacks are common enough to brandish its own acronym. Weather events happen and can cause regions to have to do without service for some time. As we have seen there are many services, and to have the same provider do them all is like putting all your eggs in the one basket.

It must also be added that the Internet wouldn’t exist without government handouts to the telcoms. It was taxpayer’s money that established the main trunk lines for the internet in the 80s and 90s in Canada and the United States. The infrastructure was practically given away to the major telcoms, and we are now seeing an example of what happens when the internet is controlled by too few companies which are largely unregulated and have little public accountability.

There is more than one major provider in Canada – Bell and Cogeco are other big players that come to mind. But we need more than just a few, so that if a DDOS attack happens, the number of people affected will be limited. Outages such as this can slow down the federal government’s attempt to provide all Canadians with universal high-speed internet by 2030.

With information from The CBC, the Toronto Star, and other websites.