Showing posts with label taylor series. Show all posts
Showing posts with label taylor series. Show all posts

Monday, 20 May 2024

Centered Platonic Numbers

On the 19th November 2018, I created a post titled Platonic Numbers and at the end of that post I made reference to Centered Platonic Numbers as follows:

Additionally, there are the centered Platonic numbers defined by starting with 1 central dot (for \(n\)=0) and adding regular convex polyhedral layers around the central dot, where the \(n\)th layer, \(n\) ≥ 1, has \(n\)+1 dots per facet ridge (face edge for polyhedrons) including both end vertices. The formulae are very similar to the above and can be explored further here.

Let's look a particular type of centered Platonic number, namely the centered tetrahedral numbers, and the case where n=2. See Figure 1.


Figure 1

This second centered tetrahedral number differs from the equivalent tetrahedral number by 1. The progression of the tetrahedral numbers from n=1 to 4 is shown in Figure 2.


Figure 2

With the tetrahedral numbers, there is a layering process in place as is clearly visible in the progression shown in Figure 2. With the centered tetrahedral numbers, the tetrahedra shown in Figure 2 are being built around the central dot. Each progressive tetrahedron contains all the previous tetrahedra, Russian doll style. 

Thus the centered tetrahedral numbers can be derived by progressively summing the tetrahedral numbers:

1, 1 + 4, 1 + 4 + 10, 1 + 4 + 10 + 20 --> 1, 5, 15, 35 etc.

The formulae for the various centered Platonic numbers can be found at this site and for the centered tetrahedral numbers, the formula is:$$ \frac{ (2n+1)(n^2+n+3)}{3}$$This formula generates the following initial members of OEIS A005894:

1, 5, 15, 35, 69, 121, 195, 295, 425, 589, 791, 1035, 1325, 1665, 2059, 2511, 3025, 3605, 4255, 4979, 5781, 6665, 7635, 8695, 9849, 11101, 12455, 13915, 15485, 17169, 18971, 20895, 22945, 25125, 27439, 29891, 32485, 35225, 38115

The generating function for this series is: $$ \frac{(1+x)(1+x^2)}{(1-x)^4}$$For example, the first few terms of the resulting Taylor series are:$$1+5x+15x^2+35x^3+69x^4+121x^5+195x^6+295x^7 + ...$$

Friday, 25 June 2021

Dying Rabbits

The title of this post may seem unusual for a mathematical blog but rabbits of course have a close association with the Fibonacci sequence. Well live, reproducing rabbits at least. The following explains what the rabbits are all about (source):

Fibonacci's Rabbits

In the West, the Fibonacci sequence first appears in the book Liber Abaci (1202) by Leonardo of Pisa, known as Fibonacci. Fibonacci considers the growth of an idealized (biologically unrealistic) rabbit population, assuming that:
    1. a single newly born pair of rabbits (one male, one female) are put in a field;
    2. rabbits are able to mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits;
    3. rabbits never die and a mating pair always produces one new pair (one male, one female) every month from the second month on.
The puzzle that Fibonacci posed was: how many pairs will there be in one year?


Suppose we let the number of rabbit pairs in the field at the end of the nth month be denoted by \(F_n\).

Consider just the new "baby rabbit pairs" in the nth month. They must be equal in number to the pairs of rabbits that are mature enough to give birth to baby rabbits. This, of course, is precisely the number of rabbit pairs alive two months previously, \(F_{n−2}\).

Now the total number of rabbit pairs in the nth month is the number of pairs alive in the previous month (i.e., \(F_{n−1}\)) plus the number of new baby rabbit pairs, \(F_{n−2}\).

Thus, we have the following recursive definition for the nth Fibonacci number: $$F_0=F_1=1 \text{ and } F_n=F_{n−1}+F_{n−2}$$

The assumption that "rabbits never die" is big presumption for they do die and the formula for the Fibonacci sequence can be modified to account for this. I discovered this because my diurnal age at the time of writing this post is 26381 and this number happens to be a member of OEIS A023440:


 A023440

Dying rabbits: a(n) = a(n-1) + a(n-2) - a(n-10)                      


The sequence members, up to 26381, are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 88, 142, 228, 367, 590, 949, 1526, 2454, 3946, 6345, 10203, 16406, 26381.

The sequence is identical to the Fibonacci up to to the 10th term (55): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 88, … because a(10) = a(9) + a(8) - a(0) = 34 + 21 - 0 = 55. However, with a(11) = a(10) + a(9) - a(1) = 55 + 34 - 1, it begins to differ because the oldest generation of rabbits dies off.

It’s easier to generate the terms using the generating function rather than a recursive sequence. In the case of OEIS A023440, this generating function is:$$\frac{x}{(x - 1)(x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 - 1)}$$Here is the SageMath code to generate the terms together with a permalink :

L, k=[], var('k')
S=sum(x^k for k in [2..9])
P=x/((x - 1)*(S - 1))
T=taylor(P,x,0,23).coefficients()
for t in T:
    L.append(t[0])
print(L)

It is easy to generalise this function to accommodate longevities other than 10. For example, changing the 9 to an 8 in the code above will generate OEIS A023439:

 
 A023439

Dying rabbits: a(n) = a(n-1) + a(n-2) - a(n-9)                        


Here is the SageMath code together with a permalink:

L, k=[], var('k')
S=sum(x^k for k in [2..8])
P=x/((x - 1)*(S - 1))
T=taylor(P,x,0,23).coefficients()
for t in T:
    L.append(t[0])
print(L)

There are OEIS sequences corresponding to a(n-3) to a(n-12). Of course the ratio of successive terms doesn't approach the golden ratio as it does with the Fibonacci terms. In the case of OEIS A023440, the ratio approaches 1.6079827279... rather than 1.6180339887... and in the case of OEIS A023439, the ratio approaches 1.6013473338...

So that's the story of the dying rabbits.

Wednesday, 2 June 2021

The Fine Numbers

The Fine numbers and the Catalan numbers are intimately related. Two manifestations are the identity \(C_n=2F_n+F_{n−1} \text{ where }n \geq 1\), and the generating function identities:$$F(x)=\frac{C(x)}{1 +x \,C(x)} \text{ and }C(x)=\frac{F(x)}{1−x\,F(x)}$$This information is taken from the abstract to this 2001 paper titled A Survey of the Fine Numbers. However, I'm getting ahead of myself. How did I get here? Well, today I turned 26356 days old and one of the sequences to which this number belongs is OEIS A119012:


 A119012

Number of valleys strictly above the x-axis in all hill-free Dyck paths of semilength \(n\) (a hill in a Dyck path is a peak at level 1).


The members of this sequence increase rapidly on the way to 26356 (where \(n=10\), starting from \(n=1\)): 0, 0, 1, 5, 23, 98, 405, 1644, 6604, 26356, ...

The reference to Dyck paths immediately ties this number to the Catalan numbers that I've written about before on two difference occasions:
To quote from the Wikipedia article on Catalan Numbers (\(C-n\) is the \(n\)-th Catalan number):
\(C_n\) is the number of ways to form a "mountain range" with \(n\) upstrokes and \(n\) downstrokes that all stay above a horizontal line. The mountain range interpretation is that the mountains will never go below the horizon.

Figure 1 is the accompanying diagram to the previous text:

Figure 1

The depictions of "mountain ranges" are Dyck paths and can be written textually as:

  • \(n=1\): UD
  • \(n=2\): UDUD and UUDD
  • \(n=3\): UDUDUD, UDUUDD, UUDDUD, UUDUDDD and UUUDDD

The first Catalan numbers for \(n = 0, 1, 2, 3, \dots\) are 1, 1, 2, 5 (see Figure 1), 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, ... .

For Dyck paths, a peak of height one is also known as a hill and is represented as UD. It turns out that the Fine numbers count the number of Dyck paths having no hills. The Fine numbers begin: 1, 0, 1, 2, 6, 18, 57, ... beginning with \(n=0\).

Figure 2 shows the two Dyck paths with no hills for the case \(n=3\).


Figure 2

Getting back to OEIS A119012 (0, 0, 1, 5, 23, ... ) starting with \(n=1\), it can seen that there is only a valley in the case of \(n=3\) and that is confirmed by Figure 2.

There are generating functions for the Catalan numbers, the Fine numbers and the numbers making up OEIS A119012. The generating function for the Catalan numbers is:$$C(x)=\frac{1-\sqrt{1-4x}}{2x}$$For the Fine numbers, the generating function is:$$F(x)=\frac{1-\sqrt{1-4x}}{x\,(3-\sqrt{1-4x})}$$For OEIS A119012, the generating function is:$$G(x)= \frac{2 \left (1-3x-(1-x)\sqrt{1-4x}\right )}{\left (1+2x+\sqrt{1-4x}\right )^{2}\sqrt{1-4x}}$$Figure 3 shows the SageMath code for these generating functions:


Figure 3: permalink

Sunday, 13 January 2019

Derangements

Today I turned 25487 days old and the first OEIS entry for this number is A002467: 
Given \(n\) letters and \(n\) envelopes, how many ways are there to fill the envelopes so that at least one letter goes into its right envelope? 
It took some further investigation to realise that this sequence was closely related to OEIS A000166 the numbers of derangements of \(n\): 1, 0, 1, 2, 9, 44, 265, 1854, 14833, 133496, 1334961, 14684570, 176214841, 2290792932, ...

So what is a derangement? According to Wikipedia:
In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position. In other words, derangement is a permutation that has no fixed points. 
The number of derangements of a set of size \(n\), usually written \(Dn\), \(dn\), or \(!n\), is called the "derangement number" or "de Montmort number". (These numbers are generalised to rencontres numbers.) The subfactorial function (not to be confused with the factorial \(n!\)) maps \(n\) to \(!n\). No standard notation for subfactorials is agreed upon; \(n¡\) is sometimes used instead of \(!n\). 
The problem of counting derangements was first considered by Pierre Raymond de Montmort in 1708; he solved it in 1713, as did Nicholas Bernoulli at about the same time.
To construct the formula, let's consider \(n\) letters and \(n\) envelopes. The first envelope can be filled in \(n-1\) ways and, for the second envelope, there are two possibilities. If the second envelope is filled with the first letter, then the first and second letters are taken care of the problem is reduced to \(n-2\) envelopes and \(n-2\) letters. If this does not happen, then there are now \(n-1\) envelopes and \(n-1 \) letters. This can be written as: $$ !n=(n-1)(!(n-1)+!(n-2))$$From here a formula can be derived to calculate the derangements for \(n\) items, specifically:$$!n=n! \sum_{i=0}^{n} \frac{(-1)^n}{i!}$$For this formula !0=1 and !1=0. In the case of 8 letters and 8 envelopes, we get: !8 = 14833.

One letter has ended up in the right envelope. There are 25487
ways in which at least one letter will end up in the right envelope.

So 14833 is the number of ways that no letters end up in the right envelopes. We are interested in the number of ways that at least one letter will end up in the right envelope. So 14833 needs to be subtracted from 8! = 40320 (the total number of possibilities) to get 25487.

Let's look at how the probability of a derangement changes as the number of elements increases. It can be noted that the Taylor Series for the function \(f(x)=1/e^x\) is given by:$$
\frac{1}{e^x}= \sum_{i=0}^{\infty} \frac{(-1)^i x^i}{i!}
$$So when \(x=1\), it can be seen that \(1/e\) is identical to the formula for the derangements:$$
\frac{1}{e}= \sum_{i=0}^{\infty} \frac{(-1)^i}{i!} \approx 0.3678794412
$$So after about four elements, the probability of a derangement quickly settles down to about 37%, no matter what the number of elements. Here is a link to a paper on derangements that begins:
A group of \(n\) men enter a restaurant and check their hats. The hat-checker is absent minded, and upon leaving, she redistributes the hats back to the men at random. What is the probability \(P_n\) that no man gets his correct hat, and how does \(P_n\) behave as \(n \rightarrow \infty\)?
Here are two Numberphile videos on Derangements with James Grimes presenting. The first is an introduction and the second derives a proof for the formula:



Friday, 4 May 2018

Polygonal Number Generating Function and Formula

Today my diurnal age is 25233, a number that happens to be a polygonal number, specifically a 32-gonal number. A WolframAlpha article states that the generating function for the n-gonal numbers is given by: $$G_n(x)= \frac{x \, [(n-3)x+1]}{(1-x)^3} $$ This means that for the 32-gonal numbers, the formula becomes: $$G_{32}(x)= \frac{x \, (33x+1)}{(1-x)^3}$$In WolframAlpha, the coefficients can then be identified using the series command:


In Sage, the Taylor series is generated using the code:
g(x)=x*(33*x+1)/(1-x)^3
g.taylor(x,0,15).coefficients()
When run, this code produces the following output:


In the case of the 36-gonal numbers, the formula for the n-th term is given by:$$a(n)=n(17n-16) $$The general formula for the n-th polygonal number is given by:$$a(n)=(P-2) \frac{n(n+1)}{2}-(P-3)n$$where \(P\) is the number of vertices of the polygon.

In the case of \(P=36 \) (our 36-gon), the formula becomes:$$34\frac{n(n+1)}{2}-33n=n(17n-16) $$Here's a video describing how the formula is derived:

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.

Friday, 22 April 2016

Taylor Series

My diurnal age today is 24491 and this number features in OEIS A077946:  


 A077946

Expansion of \( \dfrac{1}{1 - x - 2x^2 - 2x^3} \)       
                              


The number arises as a coefficient of \(x\) in the Taylor Series expansion of the function at \(x=0\). The coefficients listed up to 24491 are:

1, 1, 3, 7, 15, 35, 79, 179, 407, 923, 2095, 4755, 10791, 24491

This means that the function can be expressed as:

\(1 + x + 3x^2 + 7x^3 + 15x^4 + 35x^5 + \dots \)

The Taylor Series for any continuous function \( f(x)\)at a point \(x=a\) is given by the following expression:$$f(x)=f(a)+\frac{f'(a)}{1!} (x-a) + \frac{f''(a)}{a!} (x-a)^2+ \frac{f'''(a)}{3!} (x-a)^3 + \dots$$
A Maclaurin Series is a Taylor Series where \(a=0\).

Here is a permalink that will display these results using SageMathCell. I have a later post about Taylor Series that I created on April 27th 2018.

REFURBISHED on Saturday November 26th 2022