Showing posts with label exponential. Show all posts
Showing posts with label exponential. Show all posts

Friday, 31 July 2026

Euler's Formula


Graphic created using Gemini

Courtesy of Gemini:

Often cited as the most beautiful theorem in mathematics, Euler’s identity (\(e^{i\pi} + 1 = 0\)) achieves its fame by elegantly linking the most fundamental constants and operations in a single, concise equation.

Here is the history behind its discovery and the mathematical proof of why it works.

The History Behind the Identity

The equation is a specific case of Euler’s formula, which states that for any real number \(x\):

\[e^{ix} = \cos(x) + i\sin(x)\]

While the identity bears the name of the brilliant Swiss mathematician Leonhard Euler, the groundwork was laid slightly earlier. In 1714, the English mathematician Roger Cotes discovered a precursor to this relationship, expressing it in terms of natural logarithms: \(\ln(\cos x + i\sin x) = ix\).

However, it was Euler who, in 1748, formalized the mathematics into the modern exponential form we use today. He published it in his foundational text Introductio in analysin infinitorum (Introduction to the Analysis of the Infinite).

The identity is celebrated because it connects five foundational mathematical constants from entirely different disciplines:

  • \(0\): The additive identity (the foundation of arithmetic).
  • \(1\): The multiplicative identity (the foundation of counting).
  • \(\pi\): The fundamental constant of geometry (the ratio of a circle's circumference to its diameter).
  • \(e\): The fundamental constant of growth and continuous change (the base of natural logarithms).
  • \(i\): The imaginary unit (\(\sqrt{-1}\)), which unlocks complex algebra.

It also seamlessly utilizes the three most basic mathematical operations: addition, multiplication, and exponentiation.


Why the Equation Holds True

To prove why this works, we must look to Taylor series (specifically, Maclaurin series expansions). A Maclaurin series allows us to express complex functions as an infinite sum of polynomial terms.

The series expansion for the exponential function \(e^x\) is:

\[e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \frac{x^5}{5!} + \dots\]

If we substitute \(x = i\theta\) into this series, we get:

\[e^{i\theta} = 1 + (i\theta) + \frac{(i\theta)^2}{2!} + \frac{(i\theta)^3}{3!} + \frac{(i\theta)^4}{4!} + \frac{(i\theta)^5}{5!} + \dots\]

Next, we evaluate the powers of \(i\). By definition, \(i = \sqrt{-1}\), which creates a repeating pattern:

  • \(i^1 = i\)
  • \(i^2 = -1\)
  • \(i^3 = -i\)
  • \(i^4 = 1\)
  • \(i^5 = i\)

Substituting these evaluated powers back into our series gives:

\[e^{i\theta} = 1 + i\theta - \frac{\theta^2}{2!} - \frac{i\theta^3}{3!} + \frac{\theta^4}{4!} + \frac{i\theta^5}{5!} - \dots\]

Now, we group the real terms (those without an \(i\)) and the imaginary terms (those multiplied by \(i\)) together:

\[e^{i\theta} = \left( 1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \dots \right) + i\left( \theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \dots \right)\]

This is where Euler's brilliant connection becomes visible. These two grouped polynomial expansions perfectly match the standard Maclaurin series expansions for the trigonometric functions cosine and sine:

\[\cos(\theta) = 1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \dots\]

\[\sin(\theta) = \theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \dots\]

By substituting \(\cos(\theta)\) and \(\sin(\theta)\) back into our grouped equation, we arrive at Euler's formula:

\[e^{i\theta} = \cos(\theta) + i\sin(\theta)\]

Reaching the Final Identity

To get Euler's Identity, we evaluate the formula at \(\theta = \pi\) radians (which corresponds to \(180\) degrees on the unit circle):

\[e^{i\pi} = \cos(\pi) + i\sin(\pi)\]

Looking at a standard trigonometric unit circle, we know that:

  • \(\cos(\pi) = -1\)
  • \(\sin(\pi) = 0\)

Substituting these values in:

\[e^{i\pi} = -1 + 0i\]

\[e^{i\pi} = -1\]

By simply adding \(1\) to both sides, we arrive at the final state of the identity, linking the five constants perfectly together:

\[e^{i\pi} + 1 = 0\]

Here is a Gemini link to information about the mathematicians Taylor and MacLaurin.

Wednesday, 11 February 2026

Generating Functions

Only yesterday in a post titled Linear Recurrence Revisited did I look at this recurrence in relation to my diurnal age of 28072:$$ \begin{align} &\text{a}(n+3) = 2\text{a}(n+2) - 3\text{a}(n+1) + 2\text{a}(n)\\ & \text{a}(0) = 1, \text{a}(1) = 1, \text{a}(2) = 0 \end{align}$$Today, a day later, I find that 28073 can also be linked to a linear recurrence via OEIS A157651:$$ \begin{align} &\text{a}(n) = 3\text{a}(n-1) -3\text{a}(n-2) +\text{a}(n-3) \\ &\text{a}(0) =57, \text{a}(1) =308, \text{a}(3)=759 \end{align}$$The initial terms are:

57, 308, 759, 1410, 2261, 3312, 4563, 6014, 7665, 9516, 11567, 13818, 16269, 18920, 21771, 24822, 28073, 31524, 35175, 39026, 43077, 47328, 51779, 56430, 61281, 66332, 71583, 77034, 82685, 88536, 94587, 100838, 107289, 113940, 120791, 127842

However, this time I want to look at ordinary generating functions and exponential generating functions in relation to this linear recurrence. The following was created by Gemini.
$$
\begin{array}{@{}l}



\textbf{Derivation of the Ordinary Generating Function } G(x) \\[12pt]


\text{Let } G(x) = \displaystyle\sum_{n=0}^{\infty} a_n x^n = a_0 + a_1 x + a_2 x^2 + \dots \\[12pt]
\text{The recurrence relation is: } a_n - 3a_{n-1} + 3a_{n-2} - a_{n-3} = 0 \text{ for } n \ge 3. \\[12pt]


\text{We multiply } G(x) \text{ by the polynomial } (1 - 3x + 3x^2 - x^3): \\[6pt]
(1 - 3x + 3x^2 - x^3)G(x) = \\[6pt]
\quad \phantom{-} (a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \dots) \\
\quad - \displaystyle 3x (a_0 + a_1 x + a_2 x^2 + \dots) \\
\quad + \displaystyle 3x^2 (a_0 + a_1 x + \dots) \\
\quad - \displaystyle x^3 (a_0 + \dots) \\[18pt]


\text{Grouping coefficients by powers of } x: \\[6pt]
\text{Constant: } a_0 = 57 \\[6pt]
x^1: a_1 - 3a_0 = 308 - 3(57) = 308 - 171 = 137 \\[6pt]
x^2: a_2 - 3a_1 + 3a_0 = 759 - 3(308) + 3(57) = 759 - 924 + 171 = 6 \\[6pt]
x^n \text{ (for } n \ge 3\text{): } a_n - 3a_{n-1} + 3a_{n-2} - a_{n-3} = 0 \\[18pt]


\text{Thus:} \\[6pt]
(1 - x)^3 G(x) = 57 + 137x + 6x^2 \\[12pt]


\text{The Ordinary Generating Function is:} \\[6pt]
G(x) = \displaystyle\frac{57 + 137x + 6x^2}{(1 - x)^3} \\[24pt]




\textbf{Derivation of the Exponential Generating Function } E(x) \\[12pt]


\text{Let } E(x) = \displaystyle\sum_{n=0}^{\infty} a_n \frac{x^n}{n!}. \\[12pt]
\text{The recurrence } a_n - 3a_{n-1} + 3a_{n-2} - a_{n-3} = 0 \\ \text{ becomes the differential equation:} \\[6pt]
E'''(x) - 3E''(x) + 3E'(x) - E(x) = 0 \\[12pt]


\text{The characteristic equation is } r^3 - 3r^2 + 3r - 1 = (r-1)^3 = 0. \\[6pt]
\text{This has a triple root at } r = 1. \\[12pt]


\text{The general solution for a triple root is:} \\[6pt]
E(x) = (C_1 + C_2 x + C_3 x^2)e^x \\[12pt]


\text{We find constants } C_1, C_2, C_3 \text{ using initial conditions } a_0=57, a_1=308, a_2=759. \\[6pt]
\text{Note that } a_n \text{ is the coefficient of } \frac{x^n}{n!}. \\[6pt]
\text{Expanding } E(x) = (C_1 + C_2 x + C_3 x^2) \displaystyle \sum \frac{x^n}{n!} \\ \text{ allows us to match coefficients directly.} \\[18pt]


\text{Solving for the constants (via derivatives at } x=0 \text{):} \\[6pt]
1. \quad E(0) = a_0 \implies C_1 = 57 \\[6pt]
2. \quad E'(0) = a_1 \implies C_1 + C_2 = 308 \implies 57 + C_2 = 308 \implies C_2 = 251 \\[6pt]
3. \quad E''(0) = a_2 \implies C_1 + 2C_2 + 2C_3 = 759 \\[6pt]
\phantom{3. \quad} 57 + 2(251) + 2C_3 = 759 \\[6pt]
\phantom{3. \quad} 559 + 2C_3 = 759 \implies 2C_3 = 200 \implies C_3 = 100 \\[18pt]


\text{The Exponential Generating Function is:} \\[6pt]
E(x) = (57 + 251x + 100x^2)e^x \\[24pt]




\textbf{Expansion of the Ordinary Generating Function} \\[12pt]


\text{The correct OGF is: } G(x) = \displaystyle\frac{57 + 137x + 6x^2}{(1-x)^3} \\[12pt]


\text{We use the binomial series expansion for } (1-x)^{-3}: \\[6pt]
(1-x)^{-3} = \displaystyle\sum_{n=0}^{\infty} \binom{n+2}{2} x^n = \displaystyle\sum_{n=0}^{\infty} \frac{(n+1)(n+2)}{2} x^n \\[12pt]


\text{Multiply this series by the numerator } (57 + 137x + 6x^2): \\[6pt]
a_n = 57 \cdot \binom{n+2}{2} + 137 \cdot \binom{n+1}{2} + 6 \cdot \binom{n}{2} \\[12pt]


\text{Let's verify the first few terms again with the correct formula:} \\[12pt]


\textbf{For } n=0: \\[6pt]
a_0 = 57 \cdot \frac{(1)(2)}{2} = 57(1) = \mathbf{57} \\[12pt]


\textbf{For } n=1: \\[6pt]
\text{The term } \binom{n}{2} \text{ is 0 for } n < 2. \\[6pt]
a_1 = 57 \cdot \frac{(2)(3)}{2} + 137 \cdot \frac{(1)(2)}{2} \\[6pt]
a_1 = 57(3) + 137(1) = 171 + 137 = \mathbf{308} \\[12pt]


\textbf{For } n=2: \\[6pt]
a_2 = 57 \cdot \frac{(3)(4)}{2} + 137 \cdot \frac{(2)(3)}{2} + 6 \cdot \frac{(2)(1)}{2} \\[6pt]
a_2 = 57(6) + 137(3) + 6(1) \\[6pt]
a_2 = 342 + 411 + 6 = \mathbf{759} \\[12pt]


\textbf{For } n=3: \\[6pt]
a_3 = 57 \cdot \frac{(4)(5)}{2} + 137 \cdot \frac{(3)(4)}{2} + 6 \cdot \frac{(3)(2)}{2} \\[6pt]
a_3 = 57(10) + 137(6) + 6(3) \\[6pt]
a_3 = 570 + 822 + 18 = \mathbf{1410} \\[24pt]




\textbf{Expansion of the Exponential Generating Function} \\[12pt]


\text{We expand } e^x = \displaystyle\sum_{n=0}^{\infty} \dfrac{x^n}{n!} = 1 + x + \dfrac{x^2}{2!} + \dfrac{x^3}{3!} + \dots \\[12pt]


\text{Multiply by the polynomial } (57 + 251x + 100x^2): \\[6pt]
E(x) = 57 \displaystyle\sum \dfrac{x^n}{n!} + 251x \displaystyle\sum \dfrac{x^n}{n!} + 100x^2 \displaystyle\sum \dfrac{x^n}{n!} \\[12pt]


\text{To find } a_n, \text{ we look for the coefficient of } \frac{x^n}{n!} \text{ in the combined sum.} \\[6pt]
\text{Note that } x \cdot \dfrac{x^{n-1}}{(n-1)!} = n \dfrac{x^n}{n!} \text{ and } x^2 \cdot \dfrac{x^{n-2}}{(n-2)!} = n(n-1) \dfrac{x^n}{n!}. \\[12pt]


\text{This gives us the direct formula:} \\[6pt]
a_n = 57(1) + 251(n) + 100(n)(n-1) \\[6pt]
a_n = 100n^2 + 151n + 57 \\[12pt]


\text{Let's calculate the terms using this formula:} \\[12pt]


\textbf{For } n=0: \\[6pt]
a_0 = 0 + 0 + 57 = \mathbf{57} \\[12pt]


\textbf{For } n=1: \\[6pt]
a_1 = 100(1) + 151(1) + 57 = 251 + 57 = \mathbf{308} \\[12pt]


\textbf{For } n=2: \\[6pt]
a_2 = 100(4) + 151(2) + 57 = 400 + 302 + 57 = \mathbf{759} \\[12pt]


\textbf{For } n=3: \\[6pt]
a_3 = 100(9) + 151(3) + 57 = 900 + 453 + 57 = \mathbf{1410}
\end{array}
$$
I prefer to work with the ordinary generating function in which case the following simple code will generate the terms:

Friday, 12 December 2025

Humans Versus Elves


Generated by Gemini 

We all know that elves live far longer than humans. Let's say that elves live on average 900 years but humans live on average only 90 years. In our imaginary world, let's say that the populations of both species are equal at one million each, with roughty equal numbers of males and females. Humans and elves cannot produce viable offspring but humas couples on average produce 2.01 babies during whereas the elves produce on average 1.99 babies during their very lengthy lifetimes. Thus we have:

  • Humans:Reproductive Rate: 2.01
    Growth of 0.5% per generation
    Generation Time: 30 years

  • Elves:Reproductive Rate: 1.99$
    Decline of 0.5% per generation)
    Generation Time: 300 years

What happens to these two starting populations over the next 50,000 years? Well, the differences are startling. Chart 1 and Table 1 tell the story.


Chart 1: produced by Gemini


Table 1: produced by Gemini

The elf population after 50,000 years has dwindled to less than half its original size (433,691) while the human population has soard to over four billion (4,074,768,381). This was just a little comparison that occurred to me when I was lying in bed and trying to get to sleep. It's remarkable how a relatively small difference in reproductive rates (one slightly above replacement level and one slightly below) can produce such divergence over extended periods of time. Of course, the real life human replacement level for humans is close to 2.1 but the scenario I've depicted is just imaginary and the realisation of a nocturnal thought experiment.

Wednesday, 24 April 2024

Visualising Sequences

While playing around with the patterns produced by some sequences, I discovered some interesting patterns. It began with the sequence produced by$$ \text{a}(n)=\sin(n) \cdot e^{-0.001 \cdot n}$$for values of \(n\) from 0 to 2000. See Figure 1 (permalink).


Figure 1

What's interesting is the hexagonal arrangement of the points. The values cannot exceed \( \pm \)1 and the exponential component brings progressive values closer and closer to zero, although at a very slow rate. The pattern becomes rather different once we introduce another element as follows:$$ \text{a}(n)=n \cdot \sin(n) \cdot e^{-0.001 \cdot n}$$for values of \(9n\) from 0 to 4000. See Figure 2 (permalink).


Figure 2

Values range from about - 367 to + 367. Once again, the exponential component eventually dominates and the range of values inexorably decrease. Increasing the exponent of the \(n\) element doesn't really alter the pattern. For example, raising the \(n\) to the fourth power:$$ \text{a}(n)=n^4 \cdot \sin(n) \cdot e^{-0.001 \cdot n}$$for values of \(n\) from 0 to 8000 produces the pattern shown in Figure 3 (permalink).


Figure 4

So nothing profound in this post, just interesting now inputting integral values into a function and plotting the output produces interesting patterns. You can see the same general shape using a program like GeoGebra but the patterns shown do not emerge. See Figure 4.


Figure 4

As can be seen from Figure 4, negative value of \(n\) cause the output values to explode. Of course, most of the sequences that I examine in this blog are integer sequences, the result of integer output from integer input, as found in the OEIS. It's interesting however, from time to time, to examine non-integer output from integer input, as I've done in this post. 

Finally, before we do, consider Figure 5 (permalink) that shows an interesting result for a sequence generated by:$$ \text{a}(n)=n \cdot e^{ \, \sin(x)}$$where the two bounding lines are given by \(y=e \cdot x\) and \(y=1/e \cdot x\).


Figure 5

Sunday, 9 May 2021

Collaboration between Integration and Summation

When it is permissible, it is often convenient when evaluating certain integrals to interchange the order of a summation and an integration. Let's use the following definite integral as an example to illustrate this technique:$$\int_0^{\infty}\frac{x}{e^x-1} \mathrm{d}x$$The graph is as shown in Figure 1.


Figure 1: created in GeoGebra

Let's begin the integration:$$\begin{align} \int_0^{1}\frac{x}{e^x-1} \mathrm{d}x&=\int_0^{1}\frac{x}{\dfrac{1}{e^{-x}}-1} \mathrm{d}x\\
&=\int_0^{1}\frac{x \, e^{-x}}{1-e^{-x}}\mathrm{d}x\\
&=\int_0^{1} x \, e^{-x} \left ( \dfrac{1}{1-e^{-x}} \right ) \mathrm{d}x\\
&=\int_0^{1} x \, e^{-x} \sum_{n=0}^{\infty} e^{-nx} \, \mathrm{d}x\\
&=\sum_{n=0}^{\infty} \int_0^{1} x \, e^{-x(n+1)} \, \mathrm{d}x\\
&=\sum_{n=1}^{\infty} \int_0^{1} x \, e^{-nx} \, \mathrm{d}x \\
\text{Now } \int x \, e^{-nx} \, \mathrm{d}x &= \int x \frac{\mathrm{d}}{\mathrm{d}x} \left (\frac{e^{-nx}}{-n} \right ) \, \mathrm{d}x\\
&=\frac{-x \, e^{-nx}}{n}+\frac{1}{n} \int e^{-nx} \, \mathrm{d}x\\
&=\frac{-x \, e^{-nx}}{n}- \frac{e^{-nx}}{n^2} +C\\
\text{So }\int_0^{1}\frac{x}{e^x-1} \mathrm{d}x&=\sum_{n=1}^{\infty} \left [ \frac{-x \, e^{-nx}}{n}- \frac{e^{-nx}}{n^2} \right ]_0^1\\
&=\sum_{n=1}^{\infty} \left ( \frac{-e^{-n}}{n}-\frac{e^{-n}}{n^2}+\frac{1}{n^2} \right )\\
&=\sum_{n=1}^{\infty} \frac{1}{n^2} -\sum_{n=1}^{\infty}\frac{e^{-n}}{n} -\sum_{n=1}^{\infty} \frac{e^{-n}}{n^2}\\
\text{Now }\sum_{n=1}^{\infty} \frac{1}{n^2} &=\zeta(2)\\
&=\frac{\pi^2}{6}\\
\sum_{n=1}^{\infty}\frac{e^{-n}}{n} &= 1-\ln(e-1) \\
\sum_{n=1}^{\infty}\frac{e^{-n}}{n^2} &= \text{Li}_2 \left (\dfrac{1}{e} \right )\\
\text{Hence } \int_0^{1}\frac{x}{e^x-1} \mathrm{d}x&=\frac{\pi^2}{6}+\ln(e-1) -\text{Li}_2 \left (\dfrac{1}{e} \right )-1\\
&\approx 0.777505

\end{align}$$Looking at Figure 1, it can be seen that this result looks just about right. I'm thankful to Mathematics M1's YouTube video for detailing the steps required to reach this result. I'm reproducing the steps here as a means of practising my LaTeX skills but it's also to remind me how interesting the integration technique is, specifically the way in which the integral and the summation are swapped around. Li is the Eulerian Logarithmic Integral and deserves a blog post of its own.$$ \mathrm{Li}(x)=\int_2^x \dfrac{\mathrm{d}t}{\ln t }= \mathrm{li}(x)-\mathrm{li}(2) \text{ where } \mathrm{li}(x)=\int_0^x \dfrac{\mathrm{d}t}{\ln t }$$

Saturday, 1 May 2021

Integration of x^x and x^(-x)

There are many YouTube videos outlining how to integrate \(x^x\) and \(x^{-x}\) but the following is the best explained that I've come across.


In the video, the function \(x^x\) is integrated from 0 to 1. In fact, this proper integral is converted into an infinite series so traditional integration is not possible. The result is quite impressive:$$\int_0^1 x^x \mathrm{d} x=\sum_0^{\infty} \frac{(-1)^n}{(n+1)^{n+1}}=1-\frac{1}{2^2}+\frac{1}{3^3}-\frac{1}{4^4}+ \dots \approx 0.783430$$The result for \(x^{-x}\) is similar:$$\int_0^1 x^{-x} \mathrm{d} x=\sum_0^{\infty} \frac{1}{(n+1)^{n+1}}=1+\frac{1}{2^2}+\frac{1}{3^3}+\frac{1}{4^4}+ \dots \approx 1.291285 $$Figure 1 shows the SageMath code to draw the two graphs in the given range and to calculate the area bounded by them:

Figure 1: permalink

Figure 2 shows the result with annotations added:

Figure 2

It's hard to see but the area bounded by the two curves is shown at the bottom left and is approximately 0.507855 square units. Figure 3 shows an alternative representation using GeoGebra:


Figure 3

These graphs, their turning points and the bounded area between them are most interesting. Let's not forget that the turning points for both graphs occur when \(x=\dfrac{1}{e}\) because:$$\begin{align} y&=x^x\\ \frac{\mathrm{d}}{\mathrm{d} x} y &=\frac{\mathrm{d}}{\mathrm{d} x } x^x\\&=\frac{\mathrm{d}}{\mathrm{d} x} e^{\,x \ln x}\\&=e^{\,x \ln x} (1+\ln x)\\&=0 \text { when }\ln x = -1 \text{ or } x=\frac{1}{e} \end{align}$$The result is the same for \(y=x^{-x}\), only the y values differ with \(e^{1/e} \approx 1.44\) for \(x^{-x}\) and \(e^{-1/e} \approx 0.69\) for \(x^x \).

Saturday, 22 October 2016

The Wallis Formula for Pi and the Dawson Function

I spent quite some time watching this video on the derivation of the Wallis product and practised until I could reproduce it without any external assistance. A crucial part of the solution relies on integration by parts to set up a reduction formula for the integral of \( sin(x)^n\). Here is the very well-presented and easy to understand video:


Note: the following discussion centres on integration by parts and is not related to the Wallis function.

I sometimes practise using integration by parts to solve integrals that I think of and last night my mind fell on a deceptively easy-looking integral, namely \(e^{x^2}\). The graph of this function is well-behaved and I thought that there would be an easy solution but try as I might I couldn't find it. Reluctantly, I checked first Symbolab and then WolframAlpha to find out how it could be done. Here's what the former had to say:


What on earth is this F(x) that just appears out of nowhere? WolframAlpha offered the same solution but had accompanying documentation that described F(x) as the Dawson integral defined by:
There is a quite comprehensive article about the Dawson integral or Dawson Function, as it's alternatively called, on Wikipedia but it's largely incomprehensible to me at the moment. Maybe I can come to terms with it later.