Artificial Intelligence 🤖
Power & Fourier Series
Taylor/Maclaurin series

Taylor/Maclaurin series

A power series centred at a point x0x_{0} is defined to be an expression of the form,

n=0cn(xx0)n=c0+c1(xx0)+c2(xx0)2\sum_{n=0}^{\infty} c_{n}\left(x-x_{0}\right)^{n}=c_{0}+c_{1}\left(x-x_{0}\right)+c_{2}\left(x-x_{0}\right)^{2} \cdots

where x0x_{0} and ci(i=0,1,)c_{i}(i=0,1, \cdots) are constants. A power series centred at the origin (i.e. when x0=0x_{0}=0 ), can be thought of as an 'infinite polynomial' and has the form,

n=0cnxn=c0+c1x+c2x2+\sum_{n=0}^{\infty} c_{n} x^{n}=c_{0}+c_{1} x+c_{2} x^{2}+\cdots

In what follows, we discuss a general method for writing a power series representation of a function. We first assume that a function f(x)f(x) has a power series representation about x=x0x=x_{0},

f(x)=n=0cn(xx0)nf(x)=\sum_{n=0}^{\infty} c_{n}\left(x-x_{0}\right)^{n}

where the first three terms are given by Eq. (6.1). The next assumption is that f(x)f(x) has derivatives of every order and that we can find them. The latter allows us to determine the unknown coefficients cic_{i}. Evaluated at x=x0x=x_{0}, we have c0=f(x0)c_{0}=f\left(x_{0}\right). Using differentiation, we can obtain formulae for the other coefficients. For instance, differentiating once wrt xx yields

f(x)=c1+2c2(xx0)+3c3(xx0)2+,f^{\prime}(x)=c_{1}+2 c_{2}\left(x-x_{0}\right)+3 c_{3}\left(x-x_{0}\right)^{2}+\cdots,

which, evaluated again at x=x0x=x_{0} gives c1=f(x0)c_{1}=f^{\prime}\left(x_{0}\right). Continuing with this pattern, we can write down the following formula for the coefficients,

cn=f(n)(x0)n!c_{n}=\frac{f^{(n)}\left(x_{0}\right)}{n !}

where f(n)f^{(n)} represents the nth n^{\text {th }} derivative. Note that the formula works for n=0n=0 since 0!=10 !=1 and f(0)(x)=f(x)f^{(0)}(x)=f(x), by definition. Provided a power series representation for the function f(x)f(x) about x=x0x=x_{0} exists then, the Taylor series for f(x)f(x) about x=x0x=x_{0} is given by,

f(x)=n=0f(n)(x0)n!(xx0)n.f(x)=\sum_{n=0}^{\infty} \frac{f^{(n)}\left(x_{0}\right)}{n !}\left(x-x_{0}\right)^{n} .

If we use x0=0x_{0}=0, we have a Taylor series about x=0x=0 sometimes referred to as the Maclaurin series for f(x)f(x) given by the following expression,

f(x)=n=0f(n)(0)n!xn.f(x)=\sum_{n=0}^{\infty} \frac{f^{(n)}(0)}{n !} x^{n} .

Remainder

Now, at this point we have not yet discussed where (i.e. for what values of xx ) does the Taylor series for f(x)f(x) converge. This is covered later in Section 6.2. What we are interested in here is another important question: in the case where the Taylor series for f(x)f(x) does converge, does it converge to f(x)f(x) ? To answer this, we refer to the remainder, a quantity which represents the difference between f(x)f(x) and the Taylor polynomial of degree nn for f(x)f(x) centred at x0x_{0}. Define the nth n^{\text {th }} degree Taylor polynomial of f(x)f(x) as,

Tn(x)=m=0nf(m)(x0)m!(xx0)m.T_{n}(x)=\sum_{m=0}^{n} \frac{f^{(m)}\left(x_{0}\right)}{m !}\left(x-x_{0}\right)^{m} .

With the full Taylor series given by (6.5), the sum Tn(x)T_{n}(x) is the nth n^{\text {th }} partial sum of the series. The remainder is defined to be,

Rn(x)=f(x)Tn(x)R_{n}(x)=f(x)-T_{n}(x)

which represents the error between the function f(x)f(x) and the nth n^{\text {th }} degree polynomial. Note that the remainder depends on nn. Rearranging (6.8) and using (6.7), we can write the function as,

f(x)=m=0nf(m)(x0)m!(xx0)m+Rn(x).f(x)=\sum_{m=0}^{n} \frac{f^{(m)}\left(x_{0}\right)}{m !}\left(x-x_{0}\right)^{m}+R_{n}(x) .

The sum in (6.7) can be used as an approximation to f(x)f(x) if, at x=x0,Tnx=x_{0}, T_{n} and its first nn derivatives agree with ff. This gives (n+1)(n+1) conditions:

Tn(x0)=f(x0),Tn(1)(x0)=f(1)(x0),Tn(2)(x0)=f(2)(x0),,T(n1)(x0)=f(n1)(x0),T(n)(x0)=f(n)(x0).\begin{aligned} T_{n}\left(x_{0}\right) & =f\left(x_{0}\right), \\ T_{n}^{(1)}\left(x_{0}\right) & =f^{(1)}\left(x_{0}\right), \\ T_{n}^{(2)}\left(x_{0}\right) & =f^{(2)}\left(x_{0}\right), \\ & \cdots, \\ T^{(n-1)}\left(x_{0}\right) & =f^{(n-1)}\left(x_{0}\right), \\ T^{(n)}\left(x_{0}\right) & =f^{(n)}\left(x_{0}\right) . \end{aligned}

We now state the following theorem.

Taylor's theorem

Let ff be an (n+1)(n+1) times differentiable function on an open interval containing the points x0x_{0} and xx. Then,

f(x)=Tn(x)+Rn(x)f(x)=T_{n}(x)+R_{n}(x)

where

Rn(x)=f(n+1)(c)(n+1)!(xx0)n+1R_{n}(x)=\frac{f^{(n+1)}(c)}{(n+1) !}\left(x-x_{0}\right)^{n+1}

for some number cc between x0x_{0} and xx. Equation (6.10) gives the Lagrange form of the remainder (see also Subsec. 6.1.3 for more details on remainders). Note that there are several formulae for the remainder like, for instance, the integral form given by

Rn(x)=1n!ax(xt)nf(n+1)(t)dt.R_{n}(x)=\frac{1}{n !} \int_{a}^{x}(x-t)^{n} f^{(n+1)}(t) d t .

If we can show that, Rn(x)0R_{n}(x) \rightarrow 0 as nn \rightarrow \infty then, we get a sequence of increasingly better approximations to ff leading to the Taylor series as given by Eq. (6.5). In general, the series will converge only for certain values of xx determined by the radius of convergence of the series (see Subsec. 6.2.3). Note that taking x0=0x_{0}=0 in Taylor's theorem gives a similar result for the Maclaurin series.

Example 6.1 Compute the Maclaurin series for f(x)=sinxf(x)=\sin x with n=4n=4.

Solution The 4th 4^{\text {th }} degree Maclaurin series is given by the sum,

S4(x)=m=04f(m)(0)m!xm.S_{4}(x)=\sum_{m=0}^{4} \frac{f^{(m)}(0)}{m !} x^{m} .

We then proceed to evaluate the function ff and its derivatives at 0:f(0)=00: \quad f(0)=0, f(0)=1,f(0)=0,f(0)=1f^{\prime}(0)=1, f^{\prime \prime}(0)=0, f^{\prime \prime \prime}(0)=-1, and f(4)(0)=0f^{(4)}(0)=0. Back in (6.11), we have

S4(x)=xx36S_{4}(x)=x-\frac{x^{3}}{6}

which approximates sinx\sin x near x=0x=0. Now, how good is this approximation? To show this, we need to determine that the remainder term [which gives the difference between f(x)f(x) and its approximation, S4(x)]\left.S_{4}(x)\right] is small. Taking x=0x=0 in Eq. (6.9) and using Eq. (6.12), we write

sinx=xx36+R4(x)\sin x=x-\frac{x^{3}}{6}+R_{4}(x)

where, using Eq. (6.10),

R4(x)=f(5)(c)5!x5R_{4}(x)=\frac{f^{(5)}(c)}{5 !} x^{5}

for some cc between 0 and xx. Since f(5)(x)=cosxf^{(5)}(x)=\cos x, the remainder term is R4(x)=(cosc)x5/5R_{4}(x)=(\cos c) x^{5} / 5 !. Further, cosc1|\cos c| \leq 1 which gives R4(x)x5/5\left|R_{4}(x)\right| \leq|x|^{5} / 5 !. Finally, using Eq. (6.13),

sinx(xx36)x55!\left|\sin x-\left(x-\frac{x^{3}}{6}\right)\right| \leq \frac{|x|^{5}}{5 !}

The x5|x|^{5} term should decay rapidly in the vicinity of x=0x=0. Example 6.2 Compute the Maclaurin series for f(x)=sinxf(x)=\sin x, as in Example 6.1 using arbitrary nn.

Solution The nth \mathrm{n}^{\text {th }} degree Maclaurin series is given by the sum,

Sn(x)=m=0nf(m)(0)m!xm.S_{n}(x)=\sum_{m=0}^{n} \frac{f^{(m)}(0)}{m !} x^{m} .

We evaluate the function ff and its derivatives at 0 : we find that f(m)(0)f^{(m)}(0) is 0 if mm is even and alternates between 1 and -1 if mm is odd, as seen above for Example 6.1. For arbitrary nn, we have

sinx=xx33!+x55!++(1)n1x2n1(2n1)!+Rn(x).\sin x=x-\frac{x^{3}}{3 !}+\frac{x^{5}}{5 !}+\cdots+(-1)^{n-1} \frac{x^{2 n-1}}{(2 n-1) !}+R_{n}(x) .

The remainder term is given as

Rn(x)=sin(n+1)(c)(n+1)!xn+1,R_{n}(x)=\frac{\sin ^{(n+1)}(c)}{(n+1) !} x^{n+1},

for some cc between 0 and xx. Since the derivatives of sinx\sin x only take values between -1 and 1 , we have that

Rn(x)xn+1(n+1)!\left|R_{n}(x)\right| \leq \frac{|x|^{n+1}}{(n+1) !}

We need to show that the Maclaurin series converges to sinx\sin x for all xx which is equivalent to showing that for any fixed value of xx the limits of the remainders, Rn0R_{n} \rightarrow 0 as nn \rightarrow \infty. If x>1,xn+1x>1,|x|^{n+1} grows fast as nn increases, however, for n>>xn>>|x|, the denominator increases faster. See below for a rough sketch of the proof.

Limit of xnn!\frac{|x|^{n}}{n !} as nn \rightarrow \infty

We show that xn/n!0|x|^{n} / n ! \rightarrow 0 as nn \rightarrow \infty for a fixed value of xx by making use of the Sandwich theorem. This brief section aims to add to the intuition in Example 6.2 that Rn0R_{n} \rightarrow 0 as nn \rightarrow \infty for fixed xx. We assume the following inequality holds

an<bn<cna_{n}<b_{n}<c_{n}

The Sandwich theorem states that if

limnan=limncn=L\lim _{n \rightarrow \infty} a_{n}=\lim _{n \rightarrow \infty} c_{n}=L

and there exists an integer NN for all n>Nn>N, then

limnbn=L.\lim _{n \rightarrow \infty} b_{n}=L .

Here, an,bna_{n}, b_{n}, and cnc_{n} are assumed to be sequences. To simplify the discussion, we fix the value of x|x| to 3 and let bn=3n/nb_{n}=|3|^{n} / n ! where clearly bn0b_{n} \geq 0. We have

bn=3333123nb_{n}=\frac{3 \cdot 3 \cdot 3 \cdots 3}{1 \cdot 2 \cdot 3 \cdots n}

which can be expressed as individuals fractions,

bn=313233343n.b_{n}=\frac{3}{1} \cdot \frac{3}{2} \cdot \frac{3}{3} \cdot \frac{3}{4} \cdots \frac{3}{n} .

We can already see that the limit approaches 0 as nn increases, since we are multiplying by smaller and smaller functions. Now, apart from the fractions 3/1,3/2,3/33 / 1,3 / 2,3 / 3, the rest of the n3n-3 fractions in the sequence above are at most equal to 3/43 / 4 which means we can write

0bn92(34)n30 \leq b_{n} \leq \frac{9}{2}\left(\frac{3}{4}\right)^{n-3}

Finally, let an=0a_{n}=0 and cn=(9/2)(3/4)n3c_{n}=(9 / 2)(3 / 4)^{n-3}; the limits of both ana_{n} and bnb_{n} are 0 as nn \rightarrow \infty and, since anbncna_{n} \leq b_{n} \leq c_{n} it follows, by the Sandwich theorem, bn0b_{n} \rightarrow 0.

Common power series

Using the definitions of series defined earlier, we can write down the Maclaurin series for cosx\cos x and exe^{x}, valid for any real xx :

cosx=1x22!+x44!=n=0(1)n(2n)!x2n;ex=1+x+x22!+x33!+=n=0xnn!.\begin{gathered} \cos x=1-\frac{x^{2}}{2 !}+\frac{x^{4}}{4 !}-\cdots=\sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2 n) !} x^{2 n} ; \\ e^{x}=1+x+\frac{x^{2}}{2 !}+\frac{x^{3}}{3 !}+\cdots=\sum_{n=0}^{\infty} \frac{x^{n}}{n !} . \end{gathered}

As a last example, consider the series of the binomial function given by fp(x)=(1+x)pf_{p}(x)=(1+x)^{p},

(1+x)p=1+px+12!p(p1)x2+13!p(p1)(p2)x3+.(1+x)^{p}=1+p x+\frac{1}{2 !} p(p-1) x^{2}+\frac{1}{3 !} p(p-1)(p-2) x^{3}+\cdots .

The series is valid in 1<x<1-1<x<1. If pp is not a positive integer, then the above series has infinitely many nonzero terms. If pp is a positive integer, the series terminates; the binomial function is a polynomial for positive pp with only the first p+1p+1 terms are nonzero. For instance, with p=2p=2,

f2(x)=(1+x)2f_{2}(x)=(1+x)^{2}

and its Maclaurin series, say TT, is given by

T(x)=1+2x+x2,T(x)=1+2 x+x^{2},

i.e. f2(x)=T(x)f_{2}(x)=T(x), since all derivatives higher than or equal to the third, vanish.

Taylor's formula with integral remainder

Here, we derive Taylor's formula with integral remainder by reconstructing a function f=f(x)f=f(x) through repeated integration (note that notation, definitions, and techniques pertaining to integration are covered in Chapter 8). Through the derivation in this subsection we arrive at the definitions of the remainder discussed in Subsec. 6.1.1. Starting with the identity,

x0xf(x)dx=f(x)f(x0)\int_{x_{0}}^{x} f^{\prime}(x) d x=f(x)-f\left(x_{0}\right)

we have

f(x)=f(x0)+x0xf(x)dx.f(x)=f\left(x_{0}\right)+\int_{x_{0}}^{x} f^{\prime}(x) d x .

Since f(x)f(x) is arbitrary, (6.22) should also hold with f(x)f(x) replaced by the function f(x)f^{\prime}(x), such that

f(x)=f(x0)+x0xf(x)dx.f^{\prime}(x)=f^{\prime}\left(x_{0}\right)+\int_{x_{0}}^{x} f^{\prime \prime}(x) d x .

Using the above expression for f(x)f^{\prime}(x) in the integral in (6.22), we obtain,

f(x)=f(x0)+x0x{f(x0)+x0xf(x)dx}dx=f(x0)+f(x0)(xx0)+x0xx0xf(x)dxdx.\begin{aligned} f(x) & =f\left(x_{0}\right)+\int_{x_{0}}^{x}\left\{f^{\prime}\left(x_{0}\right)+\int_{x_{0}}^{x} f^{\prime \prime}(x) d x\right\} d x \\ & =f\left(x_{0}\right)+f^{\prime}\left(x_{0}\right)\left(x-x_{0}\right)+\int_{x_{0}}^{x} \int_{x_{0}}^{x} f^{\prime \prime}(x) d x d x . \end{aligned}

Next, just as we obtained (6.23) from (6.22) by replacing f(x)f(x) with f(x)f^{\prime}(x), we can replace f(x)f^{\prime \prime}(x) in (6.23)(6.23) by f(x)f^{\prime \prime \prime}(x) so that

f(x)=f(x0)+x0xf(x)dxf^{\prime \prime}(x)=f^{\prime \prime}\left(x_{0}\right)+\int_{x_{0}}^{x} f^{\prime \prime \prime}(x) d x

Using this result in (6.24) yields,

f(x)=f(x0)+f(x0)(xx0)+x0xx0x{f(x0)+x0xf(x)dx}dxdx=f(x0)+f(x0)(xx0)+f(x0)2!(xx0)2+x0xx0xx0xf(x)dxdxdx.\begin{aligned} f(x) & =f\left(x_{0}\right)+f^{\prime}\left(x_{0}\right)\left(x-x_{0}\right)+\int_{x_{0}}^{x} \int_{x_{0}}^{x}\left\{f^{\prime \prime}\left(x_{0}\right)+\int_{x_{0}}^{x} f^{\prime \prime \prime}(x) d x\right\} d x d x \\ & =f\left(x_{0}\right)+f^{\prime}\left(x_{0}\right)\left(x-x_{0}\right)+\frac{f^{\prime \prime}\left(x_{0}\right)}{2 !}\left(x-x_{0}\right)^{2} \\ & +\int_{x_{0}}^{x} \int_{x_{0}}^{x} \int_{x_{0}}^{x} f^{\prime \prime \prime}(x) d x d x d x . \end{aligned}

Repeating this process, under the assumption that f(x)f(x) is sufficiently differentiable of course, we find

f(x)=f(x0)+f(x)(xx0)+f(a)2!(xx0)2++f(n)(x0)n!(xx0)n+Rn(x)f(x)=f\left(x_{0}\right)+f^{\prime}(x)\left(x-x_{0}\right)+\frac{f^{\prime \prime}(a)}{2 !}\left(x-x_{0}\right)^{2}+\cdots+\frac{f^{(n)}\left(x_{0}\right)}{n !}\left(x-x_{0}\right)^{n}+R_{n}(x)

where

Rn(x)=x0xx0xf(n+1)(x)(dx)n+1R_{n}(x)=\int_{x_{0}}^{x} \cdots \int_{x_{0}}^{x} f^{(n+1)}(x)(d x)^{n+1}

and (dx)n+1(d x)^{n+1} means dxdx,n+1d x \ldots d x, n+1 times. Equation (6.27) is known as Taylor's formula with remainder, where the remainder is expressed in integral form by (6.28).

Suppose that mf(n+1)(x)Mm \leq f^{(n+1)}(x) \leq M over [a,x][a, x], where mm and MM are constants. Then

x0xx0xm(dx)n+1Rnxx0x0xM(dx)n+1.\int_{x_{0}}^{x} \ldots \int_{x_{0}}^{x} m(d x)^{n+1} \leq R_{n} \leq \int_{x}^{x_{0}} \cdots \int_{x_{0}}^{x} M(d x)^{n+1} .

Integrating, we have

m(xx0)n+1(n+1)!RnM(xx0)n+1(n+1)!.m \frac{\left(x-x_{0}\right)^{n+1}}{(n+1) !} \leq R_{n} \leq M \frac{\left(x-x_{0}\right)^{n+1}}{(n+1) !} .

It follows from (6.29) that we must be able to express RnR_{n} as

Rn(x)=f(n+1)(c)(n+1)!(xx0)n+1R_{n}(x)=\frac{f^{(n+1)}(c)}{(n+1) !}\left(x-x_{0}\right)^{n+1}

where cc is some suitable point in [x0,x]\left[x_{0}, x\right]; this is the Lagrange form of RnR_{n} which we saw in Eq. (6.10).

In fact, this result for the remainder can also be obtained with the mean value theorem of the integral calculus:

if mf(x)Mm \leq f(x) \leq M over [a,b][a, b] then

m(ba)abf(x)dxM(ba).m(b-a) \leq \int_{a}^{b} f(x) d x \leq M(b-a) .

If mm and MM are minimum and maximum values of ff over [a,b][a, b] and ff is continuous, then there must be some point in [a,b][a, b], say cc, such that

abf(x)dx=f(c)(ba)\int_{a}^{b} f(x) d x=f(c)(b-a)

and this is known as the mean value theorem of the integral calculus. Using this theorem in (6.28), where we now have n+1n+1 derivatives, yields (6.30).