Chapter 01.07: Taylor Theorem Revisited

Lesson: Introduction to Taylor Series

Learning Objectives

After successful completion of this lesson, you should be able to:

1)  recall the formula for Taylor’s theorem (pre-requisite to course), express Taylor’s theorem in plain language, (pre-requisite to course)

2)  apply Taylor’s theorem to calculate a function at a point when the value of the function and its derivatives is given at another point.

  

Introduction

The use of the Taylor series exists in so many aspects of numerical methods that it is imperative to devote a separate chapter to reviewing it. You must have come across expressions such as

\[\cos(x) = 1 - \frac{x^{2}}{2!} + \frac{x^{4}}{4!} - \frac{x^{6}}{6!} + \ldots \;\;\;\;\;\;\;\;\;\;\;\;(1)\]

\[\sin(x) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \frac{x^{7}}{7!} + \ldots \;\;\;\;\;\;\;\;\;\;\;\;(2)\]

\[e^{x} = 1 + x + \frac{x^{2}}{2!} + \frac{x^{3}}{3!} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (3)\]

All the above expressions are a special case of the Taylor series called the Maclaurin series.

  

Why are applications of Taylor’s theorem important for numerical methods?

Firstly, expressions such as given in Equations (1), (2), and (3) give you a way to find the approximate values of these functions by using the basic arithmetic operations of addition, subtraction, division, and multiplication.

Second, we will also see how numerical methods formulas can be derived from the Taylor series. Examples include finding the numerical formulas for derivatives of continuous and discrete functions and roots of nonlinear equations.

Third, the Taylor series also allows us to find the order of accuracy of numerical methods formulas, which in turn helps us to derive numerical methods that are even more computationally efficient. Examples in the course include the derivation of Richardson’s extrapolation formulas for the first derivative approximation and numerical integration. The extrapolation formulas make the numerical methods even more efficient in these cases.

For this chapter, we will concentrate on a few introductory examples. Let’s see how one can approximately find the value of \(\displaystyle e^{0.25}\) using a Maclaurin series (a polynomial), and hence involves only the basic four arithmetic operations.

  

Example 1

Find the value of \(e^{0.25}\) using the first five terms of the Maclaurin series.

Solution

The first five terms of the Maclaurin series for \(e^{x}\) are

\[\begin{split} e^{x} &\approx 1 + x + \frac{x^{2}}{2!} + \frac{x^{3}}{3!} + \frac{x^{4}}{4!}\\ e^{0.25} &\approx 1 + 0.25 + \frac{0.25^{2}}{2!} + \frac{0.25^{3}}{3!} + \frac{0.25^{4}}{4!}\\ &= 1.2840\end{split}\]

The exact value of \(e^{0.25}\) up to \(5\) significant digits is also \(1.2840\).

  

But the above discussion and example do not answer our question of what a Taylor series is. What is the Taylor series?

We can calculate the value of the function at \(f\left( x \right)\) at \(\left( x + h \right)\), provided the function \(f\left( x \right)\) and all the derivatives of \(f\left( x \right)\) are given at a single point, \(x\)

\[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + \frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} + \ldots\ \ \ (4)\]

Of course, the function \(f\left( x \right)\) and all derivatives of \(f\left( x \right)\) should exist and be continuous between \(x\) and \(x + h\).

  

What does this mean in plain English?

As Archimedes would have said (without the fine print), “Give me the value of the function at a single point, and the value of all (first, second, and so on) its derivatives, and I can give you the value of the function at any other point.

It is very important to note that the Taylor series is not asking for the expression of the function and its derivatives, just the value of the function and its derivatives at a single point.

Now the fine print: Yes, all the derivatives have to exist and be continuous between \(x\) (the point where you are) to the point, \(x + h\) where you want to calculate the function at. However, if you want to calculate the function approximately by using the \(n^{\text{th}}\) order Taylor polynomial, then \(1^{\text{st}},2^{\text{nd}},....,n^{\text{th}}\) derivatives need to exist and be continuous in the closed interval \(\lbrack x,x + h\rbrack\), while the \((n + 1)^{\text{th}}\) derivative needs to exist and be continuous in the open interval \((x,x + h)\).

  

More Examples of Taylor Series

Example 2

Find the value of \(f\left( 6 \right)\) given that\(\text{ f}\left( 4 \right) = 125\), \(f^{\prime}\left( 4 \right) = 74\), \(f^{\prime\prime}\left( 4 \right) = 30\), \(f^{\prime\prime\prime}\left( 4 \right) = 6\) and all other higher derivatives of \(f\left( x \right)\) at \(x = 4\) are zero.

Solution

\[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + f^{\prime\prime}\left( x \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( x \right)\frac{h^{3}}{3!} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (E2.1)\]

\[x = 4\]

\[\begin{split} h &= 6 - 4\\ &= 2\end{split}\]

Since fourth and higher derivatives of \(f\left( x \right)\) are zero at \(x = 4,\) from Equation (E2.1)

\[f\left( 4 + 2 \right) = f\left( 4 \right) + f^{\prime}\left( 4 \right)2 + f^{\prime\prime}\left( 4 \right)\frac{2^{2}}{2!} + f^{\prime\prime\prime}\left( 4 \right)\frac{2^{3}}{3!}\]

\[\begin{split} f\left( 6 \right) &= 125 + 74\left( 2 \right) + 30\left( \frac{2^{2}}{2!} \right) + 6\left( \frac{2^{3}}{3!} \right)\\ &= 125 + 148 + 60 + 8\\ &= 341\end{split}\]

Note that to find \(f\left( 6 \right)\) exactly, we only needed the value of the function and all its derivatives at some other point, in this case, \(x = 4\). We did not need the expression for the function or for its derivatives. Taylor series application would be redundant if we needed to know the expression for the function, as we could just substitute \(x = 6\) in it to get the value of\(\ f\left( 6 \right)\).

Side Note: Actually, the problem posed above was obtained from a known function \(f\left( x \right) = x^{3} + 3x^{2} + 2x + 5\) and hence \(f\left( 4 \right) = 125\), \(f^{\prime}\left( 4 \right) = 74\), \(f^{\prime\prime}\left( 4 \right) = 30\), \(f^{\prime\prime\prime}\left( 4 \right) = 6\), and all other higher derivatives are zero.

Lesson: Application of Taylor Series

Learning Objectives

After successful completion of this lesson, you should be able to:

1)  derive Taylor’s polynomial for transcendental and trigonometric functions

2)  calculate transcendental and trigonometric functions at a point when the value and its derivatives are given at some other point.

  

What You Have Learned So Far

In the previous lesson, we recalled some common Taylor series of a few transcendental functions. In this lesson, we show three examples. The first example illustrates how to derive the Maclaurin series for an exponential function. The second one finds the value of a trigonometric function at a specific point using the Taylor series. The third example derives the Maclaurin series for \(sin(x)\).

Example 1

Derive the Maclaurin series of

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

Solution

Maclaurin series is simply a Taylor series around the point \(x = 0\).

\[f\left( x \right) = {e}^{x},\ f\left( 0 \right) = 1\]

\[f^{\prime}\left( x \right) = {e}^{x},\ f^{\prime}\left( 0 \right) = 1\]

\[f^{\prime\prime}\left( x \right) = {e}^{x},\ { f}^{\prime\prime}\left( 0 \right) = 1\]

\[f^{\prime\prime\prime}\left( x \right) = {e}^{x},\ { f}^{\prime\prime\prime}\left( 0 \right) = 1\]

\[f^{\prime\prime\prime\prime}\left( x \right) = {e}^{x},\ f^{\prime\prime\prime\prime}\left( 0 \right) = 1\]

\[f^{\prime\prime\prime\prime\prime}\left( x \right) = {e}^{x},\ f^{\prime\prime\prime\prime\prime}\left( 0 \right) = 1\]

Using the Taylor series now,

\[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + f^{\prime\prime}\left( x \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( x \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( x \right)\frac{h^{4}}{4!} + f^{\prime\prime\prime\prime\prime}\left( x \right)\frac{h^{5}}{5!}+...\]

For \(x=0\)

\[f\left( 0 + h \right) = f\left( 0 \right) + f^{\prime}\left( 0 \right)h + f^{\prime\prime}\left( 0 \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( 0 \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( 0 \right)\frac{h^{4}}{4!} + f^{\prime\prime\prime\prime\prime}\left( 0 \right)\frac{h^{5}}{5!} +...\]

\[\begin{split} f\left( h \right) &= f\left( 0 \right) + f^{\prime}\left( 0 \right)h + f^{\prime\prime}\left( 0 \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( 0 \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( 0 \right)\frac{h^{4}}{4!} + f^{\prime\prime\prime\prime\prime}\left( 0 \right)\frac{h^{5}}{5!} + \ldots\\ &= 1 + 1\left( h \right) + 1\frac{h^{2}}{2!} + 1\frac{h^{3}}{3!} + 1\frac{h^{4}}{4} + 1\frac{h^{5}}{5} + \ldots\\ &= 1 + h + \frac{h^{2}}{2!} + \frac{h^{3}}{3!} + \frac{h^{4}}{4} + \frac{h^{5}}{5} + \ldots\end{split}\]

and can be rewritten as\[f\left( x \right) = 1 + x + \frac{x^{2}}{2!} + \frac{x^{3}}{3!} + \frac{x^{4}}{4} + \frac{x^{5}}{5} + \ldots\]

and hence

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

  

Example 2

Take

\[f\left( x \right) = \sin\left( x \right).\]

We all know the value of

\[\sin\left( \frac{\pi}{2} \right) = 1.\]

We also know that

\[f^{\prime}\left( x \right) = \cos\left( x \right) \text{ and } \cos\left( \frac{\pi}{2} \right) = 0.\]

Similarly

\[f^{\prime\prime}\left( x \right) = - \sin(x)\text{ and } \displaystyle \sin\left( \frac{\pi}{2} \right) = 1.\]

In a way, we know the value of \(\sin\left( x \right)\) and all its derivatives at \(\displaystyle x = \frac{\pi}{2}\) without any need for any major calculations. We do not need to use any calculators; just use our knowledge of differential calculus and trigonometry. Can you use the Taylor series and the information above to find the approximate value of \(\sin\left( 2 \right)?\)

Solution

\[{x} = \frac{{\pi}}{{2}}\]

\[x + h = 2\]

\[\begin{split} h &= 2 - x\\ &= 2 - \frac{\pi}{2}\\ &= 0.42920\end{split}\]

Using the Taylor series

\[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + f^{\prime\prime}\left( x \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( x \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( x \right)\frac{h^{4}}{4!} + \ldots\]

and

\[x = \frac{\pi}{2}\]

\[h = 0.42920\]

\[f\left( x \right) = \sin\left( x \right),\ f\left( \frac{\pi}{2} \right) = \sin\left( \frac{\pi}{2} \right)= 1\]

\[f^{\prime}\left( x \right) = \cos\left( x \right),\ f^{\prime}\left( \frac{\pi}{2} \right) = 0\]

\[f^{\prime\prime}\left( x \right) = - \sin\left( x \right),\ f^{\prime\prime}\left( \frac{\pi}{2} \right) = 1\]

\[f^{\prime\prime\prime}\left( x \right) = - \cos(x),\ f^{\prime\prime\prime}\left( \frac{\pi}{2} \right) = 0\]

\[f^{\prime\prime\prime\prime}\left( x \right) = sin(x),\ { f}^{\prime\prime\prime\prime}\left( \frac{\pi}{2} \right) = 1\]

Hence

\[f\left( \frac{\pi}{2} + h \right) = f\left( \frac{\pi}{2} \right) + f^{\prime}\left( \frac{\pi}{2} \right)h + f^{\prime\prime}\left( \frac{\pi}{2} \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( \frac{\pi}{2} \right)\frac{h^{3}}{3!} + {\ f}^{\prime\prime\prime\prime}\left( \frac{\pi}{2} \right)\frac{h^{4}}{4!} + \ldots\]

\[\begin{split} f\left( \frac{\pi}{2} + 0.42920 \right) &= 1 + 0\left( 0.42920 \right) - 1\frac{\left( 0.42920 \right)^{2}}{2!} + 0\frac{\left( 0.42920 \right)^{3}}{3!}\\ & \ \ \ \ \ + 1\frac{\left( 0.42920 \right)^{4}}{4!} + \ldots\\ 0 &= 1 + 0 - 0.092106 + 0 + 0.00141393 + \ldots\\ &\cong 0.90931\end{split}\]

Within five significant digits, the value of \(\sin\left( 2 \right)\) I get from my calculator is \(0.90930,\) which is very close to the value I just obtained. Now you can get a more accurate value by using more terms of the series. In addition, you can now use the value calculated for \(\sin\left( 2 \right)\) coupled with the value of \(\cos\left( 2 \right)\) (which can be calculated by Taylor series just like this example or by using the \(\sin^{2}x + \cos^{2}x \equiv 1\) identity) to find the value of \(\sin\left( x \right)\) at some other point. In this way, we can find the value of \(\sin\left( x \right)\) for any value from \(x = 0\) to \(2\pi\) and then can use the periodicity of \(\sin\left( x \right)\), that is \(\sin\left( x \right) = \sin\left( x \pm 2n\pi \right),n = 1,2,\ldots\) to calculate the value of \(\sin\left( x \right)\) at any other point.

Let’s now revisit how we obtain the Maclaurin series of a function.

  

Example 3

Derive the Maclaurin series of

\[\sin\left( x \right) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \frac{x^{7}}{7!} + \ldots\]

Solution

In Example 2, we wrote the Taylor series for \(\sin\left( x \right)\) around the point \(\displaystyle x = \displaystyle \frac{\pi}{2}\). The Maclaurin series is simply a Taylor series around the point \(x = 0\).

\[f\left( x \right) = \sin\left( x \right),\ f\left( 0 \right) = 0\]

\[f^{\prime}\left( x \right) = \cos\left( x \right),\ f^{\prime}\left( 0 \right) = 1\]

\[f^{\prime\prime}\left( x \right) = - \sin\left( x \right),\ { f}^{\prime\prime}\left( 0 \right) = 0\]

\[f^{\prime\prime\prime}\left( x \right) = - \cos\left( x \right),\ { f}^{\prime\prime\prime}\left( 0 \right) = - 1\]

\[f^{\prime\prime\prime\prime}\left( x \right) = sin(x),\ f^{\prime\prime\prime\prime}\left( 0 \right) = 0\]

\[f^{\prime\prime\prime\prime\prime}\left( x \right) = cos(x),\ f^{\prime\prime\prime\prime\prime}\left( 0 \right) = 1\]

Using the Taylor series now,

\[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + f^{\prime\prime}\left( x \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( x \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( x \right)\frac{h^{4}}{4!} + f^{\prime\prime\prime\prime\prime}\left( x \right)\frac{h^{5}}{5!}\]

Using \(x=0\)

\[f\left( 0 + h \right) = f\left( 0 \right) + f^{\prime}\left( 0 \right)h + f^{\prime\prime}\left( 0 \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( 0 \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( 0 \right)\frac{h^{4}}{4!} + f^{\prime\prime\prime\prime\prime}\left( 0 \right)\frac{h^{5}}{5!}\]

\[\begin{split} f\left( h \right) &= f\left( 0 \right) + f^{\prime}\left( 0 \right)h + f^{\prime\prime}\left( 0 \right)\frac{h^{2}}{2!} + f^{\prime\prime\prime}\left( 0 \right)\frac{h^{3}}{3!} + f^{\prime\prime\prime\prime}\left( 0 \right)\frac{h^{4}}{4!} + f^{\prime\prime\prime\prime\prime}\left( 0 \right)\frac{h^{5}}{5!}\\ &= 0 + 1\left( h \right) - 0\frac{h^{2}}{2!} - 1\frac{h^{3}}{3!} + 0\frac{h^{4}}{4} + 1\frac{h^{5}}{5} + \ldots\\ &= h - \frac{h^{3}}{3!} + \frac{h^{5}}{5!} + \ldots\end{split}\]

So

\[f\left( x \right) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \ldots\]

and hence

\[\sin\left( x \right) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \ldots\]

Multiple Choice Test

(1). The coefficient of the \(x^{5}\) term in the Maclaurin polynomial for \(\sin\left( 2x \right)\) is

(A)  \(0\)

(B)  \(0.0083333\)

(C)  \(0.016667\)

(D)  \(0.26667\)

 

(2). Given \(f\left( 3 \right) = 6\), \(f^{\prime}\left( 3 \right) = 8\), \(f^{\prime\prime}\left( 3 \right) = 11\), and all other higher order derivatives of \(f\left( x \right)\) are zero at \(x = 3\), and assuming the function and all its derivatives exist and are continuous between \(x = 3\) and \(x = 7\), the value of \(f\left( 7 \right)\) is

(A)  \(38.000\)

(B)  \(79.500\)

(C)  \(126.00\)

(D)  \(331.50\)

 

(3). Given that \(y\left( x \right)\) is the solution to \(\displaystyle \frac{{dy}}{{dx}} = y^{3} + 2\), \(y(0) = 3\), the value of \(y\left( 0.2 \right)\) from a second order Taylor polynomial around \(x=0\) is

(A) \(4.400\)

(B) \(8.800\)

(C) \(24.46\)

(D) \(29.00\)

 

(4). The series \(\displaystyle \sum_{n = 0}^{\infty}{\left( - 1 \right)^{n}\frac{x^{2n}}{(2n)!}4^{n}}\) is a Maclaurin series for the following function

(A)  \(\cos\left( x \right)\)

(B)  \(\cos\left( 2x \right)\)

(C)  \(\sin\left( x \right)\)

(D)  \(\sin\left( 2x \right)\)

 

(5). The function \(\displaystyle {\text {erf}}\left( x \right) = \frac{2}{\sqrt{\pi}}\int_{0}^{x}{e^{- t^{2}}{dt}}\) is called the error function. It is used in the field of probability and cannot be calculated exactly. However, one can expand the integrand as a Taylor polynomial and conduct integration. The approximate value of \({\text{erf}}\left( 2.0 \right)\) using the first three terms of the Taylor series around \(t = 0\) is

(A) \(-0.75225\)

(B) \(0.99532\)

(C) \(1.5330\)

(D) \(2.8586\)

 

(6). Using the remainder of Maclaurin polynomial of \(n^{{th}}\)order for \(f\left( x \right)\) defined as

\(\displaystyle R_{n}\left( x \right) = \frac{x^{n + 1}}{\left( n + 1 \right)!}f^{\left( n + 1 \right)}\left( c \right),{\ } n \geq 0,{\ \ }0 \leq c \leq x\)

the order of the Maclaurin polynomial at least required to get an absolute true error of at most \(10^{- 6}\) in the calculation of \(\sin\left( 0.1 \right)\) is (do not use the exact value of \({\sin}\left( 0.1 \right)\) or \({\cos}\left( 0.1 \right)\)to find the answer, but the knowledge that \(|\sin(x)| \leq 1\) and \(|\cos(x)| \leq 1\)).

(A) \(3\)

(B) \(5\)

(C) \(7\)

(D) \(9\)

  

For complete solution, go to

http://nm.mathforcollege.com/mcquizzes/01aae/quiz_01aae_taylorseries_answers.pdf