April 2024

Approximation Theory

Approximation theory is the field of analysis that explores how to approximate things. It does this in the broadest sense - it deals with approximating functions, constants, distances, and providing algorithms to approximate anything that could be approximated. It is likely one of the most useful pieces of pure mathematics, applications ranging from approximating Einstein’s equations for relativity to constructing computer graphics using the Bézier curves formed by the Bernstein polynomials.

This project is divided is divided into three main chapters: one on functional analysis, one on the approximation of π\pi, and one on polynomial interpolation and its application to sequences.

The approximation of constants has existed since almost the dawn of mathematics, beginning to be necessary with the Greek and Indian discovery of the irrational following the Pythagorean theorem. However, the other fields of approximation theory are much more modern, the reason for this being that a precise notion and definition of a function is required for them, which was only first developed with the work of Bernoulli in the late 18th century.

Approximation theory then developed as a supposed solution to several problems, including Euler’s work on minimizing error on the maps of Russia in attempting converge the non Euclidian geometry of the Earth into a 2 dimensional rectangular map. Aproximation theory greatly simplified this process. A similar problem was investigated by Nash in the 1950s.

From this followed Chebyshev and Fourier’s work on the approximation of functions, culminating in the work of Bernstein in his proof of the Weierstrass approximation theorem, proving that any function can be approximated by a polynomial. Polynomial interpolation was first developed through the work of Newton in the late 17th century, and reached its culmination with the work of Lagrange in 1795.

Because approximation theory is so broad, it shows how mathematics has evolved, beginning with Archimedes’ geometric approximations, showing the development of calculus and Newton’s use of the ’divided difference’ as the derivative was developed, going through to Taylor series and integration.

Now if only it was still 2016, then we would have a square date today, since =5004225042016 = 5004^2)

Functional approximation

Introduction

Given a continuous function f(x)f(x) defined over the closed interval [a,b][a,b], how can we represent ff as another function gg such that the difference between the two functions is as small as possible? Can we construct a summation, or infinite series in terms of simple functions such that the resulting approximation is as close as possible to the target function? The theorem which proves that we can do this is known as the Weierstrass approximation theorem which states that given function f(x)f(x) defined over closed interval [a,b][a, b] and ϵ>0\epsilon >0, it is possible to construct polynomial Pn(x)P_n(x) such that |f(x)−Pn(x)|<ϵ|f(x) - P_n(x)| < \epsilon, and therefore that any function can be approximated as closely as desired by a polynomial. The Fourier and Chebyshev series on which I will elaborate below use the method of infinite summation of easier functions to approximate more complicated functions, and have astoundingly fast convergence rate. Although the mathematics asserts that the perfect approximation is formed when the series is evaluated at infinity, if we wish to evaluate this in practice, we can truncate the series at a value NN, forming a compromise between computational energy and accuracy.

Fourier analysis

Fourier analysis is the approximation of an often complicated function using only the sums of the sine and cosine functions, proposed by French mathematician Joseph Fourier, who in his classic 1822 paper "The analytical study of heat" showed that decomposing more complex functions into simpler ones made it much easier to solve differential equations. Specifically, Fourier was trying to solve the heat equation, which had been one of the biggest problems of the time. However, by simplifying the functions in the differential equation to just the sinusoidal functions, whose differential properties were well understood, Fourier managed to solve the heat equation. This method has become known as ’solving by Fourier series’. To demonstrate how the Fourier series works, consider a basic sine wave:

Sine wave, sin(x)

Now, consider the graph of sin⁡(2x)\sin(2x):

Sine wave, sin(2x)

Now, consider this graph:

Sum of sin(x) and sin(2x)

Note how dissimilar this graph is, on first examination, to the original two graphs. Given just this graph (and with no prior experience of Fourier analysis) you would assume that the graph is that of a strange and irregular function. However, this graph is just the graph of the function: f(x)=sin⁡(x)+sin⁡(2x)f(x) = \sin(x) + \sin(2x) This is the base for Fourier analysis. Given any function, how can we simplify it into just the sum of the sine and cosine functions?

This gives rise to two fields of approximation:

  1. The Fourier series: Any continuous, differentiable oscillatory function can be (using the Fourier series) described as the sum of trigonometric or exponential functions. In order to ensure convergence, the Dirichlet conditions much be met - these being that the function must be periodic, absolutely integrable over its period, have a finite number of discontinuities and a finite number of maxima and minima.

  2. The Fourier transform: Any continuous, differentiable function satisfying all the Dirichlet conditions except periodicity, can be described as a continuous integral of a complex exponential function.

Fourier Series

Let us first examine the Fourier series. What we want to achieve is an infinite series approximation for f(x)f(x), in terms of the sine and cosine functions, weighted by index nn which has the effect of reducing the wavelength of the function and increasing accuracy and convergence of the approximation. We need to work out formulas for coefficients a0a_0, ana_n and bnb_n: f(x)=a0+∑n=1∞ancos⁡nx+∑n=1∞bnsin⁡nxf(x) = a_0 + \sum^{\infty}_{n=1}a_n \cos nx + \sum^{\infty}_{n=1}b_n \sin nx In practice, when using the Fourier series to approximate a function, we will not evaluate the series to infinity, we will instead cut it off at a certain value of iterations, in a compromise between computational efficiency and convergence. Note that we do not need to have formula for bnb_n sin⁡0=0\sin 0 = 0.

Deriving the coefficients

How can we find ana_n and bnb_n? Recall first from linear algebra that one of the most basic operations which can be applied to two vectors is the dot product. We refer to the dot product as a dot in the middle of the multiplication (eg. a→⋅b→\vec{a} \cdot \vec{b}). Given two vectors a→,b→∈ℝn\vec{a}, \vec{b} \in \mathbb{R}^n, their dot product is given by either a→⋅b→=|a||b|cos⁡θ,\vec{a} \cdot \vec{b} = |a||b|\cos\theta, where |x||x| is the length of vector xx and θ\theta is the angle between the two vectors or: a→⋅b→=a1b1+...anbn\vec{a} \cdot \vec{b} = a_1b_1 + ... a_nb_n The first formula has quite an elegant geometric interpretation - consider, for the sake of example, two vectors a→\vec{a} and b→\vec{b} in 2 dimensional space.

Vectors a and b

Consider the line formed by extending the line formed by connecting the tip of b→\vec{b} and the origin. The dot product is formed by projecting a→\vec{a} onto this line, and then multiplying the length of the projected a→\vec{a} by the length of b→\vec{b}, the result is the dot product of the two vectors. This is why the cosine teresting property of this is that this property does not change whether b→\vec{b} is being projected unto the line formed by a→\vec{a} or vise versa, both cases give the dot product. One more property of this dot product is that if the two vectors are orthogonal (θ=90\theta = 90) the dot product evaluates to 0, whereas if they point in opposite directions, their dot product is negative. Let us furthermore consider how the second formula which states that if given two nth dimensional vectors, we can establish the dot product by simply summating the product of each element in both vectors (this will be of great use to us later) corresponds to the principle of projecting one vector unto another.

How can we apply this, to test whether two given functions ff and gg are orthogonal? We must represent our function as a vector, which we could do by forming a single row vector of infinitesimal increments, and then forming the dot product, which in the vector results in multiplying all the values in each row and summating this. This is essentially equivalent to the Riemann sum over aa and bb, therefore the dot product in the vector of our function is equal to ∫abf(x)g(x)dx\int^b_a f(x)g(x)dx

Where aa and bb are the ends of the function.

If we apply this to the trigonometric functions we are working with, we can take their dot product such that ⟨cos⁡nx,cos⁡kx⟩=∫−ππ(cos⁡nx)(cos⁡kx)dx\langle \cos nx, \cos kx \rangle = \int^\pi_{-\pi} (\cos nx)(\cos kx)\,dx To evaluate this integral, we use the product-to-sum identity of the cosine function, which states that cos⁡mxcos⁡nx=12[cos⁡(m+n)x+cos⁡(m−n)x]\cos mx \cos nx = \frac{1}{2}[\cos(m+n)x + \cos(m-n)x] Our integral therefore simplifies to: ⟨cos⁡nx,cos⁡kx⟩=12[∫−ππcos(m+n)xdx+∫−ππcos(m−n)xdx]\langle \cos nx, \cos kx \rangle = \frac{1}{2}\left[\int^\pi_{-\pi}\cos(m+n)x\,dx + \int^\pi_{-\pi}\cos(m-n)x\,dx\right] Therefore, by the first Fundamental Theorem of Calculus, we can say that ⟨cos⁡nx,cos⁡kx⟩=12[1m+nsin⁡(m+n)x|−ππ+1m−nsin⁡(m−n)x|−ππ]\langle \cos nx, \cos kx \rangle = \frac{1}{2}[\frac{1}{m+n}\sin(m+n)x \bigg\rvert^\pi_{-\pi} + \frac{1}{m-n}\sin(m-n)x \bigg\rvert^\pi_{-\pi}] As the sine function crosses the xx axis for multiples of π\pi, 1m+nsin⁡(m+n)x|−ππ+1m−nsin⁡(m−n)x|−ππ\frac{1}{m+n}\sin(m+n)x \bigg\rvert^\pi_{-\pi} + \frac{1}{m-n}\sin(m-n)x \bigg\rvert^\pi_{-\pi} will evaluate to 0, therefore, for m≠km \neq k, . ⟨cos⁡nx,cos⁡kx⟩=0\langle \cos nx, \cos kx \rangle = 0 For m=km = k, both terms become: ⟨cos⁡nx,cos⁡kx⟩=12[∫−ππcos(2nx)dx+∫−ππcos(0)dx]\langle \cos nx, \cos kx \rangle = \frac{1}{2}\left[\int^\pi_{-\pi}\cos(2nx)\,dx + \int^\pi_{-\pi}\cos(0)\,dx\right] The integral of cos⁡(0)\cos(0) over any interval of xx is simply 2π2\pi, while the integral of cos⁡(2nx)\cos(2nx) over a full period of 2π2\pi evaluates to 0. Thus, when m=km = k, ⟨cos⁡nx,cos⁡kx⟩=12(0+2π)=π\langle \cos nx, \cos kx \rangle = \frac{1}{2}(0 + 2\pi) = \pi Therefore: ⟨cos⁡nx,cos⁡kx⟩={0if m≠kπif m=k\langle \cos nx, \cos kx \rangle = \begin{cases} 0 & \text{if } m \neq k \\ \pi & \text{if } m = k \end{cases} This means that multiples of cosine mm and kk are orthogonal in the dot product for m≠km \neq k and are 2π2\pi in the dot product for m=km = k. We consider whether this applies to the sine function by similarly taking ⟨cos⁡nx,cos⁡kx⟩∫−ππ(sin⁡nx)(sin⁡kx)dx\langle \cos nx, \cos kx \rangle \int^{\pi}_{-\pi} (\sin nx)(\sin kx)\,dx we use the product-to-sum identities to simplify the integrand. The product-to-sum identities state that: sin⁡(α)sin⁡(β)=12[cos⁡(α−β)−cos⁡(α+β)].\sin(\alpha)\sin(\beta) = \frac{1}{2}[\cos(\alpha - \beta) - \cos(\alpha + \beta)]. Using this identity, we rewrite the integrand as: ∫−ππ(sin⁡nx)(sin⁡kx)dx=∫−ππ12[cos⁡((n−k)x)−cos⁡((n+k)x)]dx=12[∫−ππcos((n−k)x)dx−∫−ππcos((n+k)x)dx].\begin{aligned} \int_{-\pi}^{\pi} (\sin nx)(\sin kx)\,dx &= \int_{-\pi}^{\pi} \frac{1}{2}[\cos((n-k)x) - \cos((n+k)x)]\,dx \\ &= \frac{1}{2}\left[\int_{-\pi}^{\pi} \cos((n-k)x)\,dx - \int_{-\pi}^{\pi} \cos((n+k)x)\,dx\right]. \end{aligned} Now, we integrate term by term. Since the integral of the cosine function over a full period is zero, we have, by the First Fundamental Theorem of Calculus: ∫−ππcos⁡((n−k)x)dx=0,\int_{-\pi}^{\pi} \cos((n-k)x)\,dx = 0, and similarly, ∫−ππcos⁡((n+k)x)dx=0.\int_{-\pi}^{\pi} \cos((n+k)x)\,dx = 0. We can therefore state that, for all m≠nm \neq n: ⟨sin⁡nxsin⁡mx⟩=0\langle \sin nx \sin mx \rangle = 0 When m=km = k, the integral becomes: ⟨sin⁡nx,sin⁡kx⟩=12[∫−ππcos(0)dx−∫−ππcos(2nx)dx].\langle \sin nx, \sin kx \rangle = \frac{1}{2}\left[\int_{-\pi}^{\pi} \cos(0)\,dx - \int_{-\pi}^{\pi} \cos(2nx)\,dx\right]. The integral of cos⁡(0)\cos(0) over any interval of xx is 2π2\pi, while the integral of cos⁡(2nx)\cos(2nx) over a full period of 2π2\pi evaluates to 0. Thus, when m=km = k, ⟨sin⁡nx,sin⁡kx⟩=12(2π−0)=π.\langle \sin nx, \sin kx \rangle = \frac{1}{2}(2\pi - 0) = \pi. Therefore, similarly to cosine, in the dot product, sine is orthogonal for all multiples m≠km \neq k and returns π\pi for m=km = k , such that: ⟨sin⁡nx,sin⁡kx⟩={0if m≠kπif m=k\langle \sin nx, \sin kx \rangle = \begin{cases} 0 & \text{if } m \neq k \\ \pi & \text{if } m = k \end{cases} We finally consider whether the dot product of sin⁡x\sin x and cos⁡x\cos x (weighted by nn and kk respectively) demonstrates an orthogonality between the sinusoidal functions over their period. We consider the integral: ⟨sin⁡nx,cos⁡kx⟩=∫−ππ(sin⁡nx)(cos⁡kx)dx\langle \sin nx, \cos kx \rangle = \int^{\pi}_{-\pi} (\sin nx)(\cos kx)\, dx Using the product-to-sum identities, we rewrite the integrand as: sin⁡(nx)cos⁡(kx)=12[sin((n+k)x)+sin((n−k)x)]\sin(nx) \cos(kx) = \frac{1}{2} \left[ \sin((n+k)x) + \sin((n-k)x) \right]

Thus, the integral becomes: ⟨sin⁡nx,cos⁡kx⟩=12[∫−ππsin((n+k)x)dx+∫−ππsin((n−k)x)dx]\langle \sin nx, \cos kx \rangle = \frac{1}{2} \left[ \int_{-\pi}^{\pi} \sin((n+k)x) \, dx + \int_{-\pi}^{\pi} \sin((n-k)x) \, dx \right]

Evaluating each integral separately, by the first Fundamental Theorem of Calculus, we find: ∫−ππsin⁡((n+k)x)dx=∫−ππsin⁡((n−k)x)dx=0\int_{-\pi}^{\pi} \sin((n+k)x) \, dx = \int_{-\pi}^{\pi} \sin((n-k)x) \, dx = 0

This holds true for all nn and kk, including the case where n=kn = k.

Since both integrals evaluate to zero, we conclude: ∫−ππsin⁡(nx)cos⁡(kx)dx=0\int_{-\pi}^{\pi} \sin(nx) \cos(kx) \, dx = 0 And therefore that, for all nn and kk, the functions sin⁡x\sin x and cos⁡x\cos x are orthogonal by the dot product

This is another reason why the sinusoidal functions were so useful to Fourier as he was solving the heat equation, as well as the fact that the differential properties of the individual functions are well understood, when they are multiplied we can also very easily simplify differential equations thus formed.

We can use this orthogonality principle to attempt to separate out ana_n and bnb_n from our original approximation for f(x)f(x): ∫−ππf(x)cos⁡(kx)dx=∫−ππ(∑n=0∞ancos⁡nx+∑n=1∞bnsin⁡nx)cos⁡(kx)dx\int ^\pi _{-\pi} f(x) \cos (kx)dx = \int ^\pi _{-\pi} (\sum^{\infty}_{n=0}a_n \cos nx + \sum^{\infty}_{n=1}b_n \sin nx)\cos (kx)dx The integrals demonstrated earlier show that ∫−ππf(x)cos⁡(kx)dx=0\int^\pi_{-\pi} f(x) \cos(kx)\, dx = 0 for all n≠kn \neq k. When n=kn = k, we have: ∫−ππf(x)cos⁡(kx)dx=∫−ππak(cos⁡kx)2dx=akπ\int ^\pi _{-\pi} f(x) \cos (kx)dx = \int ^\pi _{-\pi} a_k (\cos kx)^2\,dx = a_k\pi Therefore we have discovered a formula for aka_k, namely that: ak=1π∫−ππf(x)cos⁡(kx)dxa_k = \frac{1}{\pi}\int^\pi_{-\pi} f(x)\cos(kx)\,dx for k≠0k \neq 0. The key to finding a0a_0 is to realise that, to ensure that the Fourier series is accurate, we need to include a constant term that represents the average value of the function over one period. The average value of a function is given by 12L∫−LLf(x)dx\frac{1}{2L}\int^L_{-L} f(x) \,dx

By integrating the function over its entire period the formula captures the total area under the curve of the function over one complete cycle. Dividing the integral by the length of the period scales the integral result to represent an average over the entire period. This normalization ensures that the average value is independent of the period’s length, focusing solely on the function’s behavior within one complete cycle. The result of this computation gives the average height of the function over one period. In graphical terms, if you were to draw the function’s graph over one period, the height of the rectangle whose area equals the integral would represent the average value of the function over that period. Therefore, we can say that:

a0=12π∫−ππf(x)dxa_0 = \frac{1}{2\pi}\int^\pi_{-\pi}f(x)\,dx To achieve coefficient bnb_n, we multiply by sin⁡kx\sin kx and integrate, such that ∫−ππf(x)sin⁡(kx)dx=∫−ππ(∑n=0∞ancos⁡nx+∑n=1∞bnsin⁡nx)sin⁡(kx)dx\int ^\pi _{-\pi} f(x) \sin (kx)\,dx = \int ^\pi _{-\pi} (\sum^{\infty}_{n=0}a_n \cos nx + \sum^{\infty}_{n=1}b_n \sin nx)\sin (kx)\,dx Similarly, using the orthogonality principle, the integral will cancel to 0, for all n≠kn \neq k. When n=kn = k, we have: ∫−ππf(x)sin⁡(kx)dx=∫−ππbk(sin⁡kx)2dx=bkπ\int ^\pi _{-\pi} f(x) \sin (kx)\,dx = \int ^\pi _{-\pi} b_k (\sin kx)^2\,dx = b_k\pi which yields bn=12π∫−ππf(x)sin⁡(kx)dx.b_n = \frac{1}{2\pi}\int^\pi_{-\pi}f(x)\sin(kx)dx. We therefore have the complete Fourier series: f(x)=14π∫−ππf(x)dx+∑n=1∞1π∫−ππf(x)cos⁡(nx)dxcos⁡nx+∑n=1∞12π∫−ππf(x)sin⁡(nx)dxsin⁡nxf(x) = \frac{1}{4\pi}\int^\pi_{-\pi}f(x)dx+\sum^{\infty}_{n=1}\frac{1}{\pi}\int^\pi_{-\pi} f(x)\cos(nx)dx \cos nx + \sum^{\infty}_{n=1}\frac{1}{2\pi}\int^\pi_{-\pi}f(x)\sin(nx)dx \sin nx Note that, by beginning index n a t 1 for both series, we add a separate formula for a0a_0. Note also that this must be divided by two so that a0a_0 be distributed equally between sine and cosine.

An important thing to note whilst approximating a function using the Fourier series is which of the functions sine and cosine should be used. Given an even function (where f(x)=f(−x)f(x) = f(-x)) we use just the even cosine function, whereas given an odd function (where f(−x)=−f(x)f(-x) = -f(x)) we use just the odd sine function. In all other cases we use both.

Reconstructed schematic of the Dirac delta impulseDiagram reconstructed for this web edition; original image not supplied.
Dirac delta functiojn

Dirac Delta Function

Let us now use an example to illustrate the use of the Fourier series, namely the Dirac delta function. The Dirac delta function, denoted by δ(x)\delta(x), is shown in Figure 1.1 above. The Dirac delta function is very interesting, because it is equal to zero at all values xx except at x=0x=0. This function is very good for describing oscillatory behaviour - for example in an article I recently wrote for the most recent Axiom edition, I described how the periodic synchronization of fireflies can be modelled by showing that the probability PN(Tb)P_N(T_b) of all NN fireflies flashing at time time TbT_b must converge to the Dirac delta function.

We can loosely define this function as

δ(x)≃{+∞,if x=00,if x≠0\delta (x) \simeq \begin{cases} +\infty, & \text{if } x = 0 \\ 0, & \text{if } x \neq 0 \end{cases}

However, this piecewise definition is not very elegant. It is better to define the delta function in terms of its properties - namely that ∫−∞∞δ(x)dx=1\int_{-\infty}^{\infty} \delta(x) \, dx = 1 Note that this function is even, δ(x)=δ(−x)\delta(x) = \delta(-x) therefore when using the Fourier series to approximate it we will not use sines, and only cosines. Therefore, if we approximate the delta function between −π-\pi and π\pi, we have: δ(x)=∑n=0∞ancos⁡nx\delta(x) = \sum^\infty_{n=0} a_n \cos nx We also have the previously derived formula for a0a_0 a0=12π∫−ππδ(x)dxa_0 = \frac{1}{2 \pi}\int^\pi_{-\pi}\delta(x)dx We also know from the earlier given property that the integral of the delta function is always equal to one. Therefore: a0=12πa_0 = \frac{1}{2\pi} Now let us also evaluate aka_k. ak=1π∫−ππδ(x)cos⁡(kx)dxa_k = \frac{1}{\pi}\int^\pi_{-\pi} \delta(x)\cos(kx)dx We can again use the previously named property. Furthermore, we must remember that the delta function returns 0 at all values except x = 0, therefore it isn’t really necessary for us to evaluate the integral as the multiplication will go to zero at all points except x = 0. In other words - in the multiplication, x = 0 is the only point which is interesting enough to consider. This point is very convenient as cos(0) = 1. Therefore, ak=1πa_k = \frac{1}{\pi} This formula for the constant tells us something amazing and very specific to the Dirac delta function - the constants remain constant regardless of kk. All the frequencies are the same. Normally, we would see a decay in values a aka_k, however, the singular delta function has constant coefficients throughout. The Fourier series for the Dirac delta function is therefore: δ(x)=12π+1π(∑n=1∞cos⁡nx)\delta(x) = \frac{1}{2\pi} + \frac{1}{\pi}(\sum^\infty_{n=1}\cos nx)

Complex Fourier exponential series

It is important for the sake of the Fourier transform which follows, that our series can be rewritten in terms of only a complex coefficient cnc_n. We can do this because, if we have the set of complex exponentials einxe^{inx} where n∈ℤn \in \mathbb{Z}, we can say that these represent the base of the sine and cosine functions, where nn is the frequency of the wave. This is encapsulated by Euler’s formula that eix=cos⁡x+isin⁡x.e^{ix} = \cos x + i\sin x. Euler’s formula is a beautiful mathematical identity that relates the exponential function, sine function, and cosine function in a single equation:

eiθ=cos⁡(θ)+isin⁡(θ)e^{i\theta} = \cos(\theta) + i\sin(\theta)

This formula is quite elegant because it combines these fundamental mathematical functions in a concise and profound way. This formula is derived using power series expansions. It can be shown that the exponential function exe^x can be represented as a power series:

ex=1+x+x22!+x33!+x44!+⋯e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots

Furthermore, the sine function can also be represented as a power series:

sin⁡(x)=x−x33!+x55!−x77!+⋯\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots

Similarly, the cosine function can be represented as a power series:

cos⁡(x)=1−x22!+x44!−x66!+⋯\cos(x) = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots

Now, let’s consider the expression eixe^{ix}:

eix=1+ix+(ix)22!+(ix)33!+(ix)44!+⋯e^{ix} = 1 + ix + \frac{(ix)^2}{2!} + \frac{(ix)^3}{3!} + \frac{(ix)^4}{4!} + \cdots

Simplify each term:

eix=1+ix−x22!−ix33!+x44!+ix55!−⋯e^{ix} = 1 + ix - \frac{x^2}{2!} - i\frac{x^3}{3!} + \frac{x^4}{4!} + i\frac{x^5}{5!} - \cdots

Now, let’s group the real and imaginary parts:

eix=(1−x22!+x44!−⋯)+i(x−x33!+x55!−⋯)e^{ix} = (1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \cdots) + i(x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots)

Notice now that the real part is exactly the power series expansion of cos⁡(x)\cos(x), and the imaginary part is exactly the power series expansion of sin⁡(x)\sin(x). Thus, we have:

eix=cos⁡(x)+isin⁡(x)e^{ix} = \cos(x) + i\sin(x) This formula can be made even more beautiful if we let x=πx = \pi, yielding eiπ+1=0e^{i\pi} + 1 = 0 which beautifully combines all the fundamental mathematical constants. Euler’s formula neatly represents the link between the exponential and sinusoidal functions, showing that we can rewrite our approimation in terms of just a complex coefficient cnc_n and the exponential function. Therefore, we can approximate f(x)f(x) as f(x)=∑n=−∞∞cneinx,f(x) = \sum^{\infty}_{n=-\infty} c_n e^{inx}, Furthermore, einxe^{inx} shares a similar orthogonality principle with the sinusoidal functions. This can be shown by evaluating ⟨einxe−ikx=∫−ππeinxe−ikx\langle e^{inx}e^{-ikx} = \int^\pi_{-\pi}e^{inx}e^{-ikx} To solvce this, we can use Euler’s formula, derived earlier by the power series. We express einxe^{inx} and e−ikxe^{-ikx} by Euler’s formula:

einx=cos⁡(nx)+isin⁡(nx)e^{inx} = \cos(nx) + i\sin(nx)

e−ikx=cos⁡(kx)−isin⁡(kx)e^{-ikx} = \cos(kx) - i\sin(kx)

Substituting these expressions into the integral, we get:

∫−ππ(cos⁡(nx)+isin⁡(nx))(cos⁡(kx)−isin⁡(kx))dx\int_{-\pi}^{\pi} (\cos(nx) + i\sin(nx))(\cos(kx) - i\sin(kx)) \, dx

Expanding this expression, we get:

∫−ππcos⁡(nx)cos⁡(kx)dx−i∫−ππsin⁡(nx)cos⁡(kx)dx+i∫−ππcos⁡(nx)sin⁡(kx)dx+∫−ππsin⁡(nx)sin⁡(kx)dx\begin{align*} &\int_{-\pi}^{\pi} \cos(nx)\cos(kx) \, dx - i\int_{-\pi}^{\pi} \sin(nx)\cos(kx) \, dx \\ &\quad + i\int_{-\pi}^{\pi} \cos(nx)\sin(kx) \, dx + \int_{-\pi}^{\pi} \sin(nx)\sin(kx) \, dx \end{align*}

Now, since cos\cos is an even function and sin\sin is an odd function, the integrals involving products of cos\cos and sin\sin over a symmetric interval like [−π,π][-\pi, \pi] will all evaluate to zero. So we are left with:

∫−ππcos⁡(nx)cos⁡(kx)dx+∫−ππsin⁡(nx)sin⁡(kx)dx\int_{-\pi}^{\pi} \cos(nx)\cos(kx) \, dx + \int_{-\pi}^{\pi} \sin(nx)\sin(kx) \, dx

Using the orthogonality property of sine and cosine functions, which states that:

∫−ππcos⁡(mx)cos⁡(nx)dx={πif m=n0if m≠n\int_{-\pi}^{\pi} \cos(mx)\cos(nx) \, dx = \begin{cases} \pi & \text{if } m = n \\ 0 & \text{if } m \neq n \end{cases}

and similarly for sin\sin, we can evaluate the remaining integrals:

∫−ππcos⁡(nx)cos⁡(kx)dx={πif n=k0if n≠k\int_{-\pi}^{\pi} \cos(nx)\cos(kx) \, dx = \begin{cases} \pi & \text{if } n = k \\ 0 & \text{if } n \neq k \end{cases}

∫−ππsin⁡(nx)sin⁡(kx)dx={πif n=k0if n≠k\int_{-\pi}^{\pi} \sin(nx)\sin(kx) \, dx = \begin{cases} \pi & \text{if } n = k \\ 0 & \text{if } n \neq k \end{cases}

So, the integral becomes:

π(δnk+δnk)={2πif n=k0if n≠k\pi(\delta_{nk} + \delta_{nk}) = \begin{cases} 2\pi & \text{if } n = k \\ 0 & \text{if } n \neq k \end{cases}

where δnk\delta_{nk} is the Kronecker delta, defined as:

δnk={1if n=k0if n≠k\delta_{nk} = \begin{cases} 1 & \text{if } n = k \\ 0 & \text{if } n \neq k \end{cases}

Therefore,

∫−ππeinxe−ikxdx={2πif n=k0if n≠k\int_{-\pi}^{\pi} e^{inx}e^{-ikx} \, dx = \begin{cases} 2\pi & \text{if } n = k \\ 0 & \text{if } n \neq k \end{cases} Demonstrating that, similar to the sinusoidal functions, the exponential functions are orthogonal by the dot product with different weights nn and kk for n≠kn \neq k, whereas for n=kn = k, the dot product returns 0. Using this, we can derive the complex coefficient cnc_n, by multiplying the equation by e−ikxe^{-ikx} and integrating over the closed interval [−π,π][-\pi, \pi] to yield ∫−ππf(x)e−ikxdx=∫−ππ(∑−∞∞cneinx)e−ikxdx\int^\pi_{-\pi} f(x) e^{-ikx}\, dx = \int^\pi_{-\pi} (\sum^\infty_{-\infty} c_n e^{inx})e^{-ikx}\,dx =∑−∞∞cn∫−ππeinxe−ikxdx= \sum^\infty_{-\infty} c_n \int^\pi_{-\pi} e^{inx}e^{-ikx}\, dx Therefore, for all n≠kn \neq k the integral is 0. When n=kn = k, it simplifies to 2π2\pi, therefore we can write that ∫−ππf(x)e−ikxdx=2πck\int^\pi_{-\pi} f(x) e^{-ikx}\, dx = 2\pi c_k From this, we can say that ck=12π∫−ππf(x)e−ikxdxc_k = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) e^{-ikx} \, dx We can therefore write the complex exponential form of the Fourier series as f(x)=∑−∞∞12π∫−ππf(x)e−inxdxeinxf(x) = \sum^\infty_{-\infty}\frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) e^{-inx} \, dx \,e^{inx}

Fourier Transform

We will use the complex form of the Fourier series, which I wrote to be f(x)=∑−∞∞12π∫−ππf(x)e−inxdxeinxf(x) = \sum^\infty_{-\infty}\frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) e^{-inx} \, dx \,e^{inx} If we extrapolate from the sinusoidal functions with base period π\pi into an arbitrary (must satisfy all the Dirichlet conditions except that of periodicity) function f(x)f(x) of period LL, the whole formula can be rewritten in terms of the period L as: f(x)=∑n=−∞∞cneinxπLf(x) = \sum^{\infty}_{n=-\infty} c_n e^{\frac{inx\pi}{L}} If we let cn=12L∫−LLf(x)e−inπxLdxc_n = \frac{1}{2L}\int^L_{-L} f(x) e^{\frac{-in\pi x}{L}}dx where L is the interval on which we set the function. Now, in order to be able to take the Fourier transform, we want to know what happens when we take the limit limL→∞∑n=−∞∞cneinxπL.\lim_{L \to \infty} \sum^{\infty}_{n=-\infty} c_n e^{\frac{inx\pi}{L}}. This means we no longer will be considering a fixed period, but the entire real numbers. We can try to make the equations slightly less convoluted by defining kn=πnLk_n = \frac{\pi n}{L} It is important to note that when we summate these knk_ns over the ends of the function (being + and - infinity) what we are essentially doing is creating a grid in the xx axis with interval Δk=πL\Delta k = \frac{\pi}{L} We define function F(a)=∫−LLf(x)eiaxF(a) = \int^L_{-L} f(x) e^{ia x} Using this, we can rewrite our complex coefficient cnc_n to be cn=12LF(kn)c_n = \frac{1}{2L}F(k_n) Therefore, the Fourier exponential series with cnc_n becomes: f(x)=∑n=−∞∞F(kn)2Leiknxf(x) = \sum^{\infty}_{n=-\infty} \frac{F(k_n)}{2L} e^{ik_nx} Notice, however, that 12L=Δk2π\frac{1}{2L} = \frac{\Delta k}{2\pi}. Therefore: f(x)=∑n=−∞∞12πF(kn)eiknxΔk,f(x) = \sum^{\infty}_{n=-\infty} \frac{1}{2\pi}F(k_n) e^{ik_nx} \Delta k, which is a much more aesthetic (and for our purposes useful) form. Recall that a Riemann sum approximates the integral of a function ∫abf(x)\int^b_af(x) as the areas of a set of rectangles of equal width under a curve as the number of rectangles tends to infinity (or conversely the width of the rectangles tends to 0). It is written as: ∑i=1nf(xi*)Δx\sum_{i=1}^{n} f(x_i^*) \Delta x

where Δx\Delta x is the width of each subinterval, and f(xi*)f(x_i^*) represents the value of the function at a particular point xi*x_i^* within each subinterval (this can be done in terms of left endpoint, right endpoint and centrepoint sums, being in what way the rectangle is aligned with the curve, however for our purposes we deal only with the left endpoint Riemann sum). The similarity between our summation and the Riemann sum should now become visible - consider what happens as L approaches infinity in our previous summation: f(x)=∑n=−∞∞12πF(kn)eiknxΔk.f(x) = \sum^{\infty}_{n=-\infty} \frac{1}{2\pi}F(k_n) e^{ik_nx} \Delta k. We know that knk_n will go to zero. Therefore, eiknxe^{ik_nx} will go to 1. Recall the grid image I described earlier - as Δk\Delta k goes to 0, the grid will become infinitely dense. We can take out the 12π\frac{1}{2\pi} to yield f(x)=12π∑n=−∞∞F(kn)eiknxΔk.f(x) = \frac{1}{2\pi}\sum ^{\infty}_{n=-\infty} F(k_n) e^{ik_nx} \Delta k. Now, if Δk\Delta k goes to zero (which it does), the Riemann sum can be made equivalent to the integral by saying that f(x)=L→∞12π∫−∞∞F(k)eikxdkf(x) =_{L \to \infty} \frac{1}{2\pi}\int ^{\infty}_{-\infty} F(k)e^{ikx} \, dk for F(k)=∫−∞∞f(x)eikxdxF(k) = \int^{\infty}_{-\infty} f(x) e^{ikx} \, dx Which extends the Fourier series across the entire real number line.

Chebyshev Approximation

A method of approximation came to the great Russian mathematician P. L. Chebyshev whilst he was working on the problem of linkages, specifically relating to translating the linear motion of steam engines to the circular motion of wheels. Linkages are devices composed of rigid bodies (called links) connected by joints or pivots. The problem of linkages more generally is that of converting any geometry of motion into any other geometry, which must not necessarily be linear. The problem is still greatly applicable today, examples of its application being in robotics, prosthetics and linkage based engines (which is the problem Chebyshev was working on), and research is still in progress, examples of papers including https://doi.org/10.48550/arXiv.1312.1060 (An algebraic study of linkages with helical joints, Abban et al., 2024) and https://doi.org/10.48550/arXiv.2307.13839 (Geometry of integrable linkages, Perline and Tabachnikov, 2023). Chebyshev is often called the father of Russian mathematics, a claim which is particularly backed up by his founding of the St. Petersburg Mathematical School, kickstarting Russian mathematics.

Pascal’s triangle and Chebyshev polynomials

Pascal’s triangle is formed by beginning with 1 at the top, and summing each number with the number next to it (imagining the triangle is in a space of infinite zeroes) forming the triangular array of the binomial coefficients arising in probability theory, combinatorics, and algebra. The beginning of the triangle is shown above as Figure 1.2. Pascal’s triangle is intrinsically linked to the Fibonacci numbers, a sequence defined inductively as: F0=0,F1=1F_0 = 0, \quad F_1 = 1 Fn=Fn−1+Fn−2,for n>1F_n = F_{n-1} + F_{n-2}, \quad \text{for } n > 1 and with the first few terms being: 0,1,1,2,3,5,…0, 1, 1, 2, 3, 5, \ldots

Reconstructed Pascal triangle with Fibonacci diagonal sumsDiagram reconstructed for this web edition; original image not supplied.
Pascal’s Triangle’s forming the Fibonacci numbers.

Figure 1.2 also shows red lines, travelling in a northeast pattern and each time travelling down one place and to the right two from the previous index of the numbers. The numbers on the red line are then summated, resulting in the Fibonacci sequence. From these lines, we find the coefficients of an interesting set of polynomials: the Fibonacci polynomials. These are polynomials which use the same recursion as the Fibonacci numbers, and add a variable. They are defined as: Fn(x)={0if n=01if n=1xFn−1(x)+Fn−2(x)if n≥2F_n(x) = \begin{cases} 0 & \text{if } n = 0 \\ 1 & \text{if } n = 1 \\ xF_{n-1}(x) + F_{n-2}(x) & \text{if } n \geq 2 \end{cases} We can therefore write out the first few Fibonacci polynomials as: F0(x)=0F1(x)=1F2(x)=xF3(x)=x2+1F4(x)=x3+2xF5(x)=x4+3x2+1F6(x)=x5+4x3+3x\begin{align*} F_0(x) &= 0 \\ F_1(x) &= 1 \\ F_2(x) &= x \\ F_3(x) &= x^2 + 1 \\ F_4(x) &= x^3 + 2x \\ F_5(x) &= x^4 + 3x^2 + 1 \\ F_6(x) &= x^5 + 4x^3 + 3x \\ \end{align*} Notice that the coefficients of the nthn^{th} Fibonacci polynomial are simply the numbers along the nthn^{th} red line. We can play around with Pascal’s triangle by changing the signs in every second diagonal. 11−11−211−33−11−46−411−510−105−11−615−2015−611−721−3535−217−1\begin{array}{ccccccccccccccc} & & & & & & & 1 & & & & & & & \\ & & & & & & 1 & & -1 & & & & & & \\ & & & & & 1 & & -2 & & 1 & & & & & \\ & & & & 1 & & -3 & & 3 & & -1 & & & & \\ & & & 1 & & -4 & & 6 & & -4 & & 1 & & & \\ & & 1 & & -5 & & 10 & & -10 & & 5 & & -1 & & \\ & 1 & & -6 & & 15 & & -20 & & 15 & & -6 & & 1 & \\ 1 & & -7 & & 21 & & -35 & & 35 & & -21 & & 7 & & -1 \\ \end{array}

From this, we can form a new set of polynomials: the Chebyshev polynomials of the second kind. These are formed in a very similar way as we formed the Fibonacci polynomials: Un(x)={0if n=01if n=1xUn−1(x)−Un−2(x)if n≥2U_n(x) = \begin{cases} 0 & \text{if } n = 0 \\ 1 & \text{if } n = 1 \\ xU_{n-1}(x) - U_{n-2}(x) & \text{if } n \geq 2 \end{cases} this definition being identical to the one of Fibonacci polynomials, save that we changed the sign from a + to a - in the expression xUn−1(x)−Un−2(x)xU_{n-1}(x) - U_{n-2}(x). As well as the Chebyshev polynomials of the second kind, Chebyshev also introduced the Chebyshev polynomials of the first kind, which are the polynomials which uniquely satisfy conditions Tn(x)={cos⁡(narccos⁡x) if |x|≤1cosh⁡(narcosh⁡x) if x≥1(−1)ncosh⁡(narcosh⁡(−x)) if x≤−1{\displaystyle T_{n}(x)={\begin{cases}\cos(n\arccos x)&{\text{ if }}~|x|\leq 1\\\cosh(n\operatorname {arcosh} x)&{\text{ if }}~x\geq 1\\(-1)^{n}\cosh(n\operatorname {arcosh} (-x))&{\text{ if }}~x\leq -1\end{cases}}} The Chebyshev,polynomials of the first kind are also highly useful for approximation, but we will focus here on the second kind. Here the coefficient operate in the same way, being the same diagonal lines on the triangle as formed before (unfortunately LaTeX does not allow me to format the lines on a non-figure). Given this method of computing them, we can consider the first few Chebyshev polynomials and their graph below: U0(x)=1U1(x)=xU2(x)=2x2−1U3(x)=4x3−3xU4(x)=8x4−8x2+1\begin{align*} U_0(x) &= 1 \\ U_1(x) &= x \\ U_2(x) &= 2x^2 - 1 \\ U_3(x) &= 4x^3 - 3x \\ U_4(x) &= 8x^4 - 8x^2 + 1 \\ \end{align*}

The six polynomials plotted in the original

This graph is neat (a lot more so than that of the Fibonacci polynomials), and shows one of the fundamental properties of the Chebyshev polynomials, which will be of use to us later: they have very neat and roots.

Using the Chebyshev polynomials for approximation

These Chebyshev polynomials are extremely useful for approximation. This section will concern itself only with the Chebyshev polynomials of the second kind. What is important about them is that they minimize oscillations that can occur at the edges of the interval when using polynomial approximations. This is why, when Chebyshev polynomials are used for approximations, they are commonly only used between the interval [-1, 1]. The reason that the interval [-1, 1] is perfect for the use of Chebyshev polynomials is because Chebyshev polynomials Un(x)U_n(x) have exactly nn real roots evenly (due to the symmmetry of Un(x)U_n(x) about the origin) spaced out (as is visible in the graph above). Therefore, on the interval [-1, 1], function f(x)f(x) can be represented as f(x)=∑k=0∞akUk(x)f(x) = \sum^{\infty}_{k=0} a_k U_k(x) Similarly as in the previous section on Fourier analysis, we need to derive aka_k. We will again, as in the section on Fourier analysis, need to exploit the property of orthogonality. Recall that two functions are orthogonal if ∫−LLf(x)g(x)w(x)dx=0\int^L_{-L}f(x)g(x)w(x) \, dx= 0 and we let w(x)w(x) be the weight function (which we have previously just kept as 1). Now consider whether this is true in the case of the Chebyshev polynomials. Consider ⟨Um(x)Un(x)⟩=∫−11Um(x)Un(x)\langle U_m(x)U_n(x)\rangle= \int^1_{-1} U_m(x)U_n(x) The Chebyshev polynomials are constructed in such a way that they are orthogonal with respect to weight function w(x)=11−x2w(x) = \frac{1}{\sqrt{1-x^2}} over the interval [−1,1][-1, 1]. Therefore, we can write that:

∫−11Um(x)Un(x)1−x2=0,m≠n\int^1_{-1} \frac{U_m(x)U_n(x)}{1 - x^2} = 0, m \neq n And for m=nm=n, ⟨Um(x)Un(x)⟩=∫−11Um2(x),\langle U_m(x)U_n(x)\rangle = \int^1_{-1}U^2_m(x), which yields (with respect to w(x)w(x)): ⟨Um,Un⟩=∫−11Um(x)Un(x)={0if m≠nπif m=n≠0π/2if m=n=0\langle U_m, U_n \rangle = \int^1_{-1} U_m(x)U_n(x) = \begin{cases} 0 & \text{if } m \neq n \\ \pi & \text{if } m = n \neq 0 \\ \pi/2 & \text{if } m = n = 0 \end{cases} Having now demonstrated that the Chebyshev polynomials are orthogonal, we can now levy this property by multiplying our previous expression by another Chebyshev polynomial UmU_m. Therefore f(x)Um(x)=(∑k=0∞akUk(x)(x))Um(x)f(x)U_m(x) = (\sum^{\infty}_{k=0}a_kU_k(x)(x))U_m(x) We can integrate over [-1, 1] so that ∫−11f(x)Um(x)dx=∫−11(∑k=0∞akUk(x)(x))Um(x)dx\int^{1}_{-1}f(x)U_m(x)\, dx = \int^1_{-1}(\sum^{\infty}_{k=0}a_kU_k(x)(x))U_m(x) \, dx Since we have discovered the behaviour of the integral of the multiple of two Chebyshev polynomials, we can say that the integral is 0, except when m=km = k, ∫−11f(x)Uk(x)(x)dx=ak∫−11Um2(x)dx\int^1_{-1}f(x)U_k(x)(x)\, dx = a_k \int^1_{-1}U^2_m(x)\,dx Since we know that ∫−11Uk(x)2(x)={πif m=n≠0π/2if m=n=0\int^1_{-1} U_k(x)^2(x)= \begin{cases}\pi & \text{if } m = n \neq 0 \\ \pi/2 & \text{if } m = n = 0 \end{cases} we can say that ∫−11f(x)Ukx)dx={πakif k≠0π/2akif k=0.\int_{-1}^{1} f(x) U_kx) \, dx = \begin{cases} \pi a_k & \text{if } k \neq 0 \\ \pi/2 a_k & \text{if } k = 0 \end{cases}. Therefore, we divide by the respective constant to yield: ak=1π∫−11f(x)Uk(x)(x)dx,k≠0a_k= \frac{1}{\pi} \int_{-1}^{1} f(x)U_k(x)(x) \, dx, k \neq 0 And a0=12∫−11f(x)dxa_0 = \frac{1}{2} \int_{-1}^{1} f(x) \, dx Note that we need to multiply these constants by the weight function w(x)=11−x2w(x) = \frac{1}{\sqrt{1-x^2}} discussed earlier, in order to ensure the integral of the inner product can be correctly calculated with the orthogonality. Therefore: ak=2π∫−11f(x)Uk(x)(x)1−x2dx,for k≠0a_k = \frac{2}{\pi} \int_{-1}^{1} \frac{f(x) U_k(x)(x)}{\sqrt{1-x^2}} \, dx, \quad \text{for } k \neq 0 and a0=1π∫−11f(x)1−x2dxa_0 = \frac{1}{\pi} \int_{-1}^{1} \frac{f(x)}{\sqrt{1-x^2}} \, dx

Approximation of π\pi

Mathematics is filled with beautiful and important irrational constants. This chapter will concern itself with just π\pi. π\pi is one of the most fundamental constants in all of mathematics (and I think the only mathematical object to which one of the 365 days of the year is dedicated) - it is the ratio formed by the geometric length of a locus of points equidistant with radius rr from a centrepoint, and the length 2r2r. It is therefore the ratio between the diameter and the circumference of a circle. Hence comes the formula for the circumference c=πd.c = \pi d. This value was first proposed by Archimedes. However, how can we approximate it? How do we know it needs to be approximated and is not just rational?

Hermite’s proof that π\pi is irrational

A key question in the consideration of whether or not a constant can be approximated to complete accuracy is the question of whether or not it is irrational. This question was first considered by Johann Heinrich Lambert in the 1760s, who proved that π\pi is irrational, that is to say it cannot be described by a proper fraction. Lambert demonstrated this (although I will not go into the particulars here) by showing that this continued fraction expansion holds: tan⁡(x)=x1−x23−x25−x27−⋱.\tan(x)=\frac{x}{1-\frac{x^2}{3-\frac{x^2}{5-\frac{x^2}{7-\ddots}}}}.

Then Lambert proved that if xxis non-zero and rational, then this expression must be irrational. However, tan⁡π4=1\tan \frac{\pi}{4} = 1, therefore π4\frac{\pi}{4} is irrational, and so, therefore, is π\pi.

However, in the 19th century Charles Hermite created a much simpler proof, relying only on elementary calculus, such as that taught in the last few years of secondary schools today. Simplicity of ideas used is key in the development of fundamental proofs, and I think that Hermite’s proof demonstrates this beautifully. Hermite’s proof is now the most commonly used and taught proof for π\pi’s irrationality.

Hermite’s proof operates through use of Reductio ad Absurdem, one of the most powerful techniques of proof by contradiction. It’s power was put perfectly by mathematician GH Hardy in his book A Mathematician’s Apology: "a chess player may offer the sacrifice of a pawn or even a piece, but a mathematician offers the game." (many thanks to NA for gifting me said book.) Let us first assume that π\pi can be expressed by a fraction: π=uv\pi = \frac{u}{v} The next step of the proof is to define a sequence. This sequence is very interesting - its terms are as follows: I0=2I1=4v2⋮In=v2nn!∫0πxn(π−x)nsin⁡xdx\begin{align*} I_0 &= 2 \\ I_1 &= 4v^2 \\ &\vdots \\ I_n &= \frac{v^{2n}}{n!}\int_0^\pi x^n(\pi - x)^n\sin x \, dx \end{align*}

I realise that at first, resulting out of such simple terms I0I_0 and I1I_1 we have such an immensely complicated nthn^{th} term InI_n, however the explanation for the formula is remarkably simple, and the resulting consequences are immense. Let us begin by attempting to evaluate the integral ∫0πxn(π−x)nsin⁡xdx\int^\pi_0 x^n(\pi - x)^n\sin x dx. Consider the function f(x,n)=xn(π−x)nsin⁡xf(x, n) = x^n(\pi - x)^n\sin x being integrated, defined over the interval [0, π\pi] with variable positive values for n. The graphs all look relatively similar to this one (where n = 0.5):

Hermite integral: square root of x times pi minus x, times sin(x)

Note the fact that the curve begins at 0, comes up to a maximum value and then goes down to 0 again. Let us now consider the maximum possible value for the function, to get a rough idea for the area of the curve. Since 0≤x≤π0 \leq x \leq \pi we know that the factor xnx^n in the integral cannot be greater than πn\pi^n, achieved when x=πx = \pi. The second term is similarly equal to πn\pi^n, however this is achieved when x=0x = 0. Furthermore, sin⁡x\sin x can be at most 1. Therefore, when we take into account the entire function which is being integrated, we can definitively say that: f(x,n)≤π2nf(x, n) \leq \pi^{2n} Therefore, the maximum value for the function must be below the line y=π2ny = \pi^{2n}. From this we can extend that the area ∫0πxn(π−x)nsin⁡xdx\int^\pi_0 x^n(\pi - x)^n\sin x dx must be less than the area formed by the lines y=π2ny = \pi^{2n} and x=πx = \pi, x=0x = 0 and y=0y = 0. Therefore, 0<In≤(v)2nn!π2nπ0 < I_n \leq \frac{(v)^{2n}}{n!}\pi^{2n}\pi Simplification yields that: 0<In≤(vπ)2nn!π0 < I_n \leq \frac{(v\pi)^{2n}}{n!}\pi We now consider what happens when n→∞n \to \infty. Let us primarily consider the fraction (uπ)2nn!\frac{(u\pi)^{2n}}{n!}, if we let (uπ)2=x(u\pi)^2 = x, we are left with the more general problem - to what value will xnn!\frac{x^n}{n!} tend as n→∞n \to \infty? As we now that factorial growth is greater than exponential growth, it is demonstrated that it will, in fact converge to 0. Therefore, it follows that sequence I0,I1,I2,...IN→0.I_0, I_1, I_2, ... I_N \to 0. This is a fundamental step in the proof that π\pi is irrational. Recall that we begun with the assumption that π\pi can be described as a fraction uv\frac{u}{v}, where uu and vv are positive integers. We have now demonstrated that the sequence I0,I1,I2,...INI_0, I_1, I_2, ... I_N converges to 0, if we can prove that this sequence is also made up of only positive integers based on the assumption that uu and vv are positive integers, we will have an absurdity - positive integers cannot converge to 0! Therefore we will have proved that uu and vv cannot be positive integers, proving that π\pi is irrational. In order to establish the fact that all integers in II are positive integers, we need to create a recurrence relation for InI_n, based on In−1I_{n-1} and In−2I_{n-2}.

The proof that all values of the sequence lies in a way of rewriting this sequence as an inductive sequence. Earlier, I stated the first to values of the sequence I as I0=2I_0 = 2 and I1=4v2I_1 = 4v^2

Let me quickly demonstrate that these are true. The first is just the result of the simple and easy to evaluate integral I0=∫0πsin⁡xdx=2,I_0 = \int^\pi_0 \sin x dx = 2, The second term is slightly more difficult to derive, it comes from the integral I1=v2∫0πx(π−x)sin⁡xdx.I_1 = v^2 \int^\pi_0 x(\pi - x) \sin x dx. This simplifies to I1=v2π∫0πxsin⁡xdx−v2∫0πx2sin⁡xdxI_1 = v^2 \pi \int^\pi_0 x \sin x dx - v^2\int^\pi_0 x^2 \sin x dx This simplified integral simplifies to two much simpler, standard integrals for integration by parts, which simplifies the integral further to I1=v2π2−v2π2+4v2,I_1 = v^2\pi^2 - v^2\pi^2 + 4v^2, which simplifies to I1=4v2.I_1 = 4v^2.

Now we have fully established the starting values of the sequence, let us again use integration by parts to establish a recurrence relation. Let us evaluate the integral on a specific case in the sequence, namely that for I5I_5. Consider the integral ∫0πx5(π−x)5sin⁡xdx\int_0^\pi x^5(\pi - x)^5\sin xdx We can simplify this to: ∫0π5(π−2x)x4(π−x)4cos⁡xdx\int_0^\pi 5(\pi - 2x)x^4(\pi - x)^4\cos x \, dx Note the interesting property that the formula looks very similar to what we established as the nth term, only the exponents are down by one, sine is replaced with cosine and we have some extra terms at the start. Let us now integrate by parts again, resulting in ∫0π(10x4(π−x)4−20(π2−4πx+4x2)x3(π−x)3)sin⁡xdx\int_0^\pi (10x^4(\pi - x)^4 - 20(\pi^2 - 4\pi x + 4x^2)x^3(\pi - x)^3)\sin x\,dx Some basic algebra simplifies this to ∫0π−20π2x3(π−x)3+90x4(π−x)4\int_0^\pi -20 \pi^2x^3(\pi - x)^3 + 90x^4(\pi - x)^4 This presents important progress, because the above expression can be split into two separate integrals, resulting in −20π2∫0πx3(π−x)3sin⁡xdx+90∫0πx4(π−x)4sin⁡xdx-20 \pi^2\int^\pi_0 x^3 (\pi - x)^3 \sin x \, dx + 90\int^\pi_0 x^4(\pi - x)^4 \sin x \, dx

This looks quite neatly simplified so far, so let’s now input it into our general formula for I5I_5: I5=−v105!20π2∫0πx3(π−x)3sin⁡xdx+v105!90∫0πx4(π−x)4sin⁡xdxI_5 = -\frac{v^{10}}{5!}20 \pi^2\int^\pi_0 x^3 (\pi - x)^3 \sin x \, dx + \frac{v^{10}}{5!}90\int^\pi_0 x^4(\pi - x)^4 \sin x \, dx This gives us one final step of simplification, resulting in I5=−u4π2v63!∫0πx3(π−x)3sin⁡xdx+2v29v84!∫0πx4(π−x)4sin⁡xdx.I_5 = -u^4 \pi^2 \frac{v^6}{3!}\int^\pi_0 x^3(\pi - x)^3\sin x \, dx + 2v^2 9 \frac{v^8}{4!}\int^\pi_0 x^4 (\pi - x)^4 \sin x \, dx. This results in our proof. We can now simply replace v63!∫0πx3(π−x)3sin⁡x\frac{v^6}{3!}\int^\pi_0 x^3(\pi - x)^3\sin x with I3I_3, and v84!∫0πx4(π−x)4sin⁡xdx\frac{v^8}{4!}\int^\pi_0 x^4 (\pi - x)^4 \sin x \, dx with I4I_4. Off the back of this, we can build an inductive sequence, I5=18v2I4−v4π2I3.I_5 = 18v^2 I_4 - v^4\pi^2I_3. We can now make use of our assumption that pi is rational: I5=18v2I4−v2u2I3I_5 = 18v^2 I_4 - v^2u^2I_3 Also note that 18=2(2⋅5⋅−1)18 = 2(2 \cdot 5 \cdot - 1). If we wanted to generalise this, we could write that In=2v2(2n−1)In−1−v2u2In−2I_n = 2v^2(2n - 1)I_{n-1} - v^2u^2I_{n-2} Note that this does not prove the relation for all nn. In order to prove this for all nn, we can begin by considering the sequences of real functions: A0(x)=sin⁡(x),An+1(x)=∫0xyAn(y)dyU0(x)=sin⁡(x)x,Un+1(x)=−Un′(x)x\begin{aligned}A_{0}(x)&=\sin(x),&&A_{n+1}(x)=\int _{0}^{x}yA_{n}(y)\,dy\\[4pt]U_{0}(x)&={\frac {\sin(x)}{x}},&&U_{n+1}(x)=-{\frac {U_{n}'(x)}{x}}\end{aligned}

We can inductively prove that these functions can be represented as infinite series, such that An(x)=x2n+1(2n+1)!!−x2n+32×(2n+3)!!+x2n+52×4×(2n+5)!!∓⋯Un(x)=1(2n+1)!!−x22×(2n+3)!!+x42×4×(2n+5)!!∓⋯{\displaystyle {\begin{aligned}A_{n}(x)&={\frac {x^{2n+1}}{(2n+1)!!}}-{\frac {x^{2n+3}}{2\times (2n+3)!!}}+{\frac {x^{2n+5}}{2\times 4\times (2n+5)!!}}\mp \cdots \\[4pt]U_{n}(x)&={\frac {1}{(2n+1)!!}}-{\frac {x^{2}}{2\times (2n+3)!!}}+{\frac {x^{4}}{2\times 4\times (2n+5)!!}}\mp \cdots \end{aligned}}} and therefore that Un(x)=An(x)x2n+1.U_{n}(x)={\frac {A_{n}(x)}{x^{2n+1}}}.\, From this, we can say that (using the quotient rule for differentiation) An+1(x)x2n+3=Un+1(x)=−Un′(x)x=−1xddx(An(x)x2n+1)=−1x(An′(x)⋅x2n+1−(2n+1)x2nAn(x)x2(2n+1))=(2n+1)An(x)−xAn′(x)x2n+3{\displaystyle {\begin{aligned}{\frac {A_{n+1}(x)}{x^{2n+3}}}&=U_{n+1}(x)=-{\frac {U_{n}'(x)}{x}}=-{\frac {1}{x}}{\frac {\mathrm {d} }{\mathrm {d} x}}\left({\frac {A_{n}(x)}{x^{2n+1}}}\right)\\[6pt]&=-{\frac {1}{x}}\left({\frac {A_{n}'(x)\cdot x^{2n+1}-(2n+1)x^{2n}A_{n}(x)}{x^{2(2n+1)}}}\right)\\[6pt]&={\frac {(2n+1)A_{n}(x)-xA_{n}'(x)}{x^{2n+3}}}\end{aligned}}} This is equivalent to saying that An+1(x)=(2n+1)An(x)−x2An−1(x).{\displaystyle A_{n+1}(x)=(2n+1)A_{n}(x)-x^{2}A_{n-1}(x).\,} Notice an inherent similarity between this recurrence relation and the one which was demonstrated for I5I_5 - the final step in the proof is the idea that we can demonstrate that AnA_n and InI_n are essentially the same function.

Therefore, given that base cases for the induction I0I_0 and I1I_1 are both integers, given further that the formula given for InI_n does not in any way change an input from integer form, we can safely say that any value in the sequence In∈ℤI_n \in \mathbb{Z}, resting on the assumption that π\pi can be expressed as a rational fraction uv\frac{u}{v}. However, we have also demonstrated that as n approaches infinity, InI_n approaches 0. Integers cannot approach 0, as the closest they can be to 0 is 1. Therefore, we have demonstrated that our assumption that π\pi can be displayed as a rational fraction leads to an absurdity. Therefore, π\pi is irrational.

Archimedes’ approximations

Archimedes was working with circles when he first discovered a constant π\pi, which was to be the ratio between the diameter of a circle and its circumference. Therefore, Archimedes equated that π=cd\pi = \frac{c}{d}. Consider first a square, with diameter d and perimeter 4d4d. Therefore, if we take the ratio between the circumference and the diameter, we can say that, as a circle with same diameter can be fit inside a square, π<4\pi < 4 Now consider a regular hexagon, constructed in such a way that from each side to the centrepoint an equilateral triangle is formed. Therefore, if we let the sidelength of one of the equilateral triangles be nn, we know that the diameter of the hexagon is 2n2n and its perimeter 6n6n. Therefore, the ratio between the perimeter and diameter of this hexagon is 3. However, a circle with the same diameter as a hexagon can only be fit on the outside of the hexagon, therefore: 3<π<43 < \pi < 4 We have now reduced the possible values for π\pi from the infinite set of real numbers to the infinite set of real numbers between 3 and 4, which represents progress nonetheless. However, Archimedes approximated π\pi even closer to its real value.

He did this by imagining a circle with diameter 1. He also knew that the circumference of this circle is π\pi. In our previous approximation, we used a hexago n and a square to approximate that π\pi is between 3 and 4. Consider what would happen if we replaced the square with a hexagon, thus having a hexagon circumscribed about a circle, as well as a circle circumscribed about a hexagon. We can divide the hexagon into equilateral triangles, each of sidelength the same as that of the hexagon. Therefore, using our previous numerical example, each edge of the inner hexagon is 0.5, therefore the inner perimeter is 3. On the outer triangle, we can do the same thing, however instead of knowing the sidelength of the triangle, we only know its height to be 0.5. We can split the triangle in half, resulting in a 30 60 90 triangle, which has the property that the ratio between the sides is 3\sqrt{3}. Therefore, the total outside perimeter is 63\frac{6}{\sqrt{3}}. We can therefore say that 3<π<3.4613 < \pi < 3.461 This gives us one method to approximate pi - we need a method to calculate the perimeter of a polygon with an arbitrary number of sides. To do this, we can use some basic trigonometry, however we must ensure not to use any results which already contain π\pi so as not to base our approximation on knowledge Archimedes would not have had. Let the perimeter of the circumscribed polygon be PnP_n and the perimeter of the inscribed polygon be pnp_n. Consider again a circle, with centre O of radius 0.5. Consider furthermore, a point A on the circumference of the circle, which is also the midpoint of a side of the polygon, and a point B on the edge between the same side of the circumscribed polygon as A, and the adjacent side. Let angle AôB be xx. Therefore, by the basic trigonometric ratios in which Archimedes would have been versed,

AB=tan⁡x2.AB = \frac{\tan x}{2}. Furthermore, we can say that x=180nx = \frac{180}{n} And that therefore the perimeter of the n-agon is simply P=ntan⁡(180n)P = n \tan(\frac{180}{n}) We can follow a similar procedure with the inscribed polygon: let O be the centre of the circle, B the midpoint of one of the sides of the polygon, and A the vertex between the side on which A lies and an adjacent side. Therefore, we can again say that AB=sin⁡(x)2AB = \frac{\sin(x)}{2} and furthermore that P=nsin⁡(1802).P = n\sin(\frac{180}{2}). This is the formula Archimedes used to show that:

31071<π<317\frac{310}{71} < \pi < \frac{31}{7}

Ramanujan, Leibniz and Gregory’s approximation

Ramanujan was the son of a clerk in India, and despite not having had any training in mathematics, he came to publish some of the most important results in modern mathematics. Ramanujan was invited to Cambridge by G.H. Hardy, and it was during his time at Cambridge that he discovered his formula for π\pi. It is worth noting that Ramanujan derived many approximations for π\pi (see the Ramanujan-Sato series or Ramanujan’s modular equation), however I have chosen his series which is based on the arctangent function and adaptations to the Leibniz-Gregory series..

Ramanujan began by considering the arctangent series. This series is generally attributed to the work of James Gregory and Gottfried Leibniz in the 1670s. Consider the derivative of the arctangent function ddxtan⁡−1(x)=11+x2.\frac{d}{dx}\tan^{-1}(x) = \frac{1}{1 + x^2}. Now consider what happens if we take the indefinite integral of both sides ∫11+x2dx=∫ddxtan−1(x)dx\int \frac{1}{1 + x^2} \, dx = \int \frac{d}{dx}tan^{-1}(x) \, dx As the integral of the derivative is simply equal to the original function, tan⁡−1(x)+C=∫11+x2dx\tan^{-1}(x) + C = \int \frac{1}{1 + x^2} \, dx We now use the Taylor series approximation for this function. The Taylor series approximation of a function uses the nthn^{th} derivative of this function at point aa to approximate it around f(a)f(a). The Taylor series expansion of a function f(x)f(x) about a point x=ax=a is given by:

f(x)=f(a)+f′(a)(x−a)+f″(a)2!(x−a)2+f‴(a)3!(x−a)3+⋯f(x) = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \frac{f'''(a)}{3!}(x-a)^3 + \cdots

Alternatively, it can be expressed in sigma notation as:

f(x)=∑n=0∞f(n)(a)n!(x−a)nf(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n If we consider the Taylor series expansion of a function f(x)f(x) about a point x=0x = 0 is given by:

f(x)=∑n=0∞f(n)(0)n!xnf(x) = \sum_{n=0}^\infty \frac{f^{(n)}(0)}{n!} x^n

In this case, f(x)=11+x2f(x) = \frac{1}{1+x^2}. We find the derivatives of f(x)f(x) at x=0x=0 to obtain the coefficients of the series.

f(0)=1,f′(0)=0,f″(0)=−2,f‴(0)=0,f(4)(0)=24,…f(0) = 1, \quad f'(0) = 0, \quad f''(0) = -2, \quad f'''(0) = 0, \quad f^{(4)}(0) = 24, \quad \dots Therefore the Taylor series expansion of 11+x2\frac{1}{1+x^2} about x=0x=0 is:

11+x2=1−x2+x4−x6+x8−…=∑n=0∞(−1)nx2n.\frac{1}{1+x^2} = 1 - x^2 + x^4 - x^6 + x^8 - \dots = \sum_{n=0}^\infty (-1)^n x^{2n}. We can insert this into our original formula: tan⁡−1(x)+C=∫11+x2dx=∫[1−x2+x4−x6+x8−…]dx=∫∑n=0∞(−1)nx2ndx\tan^{-1}(x) + C = \int \frac{1}{1+x^2} \, dx = \int[1 - x^2 + x^4 - x^6 + x^8 - \dots]\, dx = \int \sum_{n=0}^\infty (-1)^n x^{2n} \, dx Let us now evaluate the integral of each term of the series. This results in

tan⁡−1(x)=x−x33+x55−x77+x99−…=∑n=0∞(−1)nx2n+12n+1\tan^{-1}(x)= x - \frac{x^3}{3} + \frac{x^5}{5} - \frac{x^7}{7} + \frac{x^9}{9} - \dots = \sum_{n=0}^\infty (-1)^n \frac{x^{2n+1}}{2n+1}

Consider now the case when x=1x = 1: tan⁡−1(1)=1−133+155−177+199−…=∑n=0∞(−1)n12n+12n+1\tan^{-1}(1) = 1 - \frac{1^3}{3} + \frac{1^5}{5} - \frac{1^7}{7} + \frac{1^9}{9} - \dots = \sum_{n=0}^\infty (-1)^n \frac{1^{2n+1}}{2n+1}

=1−13+15−17+19−…= 1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \dots

Recall that tan⁡−1(1)=π4\tan^{-1}(1) = \frac{\pi}{4} Therefore, we multiply by 4 to obtain an approximation of π\pi:

π≈4(1−13+15−17+19−…)\pi \approx 4 \left(1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \frac{1}{9} - \dots \right)

This series converges slowly, so it may take many terms to get an accurate approximation of π\pi. This was one of the main problems Ramanujan saw with it, this slow convergence is what he sought to improve with his formula for π\pi. Ramanujan began with the formula that has been outlined above, and added a factor of 3\sqrt{3}. Ramanujan then ingeniously added the factor 13n\frac{1}{3^n}. His formula was therefore: π=23∑n=0∞(−1)n(2n+1)3n.\pi = 2\sqrt{3}\sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)3^n}. Ramanujan’s minor changes to the formula make a massive difference. I run a python code and display its results in Table 2.1 to demonstrate this (for clarity the code has been included as Appendix 1 of this chapter). Note how big the differences remain (as a fraction of the individual differences), and that they are always on the same order of magnitude as EsE_s, even when the value becomes

Comparison between errors in truncated Ramanujan and Gregory-Leibniz series approximation for π\pi
Max term ERE_R EsE_s ER−EsE_R - E_s
1 0.0623 0.4749 0.4125
2 0.0145 0.3250 0.3104
3 0.0037 0.2463 0.2426
4 0.0010 0.1980 0.1970
100 8.881784197001252e-16 0.009900747481198291 0.009900747481197403
10710^7 Computer cannot calculate low value 9.999899927226608e-06 Cannot be calculated

Let us now try to understand why adding just these few simple factors has such a great effect. Consider first the addition of the factor 13n\frac{1}{3^n}. As nn increases, the factor exponentially decays as the denominator exponentially grows. This means that, as n approaches infinity, the increments become smaller and smaller, which means that oscillations around the true value are avoided, and the value approaches the true value as quickly as possible. The reason why Ramanujan’s additional factor avoids oscillations touches on the effect created by the the term inside the series (−1)n(-1)^n. This term means that consecutive values of the series cancel each other out, however, if each term is not reduced quickly enough, major oscillations will form around the true value of π\pi. Minimizing the change in increment to a specific value means that the oscillations become succedingly less, as is demonstrated by the figure above. Furthermore multiplying by 13n\frac{1}{3^n} makes the series a geometric series. This is useful, because geometric series are easy to analyze, and it is easier to prove that they converge. Furthermore, describing the series as a geometric series provides a neat geometric interpretation of the terms, which represent lengths of line segments. This interpretation helps visualize the approximation process and understand how the series constructs an approximation of the circumference of a circle, and I will explore it later in this section. However, on a deeper note, I would argue that Ramanujan’s use of a geometric series reflects his mathematical intuition and creativity. By recognizing the series as a geometric progression, he was able to exploit its convergence properties to derive an elegant and efficient approximation for π\pi. In addition to this, Ramanujan added an additional factor of 3\sqrt{3} to the outside of the summation, which scales the series up by scaling each individual term The effect of this is to scale the series neatly up to precisely π\pi. The use of 3\sqrt{3} is interesting, and adds to the mystery surrounding the approximation and much of Ramanujan’s work - Ramanujan was famous for not including proofs or any real explenations for his results (until Hardy forced him to). The inclusion of 3\sqrt{3} adds an elegance through 3\sqrt{3}’s geometric significance - below are just a few examples of its significance:

  1. The ratio of the length of the side of an equilateral triangle to its altitude (the line segment from any vertex perpendicular to the opposite side) is 2:32: \sqrt{3}. This ratio remains constant for all equilateral triangles.

  2. Hexagonal patterns appear frequently in nature due to their efficient use of space. The square root of 3 is intimately related to the geometry of hexagons (which follows from the properties of equilateral triangles, as the shapes are closely linked). For instance, in a regular hexagon, the ratio of the length of a side to the length of the apothem (the distance from the center of the hexagon to the midpoint of a side) is 3\sqrt{3}.

  3. The square root of 3 frequently appears in trigonometric calculations, especially involving the sine and cosine of certain angles. For example, in a 30-60-90 triangle, where one angle is 30 degrees and another is 60 degrees, the sine and cosine of 30 degrees are 12\frac{1}{2} and 32\frac{\sqrt{3}}{2} respectively.

Furthermore, 3\sqrt{3} is irrational. However, it again cannot be denied that really, due to Ramanujan’s way of dreaming up new results, that this amazingly quick convergion of the series adds to the mystique, and beauty, surrounding Ramanujan’s work.

Code to evaluate and compare approximations for π\pi

import math

def ramanujan_series(n):
    pi_estimate = 0
    for i in range(n + 1):
        pi_estimate += ((-1) ** i) / ((2 * i + 1) * 3 ** i)
    pi_estimate *= 2 * math.sqrt(3)
    return pi_estimate

def original_series(n):
    pi_estimate = 0
    for i in range(n + 1):
        pi_estimate += ((-1) ** i) / (2 * i + 1)
    pi_estimate *= 4
    return pi_estimate

def true_pi():
    return math.pi

def calculate_error(n):
    pi_estimate_ramanujan = ramanujan_series(n)
    pi_estimate_original = original_series(n)
    pi_true = true_pi()
    error_ramanujan = abs(pi_estimate_ramanujan - pi_true)
    error_original = abs(pi_estimate_original - pi_true)

    return error_ramanujan, error_original

def main():
    n = int(input("Enter the index for the term in Ramanujan's series: "))
    error_ramanujan, error_original = calculate_error(n)
    print(f"Error using Ramanujan's formula at index {n}: {error_ramanujan}")
    print(f"Error using original formula at index {n}: {error_original}")
    print(f"Difference in errors: {abs(error_ramanujan - error_original)}")

main()

Polynomial interpolation

Introduction

The idea of interpolation follows on from the idea of functional approximation in that our aim is to define a function, as simple as possible, around a set of points, rather than simplify an existing function. In such a way, we can think of approximation as interpolation with infinite, rather than a finite number of points. This section explains interpolation through the lens of finding the nthn^{th} term of an arbitrary sequence.

I define the nthn^{th} term as the function f(n)f(n) that returns, given any integer nn less than or equal to the length of the sequence, the number in the sequence at index nn. There is a function F(s)F(s) which returns f(n)f(n) given any sequence ss. Therefore if: S=(a1,a2,a3,...,an)S = (a_1, a_2, a_3, ..., a_n) we can define F(S)=f(n)F(S) = f(n), and f(n)=anf(n) = a_n. In this paper I explain several methods to return f(n)f(n), culminating in a Python code which, given a sequence of any length, will return its nthn^{th} term. Note however that, given only values of sequence, it is impossible to predict the next term as there are infinite curves which can go through a set of points with infinite possible yy values at the next xx value. This paper however focuses on finding the lowest order polynomial curve which passes through the points.

Interpolation by simultaneous equations

The nthn^{th} term of sequences can be solved for by forming simultaneous equations in the form axn−1+bxn−2+...+cax^{n-1}+ bx^{n-2} + ... + c. Let each value of sequence SS be described by an (x,y)(x, y) coordinate in the plane, where the xx value is the index of the yy value in the sequence. We thus have: (1,a1),(2,a2),(3,a3),...,(n,an)(1, a_1), (2, a_2), (3, a_3), ..., (n, a_n) There is a line, which can pass through all the given points. Furthermore, this line can be a polynomial, as any number of any points may define a polynomial curve (see Appendix 1 for a proof). As it is a curve, its equation can be represented as an n−1thn-1^{th} degree polynomial: y=axn−1+bxn−2+cxn−3+...+dy = ax^{n-1} + bx^{n-2} + cx^{n - 3} + ... + d We can thus substitute values for xx and yy and solve the equations simultaneously for aa, bb, cc, and dd, from which we receive the equation of the nthn^{th} term. Let us illustrate this through an example. S=(3,11,9,8)S = (3, 11, 9, 8) We thus have the cubic equation: y=ax3+bx2+cx+dy = ax^3 + bx^2 + cx + d Which can be solved by substituting values of xx and yy. This yields: a=116a = \frac{11}{6} b=−16b = -16 c=2596c = \frac{259}{6} d=−26d = -26 We now have the general equation: f(x)=116n3−16n2+2596n−26f(x) = \frac{11}{6}n^3 - 16n^2 + \frac{259}{6}n - 26 Let us now insert n=1n = 1: f(1)=116−16+2596−26f(1) = \frac{11}{6} - 16 + \frac{259}{6} - 26 which correctly solves to: f(1)=3f(1) = 3

Cubic interpolation
Graph of the cubic function

Although this is huge progress and presents a method for a human (or computer running standard methods such as elimination or substitution) to solve for the nthn^{th} term of any sequence, the solution is an inefficient one. It finds the solution by brute force instead of using an elegant method. This solution works perfectly well when our sequence contains only three values, however the obvious question to ask when assessing such a solution is how it will work with a thousand, or a million values in the sequence. I am certain that I am not alone in thinking that solving 1000 simultaneous equations is neither an appealing nor elegant nor efficient solution to the problem. We have thus established a base in solving the problem, but we must now progress into more elegant and efficient solutions.

Lagrange Interpolation

For the sake of example, let there be 4 nodes. We can create a set of polynomials l0l_0, l1l_1, l2l_2, and l3l_3. To reduce oscillation and allow for scaling, these are based of the Kroenecker’s delta function. These polynomials are known as the Lagrange polynomials.

We can therefore say that the Lagrange interpolant over n+1n + 1 points can be written as: ∑i=0nyili(x)\sum_{i=0}^{n}y_il_i(x) Where li(x)l_i(x) is the Lagrange polynomial at xx, and yiy_i is the yy value at xx. We can loosely define li={1if x=xi0if x=xj,j≠il_i = \begin{cases} 1 & \text{if } x = x_i \\ 0 & \text{if } x = x_j, j \neq i\\ \end{cases} Note that here xix_i is the point in lil_i where it is equal to the node, and xjx_j represents any other node. This is essentially equivalent to Kroenecker’s delta function, which is a function which takes as input two variables and returns 1 if they are equal, and 0 if they are not.

It is not difficult for us to construct polynomial equal to zero at the points we want it to be - consider the polynomial: y=(x−a)(x−b)(x−c)y = (x-a)(x-b)(x-c) We know that this polynomial will be equal to 0 when x=ax=a or x=bx = b or x=cx=c. Let’s use this idea to make x=0x = 0 when we want it to. Say we have the nodes at x=0x= 0, x=1x=1, x=2x=2 and x=3x=3. Note for later the importance of this chronological order as we must remember that in most sequences, we will be given values in chronological order at indices 1, 2, 3 ... We want l1(1)=1l_1(1) = 1 and l2(0,2,3)=0l_2(0, 2, 3) = 0, per our definition.

We can now make a "guess" of our Lagrange polynomial l1l_1: l1*=(x−0)(x−2)(x−3)l^*_{1} = (x - 0)(x - 2)(x - 3) Notice that this is precisely the same form as our prior polynomial equation except that a=0a = 0, b=2b = 2, and c=3c = 3.

We can draw its graph, and notice that it equals 0 at the correct places, but at x=1x = 1 is equal to 2 instead of 1 per our earlier definition.

Unnormalised Lagrange basis

What can we do to fix this? Let us see what happens at x=0x = 0: We have: (1−0)(1−2)(1−3)=2(1 - 0)(1 - 2)(1 - 3) = 2 0 divided by any number is still 0, but any number divided by itself is equal to 1. We now have the correct formula, the graph of which is shown below: l1=(x−0)(x−2)(x−3)(1−0)(1−2)(1−3)l_1 = \frac{(x-0)(x-2)(x-3)}{(1-0)(1-2)(1-3)}

Normalised Lagrange basis

However, we have not fully defined the Lagrange polynomial lil_i for all values ii. We can formalise what we said earlier by saying that, given a set of nodes xix_i, i=0,1,…,ni = 0, 1, \ldots, n you will have n+1n+1 Lagrange polynomials such that the ithi^{th} Lagrange polynomial is the product from j=0j = 0 to j=nj = n (excluding j=ij = i) of x−xjx - x_j divided by xi−xjx_i - x_j, into which the values for xix_i and xjx_j can be substituted, forming a polynomial of degree nn per the formula below and the graph above: li(x)=∏j=0,j≠inx−xjxi−xjl_i(x) = \prod_{j = 0,\> j \neq i}^{n}\frac{x-x_j}{x_i-x_j}

Four Lagrange basis polynomials
Lagrange Polynomials

We can illustrate this through one example: Say we wish to find the nthn^{th} term of the sequence (3, 11, 13). We can now establish the data points (1, 3), (2, 11), (3, 13). Then, we use the Lagrange interpolation formula to summate we get the following: L(x)=∑i=13yi⋅li(x)L(x) = \sum_{i=1}^{3}y_i\cdot l_i(x) We need to find out the value of li(x)l_i(x), so per our earlier formula we can derive: li(x)=∏j=1,j≠i3x−xjxi−xjl_i(x) = \prod_{j=1,\> j \neq i }^{3}\frac{x-x_j}{x_i-x_j} Substituting our value for lil_i into the Lagrange interpolation formula we have: L(x)=3⋅(x−2)(x−3)(1−2)(1−3)+11⋅(x−1)(x−3)(2−1)(2−3)+13⋅(x−1)(x−2)(3−1)(3−2)L(x) = 3 \cdot \frac{(x - 2)(x - 3)}{(1 - 2)(1 - 3)} + 11 \cdot \frac{(x - 1)(x - 3)}{(2 - 1)(2 - 3)} + 13 \cdot \frac{(x - 1)(x - 2)}{(3 - 1)(3 - 2)} This simplifies to: L(n)=−3n2+17n−11L(n) = -3n^2 + 17n - 11 Which is the nthn^{th} term of the sequence as shown in the graph below.

Quadratic interpolation of 3, 11, 13

Newtonian interpolation

We have again made huge progress on the efficiency scale, but there is still a big problem. The Lagrange method requires a huge amount of computational complexity, and is difficult to implement especially with higher order polynomials, due to the large amount of computations which must be done. This is nowhere as complex as solving 1000 simultaneous equations, but the algebraic simplifications and multiplications I did to achieve the formula for L(n)L(n) would be extremely complicated and slow for a machine to achieve. On the other hand, Lagrange’s method provides a very elegant solution (as I prove in Appendix 3). Perhaps, however, there is an equally elegant, but more computationally efficient and involving less calculations. The same question was asked and answered by Sir Isaac Newton, one of the most influential mathematicians and physicists of his time, known amongst many things for his inverse square law of gravity and his contributions to calculus.

Suppose you have the set of data points:

(x1,y1),(x2,y2),(x3,y3)...(xn,yn)(x_1, y_1), (x_2, y_2), (x_3, y_3) ... (x_n, y_n)

These values, as earlier discussed represent values of a certain function f(x)f(x), which we must find. To do this, Newton uses divided differences. Divided differences can be understood as the change in the yy coordinates of two points divided by the change in the xx coordinate between the same two points. Thus, the divided difference is the average rate of change between the given points

f[xi,xi+1]=yi+1−yixi+1−xif[x_i, x_{i + 1}] = \frac{y_{i + 1} - y_{i}}{x_{i+1} - x_{i}} This difference is a first-order divided difference. We now continue to calculate higher-order divided differences. Note however also the second part of the definition of the divided difference to provide a base case for recursion: f[xi]=yif[x_i] = y_i We can now attempt to solve the problem. f[xi,xi+1,xi+2]=f[xi+1,xi+2]−f[xi,xi+1]xi+2−xif[x_i, x_{i + 1}, x_{i+2}] = \frac{f[x_{i + 1}, x_{i + 2}] - f[x_i, x_{i + 1}]}{x_{i+2} - x_i} We can now continue calculating these divided differences recursively, using the last value for f(x)f(x) until we reach the maximum number of divided differences allowed by the data points, which is (for a set of points of size nn) n−1n-1 divided differences.

As a small aside - this plays in beautifully into calculus and taking the derivative (which is probably how Newton thought of it). When we take the derivative, we use almost exactly the same formula: f′(a)=f(x+Δx)−f(x)(x+Δx)−xf'(a) = \frac{f(x + \Delta x) - f(x)}{(x + \Delta x) - x}

Visibly, the xxs in the denominator cancel. Perhaps the similarity is not immediately obvious, however remember that f(x)f(x) just refers to the yy value, we can thus think of f(x)+Δxf(x) + \Delta x as yx+Δxy_{x+\Delta x}. Note that this is essentially the same as just taking the divided difference of f(x)f(x) and f(Δx)f(\Delta x), which is often referred to in textbooks as the difference quotient. As we take the derivative, we want the instantaneous change, so thus the change as Δx\Delta x approaches 0. Therefore:

f′(a)=limΔx→0f(x+Δx)−f(x)Δxf'(a) = \lim_{{\Delta x \to 0}} \frac{f(x + \Delta x) - f(x)}{\Delta x} Returning to our prior equations - we can now generalise the example, for any size of dataset, to:

Pn(x)=∑i=0nf[x0,x1,...,xi]∏j=0i−1(x−xj)P_n(x) = \sum_{i = 0}^{n}f[x_0, x_1 ,..., x_i]\prod_{j=0}^{i-1}(x-x_j)

This generalisation links the recursive divided differences demonstrated earlier with a basis polynomial of degree i−1i - 1, which is similar in nature by that used in the Lagrange polynomials.

We have now come to the final step - we summate all of these basis polynomials weighted by their respective divided difference, to ensure each of them contributes to the overall polynomial.

Say, as an example, we have the sequence:

4,18,124, 18, 12

This can be translated into the data points:

(1,4),(2,18),(3,12)(1,4), (2,18), (3,12)

Therefore we can calculate the divided differences such that: f[1]=4f[2]=18f[3]=12f[1,2]=f[2]−f[1]2−1=18−42−1=14f[2,3]=f[3]−f[2]3−2=12−183−2=−6f[1,2,3]=f[2,3]−f[1,2]3−1=−6−143−1=−10We can now substitute:P2(x)=∑i=02f[x0,x1,…,xi]∏j=0i−1(x−xj)P2(x)=4+(x−1)f[1,2]+(x−1)(x−2)f[1,2,3]=4+(x−1)(14)+(x−1)(x−2)(−10)Now simplify:P2(x)=4+14x−14+10x2−30x+20=10x2−16x+10\begin{align*} f[1] &= 4 \\ f[2] &= 18 \\ f[3] &= 12 \\ f[1, 2] &= \frac{f[2] - f[1]}{2 - 1} \\ &= \frac{18 - 4}{2 - 1} \\ &= 14 \\ f[2, 3] &= \frac{f[3] - f[2]}{3 - 2} \\ &= \frac{12 - 18}{3 - 2} \\ &= -6 \\ f[1, 2, 3] &= \frac{f[2, 3] - f[1, 2]}{3 - 1} \\ &= \frac{-6 - 14}{3 - 1} \\ &= -10 \\ \text{We can now substitute:} & P_2(x) = \sum_{i=0}^{2} f[x_0, x_1, \ldots, x_i] \prod_{j=0}^{i-1} (x - x_j) \\ \ & P_2(x) = 4 + (x - 1)f[1, 2] + (x - 1)(x - 2)f[1, 2, 3] \\ &= 4 + (x - 1)(14) + (x - 1)(x - 2)(-10) \\ \text{Now simplify}: & P_2(x) = 4 + 14x - 14 + 10x^2 - 30x + 20 \\ &= 10x^2 - 16x + 10 \\ \end{align*}

This is the polynomial nthn^{th} term of the sequence, as is visible in the graph below:

Newton interpolation of 4, 18, 12

We have now got three relatively competent methods of finding the nthn^{th} term of any sequence and, more broadly, approximating a polynomial curve to any set of points. The method of simultaneous equations becomes extremely inefficient extremely quickly, however has the advantage that it is very intuitive and does not require a great deal of additional knowledge to implement. The Lagrange solution is slower in large datasets, however is arguably the fastest if the size of the dataset is known, (recall that in sequences we are given value in increasing chronological order ie at x=0x = 0, x=1x=1, etc.) and we can then store the equations of various Lagrange interpolants at different nodes, which are then scaled achieve a specific yy value. The Newtonian solution is best for large data sets due to the neat use of recursion, and the simplicity of the calculations.

The appendices of this chapter follow on the next page.

Appendix 1: Lines through points

How can we prove that a method such as the Lagrange polynomial method will work for any set of points? First, we must prove that, given any number of any points, we can draw a polynomial curve through them. We know that to define a straight line (which is just a first degree polynomial) we require 2 points, to define a quadratic we require 3 points, to define a cubic we require 4 points etc. How can we prove that for any polynomial of degree nn can be defined by n+1n + 1 or more points. Given any set of distinct points (x1,y1),(x2,y2),…,(xn,yn)(x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n) where the xx-values are distinct, there exists a unique polynomial of degree n−1n-1 passing through all these points.

We can denote the polynomial as P(x)=a0+a1x+a2x2+…+an−1xn−1P(x) = a_0 + a_1x + a_2x^2 + \ldots + a_{n-1}x^{n-1}. We need to find a0,a1,…,an−1a_0, a_1, \ldots, a_{n-1} such that P(xi)=yiP(x_i) = y_i for all i=1i = 1 to nn.

We can set up simultaneous equations:

For i=1 to n, we have P(xi)=yi:a0+a1x1+a2x12+…+an−1x1n−1=y1a0+a1x2+a2x22+…+an−1x2n−1=y2…a0+a1xn+a2xn2+…+an−1xnn−1=yn\begin{align*} & \text{For } i = 1 \text{ to } n, \text{ we have } P(x_i) = y_i: \\ & a_0 + a_1x_1 + a_2x_1^2 + \ldots + a_{n-1}x_1^{n-1} = y_1 \\ & a_0 + a_1x_2 + a_2x_2^2 + \ldots + a_{n-1}x_2^{n-1} = y_2 \\ & \ldots \\ & a_0 + a_1x_n + a_2x_n^2 + \ldots + a_{n-1}x_n^{n-1} = y_n \end{align*}

This gives us a system of nn linear equations with nn unknowns (a0,a1,…,an−1)(a_0, a_1, \ldots, a_{n-1}). Since the xx-values are distinct, the system of equations is non-singular, meaning it has a unique solution.

Therefore, there exists a unique polynomial of degree n−1n-1 passing through all the given points. This applies to all points, and therefore any points can be described by a polynomial of degree n−1n-1.

Appendix 2: Calculating the efficiency of the various algorithms

To do this, we will use big O notation, a method of approximating the runtime of an algorithm by considering what happens as the size of the dataset/input grows arbitrarily large. This is a sister function to the little o notation, which compares the runtimes of different algorithms. The mathematical basis for Big O and little o notations were both developed by Paul Bachman and Edmund Landau, who (by interesting coincidence) happens to be my great uncle.

Efficiency of using simultaneous equations

: Calculating the efficiency of solving such simultaneous equations is tricky, as solving simultaneous equations depends very much on the equations themselves. However, for the purpose of finding efficiency, we will in some sense assume the worst - that the dataset is so bad that we must use generic methods such as elimination, which affect all the equations and thus the entire dataset. In big O notation, these result in O(n3)O(n^3). We can further explore this by attempting to understand what we do in the elimination method - we choose one equation as a pivot equation and use it to eliminate a certain variable from all other equations. We then repeat this for all equations. Thinking in terms of writing code: this involves two nested loops over rows and columns, resulting in a runtime of O(n2)O(n^2). However, the worst case scenario for the runtime of each row is O(n)O(n) therefore combined runtime is O(n3)O(n^3)

Efficiency of Lagrange method

In the Lagrange method, we can go through similar logic as we did with the simultaneous equations: in the Lagrange method we evaluate the Lagrange polynomials at each point and then sum them after weighting them to appropriate yy values. Evaluating a Lagrange polynomial requires O(nO(n operations, and these must each be summed n times to give O(n2)O(n^2). However, if we had the polynomials stored for integer nodes, the efficiency would be O(n)O(n), which would make it the most efficient algorithm.

Efficiency of Newton’s method

Again we can think this through in a similar way - calculating the divided differences table requires O(n2)O(n^2) operations, we add this to the number of operations needed to separately evaluate the polynomial which are O(n)O(n) . However, in the equation O(n2)+O(n)O(n^2)+O(n) the O(n2)O(n^2) term dominates as nn increases - thus the efficiency of Newton’s method is O(n2)O(n^2)

The Ultimatum: A code which will, given any sequence of integers return its nthn^{th} term

The code:

from sympy import symbols
from fractions import Fraction

def calculate_divided_differences(indices, sequence_values, n):
    differences = [[Fraction(value) for value in sequence_values]]
    for j in range(1, n):
        differences.append([])
        for i in range(n - j):
            d = (differences[j - 1][i + 1] - differences[j - 1][i]) / (indices[i + j] - indices[i])
            differences[j].append(d)
    return differences

def interpolate(indices, sequence_values, n):
    differences = calculate_divided_differences(indices, sequence_values, n)
    term = symbols('n')
    polynomial = differences[0][0]
    x_term = 1

    for i in range(1, n):
        x_term *= (term - indices[i - 1])
        polynomial += differences[i][0] * x_term

    polynomial_str = str(polynomial).replace("**", "^").replace("*", "")

    return polynomial_str

sequence = [0, 0, 0, 0, 0, 0 , 0, 1]


indices = [i for i in range(len(sequence))]
n = len(sequence)

polynomial = interpolate(indices, sequence, n)
print("Nth term:", polynomial)

About my code: a walkthrough

:

1. General stats

This code takes input (as can be adjusted at the end of the code in the sequence values) a sequence of any number of values, and returns as output its nthn^{th} term. Per my testings the code can do 10 values (each less than 10) in 0.2 seconds, 50 values in 0.6s, 100 values 1.2 seconds, and 1000 values (thank the random number generator I coded) in 39.2 seconds.

2. CalculateDividedDifferences function

Note that I have used capitals to indicate underscores as LaTeX doesn’t allow me to write them. This function takes as input three values: the list of sequence values as provided by the user, the list of indices (ie just counting [0, 1, 2...]) and the length of the sequence nn. Note that the only reason this function takes the indices and nn as input is due to the fact that the same values are needed in the next function - it is therefore more efficient to calculate them once and have the functions take them as input than to calculate them twice. We then initialize our list of differences, making use of the Fractions function from the fractions module to ensure that our calculations are neatly formatted at the end. We then loop over 1 to n, initialize a new row in the differences table and then iterate over a nested loop, which goes over the range from 0 to n−j−1n - j - 1 (note the n−1n - 1 is necessary when counting from 0.) We can now populate the table per Newton’s formula: f(xi+1)−f(xi)xi+j−xi\frac{f(x_{i+1}) - f(x_i)}{x_{i+j} - x_i} I rewrite the recursion algorithm implicitly as a nested loop to reduce stack overflow.

Interpolate function

(Note that the same applies with underscores) The interpolate function takes as inputs the same arguments as the CalculateDividedDifferences functions - indices, SequenceValues and n. This function then runs the CalculateDividedDifferences function to create a 2d list differences. We then create a symbolic variable term of size n (it must be symbolic so that we an use the sympy library to manipulate it). We then initialise the polynomial to the first divided difference, which is the value of the function at the first point. We then initialise the xterm variable (which we will use to accumulate terms) to 1. We can now loop over 1 and n and multiply xterm by the difference between the current value of term and the previous index. We now add this to the polynomial variable, format nicely and return the polynomial.

Another code using the Lagrange method

from sympy import symbols, factor

def simplify_and_factorize(expression):
    factored_expression = factor(expression)
    factored_expression_str = str(factored_expression).replace("**", "^").replace("*", "")
    return factored_expression_str

def lagrange_interpolation(sequence):
    n = symbols('n')
    result = 0
    for i, term in enumerate(sequence):
        numerator = 1
        denominator = 1
        for j, other_term in enumerate(sequence):
            if i != j:
                numerator *= (n - j)
                denominator *= (i - j)
        result += term * numerator / denominator
    interpolated_expression = simplify_and_factorize(result)
    return interpolated_expression


sequence = [0, 0, 0, 0, 0, 0, 0, 1] 

nth_term_expression = lagrange_interpolation(sequence)
print("The nth term of the sequence is:", nth_term_expression)