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.

Sunday 1 April 2018

Highly Composite Numbers

Today I turned 25200 days old and I was surprised to find that this number has a staggering 347 entries in the Online Encyclopaedia of Integer Sequences (OEIS). Most numbers of this size are lucky to have more than a dozen entries. So what's so special about 25200? Well, it turns out to be a highly composite number, a term first coined by Ramanujan in 1915 and defined as a number that sets a record for the highest number of factors (in this case 90). Here is a table from Wikipedia showing details for the first 38 highly composite numbers (sequence A002182 in the OEIS).
OrderHCN
n
prime
factorization
prime
exponents
prime
factors
d(n)primorial
factorization
1101
22112
34223
461,124
5122,136
6243,148
7362,249
8484,1510
9602,1,1412
101203,1,1516
111802,2,1518
122404,1,1620
133603,2,1624
147204,2,1730
158403,1,1,1632
1612602,2,1,1636
1716804,1,1,1740
1825203,2,1,1748
1950404,2,1,1860
2075603,3,1,1864
21100805,2,1,1972
22151204,3,1,1980
23201606,2,1,11084
24252004,2,2,1990
25277203,2,1,1,1896
26453604,4,1,110100
27504005,2,2,110108
28554404,2,1,1,19120
29831603,3,1,1,19128
301108805,2,1,1,110144
311663204,3,1,1,110160
322217606,2,1,1,111168
332772004,2,2,1,110180
343326405,3,1,1,111192
354989604,4,1,1,111200
365544005,2,2,1,111216
376652806,3,1,1,112224
387207204,2,1,1,1,110240
All highly composite numbers are products of primorials as can be see from rightmost column of the table. In the case of 25200, the primorial factorisation is \( 2^2 \times 30 \times 210 \). There is a formula for calculating the number of factors for a number n:$$ \text{If }n=\prod_{i=1}^k p_i \, c^i \text{ then } d(n)=\prod_{i=1}^k (c^i+1)$$For example: $$ 25200=2^4\cdot 3^2\cdot 5^2\cdot 7 $$ $$ d(25200)=(4+1) \cdot (2+1) \cdot (2+1) \cdot (1+1) = 5 \cdot 3 \cdot 3 \cdot 2 = 90 $$The sequence of indices is non-increasing when the prime factor bases are placed in ascending order (4, 2, 2, 1 in the case of 25200). The final index is always 1 except in the cases of 4 and 36 where it is 2, thus making 1, 2 and 4 the only square, highly composite numbers.