Saturday, 25 February 2012

Fun with Vector Calculus!

So this is more for my own reference on how to derive various vector identities, but who knows it might prove useful to someone here on the internet so I figured I'd post it anyway. I'm going to be using Einstein notation to make this more compact.

A crash course in Einstein notation

Einstein notation is not hard to grasp, it is just a series of conventions to eliminate the writing of sum signs. When there are repeated indices you sum over them, namely \[ \sum_i a_i b_i = a_i b_i \] So in the case of this post it will always be sum from $i=1$ to $i=3$. There are a couple of important symbols that are very useful, first there is the Kronecker delta, defined as \[ \delta_{ij} = \begin{cases} 1 &: i = j \\ 0 &: i \not= j \end{cases} \] There is also the Levi-Civita symbol which is defined as \[ \varepsilon_{ijk} = \begin{cases} +1 &\text{if symmetric} \ ijk\\ -1 &\text{if antisymmetric} \ ijk\\ 0 &\text{if} \ i=j \ \text{or} \ j=k \ \text{or} \ k=i \end{cases} \] So if there is an even permutation, i.e. symmetric combination {1,2,3}, $\varepsilon = 1$. If there is an odd permutation, i.e. an antisymmetric combination {3,2,1}, then $\varepsilon = -1$, if any index is repeated then $\varepsilon = 0$

These might seem rather arbitrary however the Kronecker delta and Levi-Civita symbol make it very easy to define vector operations. First let's consider the dot product, this is given in 3 dimensional Cartesian as: \[ \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{3} \delta_{ij} a_i b_j \] Rather conveniently the Kroncker delta is 0 everywhere except for $i=j$, so the dot product in Cartesian can be rewritten in its more familiar form \[ \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{3} a_i b_i \] And expressed in Einstein notation this is simply \[ \mathbf{a} \cdot \mathbf{b} = a_i b_i \] Not really too much of a saving on writing the dot product using Einstein notation, but what about the cross product?

We can write the cross product by making use of the Levi-Civita symbol \[ \mathbf{a} \times \mathbf{b} = \sum_{i=1}^{3}\sum_{j=1}^{3} \sum_{k=1}^{3} \varepsilon_{ijk} \hat{\mathbf{e}}_i a_j b_k \] Now the merits of Einstein notation become more apparent, cumbersome calculations like this can be written much more easily, the same thing in Einstein notation is simply \[ \mathbf{a} \times \mathbf{b} = \varepsilon_{ijk} \hat{\mathbf{e}}_i a_j b_k \] As an aside, by writing the cross product in this way it can be seen how it is generalised. This formula is the definition of the wedge product, a generalisation of the cross product. It is valid in any number of dimension rather than the 3 or 7 dimensions that the cross product is valid in.

General Vector Identities

Let's start with the absolute basics: div, grad and curl. \[ \begin{eqnarray} \nabla \phi &=& \partial_i ( \phi ) \ \hat{\mathbf{e}}_i \\ \nabla \cdot \mathbf{F} &=& \partial_i F_i \\ \nabla \times \mathbf{F} &=& \varepsilon_{ijk} \hat{\mathbf{e}}_i \partial_j F_k \end{eqnarray} \]

Some first order identities

So let's consider the gradient of a product $\nabla (\psi \phi)$ \[ \begin{eqnarray} \nabla (\psi \phi) &=& \partial_i ( \phi \psi ) \ \hat{\mathbf{e}}_i \\ &=& ( \phi \partial_i \psi + \psi \partial_i \phi ) \ \hat{\mathbf{e}}_i \\ &=& \phi \nabla \psi + \psi \nabla \phi \end{eqnarray} \] The divergence of a scalar and a vector $\nabla \cdot ( \phi \mathbf{F} )$ \[ \begin{eqnarray} \nabla (\phi \mathbf{F}) &=& \partial_i (\phi F_i )\\ &=& \phi \partial_i F_i + F_i \partial_i \phi \\ &=& \phi \nabla \cdot \mathbf{F} + \mathbf{F} \cdot \nabla \phi \end{eqnarray} \] The curl of a scalar and vector $\nabla \times (\phi \mathbf{F})$ \[ \begin{eqnarray} \nabla \times (\phi \mathbf{F}) &=& \varepsilon_{ijk} \hat{\mathbf{e}}_i \partial_j \phi F_k \\ &=& \varepsilon_{ijk} \hat{\mathbf{e}}_i ( \phi \partial_j F_k + F_k \partial_j \phi ) \\ &=& \phi \ \varepsilon_{ijk} \hat{\mathbf{e}}_i \partial_j F_k + \varepsilon_{ijk} \hat{\mathbf{e}}_i ( \partial_j \phi) F_k \\ &=& \phi \nabla \times \mathbf{F} + \nabla \phi \times \mathbf{F} \end{eqnarray} \] The scalar triple product $\nabla \cdot (\mathbf{A} \times \mathbf{B} )$ \[ \begin{eqnarray} \nabla \cdot (\mathbf{A} \times \mathbf{B}) &=& \partial_i \varepsilon_{ijk} A_j B_k \\ &=& \varepsilon_{ijk} \partial_i (A_j B_k) \\ &=& \varepsilon_{ijk} ( A_j \partial_i B_k + B_k \partial_i A_j ) \\ &=& \varepsilon_{ijk} A_j \partial_i B_k + \varepsilon_{ijk} B_k \partial_i A_j \\ &=& - \varepsilon_{jik} A_j \partial_i B_k + \varepsilon_{kij} B_k \partial_i A_j \\ &=& -\mathbf{A} \cdot (\nabla \times \mathbf{B}) + \mathbf{B} \cdot (\nabla \times \mathbf{A}) \end{eqnarray} \] There are more vector identities that I could derive however it would be tedious as these are the only ones needed to establish all the integral identities I am going to derive.

Some second order identities

Let's start with an easy one, it's just a definition. The divergence of a gradient is just the Laplacian $\nabla \cdot (\nabla \phi) = \nabla^2 \phi$, this takes a scalar field and returns another scalar field.

The curl of a gradient, $\nabla \times (\nabla \phi)$, this is a slightly trickier identity to prove. Let's start with the basics and write it in Einstein notation. \[ \nabla \times (\nabla \phi) = \varepsilon_{ijk} \partial_j \partial_k \phi \] Now we can use the definition of the Levi-Civita and swap our indices to arrive at \[ \nabla \times (\nabla \phi) = -\varepsilon_{ikj} \partial_j \partial_k \phi \] But these are all just dummy indices; we can relabel them all as we please, so let's do the following \[ \begin{align} k \to j \\ j \to k \end{align} \] So now we have \[ \nabla \times (\nabla \phi) = -\varepsilon_{ijk} \partial_k \partial_j \phi \] But if we have continuous second order mixed partial derivatives, then the order in which we take them is irrelevant as they commute. From this we find that \[ \varepsilon_{ijk} \partial_j \partial_k \phi = -\varepsilon_{ijk} \partial_j \partial_k \phi \] This equation is only satisfied by $0$, so thus we conclude that \[ \nabla \times (\nabla \phi) = 0 \]

The divergence of the curl $\nabla \cdot (\nabla \times \mathbf{F})$. This is very similar to the divergence of a gradient so I shall omit the full proof. Let's write it out fully first \[ \nabla \cdot (\nabla \times \mathbf{F}) = \partial_i \varepsilon_{ijk} \partial_j F_k \] We can take the partial derivative inside the equation to yield \[ \nabla \cdot (\nabla \times \mathbf{F}) = \varepsilon_{ijk} \partial_i \partial_j F_k \] This is now the same form as in the previous identity and exactly the same logic applies, or as a general rule a symmetric symbol times an antisymmetric symbol is 0. So this identities is \[ \nabla \cdot (\nabla \times \mathbf{F}) = 0 \]

The final second order identity is the curl of a curl $\nabla \times (\nabla \times \mathbf{F})$, I'm going to resolve into components to avoid dealing with multiple unit vectors, this does not change the result of the derivation. \[ [ \nabla \times (\nabla \times \mathbf{F}) ]_i = \varepsilon_{ijk} \partial_j \varepsilon_{klm} \partial_l F_m \] This can be rearranged into a far more useful form \[ [ \nabla \times (\nabla \times \mathbf{F}) ]_i = \varepsilon_{ijk} \varepsilon_{klm} \partial_j \partial_l F_m \] There is a useful identity that we can apply here, I'm not going to prove it here as it is rather long however relatively simply. \[ \varepsilon_{ijk} \varepsilon_{klm} = \delta_{il} \delta_{jm} - \delta_{jl} \delta_{im} \] Making use of this identity we now have \[ [ \nabla \times (\nabla \times \mathbf{F}) ]_i = ( \delta_{il} \delta_{jm} - \delta_{jl} \delta_{im} )\partial_j \partial_l F_m \] The definition of the Kronecker delta makes this really easy to simplify down as only 2 pairs of indices result in a non zero Kronecker delta combination. The pairs are $l = i , \ m=j$ and $l=j, \ m=i$. So we now have \[ [ \nabla \times (\nabla \times \mathbf{F}) ]_i = \partial_i \partial_j F_j - \partial_j \partial_j F_i \] So from here we find that \[ \nabla \times (\nabla \times \mathbf{F}) = \nabla (\nabla \cdot \mathbf{F}) - \nabla^2 \mathbf{F} \]

Vector Identities from the Ostrogradsky-Gauss Divergence theorem

So as a quick refresher the Divergence theorem is given as: \[ \oint_{S} \mathbf{F} \cdot \mathbf{dS} = \int_{V} (\nabla \cdot \mathbf{F}) dV \]

Divergence theorem for a scalar function

Now consider the situation where the vector can be represented as the product of some constant vector $\mathbf{A}$ and a function of position $\phi \equiv \phi(\mathbf{r})$, so: $\mathbf{F} = \phi \mathbf{A} $. Now let's apply the divergence theorem. \[ \oint_{S} ( \phi \mathbf{A} ) \cdot \mathbf{dS} = \int_{V} \nabla \cdot ( \phi \mathbf{A} ) dV \] This can be simplified by making use of some of the earlier vector identities, first let's consider the LHS. \[ \oint_{S} \mathbf{A} \cdot \mathbf{dS} = \mathbf{A} \cdot \oint_{S} \phi \mathbf{dS} \] And now let's consider the RHS, by applying an earlier vector identity: \[ \int_{V} \nabla \cdot ( \phi \mathbf{A} ) dV = \int_{V} (\nabla \phi) \cdot \mathbf{A} + \phi (\nabla \cdot \mathbf{A}) dV \] But remember that $ \mathbf{A} $ is a constant non zero vector so $\nabla \cdot \mathbf{A} = 0$, this simplifies our expression for the RHS to: \[ \int_{V} (\nabla \phi) \cdot \mathbf{A} dV = \mathbf{A} \cdot \int_{V} \nabla \phi dV \] Now we can take the right side from the left or vice versa and take the constant vector outside, this yields: \[ \mathbf{A} \cdot \Bigg( \oint_{S} \phi \mathbf{dS} - \int_{V} \nabla \phi dV \Bigg)= 0\] But $\mathbf{A} \not= 0$, so clearly the expression inside the brackets must be which leads to the new identity: \[ \oint_{S} \phi \mathbf{dS} = \int_{V} \nabla \phi dV \]

Divergence theorem for a cross product

Now what if now the vector $\mathbf{F}$ can be represented as the cross product of a constant vector $\mathbf{A}$ and a vector function of position $\mathbf{B} \equiv \mathbf{B} (\mathbf{r}) $, so: $\mathbf{F} = \mathbf{A} \times \mathbf{B}$. Now applying the divergence theorem to this yields \[ \oint_{S} ( \mathbf{A} \times \mathbf{B} ) \cdot \mathbf{dS} = \int_{V} \nabla \cdot ( \mathbf{A} \times \mathbf{B}) dV \] As before let's first consider the LHS, this is easy to rearrange this time, just consider the cyclic relation of the scalar triple product: \[ \oint_{S} ( \mathbf{A} \times \mathbf{B} ) \cdot \mathbf{dS} = - \mathbf{A} \cdot \oint_{S} \mathbf{dS} \times \mathbf{B} \] And now let's consider the RHS, by applying an earlier vector identity: \[ \int_{V} \nabla \cdot ( \mathbf{A} \times \mathbf{B}) dV = \int_{V} \mathbf{B} \cdot (\nabla \times \mathbf{A}) - \mathbf{A} \cdot (\nabla \times \mathbf{B}) dV \] As with before remember that $\mathbf{A}$ is a constant vector so $\nabla \times \mathbf{A} = 0$, thus simplifying the RHS to: \[ \int_{V} - \mathbf{A} \cdot (\nabla \times \mathbf{B}) dV = - \mathbf{A} \cdot \int_{V} (\nabla \times \mathbf{B}) dV \] Now as before we now combine both sides and factor out $\mathbf{A}$ \[ \mathbf{A} \cdot \Bigg( - \oint_{S} \mathbf{dS} \times \mathbf{B} + \int_{V} (\nabla \times \mathbf{B}) dV \Bigg) = 0 \] Now as before $\mathbf{A} \not= 0$, so clearly the expression inside the brackets must be which leads to the new identity: \[ \oint_{S} \mathbf{dS} \times \mathbf{B} = \int_{V} (\nabla \times \mathbf{B}) dV \]

Vector Identities from the Kelvin-Stokes theorem

So as a quick refresher stokes' theorem is given as: \[ \oint_{C} \mathbf{F} \cdot \mathbf{ds} = \int_{S} (\nabla \times \mathbf{F}) \cdot \mathbf{dS} \]

Stokes' theorem for a scalar function

As with the case with the divergence theorem we assume that a vector function $\mathbf{F}$ can be rewritten as the product of a scalar of position $\phi \equiv \phi(\mathbf{r})$, and a constant vector $\mathbf{A}$. So $\mathbf{F} = \phi \mathbf{A}$, now if we apply the divergence theorem. \[ \oint_{C} \phi \mathbf{A} \cdot \mathbf{ds} = \int_{S} (\nabla \times \phi \mathbf{A}) \cdot \mathbf{dS} \] Now consider the LHS of the equation, it's very similar to the case with the divergence theorem. \[ \oint_{C} \phi \mathbf{A} \cdot \mathbf{ds} = \mathbf{A} \cdot \oint_{C} \phi \mathbf{ds} \] And now let's consider the RHS \[ \int_{S} (\nabla \times \mathbf{A}) \cdot \mathbf{dS} = \int_{S} [ (\nabla \phi) \times \mathbf{A} + \phi (\nabla \times \mathbf{A}) ] \cdot \mathbf{dS} \] Now this simplifies as $\mathbf{A}$ as in a constant, so $\nabla \times \mathbf{A} = 0$. This now reduces the equation to \[ \int_{S} [ (\nabla \phi) \times \mathbf{A}] \cdot \mathbf{dS} = \mathbf{A} \cdot \int_{S} \mathbf{dS} \times ( \nabla \phi ) \] Now combining both sides \[ \mathbf{A} \cdot \Bigg( \oint_{C} \phi \mathbf{ds} - \int_{S} \mathbf{dS} \times \nabla \phi \Bigg) = 0 \] $\mathbf{A} \not= 0 $, so we arrive at the identity \[ \oint_{C} \phi \mathbf{ds} = \int_{S} \mathbf{dS} \times \nabla \phi \]

Stokes' theorem for a cross product

Now what if now the vector $\mathbf{F}$ can be represented as the cross product of a constant vector $\mathbf{A}$ and a vector function of position $\mathbf{B} \equiv \mathbf{B} (\mathbf{r}) $, so: $\mathbf{F} = \mathbf{A} \times \mathbf{B}$. Now applying the stokes' theorem to this yields \[ \oint_{C} ( \mathbf{A} \times \mathbf{B} ) \cdot \mathbf{ds} = \int_{S} [\nabla \times ( \mathbf{A} \times \mathbf{B}) ] \cdot \mathbf{dS} \] Consider the LHS \[ \oint_{C} ( \mathbf{A} \times \mathbf{B} ) \cdot \mathbf{ds} = - \mathbf{A} \cdot \oint_{C} \mathbf{ds} \times \mathbf{B} \] Now consider the RHS, it has two cross product and a dot product however we can manipulate it by consider the bracketed cross term as a single vector term, this reduces the expression to a scalar triple product that can easily be manipulated. First let's consider $(\mathbf{A} \times \mathbf{B})$ as a single term. \[ [\nabla \times (\mathbf{A} \times \mathbf{B})] \cdot \mathbf{dS} = \mathbf{dS} \times \nabla \cdot (\mathbf{A} \times \mathbf{B}) \] Now consider consider $\mathbf{dS} \times \mathbf{\nabla}$ as a single term \[ \mathbf{dS} \times \nabla \cdot (\mathbf{A} \times \mathbf{B}) = -\mathbf{A} \cdot [(\mathbf{dS} \times \mathbf{\nabla}) \times \mathbf{B}] \] So now we can rewrite the RHS as \[ \int_{S} [\nabla \times ( \mathbf{A} \times \mathbf{B}) ] \cdot \mathbf{dS} = -\mathbf{A} \cdot \int_{S} ( \mathbf{dS} \times \mathbf{\nabla}) \times \mathbf{B} \] Now combining these terms we arrive at the now familiar form \[ \mathbf{A} \cdot \Bigg( \oint_{C} \mathbf{ds} \times \mathbf{B} - \int_{S} ( \mathbf{dS} \times \mathbf{\nabla}) \times \mathbf{B} \Bigg) = 0 \] And again as $\mathbf{A} \not= 0$ we arrive at the identity \[ \oint_{C} \mathbf{ds} \times \mathbf{B} = \int_{S} ( \mathbf{dS} \times \mathbf{\nabla}) \times \mathbf{B} \]

Green's Identities

I'm only deriving two of the identities here as I do not yet understand the third identity. To derive Green's identities we start with the vector identities \[ \begin{eqnarray} \nabla \cdot (\psi \nabla \phi) = \psi \nabla^2 \phi + \nabla \psi \cdot \nabla \phi \\ \nabla \cdot (\phi \nabla \psi) = \phi \nabla^2 \psi + \nabla \phi \cdot \nabla \psi \end{eqnarray} \] Now if we subtract equations 2 from equation 1 we have \[ \nabla \cdot (\psi \nabla \phi - \phi \nabla \psi) = \psi \nabla^2 \phi - \phi \nabla^2 \psi \] Now we want to consider the closed surface integral over the vector field $\psi \nabla \phi$ and apply the divergence theorem and use equation 1. This is Green's first identity. \[ \oint_{S} \psi \nabla \phi \cdot \mathbf{dS} = \int_{V} \psi \nabla^2 \phi + \nabla \psi \cdot \nabla \phi dV \] Now we consider the closed surface integral over the vector field $\psi \nabla \phi - \phi \nabla \psi$ and apply the divergence theorem again and utilise equation 3. This is Green's second identity. \[ \oint_{S} (\psi \nabla \phi - \phi \nabla \psi) \cdot \mathbf{dS} = \int_{V} (\psi \nabla^2 \phi - \phi \nabla^2 \psi) dV \]

Monday, 26 December 2011

The Riemann Integral

So I've been using the term "Riemann Integrable" a few times, but what does it mean to be riemann integrable on a closed interval $[a,b]$.

Defining the Riemann Integral 1.0

The Riemann integral is a method of exhaustion applied to finding the area under the curve. The area is approximated using rectangles with decreasing widths. As an infinite number of rectangles are used to find the area this ceases to be an approximation and the true area is found. I talked about this in my previous post but it is important to understand the intuition behind the riemann integral.

First we will consider the function $f: [a,b] \mapsto \mathbb{R}$

As we did previously we want to split up the interval $[a,b]$, where $a < b$. In this case we split the interval into a set of partitions $\mathcal{P}$ that we define as: \[ \mathcal{P} := \{ a = x_0 < x_1 < ... < x_{n-1} < x_n = b \} \] We will also define the norm of this partition \[ || \mathcal{P} || := \max_{1 \leq i \leq n} \Delta x_i\] where we define the partition width as (the partitions may be of different sizes rather than uniform as we were dealing with before): \[\Delta x_i = x_i - x_{i-1}\] We're going to define another partition on $[a,b]$ and call it $\mathcal{P}'$, this new partition $\mathcal{P}'$ is a refinement of $\mathcal{P}$. This is done by inserting additional points between those defined by $\mathcal{P}$ such that $ \mathcal{P} \subseteq \mathcal{P}'$. Now if $f$ is defined on [a,b] we can write the sum \[\Lambda (f, \mathcal{P})= \sum_{i=1}^{n} f(x) \Delta x_i \] where $x \in [x_{i-1} , x_i]$ and $1 \leq i \leq n$. $\Lambda$ is the riemann sum of $f$ over the partition $\mathcal{P}$. It is important to note that there are infinitely many riemann sums of a single function $f$ over a given partition $\mathcal{P}$ as over the interval $[x_{i-1},x_i]$ the reals are infinitely dense and $x$ can take any real number in the interval as its value.

Definition 1.1

Now we're going to define what it means to be riemann integrable, we say that a function $f$ is riemann integrable on $[a,b]$ if there exists a unique number $\mathcal{L} \in \mathbb{R}$ with the property that for all $\epsilon > 0$ there is a $\delta > 0 $ such that \[ | \Lambda - \mathcal{L} | < \epsilon \] Where $\Lambda$ is an arbitrary riemann sum of $f$ over the partition $\mathcal{P}$ of $[a,b]$ such that $|| \mathcal{P} || < \delta $. If we take the limit as $|| \mathcal{P} || \to 0$ We can say that $\mathcal{L}$ is the riemann integral of $f$ on $[a,b]$ and denote this in the familiar way as: \[ \int_{a}^{b} f(x) dx = \mathcal{L} \] I'm not going to prove here that $\mathcal{L}$ is unique, however this result will soon become apparent.

Definition 1.2 : The Riemann Sum

If you're familiar with real analysis you way want to look away for this paragraph as the following "definition" may offend you. Now I'm going to introduce some new notation that applies to sets, the supremum, $\sup$ and infimum, $\inf$. Loosely speaking these correspond to maximum and minimum elements of an arbitrary set $\mathcal{S}$.

Now we want to define the maximum value of $f(x)$ over an arbitrary partition $[x_{i-1},x_i]$ and denote this as $J_i$ \[ J_i := \sup \ \{ \ f(x) : \ {x \in [x_{i-1}, x_i]} \ \} \] Now we want to do the same with the lower partition denoting it as $j_i$ \[ j_i := \inf \ \{ \ f(x) : \ {x \in [x_{i-1}, x_i]} \ \} \]

From these we can now form the upper and lower riemann sums, these flavours of sum represent the maximum and minimum area under the curve $f(x)$ over the partition $[a,b]$.

First the upper sum of $f$ over the partition $\mathcal{P}$ \[ U(f,\mathcal{P}) := \sum_{i=1}^{n} J_i \Delta x_i\] And the lower sum of $f$ over $\mathcal{P}$ \[ L(f,\mathcal{P}) := \sum_{i=1}^{n} j_i \Delta x_i\]

Theorem 1.3

Now let $f$ be bounded in the interval $[a,b]$ such that $j \leq f \leq J$, where $j, J \in \mathbb{R}$ and are defined as follows: $j = \inf \ \{ \ f(x) : \ x \in [a,b] \ \}$ and $J = \sup \ \{ \ f(x) : \ x \in [a,b] \ \}$. Now using our definition of the upper and lower riemann sums we can say that \[ j(b-a) \leq L(f,\mathcal{P}) \leq U(f,\mathcal{P}) \leq J(b-a) \] Now we return to our refined partition $\mathcal{P}'$, suppose it refines the partition $\mathcal{P}$ by adding in a single extra point $r$ such that $\mathcal{P}' = \mathcal{P} \cup \{r\}$. Now suppose that there exists an integer $k$ such that $x_{k-1} \leq r \leq x_k$. Now suppose that this new point $r$ divides the $k^{th}$ term, this means the final interval is now divided into two intervals that we shall call the left and right interval. \[ j_i^L := \inf \ \{ \ f(x) : \ x \in [x_{i-1}, r] \ \} , \ \ \ \ J_i^L := \sup \ \{ \ f(x) : \ x \in [r, x_i]: \ f(x) \ \} \] \[ j_i^R := \inf \ \{ \ f(x): \ x \in [x_{i-1}, r] \ \} , \ \ \ \ J_i^R := \sup \ \{ \ f(x) : \ x \in [r, x_i] \ \} \] Now we can calculate the riemann sums of the refined partition, note that as only the last term is changed by the additional point so we only need to calculate this \[ J_i \Delta x_i = J_i^{L}(r - x_{i-1}) + J_i^{R} (x_i - r)\] \[ j_i \Delta x_i = j_i^{L}(r - x_{i-1}) + j_i^{R} (x_i - r)\] From this it follows that \[ U(f,\mathcal{P}) - U(f,\mathcal{P}') = (J_i - J_i^L)(r-x_{i-1}) + (J_i - J_i^R)(x_i - r) \] \[ L(f,\mathcal{P}) - L(f,\mathcal{P}') = (j_i - j_i^L)(r-x_{i-1}) + (j_i - j_i^R)(x_i - r) \] Now it may take a little bit of thought but by following our definitions for the right and left intervals we can note that for the left interval $j_i \leq j_i^L \leq J_i^L \leq J_i$ and that $j_i \leq j_i^R \leq J_i^R \leq J_i$ analogously for the right interval. From this it follows that \[ L(f,\mathcal{P}) \leq L(f,\mathcal{P}') \leq U(f,\mathcal{P}') \leq U(f,\mathcal{P}) \] This is what we're looking for, hold this result as we will use it later. In summary this basically says that if we refine some partition $\mathcal{P}$ by adding in additional points the lower riemann sum will increase and the upper riemann sum will decrease.

Theorem 1.4

Now let $\mathcal{P}_1$ and $\mathcal{P}_2$ be two partitions on $[a,b]$. Now if we let them both be a refinement on $\mathcal{P}'$ such that $ \mathcal{P}' := \mathcal{P}_1 \cup \mathcal{P}_2$. We can now use theorem 1.3 to establish the inequality \[ L(f,\mathcal{P}_1) \leq L(f,\mathcal{P}') \leq U(f,\mathcal{P}') \leq U(f,\mathcal{P}_2) \] This is a very important results as it means the the lower sum can never exceed the upper sum regardless of how we choose the partitions of summation. Which leads us to \[ \sup \ \{ \ L(f,\mathcal{P}) : \ \mathcal{P} \in [a,b] \ \} \leq \inf \ \{ \ U(f,\mathcal{P}) : \ \mathcal{P} \in [a,b] \ \} \] Which we will need to define the riemann integral

We haven't quite finished here yet earlier when we added in points we only considered adding in one additional interval into the partition $\mathcal{P}$. Now lets consider the more general case when we add $N$ more points. I'm not going to prove it, but from theorem 1.3 it follows that if we refine the partition by adding another point the inequality still holds. So we can add $N$ additional points and the inequality will still hold.

Definition 1.5 : The upper and lower riemann sum

As you may have guessed we're now going to form riemann integrals from the summations we have constructed. We're in a position to define the upper and lower riemann sums that correspond to these summations.

The upper riemann integral is defined as: \[ \overline{\int_{a}^{b}} f(x) dx := \inf \ \{ \ \mathcal{P} \in [a,b]: \ \ U(f,\mathcal{P}) \ \} \] The lower riemann integral is defined as \[ \underline{\int_{a}^{b}} f(x) dx := \sup \ \{ \ \mathcal{P} \in [a,b]: \ \ L(f,\mathcal{P}) \ \} \] So we can interpret the upper riemann integral as the lowest upper bound of $f$, this is because we can vary the partition size to change the value of $U$, utilising the infimum and supremum to do this. Likewise we can do the same to the lower riemann sum $L$ except in this case $f$ is the greatest lower bound. \[ \underline{\int_{a}^{b}} f(x) dx \leq \overline{\int_{a}^{b}} f(x) dx \] This inequality is formed by using theorem 1.4 And from it we arrive at one of the conditions for a function $f$ to be riemann integrable on $[a,b]$. The function $f$ is integrable on $[a,b]$ if and only if the upper and lower sums converge on a common value and we denote this as $\int_a^b f(x) dx$.

Theorem 1.6

From definition 1.6 a function $f$ is riemann integrable on $[a,b]$ if and only if a unique limit exists which means \[ \overline{\int_{a}^{b}} f(x) dx = \underline{\int_{a}^{b}} f(x) dx = \int_{a}^{b} f(x) dx \] Any integrable function $f$ will fulfil it. We can reformulate this expression to form the Riemann lemma, a condition for integrability that will be very useful in identifying riemann integrable functions.

Lemma 1.7 : The Riemann Lemma

A function $f : [a,b] \mapsto \mathbb{R}$ is riemann integrable on $[a,b]$ if and only if for a partition $\mathcal{P}$ on $[a,b]$ for all $\epsilon > 0$ such that \[ \Big| U(f, \mathcal{P}) - L(f, \mathcal{P}) \Big| < \epsilon \] To prove this suppose that there is a real number $\mathcal{L}$ and an $\epsilon > 0$ and consider the interval $\Big[ \mathcal{L}, \mathcal{L} + \dfrac{\epsilon}{2} \Big]$ Clearly all the lower sums are less than or equal to $\mathcal{L}$ and the upper sums are greater than or equal to $\mathcal{L}$. So for some partition $\mathcal{P}_2$ we have \[ \mathcal{L} \leq U(f, \mathcal{P}_2) \leq \mathcal{L} + \dfrac{\epsilon}{2} \] Now a similar inequality exists for the lower sum. Consider this over the partition $\mathcal{P}_1$ \[ \mathcal{L} - \dfrac{\epsilon}{2} \leq L(f, \mathcal{P}_1) \leq \mathcal{L} \] Now consider the refined partition $\mathcal{P}' := \mathcal{P}_1 \cup \mathcal{P}_2 $ Now combining these together into a single inequality which, unsurprisingly, resembles theorem 1.3 & 1.4 \[ \mathcal{L} - \dfrac{\epsilon}{2} \leq L(f,\mathcal{P}_1) \leq L(f,\mathcal{P}') \leq U(f,\mathcal{P}') \leq U(f,\mathcal{P}_2) \leq \mathcal{L} + \dfrac{\epsilon}{2} \] Both $U(f, \mathcal{P}')$ and $L(f, \mathcal{P}')$ lie within the boundary \[ \Big[ \mathcal{L} - \dfrac{\epsilon}{2}, \mathcal{L} + \dfrac{\epsilon}{2} \Big] \] And the Riemann lemma follows from this.

So a function $f$ for to be integrable it must fulfil the Riemann lemma and if it fulfils this criterion we say $f$ is riemann integrable on $[a,b]$ and we denote this value as \[ \int_{a}^{b} f(x) dx = \mathcal{L} \]

Friday, 12 August 2011

Riemann Sums

What is a Riemann sum?

A Riemann sum is a method of evaluating definite integrals; it is in my opinion an intuitive idea, using rectangular strips from the x axis to approximate the area under the curve. At a finite level this only provides an approximate of the area under the curve, but as the strip length of the rectangles tends to $0 \ (\delta x \to 0)$ it ceases to be an approximate and provides an exact area.

Naturally an example is the best way to visualise this, consider the function: \[ f(x) = x^2 \ \text{between} \ 1 \le x \le 4 \] As this closed interval is of size 3 this is an obvious number of strips to use. I'm taking the height of each rectangle to be the value of $f(x)$ at the right most point of the rectangle. This may seem confusing at the moment but the graphics below should make it all clear.

Ta-da! Now as there are a finite number of rectangles (3) this is only an approximate of the area under the curve. Suppose I wanted a better approximation, I could try 9 rectangles.

I could better my approximation again by using 27 rectangles.

I could keep on improving my approximates by increasing the number of rectangles further. However it should now be clear that increasing the number of rectangles as well as decreasing the width of the rectangles improves the approximation. And as I said earlier as the width tends to $0$ and the the number of rectangles using tends to infinity this becomes the exact area under the curve.

The maths behind the Riemann sum

Riemann sums come in three flavours: the left sum, the right sum and the middle sum. The prefix refers to the point of the rectangle that is taken up to the curve $f(x)$. So in my example it was the right, however you could use the left most point or the mid point of the rectangle instead. The most accurate of these for use in approximations is the middle sum.

Formulating a Riemann sum is not particularly difficult either. Consider the size of an individual rectangle, it's just $f(x) \times \Delta x$ where $\Delta x$ denotes the width of an individual rectangle and $f(x)$ the height at the point $x$. When the interval of integration between $a$ and $b$ is split into uniformly wide pieces it becomes clear that: \[ \Delta x = \frac{b-a}{n} \] Each rectangle is of a different height based on its position on the curve $f(x)$ and so each successive height must be taken an additional $\Delta x$ further ahead, or more mathematically as: \[ x_k = a + k \Delta x \] From this we can formulate the right Riemann sum: \[ S = \ \sum_{k=1}^{n} f(x_k) \ \Delta x \] For the right sum the height of each rectangle $f(x)$ is taken at the leading edge of the rectangle.

The other two Riemann sums can be formulated in a similar way, however for finding exact areas they are less useful so I have not included them.

Finding approximate solutions

To do this just put numbers into the formulae. I'll use the first approximate using 3 strips and the right summation as an example. So: \[ \Delta x = \frac{4-1}{3} = 1\] The formulated sum is: \[ S = \sum_{k=1}^{3} (1 + k \times 1 )^2 \times 1 \] Or in its more simplified form: \[ S = \sum_{k=1}^{3} ( 1 + k )^2 \] Evaluating this yields: \[ S = 29\] In this case the approximate is fairly close to the actual value of 21, however for larger more complex functions such a small number of strips usually provides a poor estimate.

Finding exact solutions

For the purposes of finding definite integrals the right sum is the best choice as summations from $1 \ \text{to} \ n$ have forms to work with and make it possible to find exact solutions using Riemann sums.

As n tends to infinty the strip length $\Delta x \to 0 $ When we have a summation of an infinite number of strips in a given interval we call this an integral. At its most basic level an integral is just a summation of all the strips in a range. \[ \lim_{n \to \infty} \ \sum_{k=1}^{n} f(x_k) \ \Delta x \equiv \int_a^b f(x) \ \mathrm{d}x \] Now you might ask, why is this the case, well this is how we define the riemann integral. And it makes sense intuitively too, the definite integral is just the area under the curve, which is exactly what this summation represents. And for this summation the Riemann sum looks quite different, it is an exact representation of the area under the curve.

A practical comparison

These can be shown to be equivilent, consider the function: \[ f(x) = x^3 \text{between} \ 1 \le x \le 4 \]

Using standard integration

So for the standard method of integration: \[S = \int_{1}^{4} x^3 \mathrm{d}x\] Evaluating this: \[\begin{align} S &= \Big[ \frac{x^4}{4} + C \Big]_{1}^{4} \\ S &= 64 - \frac{1}{4} \\ S &= \frac{255}{4} \end{align} \]

Using Riemann sums

The Riemann sum is a bit harder to do, it is also quite tedious to perform as even fairly simply integrals will throw up fairly nasty summations that are difficult to simplify down by hand.
So in this summation the strip length will be: \[ \Delta x = \frac{4-1}{n} = \frac{3}{n} \] and the position on the $x$ axis is given by: \[ x_k = 1 + \frac{3k}{n} \] So we will be evaluating the Riemann sum: \[ S = \lim_{n \to \infty} \ \sum_{k=1}^{n} (1+x)^3 \ \Delta x \] $\Delta x$ can be factored out because it's a constant: \[ S = \lim_{n \to \infty} \ \frac{3}{n} \sum_{k=1}^{n} \Big( 1+\frac{3k}{n} \Big)^3 \] Expanding the brackets yields: \[ S = \lim_{n \to \infty} \ \frac{3}{n} \sum_{k=1}^{n} \Big( \frac{27k^3}{n^3} + \frac{27k^2}{n^2} + \frac{9k}{n} +1 \Big) \] This can be broken down into four individual summations ($\Delta x$ is included in the term that is factored out): \[ S = \lim_{n \to \infty} \ \frac{81}{n^4}\sum_{k=1}^{n} k^3 + \frac{81}{n^3} \sum_{k=1}^{n} k^2 + \frac{27}{n^2} \sum_{k=1}^{n} k + \frac{3}{n} \sum_{k=1}^{n} 1 \] Evaluating each summation yields: \[ S = \lim_{n \to \infty} \ \frac{81}{4n^2}(n+1)^2 + \frac{81}{6n^2}(n+1)(2n+1) + \frac{27}{2n}(n+1) + 3 \] Simplifying this yields: \[ \begin{align} S &= \lim_{n \to \infty} \ \frac{255}{4} + \frac{189}{2n} + \frac{135}{4n^2} \\ \\ S &= \frac{255}{4} \end{align} \] Which is the same as the more standard method.

Formalising integration

Riemann sums formalise the method of finding the definite integral. As you saw above they are usually fairly complex and require a lot of work, similar to finding derivatives from first principles. The Riemann sum really has little use outside of defining the definite integral, shortcut methods of integration are much easier to remember and perform. However Riemann sums provide a point to definite integration from in much the same way infinitesimals do for differentiation.

*All the graphics used in this were made by myself using Mathematica 7.0, if you wish to use them please provide credit and link back to my blog.

Thursday, 23 June 2011

Drop Rates

So anyone who has ever played an MMO or RPG will be familiar with these, the probability that the monster you just killed drops a valuable. This can be modelled by the binomial distribution. This is a distribution with two outcomes termed success and failure, denoted as p = success and q = failure, failure is not succeeding so q = 1 - success (in statistics 1 denotes 100% probability). So lets assume that the monster in question has a 1% probability of dropping a particular valuable item. This is: \[ \begin{array}{rlc} p = \frac{1}{100} & q = \frac{99}{100} \end{array} \] The probability of succeeding is the same as not failing which can be denoted as: \[ 1 - (1-p)^n\] In this context: \[1 - \Big(1 - \frac{1}{100} \Big)^{100} \approx 0.6339 \approx 63.4 \% \] This can be generalised for any drop rate, if the drop rate is $\frac{1}{n}$ and you kill $n$ monsters the probability of receiving a drop is always around 63%, providing that $n$ is sufficiently large.*

So what if we wanted a 90% to be the minimum probability of getting a drop? Well consider the above equation for a probability of 0.90 \[ 1 - \Big( \frac{99}{100} \Big)^{n} > 0.9 \] Solving this expression for n yields: \[ n = \frac{\ln \frac{1}{10}}{\ln \frac{99}{100}} = 229.1 \approx 230 \] So if you were to kill 230 monsters you'd have a 90% probability of receiving a drop.

It is very important to note that each trial is independent of all other trials. That is to say that if you have killed 10 or 10,000 monsters the probability that the next kill will yield a drop is still $p$.

A practical example is tossing a coin. If I flip a coin and get 10 heads in a row, what is the probability that the next toss is heads? It might seem that the "law of averages" would make the next toss tails. However there is no such force, this is another independent trial, so the probability is still $\frac{1}{2}$ regardless of how many heads were tossed beforehand.




*there is a reason that as $n$ increases the probability tends to 63%. This is because: \[ \lim_{n \to \infty} \Big(1 - \frac{1}{n} \Big)^n = \frac{1}{e}\] I proved in my last post that: \[ \lim_{n \to \infty} \Big(1 + \frac{1}{n} \Big)^n = e \] This is a specific case of the formula: \[ \lim_{n \to \infty} \Big(1 + \frac{x}{n} \Big)^{n} = e^x \] In the case where $x=-1$: \[ \lim_{n \to \infty} \Big(1 - \frac{1}{n} \Big)^{n} = \frac{1}{e} \] So as $n \to \infty$: \[ 1 - \lim_{n \to \infty} \Big(1 - \frac{1}{n} \Big)^{n} = 1 - \frac{1}{e} \approx 0.6321 \approx 63.21 \text{%} \]

Monday, 6 June 2011

Derivative of polar equations

Consider an arbitrary polar equation defined as: \[ r(\theta), \ \ \ 0 \le \theta < 2 \pi \] The polar curve can be converted into Cartesian coordinates using parametric equations. The relationship between polar equations and their parametric equivalent is neatly shown below:

So we can define the polar curve parametrically using $\theta$ as the parameter. This is: \[\begin{align} y &= r(\theta) \sin \theta \\ x &= r(\theta) \cos \theta \end{align}\]

The derivative of the two parameters can be found using the product rule, this is a trivial step so I have not included the method: \[\begin{align} \frac{\mathrm{d}y}{\mathrm{d} \theta} = r(\theta) \cos \theta + r'(\theta) \sin \theta \\ \\ \frac{\mathrm{d} x}{\mathrm{d} \theta} = r'(\theta) \cos \theta - r(\theta) \sin \theta \end{align} \]

We can apply the chain rule to find the derivative of this set of parametric equations: \[\begin{align} \frac{\mathrm{d}y}{\mathrm{d}x} &= \frac{\mathrm{d}y}{\mathrm{d} \theta} \times \frac{\mathrm{d} \theta}{\mathrm{d}x} \\ \\ &= \frac{\mathrm{d}y}{\mathrm{d} \theta} \times \frac{1}{\frac{\mathrm{d} x}{\mathrm{d} \theta}} \end{align}\] So substituting in the two derivatives: \[ \frac{\mathrm{d}y}{\mathrm{d}x} = r(\theta) \cos \theta + r'(\theta) \sin \theta \times \frac{1}{r'(\theta) \cos \theta - r(\theta) \sin \theta } \] Hence the derivative of an arbitrary polar equation is: \[\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{ r(\theta) \cos \theta + r'(\theta) \sin \theta }{r'(\theta) \cos \theta - r(\theta) \sin \theta} \]

Monday, 30 May 2011

An introduction to e

*edit: I fixed the graphics, they should work in any browser now.

What is e?

Euler's number, $e$, is a very important irrational constant, it has wide uses across maths, science and economics. In particular it's useful in modelling the natural processes of growth and decay, compound interest as well as having a number of useful properties in calculus. We define $e$ as the exponential function that has a gradient of $1$ when it crosses the coordinate axis $x=0$, this can be represented in functions as: \[ \frac{\mathrm{d}}{\mathrm{d}x} e^x = 1, \ \text{when} \ x = 0\] Or graphically. The graph shows the plots of $e^x$, $3^x$ and the line $y = x+1$. The line also has a gradient of 1 for comparison:

But what is the value of $e$? Lets suppose there exists an exponential function $a^x$ where $a$ is an arbitrary constant, the derivative of this function is: \[\begin{align} \frac{\mathrm{d}}{\mathrm{d}x} a^x &= \lim_{\delta x \to 0} \ \frac{a^{x+ \delta x} - a^x}{\delta x} \\ \\ &= \lim_{\delta x \to 0} \ \frac{a^{x} ( a^{\delta x} - 1)}{\delta x} \end{align} \] $e$ has the unique property that its gradient is 1 when it crosses the coordinate axis. So make the derivative 1 and set $x=0$. This is: \[\begin{align} &\lim_{\delta x \to 0} \ \frac{a^{0} ( a^{\delta x} - 1)}{\delta x} = 1 \\ \\ &\lim_{\delta x \to 0} \ \frac{( a^{\delta x} - 1)}{\delta x} = 1 \\ \\ &\lim_{\delta x \to 0} \ a^{\delta x} = 1 + \delta x \\ \\ &\lim_{\delta x \to 0} \ 1 + \delta x = a^{\delta x} \\ \\ &\lim_{\delta x \to 0} \ (1 + \delta x)^{\frac{1}{\delta x}} = (a^{\delta x})^{\frac{1}{\delta x}} \\ \\ &\lim_{\delta x \to 0} \ (1 + \delta x)^{\frac{1}{\delta x}} = a \end{align}\] When this limit is evaluated the arbitrary constant $a$ is found to be $2.71828...$ This is Euler's number!

Euler's number can be expressed as another limit as well, by making the substitution $\delta x = \frac{1}{\xi}$. It can be seen that for $\frac{1}{\xi} \to 0$, $\xi \to \infty$, this can replace the limit of the final expression, so: \[ \lim_{\xi \to \infty} \ \Big(1+ \frac{1}{\xi} \Big)^{\xi} = e \] I have graphed this limit over a small range of $\xi$ values to demonstrate that it converges onto $e$.

e and calculus
Derivatives of exponents

Lets say I wanted to find the derivative of $a^x$: \[\begin{align} \frac{\mathrm{d}}{\mathrm{d}x} a^x &= \lim_{\delta x \to 0} \ \frac{a^{x+ \delta x} - a^x}{\delta x} \\ \\ &= \lim_{\delta x \to 0} \ \frac{a^{x} ( a^{\delta x} - 1)}{\delta x} \\ \\ &= \lim_{\delta x \to 0} \ a^{x} \Big( \frac{a^{\delta x} - 1}{\delta x} \Big) \end{align} \] Now that derivative isn't very pleasant. However we saw earlier that in the case where the arbitrary constant $a$ is equal to $e$ the limit evaluates to 1, so: \[ \lim_{\delta x \to 0} \ \frac{ (e^{\delta x} - 1) }{\delta x} = 1\] So it can be seen that: \[ \frac{\mathrm{d}}{\mathrm{d}x} e^x = \lim_{\delta x \to 0} \ e^{x} \Big( \frac{e^{\delta x} - 1}{\delta x} \Big) = e^x \cdot 1 = e^x \] So not only does $e$ make finding the derivative of exponents easier it has a rather unique property, it is its own derivative!

Integrating exponents

We can also find the antiderivative of $e^x$ using the the fact that $\frac{\mathrm{d}}{\mathrm{d}x} e^x = e^x$: \[ \int e^x \ \mathrm{d}x = \int \frac{\mathrm{d}}{\mathrm{d}x} (e^x) \ \mathrm{d}x \] From here it is simple enough to apply the fundamental theorem of calculus to find the antiderivative: \[ \int e^x \ \mathrm{d}x = \int \frac{\mathrm{d}}{\mathrm{d}x} (e^x) \ \mathrm{d}x = e^x + C \]

Derivatives of logarithms

$e$ is also very useful when dealing with logarithms. Suppose I find the differential of an arbitrary logarithm in base $a$: \[ \begin{align} \frac{\mathrm{d}}{\mathrm{d}x} \log_{a} x &= \lim_{\delta x \to 0} \ \frac{\log_{a} (x + \delta x) - \log_{a} x }{\delta x} \\ \\ &= \lim_{\delta x \to 0} \ \frac{ \log_{a} \Big( \frac{x + \delta x} {x} \Big) } {\delta x} \\ \\ &= \lim_{\delta x \to 0} \ \frac{ \log_{a} \Big( 1 + \frac{\delta x}{x} \Big) } {\delta x} \end{align} \] Making the substitution $\xi = \frac{\delta x}{x}$, the limit is now becomes $\xi \to 0$ \[ \begin{align} \frac{\mathrm{d}}{\mathrm{d}x} \log_{a} x &= \lim_{\xi \to 0} \ \frac{ \log_{a} (1 + \xi) } {x \xi} \\ \\ &= \lim_{\xi \to 0} \ \frac{1}{x} \Big( \frac{1}{\xi} \log_{a} (1 + \xi) \Big) \end{align} \] Now it isn't a particularly pleasant derivative, but what if $ \lim_{\xi \to 0} \frac{1}{\xi} \log_{a} (1+ \xi) = 1$, then the derivative would just be $\frac{1}{x}$. This can be solved fairly easily using algebra: \[ \begin{align} &\lim_{\xi \to 0} \ \frac{1}{\xi} \log_{a} (1+ \xi) = 1 \\ \\ &\lim_{\xi \to 0} \ \log_{a} (1+ \xi) = \xi \\ \\ &\lim_{\xi \to 0} \ 1 + \xi = a^{\xi}\end{align} \] Raising both these expressions to the power $\frac{1}{\xi}$: \[ \lim_{\xi \to 0} \ (1+\xi)^{\frac{1}{\xi}} = a\] Now that limit should look familiar, we derived it earlier, it is $e$. The logarithm to base $e$ is very useful as it is easy to find derivatives of logarithms. The logarithm to base $e$ is given a special symbol $\log_{e} x = \ln x$

Some interesting properties

We established that $e$ is its own derivative, this means it can be differentiated infinitely, so it can be expressed as a Taylor expansion: \[ \exp(x) = 1 + x + \frac{1}{2}x^2 + \frac{1}{6} x^3 + \cdots \] To find $e$ we must set $x=1$, this simplifies the expansion down to: \[ e = 1 + 1 + \frac{1}{2} + \frac{1}{6} + \cdots \] or in sigma notation: \[ e = \sum_{k=0}^{\infty} \frac{1}{k!} \] The function $e^x$ is defined by the area under the curve $e^x$ so $e^x$ can be represented by the integral: \[ e^x = \int_{-\infty}^{x} e^x \ \mathrm{d}x \] So an expression of $e$ is: \[e = \int_{-\infty}^{1} e^x \ \mathrm{d}x\] The function $\ln x$ is defined by the area under the curve $\frac{1}{x}$. This can be used to form an interesting expression for 1: \[ \int_{1}^{e} \frac{1}{x} \ \mathrm{d}x = 1 \]

Monday, 23 May 2011

Proof of Taylor expansion

Taylor's Theorem:

  • The function $f(x)$ is infinitely differentiable
  • The function $f(x)$ and all its derivatives exist at $x=\xi$
  • The function $f(x)$ can be expressed as a series of the form: \[ f(x) = \sum_{k=0}^{\infty} a_k (x-\xi)^k \]

Differentiating term by term: \[\begin{align*} f(x) &= a_0 + a_1(x-\xi) + a_2(x-\xi)^2 + \cdots \\ \\ f'(x) &= a_1 + 2a_2(x-\xi) + 3a_3(x-\xi)^2 + \cdots \\ \\ f''(x) &= 2a_2 + 2\times 3 a_3(x-\xi) + 3 \times 4 a_4(x-\xi)^2 +\cdots \\ \\ f'''(x) &= 2 \times 3 a_3 + 2 \times 3 \times 4 a_4 (x-\xi) + 3 \times 4 \times 5 a_5(x-\xi)^2 + \cdots \end{align*} \]

Solve for $f(x)$ around the point $x=\xi$: \[\begin{align*} f(\xi) &= a_0 \\ f'(\xi) &= a_1 \\ f''(\xi) &= 2a_2 \\ f'''(\xi) &= 2 \times 3a_3 \end{align*}\] this can be expressed more generally as: \[ f^{(k)}(\xi) = a_k k! \] so: \[ a_k = \frac{f^{(k)}(\xi)}{k!} \] Substituting this into the original series: \[ f(x) = \sum_{k=0}^{\infty} \frac{f^{(k)}(\xi)}{k!} (x-\xi)^k \] This is the Taylor expansion for a single variable.

A little more on the Taylor series:

  • In general the Taylor series is only valid in a small region of x values. Often the series will diverge if $|x-\xi| > 1 $, so in general the series is only valid for $ \xi - 1 \le x \le \xi + 1$. However this is not the case for all functions.
  • When the function $f(x)$ is not expanded completely there is some uncertainty in the expansion, this is denoted as: \[f(x) = S_n(x) + R_n (x)\] Where $S_n(x)$ is the sum of the first n terms and $R_n (x)$ is the sum of the remaining terms. As $n \to \infty $ : $S_n (x) \to f(x)$ and $R_n(x) \to 0$