The many ways of, um, … conjecturing about Collatz

Hits: 6

Article attached to this image is at: https://opencurve.info/the-collatz-conjecture/

The programming assignment about the Collatz Conjecture I give to my students is getting old. The Collatz Conjecture is a prediction about an algorithm. To state it,

      • You have a number n, a positive whole number
        • if n is even, divide n by 2
        • Otherwise, apply the formula 3n + 1
      • With this new value, repeat the above steps again

The conjecture predicts that whatever the value of n, the series will sooner or later decay down to the sequence 1, then 4, then 2, then 1. Once you reach 1, you will enter a loop that repeats the sequence 1, 4, 2, 1 forever. The repeating “1, 4, 2, 1” sequence is called a cycle. I don’t want to go into the Collatz Conjecture in detail, but you can play with some numbers and satisfy yourself that this is the case for any numbers you can do on paper, and in your head. There are also many videos on YouTube about it, where people both explain it and demonstrate it for some numbers.

It is a conjecture because it has never been proven for all integers. It had been checked computationally for integers as high as $5.7 \times 10^{18}$. Such checking might be furnished as “strong evidence” in support of Collatz, but it falls short of a convincing proof. It remains one of Mathematics’ unsolved problems.

Meanwhile, there are other sequences that have their own conjectured cycles. Dr. N. J. Wildberger (2013) has found in his research that replacing 2 and 3 in the algorithm with 2 and 5 has 1, 6, 3, 16, 8, 4, 2, 1 as one of its cycles. But if you start with n = 5 with the latter scheme, you get another cycle immediately after the first term: 26, 13, 66, 33, 166 83, 416, 208, 104, 52, 26, repeating forever. Things get haywire pretty soon however, when n=7, numbers shoot up to the higher reaches of unsigned int in my C++ program, but after 18,613,331 iterations with no repetition or any other kind of end in sight, I hit Control+C and stopped execution.

I changed the integer type to int1024_t, and by the 20,000th term, the numbers have been hovering around 308 digits for some time, and have likely reached the limitation of the widest integer type I could find. But early on as it proceeded into the thousands of terms, you could see it going down a little, but overall, the numbers swelled.

But was it a high-flying numerical cycle? Repetition was checked by running the program under UNIX’s script program, then checking the typesript file for the numbers it captured. I examined it in vi, and checked to see if the last number in the file was repeated anywhere. It wasn’t. The  same appears to happen with n = 9.

We can change the algorithm slightly to:

        • You have a number n, a positive whole number
          • if n is even, divide n by 2
          • if 5 divides n, divide n by 5
          • Otherwise, apply the formula 7n + 1
        • With this new value, repeat the above steps again

This produces a cycle when n = 6: 3, 22, 11, 78, 39, 274, 137, 960, 480, 240, 120, 60, 30, 15, 3, pretty much from the second term. I’ve observed the same cycle when =12, 15, 17, 19, for example. The doubles and quintuples of these numbers would also be infinite. Also, members of the aforementioned cylcle would predictably also produce the same cycle. n = 13 goes as high as 26,374,440 before coming down to 1. When the cycle terminates in my program, it is because the old pattern of 4, 2, 1 was observed.

The listing for the latter code is shown below:

#include <iostream>
 
int main() {
  unsigned long n;
  unsigned long highest = 0;
  unsigned long terms = 1;
  std::cout << "Enter a number: ";
  std::cin >> n;
 
  while (n > 1) {
    std::cout << n << "\n";
    if (n > highest) { highest = n; }
    terms++;
    if (n % 2 == 0) {
      n = n / 2;
    } else if (n % 5 == 0) {
      n = n / 5;
    } else {
      n = 7*n + 1;
    }
  }
  std::cout << "There are " << terms << " terms in the sequence.\n";
  std::cout << "The maximum term is: " << highest << ".\n";
}

ChatGPT: Testing out the rumors

Hits: 166

ChatGPT is a chat service with an AI bot. It is fed many samples of text from all over the net, and can answer your questions in a conversational style. I have seen videos that uncharatably characterizes chatGPT as quite often giving wrong answers to questions. Academics even play down the bot’s ability to give coherent answers.

Well, I can tell you that despite it being tied to corpus linguistics and samples given to it, chatGPT seems to learn how to respond pretty well.

There was once a famous phrase that is touted to be correct grammar but still completely nonsensical: green dreams sleep furiously. So I asked chatGPT:

why do green dreams sleep furiously?

ChatGPT: I’m sorry, but I’m not sure what you mean by “green dreams sleep furiously.” This sentence appears to be a nonsensical combination of words that does not convey a clear or meaningful message. If you could provide me with more context or rephrase your question, I would be happy to try to help you to the best of my abilities.

So it wasn’t fooled by this standard phrase found in many texts on linguistics. I thought it was entirely possible that this phrase would be so well known to the designers, that it was fed to ChatGPT as a “bad” example of a meaningful phrase.

But then I remembered a video of a prof asking chatGPT about blue wolves, and apparently, chatGPT took him seriously and attempted a serious answer using reasoning that was unsupportable on a casual Googling. There are no blue wolves. So I tried this:

can you tell me about green foxes?

ChatGPT: In the natural world, foxes come in a variety of colors, including red, gray, and even black. However, there are no known species of foxes that are naturally green.

That being said, in some fictional and mythological contexts, green foxes do appear. For example, in Japanese folklore, there is a creature called the “Kitsune” which is a fox spirit with the ability to shape-shift into a human form. Kitsune are often depicted as having red or white fur, but some stories describe them as having green fur.

In modern media, green foxes also appear in various forms of art and entertainment, such as video games and cartoons. For example, in the popular video game series “Star Fox,” the main character, Fox McCloud, is depicted with green fur.

Overall, while there are no known naturally occurring green foxes, they do have a presence in various fictional and artistic contexts.

I couldn’t fool it with that either. I am now starting to chalk it up to maybe a peculiar phrasing the prof was using, which I didn’t have the knack for. Fooling the bot isn’t easy then, and you have to know its weaknesses in a way that a layperson like me is not likely to grasp. Clearly, it is not just riffing “found text” together as claimed in any kind of haphazard manner.

But as a programmer, common sense tells me that a computer isn’t going to know the difference between good and bad responses to samples. It also isn’t going to predict, or have stored answers to, your questions. And indeed, each response to chatGPT allows me to rate an answer by clicking one of two icons — either a “thumbs up” icon or a “thumbs down”.

It is likely after millions of questions from as many users, the sampling would be far richer than what the designers alone would have given.

I even tried to deliberately trip it up with a question like “Why was president Jello Biafra considered an anarchist?” The question is premised on the Dead Kennedys former frontman being “president”, which is untrue. Here is its response:

Why was president Jello Biafra considered an anarchist?

ChatGPT: Jello Biafra, whose real name is Eric Reed Boucher, is an American musician and political activist who is best known as the lead singer of the punk rock band “Dead Kennedys.” He is often associated with anarchist and leftist politics.

Biafra was heavily influenced by the punk rock movement of the late 1970s and early 1980s, which was characterized by a DIY ethos and a rejection of mainstream culture and politics. He was particularly influenced by the British punk band “Crass,” who espoused anarchist and pacifist ideas.

Biafra’s lyrics and political activism often expressed anarchist and leftist ideas, such as opposition to corporate greed, government corruption, and police brutality. He also supported a number of progressive causes, such as environmentalism, animal rights, and LGBTQ rights.

While Biafra himself has never identified as a strict anarchist, his political beliefs and activism have often aligned with anarchist principles of anti-authoritarianism, direct action, and solidarity with marginalized groups. His advocacy for alternative forms of social organization and direct democracy have also been associated with anarchist thought.

Overall, Biafra’s anarchist and leftist leanings are a result of his political and cultural influences, as well as his own experiences and observations of social and political issues in the United States.

It seems to know its counterculture well enough to fool me, a former college DJ (except on some minor points, like his being influenced by the British punk band “Crass”, which I never heard about in all of my years following his biography since the 1980s). But it ignored my reference to him as “president”. Other things that seem just a bit “off”: I don’t think he was ever vocal on animal or LGBT rights (although I am sure he didn’t oppose them), so these are also unsupported.

When I tried a more direct question, “What year was Jello Biafra elected president?”, it then rejected my premise that he was ever president or indeed had ever held political office except in a satirical scenario. Damn. Nailed him.

Then I asked it a Calculus question:

What is the tangent equation of the function x^2 at the point (2.4)?

ChatGPT: To find the equation of the tangent line to the function f(x) = x^2 at the point (2,4), we need to find the slope of the tangent line at that point, and then use the point-slope form of a line to write the equation.

The slope of the tangent line to f(x) at x = 2 is equal to the derivative of f(x) at x = 2. We can find this derivative using the power rule of differentiation:

f'(x) = 2x

So, at x = 2, we have:

f'(2) = 2(2) = 4

This means that the slope of the tangent line to f(x) at x = 2 is 4.

Now we can use the point-slope form of a line to write the equation of the tangent line. The point-slope form is:

y – y1 = m(x – x1)

where m is the slope of the line and (x1, y1) is a point on the line.

Plugging in the values we found, we have:

y – 4 = 4(x – 2)

Simplifying, we get:

y – 4 = 4x – 8

y = 4x – 4

So the equation of the tangent line to f(x) = x^2 at the point (2,4) is y = 4x – 4.

That was scary. Notice that the question was asked with a typographical error: (2.4) should have been (2,4) in the question, but chatGPT just took it all in stride, corrected my mistake and answered the question. It didn’t even point out the mistake, it just dealt with it quietly, as if it was respecting my feelings or something.

The prospect of education and chatGPT

I can say quite succinctly that with chatGPT’s ability to produce essays or to solve math problems with detailed descriptions of the steps that education is clearly under threat.

I also asked chatGPT to produce Java code of the first 10 Fibonacci numbers along with ratios of the successive pairs of terms. It produced the Java code, which printed the terms and ratios on the same line, which I would consider the only bug in the program, albeit a minor bug. It also added comments in key places int he code. It only took a few changes of their print() statements into printf() statements before the output became presentable. Code formatting was excellent. But here I take a grade 10/grade 11 problem in programming, and it appears a call to chatGPT can now solve those programming problems, and very likely more complex problems as well. And do it in seconds.

The prospect of love, relationships and chatGPT

I love my wife, I really do. And I’m a lousy poet. So can chatGPT write romantic sonnets? Oh yeah. You pick the flavour: standard, Petrarchean, Shakespearean — those were the styles I’ve tried. The first one was the one I finally gave to my wife Diane as a “found poem with her name by an unknown author”. While that is true in its content — the AI bot just curates samples of text from all over the ‘net and munges it all together in interesting and new ways, so indeed attribution is impossible — it was the standard “white lie” of a husband who had almost forgotten today was Valentine’s day, and who had not the heart to tell her that the sonnet was computer-generated through artificial intelligence.

But I meant every word of the poem.

Write a sonnet for my wife diane

ChatGPT: Of all the things that I have come to know,
There’s none so fair or dear as Diane’s face.
Her eyes, like pools of light, with love aglow,
Her smile, a thing of wonder and of grace.

She moves with such a poise and gentle ease,
A joy to see her dancing through the day.
Her laughter, like a bird upon the breeze,
Can lift me up and chase my cares away.

In times of need, she is my shining light,
A beacon in the darkness of my soul.
Her love has helped me through the darkest night,
And made me once again feel whole.

Diane, my love, my heart’s own true delight,
You are the sun that makes my world so bright.

The most “popular” programming languages since 1960

Hits: 145

There will be people that will dismiss any “popular” programming list as a kind of meaningless horse race. But that’s as long as you are not looking for job prospects as an answer to what will pay the bills and keep the lights on when you enter the work world. But the field is large enough that you have room to ask  yourself: what kind of programming do you want to do? Systems programming? Applications? Servers? Clients? Scientific models? Statistical studies? Device drivers? Everyone hears about web programming, since that is the most visible, and seems to get the most “airplay” in the media. It might even interest you. For others, it’s dull. There is so much more out there.

With that preamble, why am I bothering to still do this? It is to show how popular languages follow the ebb and flow of computing history. Since World War II, we had the ENIAC, a host of IBM and AT&T mainframes, followed by networked computers, then personal computers, then the internet, and so on. With each major shake-up, programming needs change.

Disk drums on an IBM 2314.

By 1965, what had changed preferences in computer languages, are the same things that change it today: changes in hardware, programming for mainframes versus “personal” computers (which in this decade amounted to comptuers like the PDP-1). In the 1960s, hard drives (which were called “disk drums” back then) were relatively new, as was magnetic tape. Transistors hadn’t quite made their heyday yet, with the some of the most powerful computers still using vacuum tubes.

1960

COBOL. 1960 saw the introduction of supercomputers in the service of business, and by far the most popular language was COBOL (COmmon Buisiness-Oriented Language). COBOL was an interpreted language, which meant it was capable of running on many different machines with a minimum number of changes. Today, by the end of 2022, over 80% of business code is still written in COBOL.

1965

The Olivetti programmable calculator, about the size of a small modern digital cash register, and among the first of its kind.

ALGOL. Algol-60 saw the first implementation of the QuickSort algorithm, invented by C. A. R. Hoare, while a student in Moscow. He was knighted by Queen Elizabeth II for his discovery. Algol was behind COBOL as the most popular programming language, but both were dwarfed by FORTRAN users.

Niklaus Wirth

FORTRAN. FORTRAN was far and away the most popular programming language by 1965, and stayed that way for some decades. It was taught in many “service” computer course taken by science students and most engineering students. It was known for having a rather elaborate mathematics capability.

Other languages popular during that period: Assembly, APL, BASIC and Lisp. 1969 was the year that PASCAL was first introduced, by Niklaus Wirth.

1970

1970 saw the invention of UNIX by Kernighan and Ritchie at AT&T Labs, and Pascal came on board as a teaching language for structured programming in many university freshman courses. Otherwise, the landscape was pretty much the same for programming languages in popular use as before.

1975

By 1975, C had grown in popularity, but was not a teaching language: BASIC, Pascal, and Lisp had all ascended in popularity as we had sent men on the moon, and more students became interested in computer programming. FORTRAN and COBOL were still at the top of the heap, while ALGOL, APL and Assembly moved down. Assembly would in future decades disappear from general popularity, but it would never truly go away.

1980

Enquire was a hypertext processing system first proposed at CERN Physics labs by Tim Berners-Lee in 1980. Ideas from Enquire would be later used to design the World-Wide Web.

By 1980, C++ had been introduced by Bjarne Stroustrup over the past couple of years, bringing the concept of object-oriented programming to the world. More and more people had mastered C, and it moved to the middle of the “top 10” proramming languages used that year. Pascal became a wildly more popular language due to the introduction of household desktop PCs, and the offering of a Turbo Pascal compiler by a software company called Borland. Microsoft offered BASIC and FORTRAN compilers that extended their stock QBASIC interpreter that came with DOS. In addition, Tandy, Commodore and Sinclair were offering their own machines, each with their own BASIC interpreters.

1985

While he didn’t invent the Internet (he never claimed that at all, according to Snopes.com), Al Gore tables bills and sources funding to greatly expand the internet, post 1989.

Bjarne Stroustrup publishes his seminal work The C++ Programming Language, in 1985. With the introduction of Windows and Windows NT, Microsoft expanded their programming offering to include Visual Studio, which included compilers for C and C++.  C was rising to the top of the charts, competing with Borland’s Pascal product. C would never leave the top 3 for another 15 years.

1990

MS Windows 3.0 first shipped in 1990. Also, Adobe ships Photoshop the same year. The World-wide web also gets its first exposure this year. By 1991, a computer science student Linus Torvalds uploads his first kernel source code to an FTP site, which a maintainer mis-spelled as “Linux”, a name which stuck.

Visual BASIC was introduced by Microsoft. C++ rose to the top 5. FORTRAN, BASIC, Assembly, and COBOL all fell to the bottom 5 of the top 10 languages. C had a wild surge in popularity, as the Internet was coming onstream, and the World-Wide Web was just starting in the universities. By 1992, the top 2 positions were occupied by C and C++. Also by 1992, a need for CGI scripting was needed for the fledgling W0rld-wide web, and Perl became popular.

1995

By 1995 Netscape had been out for 5 years. 1995 was the year that Microsoft first introduces Internet Explorer and gives it away for free, causing Netscape to go open source and produce Firefox.

There were many scripting languages at the time aimed at web browsers, but there had not been any set standard as to a default scripting language. By the end of the decade, that standard would go to JavaScript, a language developed since 1995. It and Perl were rising in popularity as client-side and server-side web-based languages respectively. But in the following 5-year period there was another shake-up. Java (a very different language from JavaScript), a product of Sun Microsystems, came from out of nowhere in 1995 to be the 3rd most popular language by 1996. By this time, the web had arrived in people’s homes and there was a need to enhance people’s internet experiences.

Pascal was falling out of favour as computers were moving away from DOS in the home and in business, and by 1997, Borland designed and object-oriented version of Pascal, which was called Delphi. It turned out to be a formidable competitor to Visual Basic. By 1998, even more server-side dynamic web programming was provided with the language PHP.

2000

2000 was the year that USB flash drives grew in popularity. In other news, Google makes its IPO in 2004; and in the same year we are first hearing about “web 2.0”.

PHP overtook Perl by 2000 as the 5th-most used language that year. Java and JavaScript had occupied 2nd and 3rd, pusing C++ to the #4 spot. C was still on top.  That year, Microsoft offered the world C#. Apart from C and C++, the top 5 langugaes were all web-based languages: Java, JavaScript and PHP. Perl was descending in popularity, as a new scripted language with much cleaner syntax became ascendant: Python.

2005

In 2005, IBM sells its PC division to a Chinese firm, to make it the largest manufacturer of PC computers in the world.

C was finally pushed out of the top spot by Java; and Delphi was starting to drop out of the picture as Borland had financial troubles after a failed bid to attempt to make inroads into Linux, with their introduction of Kylix. They sold off Delphi to Embracadero, who produces that product today. Perl continues to ascend in popularity only slowly, as its popularity is buoyed up by a legacy of libraries and its role in various bioinformatics projects, such as the Human Genome Project, conducted by universities around the world.

In part due to bioinformatics and other informatics endeavours, math and stats-based languages popped up such as Matlab and R. There were still new web-based languages like Ruby.

2010

At more than 1 petaflop (over 1 quadrillion calculations per second), the Tianhe 1 (released in 2010) is capable of running massive simulations and complex molecular studies. This year, IBM’s Watson wins a Jeopardy tournament.

Perl had finally dropped off the top-10, leaving a legacy of code on web servers all over the world. Objective-C became popular with Apple developers and new operating systems line NextStep, iOS and OS X. By 2011, the top 4 were: Java, JavaScript, Python, and PHP. Apple’s teaching language, Swift was at #9 in 2014.

2015

C and C++ were pushed out of the top 5. R, primarily a statistical programming language, rose to #7, second only to C. By 2019, Python was the top language programmers were using. Kotlin showed up briefly in 2019, owing to Google’s support of the language on the Android.

2020

Not much change, except for the introduction of Go, touted to be a more “reasonable” implementation of C++ with lighter syntax. Microsoft introduced TypeScript, a superset of JavaScript, and likely an attempt to “embrace and extend” it as they attempted to do the last time to Java, for example (J++ never caught on), or to JavaScript itself with their mildly successful VBScript, which also never quite caught on over the long haul.

While that was happening, Rust, which had been around for some time, enjoyed some popularity as a back-end web language, as well as a systems language. By the end of 2022, TypeScript has risen to the top 5. Of 11 languages that are the most popular, 7 are web-based languages: Python, JavaScript, TypeScript, PHP, Go, Rust, and Kotlin. The others are Java, C++, C, and C#.

Ideology vs Getting Stuff Done

Hits: 57

I’ve disliked ideology as a personal philosophy. Nothing ever really applies in all cases. This is why, while I think of the idea of open source software is awesome, it is not awesome if you have to sacrifice doing things you need to do in the name of philosophical purity.

I share the views stated by Evan Liebovich in a video he made last year. He is more of a proponent of open source than I will ever be, but he has had to reckon with the fact that Linux is falling behind on the desktop, is a low priority for developers, and if you actually need to get things done for many ordinary use cases, you need to install Windows. Evan’s video was shot from his Windows 10 desktop.

Linux will still be the low-cost desktop solution for developers, sporting a plethora of sophisticated programming tools. In that one area, they are way ahead of all other operating systems. However, in other respects for example, Microsoft can support the latest scanners and media cards, which Linux is often slow in adopting.

The reason they are slow is, as of 2021, according to Evan, Linux is installed in only 1.8% of all desktops. This ought to be regarded as minor, considering Linux’s unquestioned dominance in android devices, Chromebooks, business infrastructure, and internet servers all over the world. Linux has scored dominance in nearly every platform imaginable. Just not on the desktop PC.

People writing software and drivers for the Windows PC are likely to stay programming in that domain, since that is where 98% of the market is. It is not very likely that most companies, especially small ones, are going to write drivers for hardware or peripherals such as adaper cards, printers or scanners since there is not enough money in it. But even if they do, it is not as likely to fully take advantage of the hardware.

Nowadays you can download licences for Windows 10 which had been taken from old, discarded machines. This is legal if a legitimately purchased licence was on one machine, is no longer used there, and is transferred to a new machine. Microsoft will have a problem if one license is on more than one machine. Otherwise, there should be no problem. Ali Express sells licences for as low as CAN$3.50 by some vendors. Some sell with DVD, others sell only the license code. In the latter case, you can go to Microsoft.com and download your own image to a USB stick, 16GB minimum.

Xemacs, xcalc, xclock, and TeXStudio, all running on Windows 10 using an X server called “vcxsrv”, all thanks to WSL2.

Microsoft has, in the view of many, moved on from the “OS wars”, and have allowed users to incorporate WSL2 (Windows Subsystem for Linux version 2) into their base operating system. This has allowed users to run Linux applications, and even X-Windows applications, on their Windows desktop. Another gesture to open source is their purchase of GitHub, and have also joined the Linux Foundation.  MS Teams also has a version made for Linux.

Even without WSL2, there are many open source (FOSS) applications that have windows versions. And chances are, they run better in Windows, since writers of video drivers, for example, likely have better support of graphics acceleration. The same can also be said for audio, printer support, network card support and scanner support. Such FOSS applications which do not use WSL2 can be found on sites such as TTCS OSSWIN Online (Trinidad and Tobago Computer Society collection of free Open Source Software for WINdows), which has one of the most comprehensive FOSS archives for MS Windows.

It is still possible, by and large, to have a FOSS computer where the only “large” software expense is the Windows OS itself.

What is that sorting algorithm?!

Hits: 39

Yes, for a while I was mystified. I had taught what I was sure was the Bubble Sort, the most basic sorting algorithm given to computer students. It was so simple, I felt little need to look it up (but should have), and just write it from memory. Here was my algorithm, written in pseudocode:

You have an array of numbers A[]
for i <- 1 to N
   for j <- (i+1) to N
      if A[i] > A[j] then
         swap A[i] and A[j]

That’s the Bubble Sort, as I thought it was, and as I have been teaching it for 5 years. The algorithm works, is inefficient as the Bubble Sort has been advertised to be, and I have never questioned it. It was also an easy one to teach and students picked up on it easily.

But from this or that source over the 5 years, I have found others attributing a wholly different algorithm to the Bubble Sort. I dove into my copy of Algorithms 2e (Cormen, Leiserson, RIvest and Stein, 2001), a text which was used in many of the better computer science programs in North America, and this was how they described it:

Let A be an array of data to sort
for i <- 1 to length[A] do
   for j <- length[A] downto (i + 1) do
      if A[j] < A[j - 1] then
         Swap A[j] and A[i]

Yes, this is the source I should have cited rather than going on memory, and that would have been the end of it. But notice that we are only ever comparing two adjacent array elements in a bubble sort. But at the time, I only saw evidence of this cropping up on a YouTube video and some other nameless, faceless websites, and thought maybe there is more than one algorithm called a bubble sort. I tried this several times on paper with several short combinations of numbers, and convinced myself that their algorithm works also.

There are other versions. Harvard CS50 adds some efficiency to the pseudocode. Since the list is often sorted well before both loops have completed, the modification is to have a conditional loop (rather than a counted one) which uses a swap counter, which is used to decide if the list really is sorted. If there are no swaps after one turn of the outermost loop, the list is declared sorted and the algorithm exits. It went something like this:

Let A be an array
Set swap_counter to a nonzero value
Repeat
|   reset swap_counter to 0
|   look at each adjacent pair in A
|   |  if A[n] and A[n-1] are not in order,
|   |     Swap A[n] and A[n-1]
|   |     Add 1 to swap_counter
|   v  end if
v   move to the next adjacent pair
Until swap_counter is 0

You have to play with some short lists on a sheet of paper to convince yourself that this will actually sort a list. It is still a nested loop, but a conditional one.

Then, there was Wikipedia. Their entry on Bubble Sort, apart from being about the proper bubble sort, had a footnote on the bottom, to a paper describing a sorting method called I can’t believe it can sort. Seriously, that was the name given and cited. Here is their algorithm, as elucidated by Dr. Stanley Fung from the University of Leicester (UK) (3 October, 2021) in a paper he entitles “Is this the simplest (and most suprising) sorting algorithm ever?”, publically archived at Cornell Univesity:

Let A be an array of length n
for i <- 1 to n do
   for j <- 1 to n do
      if A[i] < A[j] then
         Swap A[i] and A[j]

This is where I began to question my sanity. This was very close to my version of Bubble Sort, except that I started j at (i+1) and tested A[i] > A[j]. It was similar in that it used a nested for loop, comparison, and swap.

But Fung wrote a paper giving this as a kind of Ripleys’ Believe it or Not. He seemed incredulous that this could work at all. And yes I can see his point. His test of A[i] < A[j] seems backward, yet the numbers end up in increasing order. This is becuase allowing both nested loops going to the array size allows for redundant comparisons and for additional swaps which can take place if j < i, which he explains. Is it efficient? Hell, no. But it is still shares a similar efficiency to Bubble Sort, O(n^2). Would anyone in their right mind offer this to students as a sorting algorithm? Nope. And yes, he does make these points also. It’s as close as I have seen to a sorting algorithm that appears “brute force”. In addition, he gives a proof of correctness of the algorithm to sort in ascending order.

But now I began to wonder what I was doing. I had been using something like this algorithm for 4 years before Fung wrote his paper. What was my algorithm then? Did I invent something new? Am I going to be famous? That feeling was short-lived as I read on. The next algorithm he offered was the one I taught. It was called an Exchange Sort.

I stand by Exchange Sort as an basic algorithm to teach and for students to grasp in high school, and seems more straightforward than the Bubble Sort. I will probably end up teaching both in due course, and I have already changed my notes and slides, as I haven’t taught it yet this year.

This whole episode illustrates the importance of readily letting go of old ideas once they have been proven wrong, and then learning the right way. Learning takes humility, one of our human virtues we are endowed with. People who feel no need of such reflection and change are people whom I feel are crippled with one of the worst learning disabilities, not the result of biological barriers or mental illness, but instead merely borne of pride and hubris. Life is too short to hang on to old ideas that don’t work and actually never did in the past either.

Recreational Math II: Magic Squares of Composite Order

Hits: 96

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 Ninmathbb{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. This will be covered in a later article.

 

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

Hits: 108

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

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

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 more 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.

As a bit of advice, if you see a FAQ title in faqs.org that interests you, try Googling the same title. Chances are you will get a more updated FAQ by the same author(s).

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

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.