Sunday, 20 August 2023

Sums of three squares

When I turned 62 my daughter Susanna informed me that 62 was the sum of three squares in two different ways: 12 + 52 + 62 and 22 + 32 + 72.

She had looked up this fact with a keyword search such as "Interesting facts about the number 62". I certainly did find that interesting but for 15 years I didn't take the matter any further. I did however know that there was a characterisation of numbers which were representable as the sum of three squares and this characterisation indicated that, while 62 was the smallest example of a number having two representations, it would not be the only such number. In writing this note I researched this question more thoroughly and discovered that very much more is known including asymptotic results on the number of such representations. This note has little information to add to the question but, at least, I hope it will be easy reading.

Recently I observed that 2, 3, 7 were (modulo 8) the negatives of 1, 5, and 6. This "explains" Susanna's fact as an example of the following observations. Given 3 squares a2, b2, and c2 the equation

a2 + b2 + c2 = (m-a)2 + (m-b)2 + (m-c)2

will be true (by elementary algebra) if

m = (2a + 2b + 2c)/3.

If a=1, b=5, c=6 (the first of Susanna's triples) we would have m=8 and then

m-a = 7, m-b = 3, m-c = 2: the second triple.

This gives immediately the existence of many pairs of triples whose sums of squares are equal. For example, with a = 3, b = 4, c = 8, we have m = 10, m-a = 7, m-b = 6, m-c = 2. Therefore 101 is the sum of 9, 16, and 64 as well as the sum of 49, 36 and 4. This trick of obtaining a second triple does not always work. There are some cases where the triple (m-a, m-b, m-c) is the same (to within a rearrangement} as (a, b, c). Such cases are easily seen to be when a, b, c are in arithmetic progresion.

A more serious barrier to the trick producing a second triple is that m might turn out not to be an integer. For example 32 + 62 + 72 = 94. Here m=32/3 and we find that

m-a = 23/3, m-b = 14/3, m-c = 11/3

whose squares do sum to 94 but they are not integers. In this case there is, nevertheless, a second solution, namely the triple (2, 3, 9) whose squares sum to 94. However I do not see a general pattern suggested by these two solutions.

Thursday, 2 February 2023

Goodness as an absolute quality

If you were to ask anyone (Donald Trump, Adolf Hitler, Pope Pius X, Myra Hindley, Mother Theresa - name anyone you like) whether they thought they were good people then, any false modesty aside, they would surely answer "Yes". Now ask a random person whether they agreed: no such uniformity of assent would be forthcoming. On some of the names on that list it is possible that no-one would say they were good.

What can we make of that? What if we ask about particular issues: is slavery bad, is homosexuality bad, is unfaithfulness to ones spouse bad, is eating battery-farmed chicken bad? (to name just a few moral positions) we would not find universal agreement either. It is possible that some answers might be of the kind "Well, it depends on the circumstances, the time era of the issue). Even those who give answers that are qualified in this way will likely still feel that, if the question could be made more precise, then they should be able to give a clear cut answer.

Why is this? We have got very used to the idea that these questions should have definite answers. Our society often legislates the answer, or the prevailing moral climate determines an answer. So we are loath to believe that such questions have no answer. Indeed you may very well suspect that, unless a society had an agreement on the worth of an answer to these complex questions, the society would collapse in significant way because we could all behave as we felt like at the time. You might even think that, on an issue such as homosexuality, where society had legislated an answer that you didn't agree with, you would feel duty-bound to go along with the consensus rather than disrupt your society by public disagreement.

The conclusion I want to draw from these examples is that the idea of absolute good or absolute evil is too nebulous to sustain. This conclusion is unpalatable to many of us because it contradicts the way we have been educated to behave. We want to feel that we are good people who act as we do because of some absolute imperative that tells us how to behave. We have been conditioned to think like this sometimes because our parents have had to instil into us a model of behaviour that allows to rub along with our fellow humans, or our church has had offered us divinely inspired moral guidance, or our law-makers have offered absolutist reasons for certain behaviours, or important role models in our lives have set a strong example.

Yet most, if not all, of our moral positions are unsustainable as absolute positions - we cannot agree on them and it is not always just crazy people, or hardened contrarians, who cannot agree. My conclusion is simple: "goodness" or "evil" are not concepts that exist in an absolute sense.

I must add immediately that this does not mean one can therefore act as one pleases because the concept of acting as a good individual is meaningless. More of that later.

I believe that one cannot build "good" societies by first identifying the "good" qualities that one would like the society to have because the idea of a "good" quality is too elusive as we saw in the examples above. My model of societal growth is more chaotic than that. Societies grow from very small collections of people into the complex societies that we see all around us today. This growth has some features in common with the development of species arising generation by generation by random events. Some developments will arise and quickly fade away because they have not been conducive to the survival of the society - and some developments will cause long term thriving. In other words societies are complex systems whose future is a product of fortunate accidents (and the more fortunate the accident the longer will its consequences be felt). As an example, early Greek democracies (to be accurate, very crude quasi-democracies) arose more by accident than design - yet it was a a fortunate societal accident producing a prototype organisation which has lasted a very long time. An example on the other side is the National Socialist experiment of Germany in the 1930s and 1940s - again arising by the conjunction of exceptional conditions - this was not a successful accident as it only lasted two decades. 

To repeat: "good" societies do not arise because of "good" qualities. On the contrary, it is the other way round. When a society has arisen it is legitimate to ask what about the society is good. Consider the society of the Roman republic and early imperium and ask that question. The Patricians would claim they lived in a wonderful society, economically prosperous, and intellectually vibrant; the Plebs would answer very differently. Yet both of them enjoyed an urban existence that was the envy of neighbouring tribes. I would judge that society to be relatively good - it certainly lasted for centuries. When it did collapse it left an intellectual legacy that people looked back on as "good" times. As that society developed into a mighty empire one can perhaps guess at the reasons for its longevity: perhaps it was the way that early consuls were appointed or, later, the rigorous training undergone in the legions, or the mild climate of the era. Romans themselves might say "we have a good way of appointing our consuls, or we have a very good army, or the gods have given us many good harvests". In other words, the judgement of whether Roman society was "good" is a post-hoc judgement rather than a template for why their society flourished.

I think one should look at our current societies in this way. 

Consider the example of the modern USA. The Americans promote the myth that their national society was the result of deliberate design by the founding fathers. But I think that is far too simplistic. The awful things in their society were obviously not deliberately planned. But the successful aspects of it were either lucky (great natural resources, guns which enabled them to steal their land from the native population, the entrepreneurial spirit that was enabled by the natural wealth in resources and human capital) was also not deliberately planned. What has grown up has been a mixture of successes and failures and, quite naturally, they celebrate their successes and forget their failures, while pretending that the "American dream and their manifest destiny" are designed either by god or by their national spirit.

British society is an older and longer lasting example. For nearly a millenium (since the Norman conquest) it has evolved in a way where accidents have been largely responsible for the way it has changed. Magna Carta for example was definitely not the result of planned good government. The Hundred Years war was a mish-mash of successes and reverses (successes="good", reverses="bad"). The foundation of the British Royal Society in 1660 which ushered in an era of brilliant scientists was "good" but who among its founders could have foreseen that? These and many other examples make it very implausible that an intial set of good design principles are responsible for modern British society. On the other hand we can look at contemporary British society and observe some things that work very well (examples: the National Trust organisation, the rich artistic and cultural life in the big centres, the ancient beautiful buildings (ruined or not) etc. none of which were planned to develop as they have).

Finally, I will return to a point I mentioned above. Just because there is no such thing as absolute good doesn't mean that we should behave as moral delinquents. We can look around our society, spot the things that work well, and then do our best to push the successful parts of our society. For example, those parts of our society where there are undesirable actions, such as outright crime or tax-dodging, are sections of society which do not contribute to the smooth functioning of the society: this suggests that we avoid crime and tax-dodging.

It's really not very difficult. Don't appeal to those unreliable authoritative concepts which assume that goodness is an absolute concept. Instead, think about which parts of your society are successful, those likely to grow into societal success, and do your best to  support them.

Sunday, 21 February 2021

Hospital tribulations

 This post is a departure from my usual style of blog entries because it is a personal record of a series of unfortunate events about my passage through the New Zealand public health system during my treatment for prostate cancer.

The story started with the surgery to remove my prostrate in January 2018 at the Dunedin hospital. When sewing me back together the surgeon stitched the tube that drains the wound into me so securely that it required a further operation under general anaesthetic to remove the drain. Well, these things sometimes happen and I would have thought no more about it if only the surgeon had had the grace offer his apologies for a clear error.

I seemed to recover well until, in late 2020, my PSA readings began to rise and a consultation was scheduled with my urologist in November 2020. This was a different person to the one who had conducted the surgery and I will suppress their names so as not to embarrass them. The consultation was by telephone and lasted about 10 minutes. In principle I have no objection to consultations by telephone but they have the unfortunate effect of not leaving the patient to make notes conveniently. I have since learnt that a transcript is prepared by the consultant which contains useful information for the patient. It is a matter of policy not to use email to forward it to the patient and I did not receive a letter by regular mail. Instead a letter is sent to the patient's GP.

The main conclusion from this consultation was that I should go to Christchurch for a PET scan and the surgeon undertook to notify Christchurch Pacific Radiology for them to schedule an appointment. PET scans, by the way, are not funded by the public health system and I was fortunate to have some private insurance for the $3000 fee. I was told that I should hear something soon.

Nothing then happened for several weeks and in the second week of January I phoned the Urology department at Dunedin hospital. It was clear from the reaction that the consultant had not notified the radiologists and he had now gone on leave. A flurry of activity by a very competent administrator resulted in a PET scan appointment for me on 21 January.

Since the appointment was at 11.00am my wife and I rose at 4.15am that day to drive to Christchurch. It was a smooth journey until we reached Timaru some 250kms from Dunedin. Then we received a telephone call from Pacific Radiology to cancel the appointment as the radio-active pellet required had not been loaded onto the plane. This was a somewhat low psychological moment and we had to return to Dunedin with another appointment arranged for the following week.

The PET scan happened on 28 January. I was told that the results would be sent to my consultant and GP within a day or two, and I asked for a copy for myself.

Two weeks then passed and I heard nothing so made another phone call to the Urology department. They had received the results but would not give me any details. I was aware of a level of embarrassment when I said I had heard nothing from them - and they told me I would see the consultant on 8 March, and they would write to confirm (email confirmation again being impossible but, mirabile dictu, my GP would receive a letter).

A further week passed and still no letter so I made another phone call. More embarrassment and I was told the letter would be sent immediately.

The very next day I received a phone call to say that the consultant would actually be on leave on 8 March but they could offer me a phone consultation on 24 February. I agreed to this with some misgivings and after receiving assurances that all would be confirmed by letter. Possibly I was being alarmist but I had absolutely no idea about the seriousness of my condition and I was uneasy about having to react over the phone to some possibly challenging news.

The next day I received the confirmation that my 8 March consultation was arranged (the one that had been cancelled the previous day) but I recognised that this had most likely been sent before the cancellation.

I write this on 21 February and will update the saga as it continues to develop.

24 February: I waited patiently by the phone from 30 minutes before the appointment time of 1.40pm. No call. After an hour I called the Urology department to ask what was going on - and received the message that this was outside their business hours (mid-afternoon). Then I texted the Urology department, received no reply, and one hour and twenty minutes after the appointment time, still not having heard, had to leave. At 5.40pm the consultant called. The PET scan had been inconclusive and he recommended to just monitor the PSA levels and that he would write to my GP about the next PSA test.

Saturday, 16 January 2021

Early memories of Peter Neumann

My friend and mentor Peter M. Neumann died on 18 December 2020. There have already been many tributes to him and fond memories recalled. Some of these are reported through the Queen's college memorial page to him. Here I recall some personal early memories that are maybe not so widely known.

I went up to Queen’s in October 1964 at the age of 18 and immediately met the 23 year old Peter Neumann. He became my mathematical mentor first as undergraduate tutor and then doctoral supervisor, and was easily the biggest influence on my development as a mathematician.

In the acknowledgements in my D. Phil. thesis (1970) I wrote “My chief debt is to my supervisor Dr. P. M. Neumann, whose interest and encouragement were unfailing. It is a pleasure to thank him for all his advice and to record my appreciation of his friendship.” I was to know this warm, courteous, witty and clever man for a further 50 years and we had many personal and mathematical interactions. Here I’d like to mention some earlier memories as his student which, looking back, were particularly formative for me..


It was common in the 1950’s and 1960’s for boys to be called by their surname so I was taken aback when Peter immediately addressed me as ‘Mike’ and invited me to call him ‘Peter’. It was also a surprise that he always greeted me (and my fellow tutees) warmly when we met going about Queen’s. But for all this familiarity he had high expectations of his students and spared no effort in his encouragement.


In my first long vacation he got all of us to write an essay on a topic chosen from a list of mathematical topics well beyond the standard curriculum. I remember one of these was ‘The art of M. C. Escher’ but the one I chose was on Hilbert’s problems. Peter gave me the background. David Hilbert, in a famous address to the 1900 International Congress of Mathematicians, had proposed 24 problems that, in his opinion, were the greatest mathematical challenges of the day. Some of these had been solved, some had faded into oblivion, and some were open. My essay was supposed to summarise the present status of these problems. Peter appreciated  that my mathematical knowledge would be inadequate to even understand some of these problems and offered help on request. I did indeed require help and the Oxford-Leeds correspondence that ensued gave me my first insights into the research mathematical literature and such tools as Mathematical Reviews. It also impressed on me how widely knowledgable Peter was.


I became increasingly aware of the formative role that Peter’s parents, Bernhard and Hanna, had played in Peter’s early life. He once told me, as a very young child, he had watched Bernhard prepare breakfast for the family, counting out the slices of toast in the mysterious sequence 1, 4, 9, 16, 25, …. He realised eventually that the rule must be that the differences increased as 3, 5, 7, 9, …. and was delighted when Bernhard revealed the sequence of squares rule.


While his parents were obviously key influences in Peter’s early mathematical life he became an independent mathematical thinker well before I met him, publishing his first single-authored paper while still an undergraduate. However he never forgot his debt to his parents and always spoke fondly of them. In 1969 he dedicated his splendid paper on BFC groups ‘to my father on his 60th birthday, with love’.


By the time I became his graduate student Peter had become the most versatile of a generation of young Oxford researchers in algebra. But he never talked down to his students or his colleagues and was willing to engage with them almost on demand. I remember in about 1969, when I had learnt the rudiments of the theory of group characters, hyperbolically proclaiming to him that this must be the neatest little topic in the whole of mathematics. I had some reason to hope that he might agree with this proposition since I had heard him lecture on William Burnside, one of the originators of character theory. It would have been easy for Peter to prick this pompous little bubble but, after some some careful thought, he offered an alternative opinion that the theory of complex variables was even neater. Since this theory is not even part of algebra it made me realise that taking an interest in areas outside my own would be a good habit to cultivate and that has stood me in good stead ever since.


I knew Peter in another role too. He and I were both members of the University folk-dancing society. Peter’s contribution to the dancing was in providing music on his violin. I do not know very much about Peter’s other musical activities but he was a superb asset to our folk-dancing many times being the only accompanist and (so it seemed) effortlessly sight-reading whatever we asked of him. Dancing and directing dancing has been an occasional activity of mine throughout my life and, on those occasions, I always think of Peter. His face would display a mixture of concentration and enjoyment, a combination which accompanied also so many of his mathematical activities.

Friday, 22 May 2020

Joining points and sums of squares

This posting is an extended comment on another entry in R J Lipton's blog Gödel's lost letter and P=NP. Lipton's post is entitled A Math Gift for All and is a clever but simple solution to a geometric problem wrapped in a deceptive narrative. You might enjoy reading the post before proceeding here although that is not necessary provided you accept my spoiling the joke. My commentary is on both the solution and the numerical deception.

First the problem (which came from Shmuel Weinberger's  book) and Lipton's solution. You are given 2n points in the plane no three of which are collinear, n of which are coloured red and n are coloured blue. Do there exist n straight line segments each joining a unique red point to a unique blue point (as in a matching) in which no two line segments cross?

Lipton teases us with this (see below) but to cut to the chase the answer is Yes by the following argument. Among all the ways of joining the red points to the blue points in a matching consider one where the total length of the n line segments is the smallest. In this matching no two line segments cross because if two lines R1B1 and R2B2 cross then R1, R2, B1, B2 are adjacent points in a quadrilateral and if we replace the diagonal crossing of R1B1 and R2B2 by the line segments R1B2 and R2B1 we will have another matching with smaller total length of segments.

I showed the problem to my son James, a high school math teacher, who found another argument. Begin by choosing a point P not one of the given 2n points but within the cloud of such points and consider any directed straight line L through P. Because of the choice of P not all the 2n points lie on side of L. For any such line L let RL and BL denote the number of red points on the left of P and number of blue points on the left of P. If these numbers are equal then we have divided the set of 2n points into two sets - one set on the left, one set on the right - each containing equal numbers of red and blue points; then we can solve the problem on either side and get a solution to the original problem. But if RL and BL are not equal we can rotate L about P. As we do so RL and BL change by 1 every time L passes past one of the given points and after 180 degrees of rotation the values of RL and BL will have exchanged; so at some stage we shall have RL = BL and can proceed as before.

Both solutions can be made constructive but James' solution seems to lead to a more efficient algorithm (although it may well depend on how much ingenuity you are prepared to use).

The second topic I want to discuss derives from the trick Lipton played on his readers. He introduced a constant c whose value was 102+112+122-132-142, drew the readers in for a few lines and then pointed out that c=0. This identity between consecutive squares is the second in a sequence of identities the first of which is 32+42=52. There is a sequence of similar identities in which k+1 consecutive squares add up to the sum of the following k squares; the next identity (k=3) is 212+222+232+242=252+262+272. In general the middle square of the kth identity is the square of 2k(k+1) which is readily proved by elementary algebra.

Wednesday, 20 May 2020

Beetles around a circle

I recently came across a lovely combinatorial problem in R J Lipton's blog Gödel's lost letter and P=NP. You can read about it in that blog, together with its provenance, and its beautiful solution. However, in order for my comments on it to make any sense I need to recap the problem and its solution.

9 beetles are placed around a circle and the distances between them are the prime numbers 2, 3, 5, 7, 11, 13, 17, 19, 23. They start walking around the circle at the speed of 1 unit of distance per second but their directions are chosen randomly. When two beetles collide they reverse their directions but maintain their same speed. After 50 seconds and many collisions what are the distances between the beetles?

The remarkable answer is that the set of distances is still that same set of prime numbers.

The red herring in the problem is that the presence of prime numbers is irrelevant: no matter what the initial distances are the set of distances returns to that initial set after 50 seconds. The only thing that matters is that the sum of the distances is 100 which is therefore the length of the circle's circumference. The key insight is to imagine that each beetle carries a flag and whenever two beetles collide they exchange flags. Thus each flag continues to travel in the same direction it began with and so, after 50 seconds, it has travelled 50 units of distance and therefore has travelled halfway around the circle to the antipodal point. Since the final position of the flags is a reflection in a centre point mirror of the initial position, the set of distances between the flags is is the same as the original set of distances. However every flag has a beetle on it and therefore this is also true of the set of distances between the beetles.

Of course after 100 secs every flag has returned to its starting position and again the original distances are restored. However it is hardly ever the case that the beetles themselves have returned to their original positions. My friend Dennis McCaughan asked "When do the beetles get back to their original position?" and he and I quickly worked out the answer.

It is obvious that the relative order of the beetles around the circle never changes (as two beetles never swap places). After 100 seconds each beetle has moved to one of the original beetle positions, say through t original clockwise beetle positions, and t is the same for every beetle; t can be positive or negative. The clockwise distance a beetle has travelled is its clockwise drift, a sum of t original consecutive distances.  The total clockwise drift is the sum of the individual drifts and in this sum each original distance occurs t times. So the total clockwise drift is 100t. 

Initially let there be x beetles moving clockwise and y=9-x beetles moving anticlockwise. Since every collision is between a clockwise beetle and an anticlockwise beetle (turning a clockwise beetle into an anticlockwise one and vice versa) x and y do not change. We can think of d=x-y as the speed of clockwise "drift", the amount of clockwise distance consumed per second. Therefore the total clockwise drift after 100 seconds must be 100d. Hence 100d = 100t and so d = t.

We can now determine when the beetles will all return to their original positions. If d=9 or -9 then, after 100 secs, the beetles will be back in place after 100 seconds since each beetle will have moved through 9 original beetle positions. If d=3  or -3 then after 100 seconds each beetle will have moved through 3 original beetle positions clockwise or anticlockwise. So 300 seconds brings them back to place. For other values of d, a full 900 seconds is required.

Sunday, 17 May 2020

A puzzle about disease transmission

I heard this puzzle over 30 years ago when it was circling in North American Computer Science academic circles. The current pandemic and how to stem its spread reminded me of the puzzle. It concerns three sailors, one prostitute and two condoms. Stop reading now if you find that scenario too unsavoury.

The four characters have agreed that each sailor will have intercourse with the prostitute and the problem is to do this safely with only the two condoms at their disposal. What does "safely" mean here? Certainly they wish to guard against the sexual acts resulting in conception but they are all aware that, given the company they have been keeping, one or more of them may have one or more STDs and they don't want any further infection to be transmitted. There is a short discussion of the problem in this Reddit thread.

The solution is not that hard although it is quite easy to find convincing "almost" solutions. Here is one. Sailor Donald wears the first condom and has his wicked way. Then sailor Eric puts on the second condom and then the first condom over it and does the deed. Finally sailor Jared turns the second condom inside out, puts it on, then puts on the first condom over it and completes the action.

This fails in one respect only: Donald has infected the inner surface of the first condom; during the second act this infection is transmitted to the outer surface of the second condom, and so Jared can become infected by Donald's poison. A further incorrect solution appears in the Reddit thread (and then corrected).

The true solution is very similar. Donald uses both condoms (the second inside the first); Eric uses the first condom, Jared turns the second condom inside out and then dons the first condom.

In each sexual act the prostitute is only in contact with the outer surface of the first condom and so she cannot contract a fresh infection. Each man's member touches a condom surface untainted by any infection. All quite easy and possibly a puzzle and solution known to many.

I offer one final twist. Suppose there are 2n+1 sailors and n+1 condoms (but still one prostitute). How about safe sex now?

Let's number the sailors 0 to 2n and the condoms 0 to n.
For each i = 0 to n-1 sailor i wears condom i and also condom 0 over it
Sailor n just uses the single condom 0
For each i = 1 to n sailor n+i wears condom i inside out and also condom 0 over it.