Title: Default for 16.5 Maclaurin and Taylor Series
Course: HELM Workbooks 2023-2024

The Maclaurin series

Consider a function \(f(x)\) which can be differentiated at \(x=0\) as often as we please. For example \(e^x,\cos x,\sin x\) would fit into this category but \(|x|\) would not.

Let us assume that \(f(x)\) can be represented by a power series in \(x\): \[f(x)=b_0+b_1x+b_2x^2+b_3x^3+b_4x^4+\cdots =\sum_{p=0}^{\infty}b_px^p\] where \(b_0,b_1,b_2,\ldots\) are constants to be determined.

If we substitute \(x=0\) then, clearly \[ f(0)=b_0.\]

The other constants can be determined by further differentiating and, on each differentiation, substituting \(x=0\). For example, differentiating once: \[ f'(x)=0+b_1+2b_2x+3b_3x^2+4b_4x^3+\cdots\] so, putting \(x=0\), we have \(f'(0)=b_1\).

Continuing to differentiate:

\[ f''(x)=0+2b_2+3(2)b_3x+4(3)b_4x^2+\cdots\] so \[ f''(0)=2b_2\qquad\text{or}\qquad b_2=\dfrac{1}{2}f''(0)\] Further:

\(f'''(x)=3(2)b_3+4(3)(2)b_4x+\cdots\) so \(f'''(0)=3(2)b_3\qquad\text{implying}\qquad b_3=\dfrac{1}{3(2)} f'''(0).\)

Continuing in this way we easily find that (remembering that \(0!=1\)) \[\qquad b_n=\dfrac{1}{n!}f^{(n)}(0)\qquad n=0,1,2, \dots\] where \(f^{(n)}(0)\) means the value of the \(n^{th}\) derivative at \(x=0\) and \(f^{(0)}(0)\) means \(f(0)\).

Bringing all these results together we have:

Key Point

If \(f(x)\)can be differentiated as often as required: \[f(x)=f(0)+xf'(0)+\dfrac{x^2}{2!}f''(0)+\dfrac{x^3}{3!}f'''(0)+\cdots =\sum_{p=0}^{\infty}\dfrac{x^p}{p!}f^{(p)}(0)\] This is called the Maclaurin expansion of \(f(x)\)

Example

Find the Maclaurin expansion of \(\cos x\).

Solution

Here \(f(x)=\cos x\) and, differentiating a number of times: \[f(x)=\cos x,\qquad f'(x)=-\sin x,\qquad f''(x)=-\cos x,\qquad f'''(x)=\sin x\quad \text{etc.}\] Evaluating each of these at \(x=0\): \[ f(0)=1,\quad f'(0)=0,\quad f''(0)=-1,\quad f'''(0)=0\ \text{etc.}\] Substituting into \(f(x)=f(0)+xf'(0)+\dfrac{x^2}{2!}f''(0)+\dfrac{x^3}{3!}f'''(0)+\cdots\), gives : \[\cos x=1-\dfrac{x^2}{2!}+\dfrac{x^4}{4!}-\dfrac{x^6}{6!}+\cdots\] Confirm (by finding the radius of convergence) that this series is convergent for all values of \(x\). The geometrical approximation to \(\cos x\) by the first few terms of its Maclaurin series are shown in the figure below.

[Image: Linear, quadratic and cubic approximations to cos x]
Linear, quadratic and cubic approximations to \(\cos x\).

Exercise

Find the Maclaurin expansion of \(\ln(1+x)\). (Note that we cannot find a Maclaurin expansion of the function \(\ln x\) since \(\ln x\) does not exist at \(x=0\) and so cannot be differentiated at \(x=0\).)

Find the first four derivatives of \(f(x)=\ln(1+x)\):

Now obtain

1. \(f(0) =\)
2. \(f'(0) =\)
3. \(f''(0) =\)
4. \(f'''(0) =\)

Hence, obtain the Maclaurin expansion of \(\ln (1+x)\): (Hint: enter the general term for \(x^n\))

\(\ln(1+x)=x-\dfrac{x^2}{2}+\dfrac{x^3}{3}+\cdots +\) \(+\cdots \)

Now obtain the radius of convergence.

\(R = \)
Feedback: Find the first four derivatives of \(f(x)=\ln(1+x)\): \(f'(x)=\dfrac{1}{1+x},\qquad f''(x)=\dfrac{-1}{(1+x)^2},\qquad f'''(x)=\dfrac{2}{(1+x)^3}\). Generally \( f^{(n)}(x)=\dfrac{(-1)^{n+1}(n-1)!}{(1+x)^n}.\) Now obtain \(f(0)=0 \qquad f'(0)=1,\qquad f''(0)=-1,\qquad f'''(0)=2\). Generally \(f^{(n)}(0)=(-1)^{n+1}(n-1)!\). Hence the Maclaurin expansion of \[\ln (1+x) \) is \( \ln(1+x) = x-\dfrac{x^2}{2}+\dfrac{x^3}{3} + \cdots +\dfrac{(-1)^{n+1}}{n}x^n+\cdots\] Now the radius of convergence is \(R=1\).

Also at \(x=1\) the series is convergent (alternating harmonic series) and at \(x=-1\) the series is divergent. Hence this Maclaurin expansion is only valid if \(1< x \leq 1\). The geometrical closeness of polynomial terms with function \(\ln (1+x)\) for \(-1<x\le 1\) is displayed in the figure below.

[Image: Graph of In(1+x) and its Maclaurin expansion]

Linear, quadratic and cubic approximations to \(\ln (1+x)\)

Note that when \(x=1\) \(\ln 2=1-\dfrac{1}{2}+\dfrac{1}{3}-\dfrac{1}{4}\cdots\) so the alternating harmonic series converges to \(\ln 2\simeq 0.693\).

The Maclaurin expansion of a product of two functions: \(f(x)g(x)\) is obtained by multiplying together the Maclaurin expansions of \(f(x)\) and of \(g(x)\) and collecting like terms together. The product series will have a radius of convergence equal to the smaller of the two separate radii of convergence.

Example

Find the Maclaurin expansion of \(e^x\ln(1+x)\).

Here, instead of finding the derivatives of \(f(x)=e^x\ln(1+x)\), we can more simply multiply together the Maclaurin expansions for \(e^x\) and \(\ln (1+x)\) which  we already know:

\[e^x=1+x+\dfrac{x^2}{2!}+\dfrac{x^3}{3!}+\cdots\qquad \text{all}\ x\]

and

\[ \ln(1+x)=x-\dfrac{x^2}{2}+\dfrac{x^3}{3}+\cdots\qquad -1<x\leq 1.\]

The resulting power series will only be convergent if \(-1<x \leq 1\) .

Multiplying:

\[\begin{aligned}e^x\ln(1+x)&=\left(1+x+\dfrac{x^2}{2!}+\dfrac{x^3}{3!}+\cdots\right)\left(x-\dfrac{x^2}{2}+\dfrac{x^3}{3}+\cdots\right)\qquad\qquad\qquad\qquad\\&=x-\dfrac{x^2}{2}+\dfrac{x^3}{3}-\dfrac{x^4}{4}+\cdots\\&\quad +\ x^2-\dfrac{x^3}{2}+\dfrac{x^4}{3}+\cdots\\&\qquad \quad\  +\ \dfrac{x^3}{2}-\dfrac{x^4}{4}\cdots\\&\qquad \qquad\quad\quad  +\dfrac{x^4}{6}\cdots\\&=x+\dfrac{x^2}{2}+\dfrac{x^3}{3}+\dfrac{3x^5}{40}+\cdots\qquad -1<x\leq 1\end{aligned}\]

(You must take care not to miss relevant terms when carrying through the

multiplication.)

Exercise

1. If \(\cos x=1-\dfrac{x^2}{2!}+\dfrac{x^4}{4!}+\cdots\) then find the Maclaurin expansion of \(\cos^2x\) up to powers of \(x^4\)
\(\cos^2x =1-\) \(x^2+\) \(x^4-\) \(x^6-\cdots\)
2. Hence write down the expansion of \(\sin^2x\) to powers of \(x^6\). (Hint: \(\sin^2x=1-\cos^2x\))
\(\sin^2x=\) \(+\cdots\)
Feedback: 1. First, write down the expansion of cosine: \(\cos x=1-\dfrac{x^2}{2!}+\dfrac{x^4}{4!}+\cdots\) Now, by multiplication, find the expansion of \(\cos^2x\): \(\cos^2 x=\left(1-\dfrac{x^2}{2!}+\dfrac{x^4}{4!}\cdots\right) \left(1-\dfrac{x^2}{2!}+\dfrac{x^4}{4!}\cdots\right)\) \(\quad\qquad =(1-\dfrac{x^2}{2!}+\dfrac{x^4}{4!}\cdots ) +(-\dfrac{x^2}{2!}+\dfrac{x^4}{4}\cdots )+ (\dfrac{x^4}{4!}\cdots )+\cdots =1-x^2+\dfrac{x^4}{3}-\dfrac{2x^6}{45}\cdots\) 2. Now obtain the expansion of \(\sin^2x\) using a suitable trigonometric identity: \(\sin^2x=1-\cos^2x=1-\left(1-x^2+\dfrac{x^4}{3}-\dfrac{2x^6}{45}+\cdots\right)= x^2-\dfrac{x^4}{3}+\dfrac{2x^6}{45}+\cdots\) As an alternative approach you could obtain the power series expansion for \(\cos^2x\) by using the trigonometric identity \(\cos^2x\equiv\dfrac{1}{2}(1+\cos 2x)\).

Example

Find the Maclaurin expansion of \(\tanh x\) up to powers of \(x^5\).

Solution

The first three derivatives of \(f(x)=\tanh x\) are \[ f'(x)=\text{sech}^2x\qquad f''(x)= -2\text{sech}^2 x\tanh x\qquad f'''(x)= 4\text{sech}^2x\tanh^2 x-2\text{sech}^4x\] giving \[f(0)=0,\quad f'(0)=1,\quad f''(0)=0,\quad f'''(0)=-2.\]

This leads directly to the Maclaurin expansion as \[\tanh x = x -\dfrac{1}{3}x^3+\dfrac{2}{15}x^5\quad\cdots\]

Example

The relationship between the wavelength, \(L\), the wave period, \(T\), and the water depth, \(d\), for a surface wave in water is given by:\[ L=\dfrac{gT^2}{2\pi}\tanh\left(\dfrac{2\pi d}{L}\right)\] In a particular case the wave period was 10 s and the water depth was 6.1 m. Taking the acceleration due to gravity, \(g\), as 9.81 m s\(^{-2}\) determine the wave length. [Hint: Use the series expansion for \(\tanh x\) developed in the example above.]

Solution

Substituting for the wave period, water depth and \(g\) we get \[L=\dfrac{9.81\times 10^2}{2\pi}\tanh\left(\dfrac{2\pi\times 6.1}{L}\right)=\dfrac{490.5}{\pi}\tanh\left(\dfrac{12.2\pi}{L}\right).\] The series expansion of \(\tanh x\) is given by \(\tanh x=x-\dfrac{x^3}{3}+\dfrac{2x^5}{15}+\cdots\).

Using the series expansion of \(\tanh x\) we can approximate the equation as \[L=\dfrac{490.5}{\pi}\left\{\left(\dfrac{12.2\pi}{L}\right)-\dfrac{1}{3}\left(\dfrac{12.2\pi}{L}\right)^3+\cdots\right\}.\]

Multiplying through by \(\pi L^3\) the equation becomes \[\pi L^4=490.5\times 12.2\pi L^2-\dfrac{490.5}{3}\times (12.2\pi)^3\]

This equation can be rewritten as \(L^4-5984.1L^2+2930198=0.\)

Solving this as a quadratic in \(L^2\) we get \(L=74\) m.

Using Newton-Raphson iteration this can be further refined to give a wave length of 73.9 m.

Differentiation of Maclaurin series

We have already noted that, by the binomial series, \[ \dfrac{1}{1-x}=1+x+x^2+x^3+\cdots\qquad |x|<1.\] Thus, with \(x\) replaced by \(-x\) \[ \dfrac{1}{1+x}=1-x+x^2-x^3+\cdots \qquad |x|<1.\] We have previously obtained the Maclaurin expansion of \(\ln(1+x)\): \[ \ln (1+x)=x-\dfrac{x^2}{2}+\dfrac{x^3}{3}-\dfrac{x^4}{4}+\cdots \qquad -1<x\le 1.\] Now, we differentiate both sides with respect to \(x\):

\[ \dfrac{1}{1+x}=1-x+x^2-x^3+\cdots\] This result matches that found from the binomial series and demonstrates that the Maclaurin expansion of a function \(f(x)\) may be differentiated term by term to give a series which will be the Maclaurin expansion of \(\dfrac {\mathrm{d}f}{\mathrm{d}x}.\)

The derived series will have the same radius of convergence as the original series.

The Taylor series

The Taylor series is a generalisation of the Maclaurin series being a power series developed in powers of \((x-x_0)\) rather than in powers of \(x\).

Key Point

If the function \(f(x)\) can be differentiated as often as required at \(x=x_0\) then: \[f(x)=f(x_0)+(x-x_0)f'(x_0)+\dfrac{(x-x_0)^2}{2!}f''(x_0)+\cdots\] This is called the Taylor series of \(f(x)\) about the point \(x_0\).

The Maclaurin expansion is the Taylor expansion obtained if \(x_0\) is chosen to be zero.

Q: Exercise

Using differentiation, find the Maclaurin expansion of \((1-x)^{-3}\).

(Hint : \(\dfrac{1}{1-x}=1+x+x^2+\cdots\qquad |x|<1\))
- \(1+3x+6x^2+10x^3+\cdots\)
- \(2+6x+12x^2+20x^3+\cdots\)
- \(1+2x+3x^2+4x^3+\cdots\)
A: \(1+3x+6x^2+10x^3+\cdots\)
Feedback: Now, by differentiation, obtain the expansion of \(\dfrac{1}{(1-x)^2}\): \[\begin{aligned} \dfrac{1}{(1-x)^2}=\dfrac{\mathrm{d}}{\mathrm{d}x}\left(\dfrac{1}{1-x}\right) &= \dfrac{\mathrm{d}}{\mathrm{d}x}\left(1+x+x^2+\cdots\right), \\ &= 1+2x+3x^2+4x^3 \end{aligned}\] Differentiate again to obtain the expansion of \((1-x)^{-3}\): \[\begin{aligned} \dfrac{1}{(1-x)^3}=\dfrac{1}{2}\dfrac{\mathrm{d}}{\mathrm{d}x}\left(\dfrac{1}{(1-x)^2}\right) &= \dfrac{1}{2}\left[2+6x+12x^2+20x^3+\cdots\right], \\ &= 1+3x+6x^2+10x^3+\cdots \end{aligned}\]

Q: Exercise

What is the Taylor series of \(\dfrac{1}{1-x}\) about \(x=2\). (That is, find a power series in powers of \((x-2)\).)
- \(-1+(x-2)-(x-2)^2+(x-2)^3+\cdots + (-1)^{n+1}(x-2)^n+\cdots\)
- \(1+(x-2)+(x-2)^2+(x-2)^3+\cdots + (x-2)^n+\cdots\)
- \(1-(x-2)+(x-2)^2-(x-2)^3+\cdots + (-1)^{n}(x-2)^n+\cdots\)
A: \(-1+(x-2)-(x-2)^2+(x-2)^3+\cdots + (-1)^{n+1}(x-2)^n+\cdots\)
Feedback: First, obtain the first three derivatives and the \(n^{\text{th}}\) derivative of \(f(x)=\dfrac{1}{1-x}\): \[f'(x)=\dfrac{1}{(1-x)^2},\qquad f''(x)=\dfrac{2}{(1-x)^3},\qquad f'''(x)=\dfrac{6}{(1-x)^4},\qquad \cdots \quad f^{(n)}(x)=\dfrac{n!}{(1-x)^{n+1}}\] Now evaluate these derivatives at \(x_0=2\): \[f'(2)=1,\qquad f''(2)=-2,\qquad f'''(2)=6,\qquad f^{(n)}(2)=(-1)^{n+1}n!\] Hence, write down the Taylor expansion of \(f(x)=\dfrac{1}{1-x}\) about \(x=2\): \[\dfrac{1}{1-x}=-1+(x-2)-(x-2)^2+(x-2)^3+\cdots + (-1)^{n+1}(x-2)^n+\cdots\]

Exercise

Find the Taylor series expansion of \(\displaystyle [value]\) about \(x=[value].\) (That is, find a power series in powers of \( (x-[value])\).)

Find the first three derivatives and the \(n^{th}\) derivative of \(\displaystyle f(x)=[value]\) and evaluate them at \( x_0= [value] \):

Now obtain

1. \(f'([value]) =\)
2. \(f''([value]) =\)
3. \(f'''([value]) =\)
4. \(f^{(n)}([value]) =\)

Hence, obtain the Taylor series expansion of \(\displaystyle [value]\) about \(x=[value]\) up to the 3rd power:

\(\displaystyle[value]\approx \)
Feedback: We are aske to find theTaylor series expansion of \(\displaystyle [value]\) about \(x=[value].\) First we find the derivatives of \(\displaystyle f(x)=[value]\) and evaluate them at \( x=[value].\) 1. \(\displaystyle f'(x)= [value] \Rightarrow f'([value]) =[value] .\) 2. \(\displaystyle f''(x)= [value] \Rightarrow f''([value]) =[value] .\) 3. \(\displaystyle f'''(x)= [value] \Rightarrow f'''([value]) =[value] .\) 4. Generally \(\displaystyle f^{(n)}(x)= [value]\) so \(f^{(n)}([value]) =[value].\) Hence the Taylor expansion of \( \displaystyle [value] \) is \[ [value] = [value]\]

Find the Maclaurin expansion of \(\displaystyle [value]\) and state its radius of convergence.

1. First, obtain the expansion of \(\displaystyle [value]\). Give the first \(3\) terms.
\(\displaystyle [value] =\)
2. Now, by differentiation, obtain the expansion of \(\displaystyle [value]\). Give the first \(4\) terms.
\(\displaystyle [value] =\)
3. Differentiate again to obtain the expansion of \(\displaystyle [value]\). Give the first \(4\) terms.
\(\displaystyle [value] =\)
4. State the radius of convergence for \(\displaystyle [value]\).
\(R =\)
Feedback: 1. Recall that, by the binomial series, \(\displaystyle [value] = [value] + \ldots.\) 2. \(\displaystyle [value] = \dfrac{\mathrm{d}}{\mathrm{d}x}\left(\displaystyle [value]\right)\) \(\begin{aligned}\implies \displaystyle [value] &= \dfrac{\mathrm{d}}{\mathrm{d}x}([value] + \ldots), \\ &= [value] +\ldots \end{aligned}\) 3. \(\displaystyle [value] = \dfrac{1}{2}\dfrac{\mathrm{d}}{\mathrm{d}x}\left(\displaystyle [value]\right)\) \(\begin{aligned}\implies \displaystyle [value] &= \dfrac{1}{2}\dfrac{\mathrm{d}}{\mathrm{d}x}([value] + \ldots), \\ &= [value] + \ldots \end{aligned}\) 4. The final series: \([value]+\ldots\) has radius of convergence \(R=1\) since the original series has this radius of convergence. This can also be found directly using the formula \(R = \lim_{n\rightarrow\infty}\left| \dfrac{b_n}{b_{n+1}}\right|\) and using the fact that the coefficient of the \(n^{\text{th}}\) term is \(b_n = \dfrac{1}{2}n(n+1)\).