Tuesday, 1 May 2018

A Look at Sums of Multiples of Squares

I certainly have a deeper understanding now of what numbers can be expressed as a sum of two squares and in how many ways. See my earlier posts:
There's certainly some overlap in these posts but mostly they've dealt with numbers of the form \(x^2+y^2 \) rather than \(ax^2+by^2 \) where \(a \) and \(b \) are integers. It's the latter type of expression that I want to explore in this post. My interest was stimulated by today's diurnal age number, 25229, that happens to be a 4k+1 prime.

As a 4k+1 prime, it can be expressed as a sum of two squares in one way only, viz. \( 98^2+125^2 \). However, it turns out that it can be expressed a sum of two squares multiplied by varying coefficients in many different ways. I created some Sage code to investigate:
number=25229 #enter any number
x,y = var('x'),var('y')
a,b = var('a'), var('b')
for a in range(100):
    for b in range(100):
        for x in range(sqrt(number)):
            for y in range(sqrt(number)):
                if a * x^2 + b * y^2 == number:
                    if a < b:
                        print(a, b, x, y)
Running this code on the SageMathCell Server generated the following results for a <100 and b < 100. The first number represents a, the second b, the third x and the fourth y. For example, the first entry (1, 4, 125, 49) represents \(125^2+4 \times 49^2 \).
(1, 4, 125, 49)
(1, 5, 27, 70)
(1, 7, 41, 58)
(1, 13, 101, 34)
(1, 20, 27, 35)
(1, 25, 98, 25)
(1, 28, 41, 29)
(1, 29, 75, 26)
(1, 49, 125, 14)
(1, 52, 101, 17)
(1, 65, 42, 19)
(1, 85, 152, 5)
(1, 91, 127, 10)
(1, 97, 94, 13)
(2, 3, 61, 77)
(2, 11, 105, 17)
(2, 21, 110, 7)
(2, 51, 37, 21)
(3, 26, 9, 31)
(4, 25, 49, 25)
(4, 65, 21, 19)
(4, 85, 76, 5)
(4, 97, 47, 13)
(5, 6, 71, 2)
(5, 9, 70, 9)
(5, 19, 11, 36)
(5, 24, 71, 1)
(5, 46, 61, 12)
(5, 59, 45, 16)
(5, 69, 8, 19)
(5, 76, 11, 18)
(5, 81, 70, 3)
(5, 89, 69, 4)
(6, 53, 56, 11)
(7, 22, 31, 29)
(7, 29, 60, 1)
(7, 46, 53, 11)
(8, 21, 55, 7)
(9, 20, 9, 35)
(9, 29, 25, 26)
(9, 65, 14, 19)
(11, 18, 17, 35)
(11, 50, 17, 21)
(11, 98, 17, 15)
(13, 29, 36, 17) 
It would be interesting to see the full range of possibilities for a, b, x and y. However, for larger values of a and b, the SageMathCell Server seems to time out. It is easy to see how the case of (1, 4, 125, 49) comes about because: $$125^2+(2 \times 49)^2 =125^2+(2 \times 49)^2 = 125^2+ 4 \times 49^2 $$ However, in the case of (2, 3, 61, 77) where \( (\sqrt{2} \times 61)^2+ (\sqrt{3} \times 77)^2 = 25229 \), it's far from clear how the result comes about.

It's probably better to start investigating with a smaller 4k+1 prime such as 61. Now \( 61=5^2+6^2 \) and there is only one possibility with coefficients and that is \( 4 \times 2^2+5 \times 3^2 \). Similarly with \(73=3^2+8^2 \), there is only one possibility and that is \(5 \times 3^2+7 \times 2^2 \). With \(97=4^2+9^2 \), there are two possibilities: \( 4 \times 2^2 + 9 \times 3^2 \) and \(5 \times 3^2+13 \times 2^2 \).

It can be noted that 4k+3 primes such as 43, while not able to be represented as a sum of two squares, can be represented as a sum of squares with coefficients: \( 3 \times 3^2+4 \times 2^2 \). Essentially, the elements of the set of all multiples of the square numbers (let's call the set S) are being combined with themselves by addition to form a set of new numbers (let's call this set N). This set consists of \(1^2 =1\) and the multiples of 1 are the natural numbers. This of course is trivial because it means for any number n can be written as \( (n-m) \times 1^2 + m \times 1^2 \) where \( m<n \).

This result means that it is necessary to exclude 1 from our investigation and begin with \( 2^2=4 \). So all multiples of 4 are permissible, as are all multiples of 9, 25, 36, 49, 64, 81 and so on. In this scheme, the smallest possible number would be \(2^2+2 \times 2^2=12 \) with \( 2^2+2^2=8 \) being ignored since we know the rules governing the requirements for a number to be a sum of two squares. This means that coefficients must not be perfect squares and thus \(2^2+4 \times 2^2 =2^2+4^2 = 20 \) is not acceptable. Even coefficients that add to perfect squares when the squared terms are the same must be excluded.

Thus \(2^2+3 \times 2^2 = 2^2 \times (1+3) = 2^2 \times 4 = 4^2 =16 \) falls victim. From the outset, it's clear that certain numbers (apart from the numbers 1 to 11) cannot be represented by any combination of multiples of squares: 14, 15, 17, 18, 19, 20, 21 and 23. However, it seems clear that every number above 23 can be represented either as:
  • a perfect square e.g. \(25=5^2 \)
  • a multiple of a perfect square e.g. \( 50=2 \times 25 \)
  • a sum of two different squares e.g. \(25=4^2+3^2 \)
  • a sum of the multiples of two squares e.g. \(25=4 \times 2^2 +3^2 \). 
I've not proved this by any means but it seems highly likely, given the increase in possibilities as the numbers get larger. So the main takeaway from all this is that \( ax^2+by^2=23 \) is the last ellipse in the family of ellipses \( ax^2+by^2=N \), where N is a natural number and a>1 and b>1, that does not have integer solutions for a, b, x and y.

Thursday, 26 April 2018

Taylor Series

For a really superb video explaining how Taylor Polynomials and Taylor Series are created, you need go no further than this video by 3Blue1Brown.


$$ \sum_{n=0} ^ {\infty} \frac {f^{(n)}(a)}{n!} \, (x-a)^{n} =f(a)+\frac {f'(a)}{1!} (x-a)+ \frac{f''(a)}{2!} (x-a)^2+\frac{f'''(a)}{3!}(x-a)^3+ \cdots $$The formula above was copied from Wikipedia where all mathematical expressions are in LaTeX but enclosed within <math> ... </math> tags. While it's always good practice to create the LaTeX from scratch, it's still useful to remember that any mathematical expressions found in Wikipedia can be copied directly into Blogger.

Anyway, the main point of this post is to remind myself to watch more of 3Blue1Brown's videos. The Taylor Series video was created in May of 2017 and since then twenty more have been added. Altogether he has almost seventy videos of which I've watched sixteen. The description of the channel states that:
3Blue1Brown, by Grant Sanderson, is some combination of math and entertainment, depending on your disposition. The goal is for explanations to be driven by animations and for difficult problems to be made simple with changes in perspective. 
He can be followed on Twitter at https://twitter.com/3blue1brown and a website at http://www.3blue1brown.com.

Thursday, 19 April 2018

Sage Reference Manual

I first made a reference to SageMath in a previous blogpost on the 4th January 2017. At that time I installed it but, after tinkering with it a little, I forgot about it until recently. However, my interest has been rekindled and I've installed the latest version (8.1) on my laptop running macOS High Sierra 10.13.3. The online reference manual is located here but instead of a single PDF file, there is an assortment of 70+ PDF files. Because I'm travelling overseas shortly and may not always have Internet access, I wanted to download all the PDF files to have on my laptop for reference.

Fortunately, there is an extension for Chrome called Batch File Downloader that lets you download many links from a  website easily. Here is what the interface looks like:


As the name says, the extension created a batch file that allowed me to download all the *.pdf files in the online directory that it was pointed at. The total size of all files is a little over 80 MB with plotting.pdf (44.9 MB) and plot3d.pdf (20.8 MB) being the two largest. Most of the others are around 1 MB in size. 

Since SageMath uses Python, I also installed the Python  programming language on my laptop. However, my focus will be on getting more proficient at using SageMath. It's tedious to find in Python that most of the basic mathematical functions are missing. For example, if in SageMath one inputs factor(25217), then 151 * 167 is received as output. However, in Python the code must be created:

x, y = 25217, int(25217/2)
for i in range(2, y):
     if x % i == 0:
     print(i)

So the adventure begins. In the meantime, I've come across an interesting site created by a mathematics professor called Gregory V. Bard who writes:
The beauty of Sage is that it works through the internet. There is almost never any reason to do a local install of Sage on your laptop or home computer. This is good news, because it saves a lot of headaches and hassles (especially for students), that you would have to suffer if you were using Mathematica, Maple, Matlab, or Magma. The exception is if you have limited or no internet access, such as in rural areas. 
Internet access involves using the SageMathCell Server which as Professor Bard says is a competitor to WolframAlpha and up until recently was called Sage-Aleph. This is the interface:

Professor Bard has written a book called Sage for Undergraduates that is available as a zipped pdf file by clicking on the link. His site is up-to-date but is "preserving the look-and-feel of the World Wide Web as it was, in 1998".

Using SageMath, I'll be able to wean myself off WolframAlpha which, up until now, I've relied on completely for the factorisation of the number corresponding to my diurnal age and, if the factors are supportive, determining how this number can be expressed as a sum of two squares. Now, using SageMathCell or my own notebook, I can determine both.

Code that is created in SageMathCell can be shared via temporary or permanent links and also by a QR code which conveniently encodes the permalink. The permalink can be quite long and ugly because it encodes the entire block of code. Here is QR code that I generated:

If the QR code is scanned with a QR code reader, you will be taken to the SageMathCell Server where the following code should appear:



Sunday, 15 April 2018

Sum of Squares of Integers and Catalan Numbers

As I began reading a new book Catalan Numbers With Applications by Thomas Koshy, I hadn't progressed far before I came across the statement:$$ \sum_{k=1}^n k^2=\frac{n(n+1)(2n+1)}{6}$$At this point, I had to pause because the author had just assumed this result but I couldn't see how to prove it. I needed to do a little digging but before long I came across an interesting proof of the result on this site. The website starts slowly and works out firstly what the sum of the first n integers will be. Here is how it is worked out: $$ \begin{align} (k-1)^2&=k^2-2k+1\\ \text{Rearranging the terms as below:}\\k^2-(k-1)^2&=2k-1\\ \text{Now sum both sides:}\\ \sum_{k=1}^n (k^2-(k-1)^2)&=2 \sum_{k=1}^n k-\sum_{k=1}^n 1\\n^2&=2S_n-n\\S_n&=\frac{n^2+n}{2}\\&=\frac{n(n+1)}{2} \end{align} $$ After this the website goes on to tackle the sum of the squares of the first n integers as follows (using a similar approach): $$\begin{align} (k-1)^3&=k^3-3k^2+3k+1\\ \text{Rearrange the terms: }\\k^3-(k-1)^3&=3k^2-3k-1\\ \text{Summing both sides:}\\ \sum_{k=1}^n (k^3-(k-1)^3)&=3 \sum_{k=1}^n k^2-3 \sum_{k=1}^n k -\sum_{k=1}^n 1\\n^3&=3 \sum_{k=1}^n k^2 -3 \frac{n(n+1)}{2}-n \\ \sum_{k=1}^n k^2&=\frac{1}{3}n^3+\frac{1}{2}n^2+\frac{1}{6}n\\&=\frac{n(n+1)(2n+1)}{6} \end{align}$$ The website then goes on to establish a general result for the sum of integers raised to any power. The question is asked is there a formula for calculating: $$ 1^a+2^a+3^a+ \cdots + (n-1)^a + n^a=\sum_{k=1}^n k^a \text{ ?} $$Well there is, it's called Faulhaber's Formula and involves Bernoulli numbers but I won't go into that here.

For now, I can go on reading my book about the Catalan numbers. I first made a blog post about Catalan numbers back in 2015 on Tuesday the 29th September. This was the first time I'd really heard of them and I didn't delve deeply into them at all in that post. Hopefully I'll have more to say in later posts about these numbers.

The Catalan numbers are of the form: \( \dfrac{1}{n+1} \dbinom{2n}{n} \)

They can be calculated readily enough:
  • in WolframAlpha using catalannumber[n]
  • in SageMath using catalan_number(n). 
Talking of SageMath, I've installed the latest version (8.1) on my Mac and am making a concerted effort to make more use of it. I first made a blog post about this free, open source software program in 2017 on the 4th of January. It really is quite impressive in its capabilities so hopefully I can become more adept at using it. Here's a screenshot from my SageMath notebook:


Lastly, the mathematician who lent his name to these numbers, Eugène Catalan, shouldn't be ignored. He was born on the 30th of May 1814 in Bruges, French Empire (now Belgium) and died on the 14th February 1894 in Liège, Belgium. A biography can be found at MacTutor History of Mathematics archive along with biographies of a great many other mathematicians and other interesting material. I first came across this archive in the early naughties and was fascinated to read about the lives of famous mathematicians who had lent their names to so many mathematical tools that I'd used in previous years. L'Hôpital's Rule was a case in point. Although widely used and a greatly useful mathematical tool, who knows anything about the impressively named Guillaume François Antoine Marquis de L'Hôpital who lent his name to the rule?

on Sunday, March 28th 2021
layout improved

Saturday, 7 April 2018

Finding Significance in Insignificant Numbers

Sometimes in my examination of the numbers that measure my diurnal age, I come across a number with few entries in the OEIS and all of them inscrutable to my limited intellect. 25197 was a case in point. I wrote about this in an earlier post and what I found in the case of that number was that its square (634888809) contained four consecutive 8's. As such, it belonged to an as yet unidentified sequence of numbers with the common property that their squares contained a sequence of four or more 8's. These numbers are shown below:


This is the sequence that I submitted to the OEIS for approval and I'm still waiting to see it published. This example illustrates that apparently insignificant numbers can contain significance that just needs to be unlocked.

Thus we come to today's number, 25206, that is significant in that it marks a point where there is a balance struck between the number of 4k+1 primes and the number of 4k+3 primes. Prime 617249 marks a point where there are exactly 25206 primes of each sort. While this is clearly significant, the problem is that it's shared with many other nearby numbers as can be seen from this extract from OEIS A092198:
0, 1, 3, 6, 44, 1471, 1472, 1473, 1474, 1475, 1476, 25185, 25187, 25188, 25189, 25190, 25196, 25206, 25211, 25212, 25213, 25214, 25215, 25216, 25217, 25218, 25219, 25222, 25224, 25225, 25251, 25253, 25257, 25258, 25410, 25421, 25426, 25427, ...
Note particularly the gap between 1476 and 25185 (the next member in the sequence). These balance points in the number of 4k+1 and 4k+3 primes clearly exist in clusters. This is the reason that I was looking for something different when examining 25206. It's clear that the number cannot be the sum of two squares because the number factors to 2×3×4201 and there is a 4k+3 prime (3) raised to an odd power (3). However, I wondered if there is an integer solution to the equation \( x^2+2y^2=25206 \) even though there is no integer solution to \( x^2+y^2=25206 \). It turns out there are two, x=158, y=11 and x=38, y=109. This is shown geometrically in the diagram below where the solutions, for positive numbers only, are represented on an ellipse.


The frequency of integer solutions to \( x^2+2y^2=N \) seems about equal to that of  \( x^2+y^2=N \), at least judging by a quick count. For example, over the next twenty integers (25206 to 25216), there are six numbers (25211, 25218, 25219, 25222, 25224, 25225) that can be represented in the form \( x^2+2y^2 \) and six numbers (25209, 25210, 25216, 25220, 25225, 25226) that can be represented in the form  \( x^2+y^2 \). 

From this admittedly quick count, it would seem that about 30% of numbers can be represented as a sum of two squares and another 30% as a sum of a square and twice a square. There is possibly no overlap between the two sets and so it would seem that if a number cannot be represented as a sum of two squares then it may well be possible to represent it as a sum of a square and twice a square. 

This line of enquiry opens up all sorts of intriguing questions such as:
  • is it possible to represent a number in both the form \( x^2+y^2 \) and \( x^2+2y^2 \)?
  • is it possible to represent all numbers in the form \( ax^2+by^2 \) where \( a \) and \( b \) are positive integers?

The New Powerball

I received an email from the Lott today announcing the following changes to Powerball:
New Powerball Updates 
BIG JACKPOTS
There is an increased chance of big jackpots occurring more often.
 
MORE WINNERS
There will be more overall winners in every draw with the chance of winning an overall prize increasing from 1 in 78 to 1 in 44.
 
NEW 9TH PRIZE DIVISION
The Powerball prize structure will include an extra 9th prize division.
 
NUMBER UPDATES
The New Powerball game will feature 7 winning numbers drawn from a barrel of 35 balls (numbered 1-35). This was previously 6 numbers drawn from a barrel of 40 balls (numbered 1-40).
 
We’ve randomly generated replacements for numbers greater than 35 and added a new 7th number to your Favourite and Subscription entries.
There will be no changes to the Powerball. It will still be drawn from a barrel of 20 balls (numbered 1-20).
This claim of an increased chance of big jackpots occurring more often is perplexing because it seems that the number of possible combinations has increased, meaning the probability of winning has decreased (significantly as we can see below):$$ \text{BEFORE }\binom{40}{6} \times 20 = 76,767,600 \text{ <---> AFTER } \binom{35}{7} \times 20 = 134,490,400$$ The chance of winning, that is getting the correct combination of seven numbers and the powerball, is now almost halved.

Maybe I'm missing something but I can't see what it is. There may well be more overall winners with the introduction of a 9th prize division but I wonder if the provision of even more piddling minor prizes will actually entice punters. Even without knowing the precise probability, most punters will recognise intuitively that, with the powerball choices remaining the same, the chance of getting seven numbers correct out of 35 is going to be considerably less than getting six numbers out of 40. All punters have their eye of the big prize not on the increasing proliferation of minor prizes.

Tuesday, 3 April 2018

Permutahedron

On Quanta, I came across an interesting interview with a mathematician, Federico Ardila, who speaks about the connection between combinatorics and geometry:
When you look at the geometric side of things, suppose, for example, you want to study the permutations (the ways of rearranging a collection of objects). It’s pretty well known that if you have n objects, the number of ways of putting them in a row is n factorial (the product n(n-1)(n-2)…1). So it’s not a very interesting problem to count how many ways there are. But what is their inherent structure?  
The three-dimensional permutahedron, a geometric depiction of the ways to rearrange the numbers 1, 2, 3 and 4. Two permutations are connected by an edge if one can be transformed into the other by swapping two consecutive numbers.     
If you look at when two permutations are related to each other by just swapping two elements, then you start understanding not only how many there are but how are they related to each other. And then, when you say, “OK, let’s take all the permutations, and put an edge between two of them if they’re a swap away,” then you find that you get this beautiful shape that’s a polytope (a geometric object with flat sides). I think it’s completely surprising initially that the inherent relations between permutations are captured in this beautiful polytope called a permutahedron. So all of a sudden you have this geometric model, and you can use tools from polytope theory to try to say new things about permutations. And that polytope has existed for a long time and is very well understood.
The three-dimensional permutahedron, a geometric depiction of the ways to rearrange the numbers 1, 2, 3 and 4. Two permutations are connected by an edge if one can be transformed into the other by swapping two consecutive numbers
This particular structure is in fact a truncated octahedron with fourteen faces comprised of six squares and eight hexagons. There are 24 vertices and 36 edges. Whereas the octahedron is a Platonic solid, the truncated version is an Archimedean solid defined as follows:

In geometry, an Archimedean solid is one of the 13 solids first enumerated by Archimedes. They are the semi-regular convex polyhedra composed of regular polygons meeting in identical vertices, excluding the 5 Platonic solids (which are composed of only one type of polygon) and excluding the prisms and antiprisms. They differ from the Johnson solids, whose regular polygonal faces do not meet in identical vertices. Source.

An example of a Johnson solid would be a triangular bipyramid or dipyramid, a type of hexahedron formed by joining two identical tetrahedra together, the face on one being exactly against a face of the other. The truncated octahedron ends up looking like this:


Interestingly the above shape can, like the cube, tesselate or pack 3-dimensional space. It's by no means obvious but, quite amazingly, this is what happens:


In Mathematics, a permutahedron is an (n−1)-dimensional polytope embedded in an n-dimensional space, the vertices of which are formed by permuting the coordinates of the vector (1, 2, 3, ..., n). Thus the permutahedron of order 4 exists in 3 dimensions, order 3 in two dimensions and order 2 in 1 dimension. A polytope is defined as:
... a geometric object with "flat" sides. It is a generalisation in any number of dimensions of the three-dimensional polyhedron. Polytopes may exist in any general number of dimensions n as an n-dimensional polytope or n-polytope. Flat sides mean that the sides of a (k+1)-polytope consist of k-polytopes that may have (k-1)-polytopes in common. For example, a two-dimensional polygon is a 2-polytope and a three-dimensional polyhedron is a 3-polytope. Source.
All this takes us into complicated areas of mathematics but what's important here is simply to note the link has been forged between two apparently disparate mathematical topics: combinatorics and geometry.