Taylor polynomial and Maclaurin polynomial
By Bear Pinter
Post a Comment
[Taylor’s Theorem] Suppose $f\in C^{n}[a,b]$ and $f^{(n+1)}$ exists on $[a,b]$. Let $x_{0}$ be a number in $[a,b]$. For every $x$ in $[a,b]$, there exists a number $\xi(x)$ between $x_{0}$ and $x$ with \[f\left(x\right)=P_{n}\left(x\right)+R_{n}\left(x\right)\]
where
\begin{eqnarray*}
P_{n}\left(x\right) & = & f\left(x_{0}\right)+f'\left(x_{0}\right)\left(x-x_{0}\right)+\frac{f''\left(x_{0}\right)}{2!}\left(x-x_{0}\right)^{2}+\cdots\\&+&\frac{f^{\left(n\right)}\left(x_{0}\right)}{n!}\left(x-x_{0}\right)^{n}\\
& = & \sum_{k=0}^{n}\frac{f^{\left(k\right)}\left(x_{0}\right)}{k!}\left(x-x_{0}\right)^{k}
\end{eqnarray*}and
\[R_{n}\left(x\right)=\frac{f^{\left(n+1\right)}\left(\xi\left(x\right)\right)}{\left(n+1\right)!}\left(x-x_{0}\right)^{n+1}\]
\[
f'\left(x\right)=-\sin(x),\,f''\left(x\right)=-\cos(x),\,f'''\left(x\right)=\sin x,\,\text{and}\,f^{\left(4\right)}\left(x\right)=\cos(x)\] so
$$f\left(0\right)=1,\,\, f'\left(0\right)=0,\,\, f''\left(0\right)=-1,\,\,\text{and}\,\, f^{'''}\left(0\right)=0$$
1. For $n=2$ and $x_{0}=0$, we have
\begin{eqnarray*} \cos x & = & f\left(0\right)+f'\left(0\right)+\frac{f''\left(0\right)}{2!}x^{2}+\frac{f'''\left(\xi\left(x\right)\right)}{3!}x^{3}\\ & = & 1-\frac{1}{2}x^{2}+\frac{1}{6}x^{3}\sin\xi\left(x\right)\end{eqnarray*}
where $\xi\left(x\right)$ is some (unknown) number between $0$ and $x$ (See Figure 1.8.)
When $x=0,01$, this becomes
\begin{eqnarray*}\cos0,01 & = & 1-\frac{1}{2}\left(0,01\right)^{2}+\frac{1}{6}\left(0,01\right)^{3}\sin\xi\left(0,01\right)\\ & = & 0,99995+\frac{10^{-6}}{6}\sin\xi\left(0,01\right)\end{eqnarray*}
\left|\cos\left(0,01\right)-0,99995\right|=0,1\bar{6}\times10^{-6}\sin\xi\left(0,01\right)\leq0,1\bar{6}\times10^{-6}\]
The error bound is much larger than the actual error. This is due in part to the poor bound we used for $\left|\sin\xi\left(x\right)\right|$
2. Since $f(0)=0$, the third Taylor polynomial and remainder term about $x_{0}=0$ are
\[
\cos x=1-\frac{1}{2}x^{2}+\frac{1}{24}x^{4}\cos\overset{\sim}{\xi}\left(x\right),
\]
where $\overset{\sim}{\xi}\left(x\right)$ is some number between $0$ and $x$, and likely distinct from the value of $\xi\left(x\right)$ that is associated with the remainder term of the second Taylor polynomial.
\left|\frac{1}{24}x^{4}\cos\overset{\sim}{\xi}\left(x\right)\right|\leq\frac{1}{24}\left(0,01\right)^{4}\left(1\right)\approx4,2\times10^{-10}\]
3. Using the third Taylor polynomial gives
>f:=cos(x);
Maple allows us to place multiple statements on a line, and to use a colon to suppress Maple responses. For example, we obtain the third Taylor polynomial with
>s3:=taylor(f,x=0.4): p3:=convert(s3, polynom);
>Digits:=11;
and evaluate $f(0,01),P_3(0,01)$ and $|f(0,01)-P_3(0,01|$ with
>y1:=evalf(subs(x=0.01,f));
>y2:=evalf(subs(x=0.01,p3));
>err:=abs(y1-y2);
This produces $y_{1}=f(0.01)=0.99995000042,y_{2}=P_{3}(0.01)=0.99995000000,$ and $|f(0.01)-P_{3}(0.01)|$ $=.42\times10^{-9}$
To obtain a graph similar to Figure 1.8, enter
>plot({f,p3},x=-Pi..Pi);
The commands for the integrals are
>q1:=int(f,x=0..0.1);
>q2:=int(p3,x=0..0.1);
>err:=abs(q1-q2);
which give the values
$$q_{1}=\int_{0}^{0,1}f\left(x\right)dx=0.099833416647\,\,\text{and}\,\,$$ $$q_{2}=\int_{0}^{0,1}P_{3}\left(x\right)dx=0.099833333333,$$
with error $0,83314\times10^{-7}=8,3314\times10^{-8}$
Parts (1) and (2) of Example show how two techniques can produce the same approximation but have differing accuracy assurances. Remember that determining approximations is only part of our objective. The equally important other part is to determine at least a bound for the accuracy of the approximation.
where
\begin{eqnarray*}
P_{n}\left(x\right) & = & f\left(x_{0}\right)+f'\left(x_{0}\right)\left(x-x_{0}\right)+\frac{f''\left(x_{0}\right)}{2!}\left(x-x_{0}\right)^{2}+\cdots\\&+&\frac{f^{\left(n\right)}\left(x_{0}\right)}{n!}\left(x-x_{0}\right)^{n}\\
& = & \sum_{k=0}^{n}\frac{f^{\left(k\right)}\left(x_{0}\right)}{k!}\left(x-x_{0}\right)^{k}
\end{eqnarray*}and
\[R_{n}\left(x\right)=\frac{f^{\left(n+1\right)}\left(\xi\left(x\right)\right)}{\left(n+1\right)!}\left(x-x_{0}\right)^{n+1}\]
Here $P_{n}(x)$ is called the nth Taylor polynomial for $f$ about $x_{0}$ , and $R_{n}(x)$ is called the truncation error (or remainder term) associated with $P_{n}(x)$. Since the number $\xi(x)$ in the truncation error $R_{n}(x)$ depends on the value of $x$ at which the polynomial $P_{n}(x)$ is being evaluated, it is actually a function of the variable $x$. However, we should not expect to be able to explicitly determine the function $\xi(x)$. Taylor's Theorem simply ensures that such a function exists, and that its value lies between $x$ and $x_{0}$ . In fact, one of the common problems in numerical methods is to try to determine a realistic bound for the value of $f^{(n+1)}(\xi(x))$ for values of $x$ within some specified interval.
The infinite series obtained by taking the limit of $P_{n}(x)$ as $n\to\infty$ is called the Taylor series for $f$ about $x_{0}$ . In the case $x_{0}=0$, the Taylor polynomial is often called a Maclaurin polynomial, and the Taylor series is called a Maclaurin series.
The term truncation error in the Taylor polynomial refers to the error involved in using a truncated (that is, finite) summation to approximate the sum of an infinite series.
Example
Determine- the second and
- the third Taylor polynomials for $f(x)=\cos x$ about $x_{0}=0$, and use these polynomials to approximate $\cos(0,01)$.
- Use the third Taylor polynomial and its remainder term to approximate ${\displaystyle \int_{0}^{0,1}\cos x\, dx}$.
\[
f'\left(x\right)=-\sin(x),\,f''\left(x\right)=-\cos(x),\,f'''\left(x\right)=\sin x,\,\text{and}\,f^{\left(4\right)}\left(x\right)=\cos(x)\] so
$$f\left(0\right)=1,\,\, f'\left(0\right)=0,\,\, f''\left(0\right)=-1,\,\,\text{and}\,\, f^{'''}\left(0\right)=0$$
1. For $n=2$ and $x_{0}=0$, we have
\begin{eqnarray*} \cos x & = & f\left(0\right)+f'\left(0\right)+\frac{f''\left(0\right)}{2!}x^{2}+\frac{f'''\left(\xi\left(x\right)\right)}{3!}x^{3}\\ & = & 1-\frac{1}{2}x^{2}+\frac{1}{6}x^{3}\sin\xi\left(x\right)\end{eqnarray*}
where $\xi\left(x\right)$ is some (unknown) number between $0$ and $x$ (See Figure 1.8.)
Figure 1.8 |
\begin{eqnarray*}\cos0,01 & = & 1-\frac{1}{2}\left(0,01\right)^{2}+\frac{1}{6}\left(0,01\right)^{3}\sin\xi\left(0,01\right)\\ & = & 0,99995+\frac{10^{-6}}{6}\sin\xi\left(0,01\right)\end{eqnarray*}
The approximation to cos $0,01$ given by the Taylor polynomial is therefore $0,99995$. The truncation error, or remainder term, associated with this approximation is
$$\frac{10^{-6}}{6}\sin\xi\left(0,01\right)=0,1\bar{6}\times10^{-6}\sin\xi\left(0,01\right)$$
where the bar over the 6 in $0,1\bar{6}$ is used to indicate that this digit repeats indefinitely. Although we have no way of determining $\sin\xi\left(0,01\right)$, we know that all values of the sine lie in the interval $[-1,1]$, so the error occurring if we use the approximation $0,99995$ for the value of $\cos0,01$ is bounded by
\[\left|\cos\left(0,01\right)-0,99995\right|=0,1\bar{6}\times10^{-6}\sin\xi\left(0,01\right)\leq0,1\bar{6}\times10^{-6}\]
Hence the approximation $0,99995$ matches at least the first five digits of $\cos0,01$. Using standard tables we find that $\cos0,01=0,99995000042$, so the approximation actually gives agreement through the first nine digits.
The error bound is much larger than the actual error. This is due in part to the poor bound we used for $\left|\sin\xi\left(x\right)\right|$
It can be shown that or all values of $x$, we have $\left|\sin x\right|\leq\left|x\right|$. Since $0<\xi\left(x\right)<0,01$, we could have used the fact that $\left|\sin\xi\left(x\right)\right|\leq0,01$ in the error formula, producing the bound $0,1\bar{6}\times10^{-8}$
2. Since $f(0)=0$, the third Taylor polynomial and remainder term about $x_{0}=0$ are
\[
\cos x=1-\frac{1}{2}x^{2}+\frac{1}{24}x^{4}\cos\overset{\sim}{\xi}\left(x\right),
\]
where $\overset{\sim}{\xi}\left(x\right)$ is some number between $0$ and $x$, and likely distinct from the value of $\xi\left(x\right)$ that is associated with the remainder term of the second Taylor polynomial.
Notice that the second and third Taylor polynomials are the same, so the approximation to $\cos0,01$ is still $0,99995$. However, we now have a much better accuracy assurance. Since $\left|\cos\overset{\sim}{\xi}\left(x\right)\right|\leq1$ for all $x$, when $x=0,01$ we have
\[\left|\frac{1}{24}x^{4}\cos\overset{\sim}{\xi}\left(x\right)\right|\leq\frac{1}{24}\left(0,01\right)^{4}\left(1\right)\approx4,2\times10^{-10}\]
The first two parts of the example illustrate the two objectives of numerical analysis:
(i) Find an approximation to the solution of a given problem.
(ii) Determine a bound for the accuracy of the approximation.
The Taylor polynomials in both parts provide the same answer to (i), but the third Taylor polynomial gave a much better answer to (ii) than the second Taylor polynomial.
3. Using the third Taylor polynomial gives
\begin{eqnarray*}
\int_{0}^{0,1}\cos x\, dx & = & \int_{0}^{0,1}\left(1-\frac{1}{2}x^{2}\right)dx+\frac{1}{24}\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx\\
& = & \left[x-\frac{1}{6}x^{3}\right]_{0}^{0,1}+\frac{1}{24}\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx\\
& = & 0,1-\frac{1}{6}\left(0,1\right)^{3}+\frac{1}{24}\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx
\end{eqnarray*}
Therefore,
\[\int_{0}^{0,1}\cos x\, dx\approx0,1-\frac{1}{6}\left(0,1\right)^{3}=0,0998\bar{3}\]
A bound for the error in this approximation is determined from the integral of the Taylor remainder term and the fact that $\left|\cos\overset{\sim}{\xi}\left(x\right)\right|\leq1$ for all $x$ :
\[
\frac{1}{24}\left|\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx\right|\leq\frac{1}{24}\int_{0}^{0,2}x^{4}\left|\cos\overset{\sim}{\xi}\left(x\right)\right|dx\leq\frac{1}{24}\int_{0}^{0,1}x^{4}dx=8,\bar{3}\times10^{-8}\]
The true value of this integral can be easily determined as
\[\int_{0}^{0,1}\cos xdx=\sin x]_{0}^{0,1}=\sin0,1\]
The true value of $\sin0,1$ to nine decimal places is $0,099833417$, so the approximation derived from the Taylor polynomial is in error by
\[
\left|0,099833417-0,0998\bar{3}\right|\approx8,4\times10^{-8},
\]
which is essentially the same as the error bound derived from the Taylor polynomial. $\square$
\int_{0}^{0,1}\cos x\, dx & = & \int_{0}^{0,1}\left(1-\frac{1}{2}x^{2}\right)dx+\frac{1}{24}\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx\\
& = & \left[x-\frac{1}{6}x^{3}\right]_{0}^{0,1}+\frac{1}{24}\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx\\
& = & 0,1-\frac{1}{6}\left(0,1\right)^{3}+\frac{1}{24}\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx
\end{eqnarray*}
Therefore,
\[\int_{0}^{0,1}\cos x\, dx\approx0,1-\frac{1}{6}\left(0,1\right)^{3}=0,0998\bar{3}\]
A bound for the error in this approximation is determined from the integral of the Taylor remainder term and the fact that $\left|\cos\overset{\sim}{\xi}\left(x\right)\right|\leq1$ for all $x$ :
\[
\frac{1}{24}\left|\int_{0}^{0,1}x^{4}\cos\overset{\sim}{\xi}\left(x\right)dx\right|\leq\frac{1}{24}\int_{0}^{0,2}x^{4}\left|\cos\overset{\sim}{\xi}\left(x\right)\right|dx\leq\frac{1}{24}\int_{0}^{0,1}x^{4}dx=8,\bar{3}\times10^{-8}\]
The true value of this integral can be easily determined as
\[\int_{0}^{0,1}\cos xdx=\sin x]_{0}^{0,1}=\sin0,1\]
The true value of $\sin0,1$ to nine decimal places is $0,099833417$, so the approximation derived from the Taylor polynomial is in error by
\[
\left|0,099833417-0,0998\bar{3}\right|\approx8,4\times10^{-8},
\]
which is essentially the same as the error bound derived from the Taylor polynomial. $\square$
We can use a computer algebra system to simplify the calculations in Example 3. In the system Maple, we define $f$ by
>f:=cos(x);
Maple allows us to place multiple statements on a line, and to use a colon to suppress Maple responses. For example, we obtain the third Taylor polynomial with
>s3:=taylor(f,x=0.4): p3:=convert(s3, polynom);
The statement s3:=taylor(f,x=0.4) determines the Taylor polynomial about $x_0=0$ with four terms (degree 3) and its remainder. The statement p3:=convert(s3,polynom) converts the series s3 to the polynomial p3 by dropping the remainder. To obtain 11 decimal digits of display, we enter
>Digits:=11;
and evaluate $f(0,01),P_3(0,01)$ and $|f(0,01)-P_3(0,01|$ with
>y1:=evalf(subs(x=0.01,f));
>y2:=evalf(subs(x=0.01,p3));
>err:=abs(y1-y2);
This produces $y_{1}=f(0.01)=0.99995000042,y_{2}=P_{3}(0.01)=0.99995000000,$ and $|f(0.01)-P_{3}(0.01)|$ $=.42\times10^{-9}$
To obtain a graph similar to Figure 1.8, enter
>plot({f,p3},x=-Pi..Pi);
The commands for the integrals are
>q1:=int(f,x=0..0.1);
>q2:=int(p3,x=0..0.1);
>err:=abs(q1-q2);
which give the values
$$q_{1}=\int_{0}^{0,1}f\left(x\right)dx=0.099833416647\,\,\text{and}\,\,$$ $$q_{2}=\int_{0}^{0,1}P_{3}\left(x\right)dx=0.099833333333,$$
with error $0,83314\times10^{-7}=8,3314\times10^{-8}$
Parts (1) and (2) of Example show how two techniques can produce the same approximation but have differing accuracy assurances. Remember that determining approximations is only part of our objective. The equally important other part is to determine at least a bound for the accuracy of the approximation.
No comments for "Taylor polynomial and Maclaurin polynomial"
Post a Comment