Chapter 9 ยท Power Series

9.3 Taylor and Maclaurin Series

Build polynomials that copy a function's value and derivatives at one point, measure exactly how wrong they are, and let the degree go to infinity to get the series for $e^x$, $\sin x$ and $\cos x$.

How does a calculator find $e^{0.1}$ or $\sin(0.3)$? It has no table of values and it certainly cannot "draw the graph". What it can do quickly is add and multiply. So the real question is: can a complicated function be replaced by a polynomial, and if so, how large is the mistake? In Calculus I the tangent line $L(x)=f(a)+f^\prime(a)(x-a)$ was our first answer โ€” a degree-one polynomial that matches the value and the slope of $f$ at $x=a$. It is excellent very close to $a$ and poor further away.

In this section we push the same idea as far as it will go. Matching the second derivative as well gives a parabola that also bends the right way; matching more derivatives gives polynomials that hug the curve over wider and wider intervals. Taylor's theorem then tells us precisely how big the error is, and letting the degree run to infinity produces the Taylor series โ€” the power series that a function "wants" to be. In Sections 9.1โ€“9.2 we started with a series and asked which function it represents; now we go the other way and start from the function.

Taylor Polynomials

Suppose we want a polynomial $p$ of degree $n$ whose value and first $n$ derivatives agree with those of $f$ at $x=a$. Write $$p(x)=c_0+c_1(x-a)+c_2(x-a)^2+\dots+c_n(x-a)^n.$$ Differentiating $k$ times and putting $x=a$ kills every term except one: $p^{(k)}(a)=k!\,c_k$. So the matching conditions $p^{(k)}(a)=f^{(k)}(a)$ force $$c_k=\frac{f^{(k)}(a)}{k!},\qquad k=0,1,\dots,n.$$ There is no choice to make โ€” the coefficients are completely determined by the derivatives of $f$ at the single point $a$.

๐Ÿ“˜ Definition 9.3 โ€” Taylor polynomial
Let $f$ have derivatives up to order $n$ at $x=a$. The Taylor polynomial of degree $n$ of $f$ about $a$ (or "centred at $a$") is $$p_n(x)=\sum_{k=0}^{n}\frac{f^{(k)}(a)}{k!}(x-a)^k=f(a)+f^\prime(a)(x-a)+\frac{f^{\prime\prime}(a)}{2!}(x-a)^2+\dots+\frac{f^{(n)}(a)}{n!}(x-a)^n.$$ It is the only polynomial of degree at most $n$ with $p_n^{(k)}(a)=f^{(k)}(a)$ for $k=0,1,\dots,n$. When $a=0$ it is called the Maclaurin polynomial of degree $n$. Note that $p_1$ is the tangent line (the linear approximation) from Calculus I, and $0!=1$, $f^{(0)}=f$.
โœ๏ธ Example 1 โ€” Taylor polynomials of $\ln x$ about $a=1$
Find the Taylor polynomials $p_1$, $p_2$ and $p_3$ of $f(x)=\ln x$ about $a=1$, and use $p_3$ to approximate $\ln(1.1)$.
Derivatives $$\begin{array}{lll} f(x)=\ln x & & f(1)=0\\ f^\prime(x)=x^{-1} & & f^\prime(1)=1\\ f^{\prime\prime}(x)=-x^{-2} & & f^{\prime\prime}(1)=-1\\ f^{\prime\prime\prime}(x)=2x^{-3} & & f^{\prime\prime\prime}(1)=2\end{array}$$
Coefficients $c_0=0$, $c_1=1$, $c_2=\dfrac{-1}{2!}=-\dfrac12$, $c_3=\dfrac{2}{3!}=\dfrac13$. Hence $$p_1(x)=(x-1),\qquad p_2(x)=(x-1)-\frac{(x-1)^2}{2},\qquad p_3(x)=(x-1)-\frac{(x-1)^2}{2}+\frac{(x-1)^3}{3}.$$
Approximate With $x-1=0.1$: $$\ln(1.1)\approx p_3(1.1)=0.1-0.005+0.000\,333\ldots=0.095\,333.$$
Check A calculator gives $\ln(1.1)=0.095\,310\,2$, so the error is about $2.3\times10^{-5}$. In Example 3 we will predict this size without a calculator.
โœ๏ธ Example 2 โ€” Maclaurin polynomials of $\sin x$ and $\cos x$
Find the Maclaurin polynomials of $\sin x$ up to degree $5$ and of $\cos x$ up to degree $4$. Use $p_5$ to approximate $\sin\left(\tfrac{\pi}{6}\right)$.
Pattern The derivatives of $\sin x$ cycle with period four: $\sin x,\ \cos x,\ -\sin x,\ -\cos x,\ \sin x,\dots$ At $x=0$ they take the values $0,\ 1,\ 0,\ -1,\ 0,\ 1,\dots$ So only odd powers survive and their signs alternate.
Sine $$p_1(x)=p_2(x)=x,\qquad p_3(x)=p_4(x)=x-\frac{x^3}{3!},\qquad p_5(x)=p_6(x)=x-\frac{x^3}{3!}+\frac{x^5}{5!}.$$ Because every even-order coefficient is $0$, the polynomial does not change when we go from an odd degree to the next even degree.
Cosine The derivatives of $\cos x$ at $0$ are $1,0,-1,0,1,\dots$, so only even powers appear: $$p_0(x)=p_1(x)=1,\qquad p_2(x)=p_3(x)=1-\frac{x^2}{2!},\qquad p_4(x)=1-\frac{x^2}{2!}+\frac{x^4}{4!}.$$
Approximate With $x=\tfrac{\pi}{6}\approx0.523\,599$: $$p_5\!\left(\tfrac{\pi}{6}\right)=0.523\,599-0.023\,925+0.000\,328=0.500\,002.$$ The exact value is $\tfrac12$, so three terms already give five correct decimal places (error about $2\times10^{-6}$).
Interactive 1 โ€” Taylor Polynomials Hugging a Curve

The black curve is $f$; the blue curve is its Taylor polynomial $p_n$ about the centre $a$ (dot). Press Play to raise the degree $n$ one step at a time and watch the region where $p_n$ hugs $f$ grow. Drag the $x$ slider: the orange segment is the error $|f(x)-p_n(x)|$ at that point.

degree $n$โ€”
$x$โ€”
$f(x)$โ€”
$p_n(x)$โ€”
error $|f(x)-p_n(x)|$โ€”

Taylor's Theorem: How Big Is the Error?

An approximation is only useful if we know how good it is. Define the remainder $R_n(x)=f(x)-p_n(x)$, the exact error made by $p_n$. The next theorem gives a formula for $R_n$ that looks just like the next term of the polynomial โ€” except that the derivative is evaluated at some unknown point $c$ instead of at $a$. For $n=0$ it says $f(x)-f(a)=f^\prime(c)(x-a)$, which is exactly the Mean Value Theorem; Taylor's theorem is its higher-order big brother.

๐Ÿ“ Theorem 9.6 โ€” Taylor's theorem with the Lagrange remainder
Let $n\ge0$ be an integer and let $f$ have derivatives up to order $n+1$ at every point of an open interval $I$ containing $a$. Let $p_n$ be the Taylor polynomial of degree $n$ of $f$ about $a$. Then for every $x$ in $I$, $$f(x)=p_n(x)+R_n(x),\qquad R_n(x)=\frac{f^{(n+1)}(c)}{(n+1)!}(x-a)^{n+1}$$ for some number $c$ strictly between $a$ and $x$ (take $c=a$ when $x=a$).
Error bound. If $\left|f^{(n+1)}(t)\right|\le M$ for every $t$ between $a$ and $x$, then $$\left|R_n(x)\right|\le\frac{M}{(n+1)!}\,|x-a|^{n+1}.$$
Idea Fix $x\ne a$ in $I$ and let $K$ be the number with $f(x)=p_n(x)+K(x-a)^{n+1}$. We must show $K=\dfrac{f^{(n+1)}(c)}{(n+1)!}$ for some $c$ between $a$ and $x$. We do it by building a function to which Rolle's theorem applies.
Auxiliary function For $t$ between $a$ and $x$ define $$g(t)=f(x)-\sum_{k=0}^{n}\frac{f^{(k)}(t)}{k!}(x-t)^k-K(x-t)^{n+1}.$$ This is the Taylor-polynomial error with the centre moved to $t$. Then $g(x)=f(x)-f(x)-0=0$ and $g(a)=f(x)-p_n(x)-K(x-a)^{n+1}=0$. Since $f^{(n+1)}$ exists on $I$, every $f^{(k)}$ with $k\le n$ is differentiable, so $g$ is continuous and differentiable between $a$ and $x$.
Telescoping Differentiating with the product rule, almost everything cancels in pairs: $$g^\prime(t)=-\frac{f^{(n+1)}(t)}{n!}(x-t)^n+(n+1)K(x-t)^n.$$
Rolle By Rolle's theorem there is $c$ strictly between $a$ and $x$ with $g^\prime(c)=0$. As $x-c\ne0$, dividing by $(x-c)^n$ gives $(n+1)K=\dfrac{f^{(n+1)}(c)}{n!}$, i.e. $K=\dfrac{f^{(n+1)}(c)}{(n+1)!}$. The error bound follows by replacing $\left|f^{(n+1)}(c)\right|$ with its upper bound $M$. $\blacksquare$
๐Ÿงญ Problem-solving strategy โ€” bounding a Taylor error
  1. Identify $f$, the centre $a$, the degree $n$ and the point (or interval) of $x$-values.
  2. Compute $f^{(n+1)}(t)$ โ€” one derivative beyond the degree of the polynomial.
  3. Find a number $M$ with $\left|f^{(n+1)}(t)\right|\le M$ for all $t$ between $a$ and $x$ (we do not know where $c$ is, so we must cover every possibility). Any honest upper bound will do; it does not have to be the best one.
  4. Evaluate $\dfrac{M}{(n+1)!}|x-a|^{n+1}$.
  5. To choose $n$ for a required accuracy $\varepsilon$, increase $n$ until this bound is less than $\varepsilon$.
โœ๏ธ Example 3 โ€” Bounding the error in $\ln(1.1)\approx p_3(1.1)$
Use Taylor's theorem to bound the error in the approximation $\ln(1.1)\approx0.095\,333$ from Example 1, and compare with the actual error.
Next derivative $n=3$, so we need $f^{(4)}(t)=-6t^{-4}$.
Bound it For $1\le t\le1.1$ we have $t^4\ge1$, so $\left|f^{(4)}(t)\right|=\dfrac{6}{t^4}\le6=M$.
Error bound $$\left|R_3(1.1)\right|\le\frac{6}{4!}(0.1)^4=\frac{6}{24}\times0.0001=0.000\,025.$$
Check The actual error is $|0.095\,310\,2-0.095\,333\,3|\approx0.000\,023\,2$, which is indeed below $0.000\,025$ โ€” and the bound turns out to be remarkably tight. (In fact $R_3(1.1)\lt0$ because $f^{(4)}\lt0$: $p_3$ overestimates.)
โœ๏ธ Example 4 โ€” Choosing the degree: computing $e$ to five decimal places
How large must $n$ be so that the Maclaurin polynomial $p_n(x)=\displaystyle\sum_{k=0}^n\frac{x^k}{k!}$ of $e^x$ gives $e=e^1$ with error less than $10^{-5}$? Compute the approximation.
Remainder Every derivative of $e^x$ is $e^x$, so $R_n(1)=\dfrac{e^c}{(n+1)!}$ with $0\lt c\lt1$. Since $e^c\lt e\lt3$, $$0\lt R_n(1)\lt\frac{3}{(n+1)!}.$$ (We must not use the value of $e$ we are trying to compute โ€” the crude bound $e\lt3$ is enough.)
Choose $n$ We need $(n+1)!\gt300\,000$. Since $8!=40\,320$ and $9!=362\,880$, the smallest choice is $n+1=9$, i.e. $n=8$: the bound is $3/9!\approx8.3\times10^{-6}\lt10^{-5}$.
Compute $$p_8(1)=1+1+\frac12+\frac16+\frac1{24}+\frac1{120}+\frac1{720}+\frac1{5040}+\frac1{40\,320}\approx2.718\,279.$$
Check $e=2.718\,281\,8\ldots$; the actual error is $3.1\times10^{-6}$. With $n=7$ the actual error would be $2.8\times10^{-5}$ โ€” too big โ€” so $n=8$ really is needed.
โœ๏ธ Example 5 โ€” An error bound over a whole interval
Engineers often replace $\sin x$ by $x-\dfrac{x^3}{6}$ for small angles. Find the largest possible error when $|x|\le0.5$.
Use the hidden term From Example 2, $x-\tfrac{x^3}{6}$ is $p_3$ and $p_4$ for $\sin x$. Using it as $p_4$ gives a better bound, because the remainder then involves $|x|^5$ instead of $|x|^4$.
Bound $f^{(5)}(t)=\cos t$, so $M=1$ works for every $t$. For $|x|\le0.5$: $$\left|R_4(x)\right|\le\frac{1}{5!}|x|^5\le\frac{(0.5)^5}{120}=\frac{0.031\,25}{120}\approx2.60\times10^{-4}.$$
Check At $x=0.5$: $\sin(0.5)=0.479\,425\,5$ and $0.5-\tfrac{0.125}{6}=0.479\,166\,7$, an error of $2.59\times10^{-4}$ โ€” just under the bound. โœ“
โš ๏ธ Common mistakes with Taylor's theorem

1. Forgetting the factorial. The coefficient is $f^{(k)}(a)/k!$, not $f^{(k)}(a)$. Without the factorial, the derivatives of $p_n$ at $a$ would be wrong from the second one onwards.

2. Bounding the wrong derivative. The error of $p_n$ involves $f^{(n+1)}$, one order higher than the polynomial.

3. Bounding at a single point. $c$ is unknown, so $M$ must bound $\left|f^{(n+1)}\right|$ on the whole interval between $a$ and $x$. Using $\left|f^{(4)}(1.1)\right|$ in Example 3 would have given a number that is too small.

4. "Degree $n$" is not "$n$ terms". For $\sin x$, $p_3$ and $p_4$ are the same polynomial with two non-zero terms.

Interactive 2 โ€” The Lagrange Bound versus the Actual Error

For a fixed $x$, the chart shows the error of every $p_n$ ($n=0,\dots,14$) on a logarithmic scale: each grid step down is ten times smaller. Blue dots are the actual errors $|f(x)-p_n(x)|$; red squares are the Lagrange bounds $\tfrac{M}{(n+1)!}|x-a|^{n+1}$. The red must always sit on or above the blue. Play sweeps $x$; choose $n$ to read off one column.

$x$ and $n$โ€”
actual error $|R_n(x)|$โ€”
Lagrange boundโ€”
bound รท actualโ€”

Taylor and Maclaurin Series

If $f$ has derivatives of every order at $a$, nothing stops us letting $n\to\infty$. The Taylor polynomials are then the partial sums of a power series.

๐Ÿ“˜ Definition 9.4 โ€” Taylor series and Maclaurin series
Let $f$ have derivatives of all orders at $x=a$. The Taylor series of $f$ about $a$ is the power series $$\sum_{n=0}^{\infty}\frac{f^{(n)}(a)}{n!}(x-a)^n=f(a)+f^\prime(a)(x-a)+\frac{f^{\prime\prime}(a)}{2!}(x-a)^2+\cdots$$ Its $n$-th partial sum is the Taylor polynomial $p_n(x)$. When $a=0$ it is called the Maclaurin series of $f$. A function that equals its Taylor series on some open interval around $a$ is called analytic at $a$.

Why should these particular coefficients be the right ones? Because there is no other choice: if a function is given by any power series, that series must be its Taylor series.

๐Ÿ“ Theorem 9.7 โ€” Uniqueness of power series representations
Suppose $f(x)=\displaystyle\sum_{n=0}^\infty c_n(x-a)^n$ for all $x$ with $|x-a|\lt R$, where the radius of convergence $R$ is positive (possibly $\infty$). Then $f$ has derivatives of all orders on $(a-R,\,a+R)$ and $$c_n=\frac{f^{(n)}(a)}{n!}\qquad\text{for every }n\ge0.$$ (This restates Theorem 9.5 of Section 9.2.) Reason: by term-by-term differentiation (Section 9.2), $f^{(n)}(x)=n!\,c_n+(\text{terms containing }(x-a))$; put $x=a$.

So the Taylor series is the only candidate. But a candidate is not a guarantee: the Taylor series might converge to something other than $f(x)$. Since $p_n$ is the $n$-th partial sum and $f(x)-p_n(x)=R_n(x)$, the series converges to $f(x)$ exactly when the remainder dies away.

๐Ÿ“ Theorem 9.8 โ€” When a function equals its Taylor series
Let $f$ have derivatives of all orders on an open interval $I$ containing $a$, and let $R_n(x)=f(x)-p_n(x)$. For $x$ in $I$, $$f(x)=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n\quad\Longleftrightarrow\quad\lim_{n\to\infty}R_n(x)=0.$$ A convenient test. If there is one constant $M$ with $\left|f^{(n)}(t)\right|\le M$ for all $n$ and all $t$ in $I$, then $|R_n(x)|\le\dfrac{M|x-a|^{n+1}}{(n+1)!}\to0$, so $f$ equals its Taylor series on all of $I$. (We use $\displaystyle\lim_{n\to\infty}\frac{r^{n}}{n!}=0$ for every real $r$ โ€” see Section 8.1.)
โœ๏ธ Example 6 โ€” $e^x$ equals its Maclaurin series for every $x$
Find the Maclaurin series of $e^x$, its radius of convergence, and prove that it converges to $e^x$ for every real $x$.
Series $f^{(n)}(x)=e^x$, so $f^{(n)}(0)=1$ and the Maclaurin series is $\displaystyle\sum_{n=0}^\infty\frac{x^n}{n!}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots$
Radius Ratio test: $\left|\dfrac{x^{n+1}/(n+1)!}{x^n/n!}\right|=\dfrac{|x|}{n+1}\to0\lt1$ for every $x$, so $R=\infty$. The series converges everywhere โ€” but we still have to show its sum is $e^x$.
Remainder Fix any $x$ and let $b=|x|$. For $t$ between $0$ and $x$, $\left|f^{(n+1)}(t)\right|=e^t\le e^{b}$. By Theorem 9.6, $$|R_n(x)|\le\frac{e^{b}}{(n+1)!}\,b^{\,n+1}.$$ Here $e^{b}$ is a constant (it does not depend on $n$) and $\dfrac{b^{n+1}}{(n+1)!}\to0$ (it is the general term of the convergent series we just found). So $R_n(x)\to0$.
Conclude By Theorem 9.8, $$e^x=\sum_{n=0}^\infty\frac{x^n}{n!}\quad\text{for every real }x.$$ In particular $e=\displaystyle\sum_{n=0}^\infty\frac1{n!}$, which is how Example 4 computed it.

The same argument with $M=1$ (every derivative of $\sin$ or $\cos$ is $\pm\sin$ or $\pm\cos$) shows that $\sin x$ and $\cos x$ equal their Maclaurin series for every $x$. Together with the geometric series from Section 9.1 we obtain the four series that the rest of the chapter is built on.

๐Ÿ“ Theorem 9.9 โ€” The standard Maclaurin series
$$\begin{array}{lll} e^x=\displaystyle\sum_{n=0}^\infty\frac{x^n}{n!}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots & & \text{all real }x\ (R=\infty)\\[8pt] \sin x=\displaystyle\sum_{n=0}^\infty\frac{(-1)^nx^{2n+1}}{(2n+1)!}=x-\frac{x^3}{3!}+\frac{x^5}{5!}-\cdots & & \text{all real }x\ (R=\infty)\\[8pt] \cos x=\displaystyle\sum_{n=0}^\infty\frac{(-1)^nx^{2n}}{(2n)!}=1-\frac{x^2}{2!}+\frac{x^4}{4!}-\cdots & & \text{all real }x\ (R=\infty)\\[8pt] \dfrac{1}{1-x}=\displaystyle\sum_{n=0}^\infty x^n=1+x+x^2+x^3+\cdots & & -1\lt x\lt1\ (R=1) \end{array}$$
For $\dfrac1{1-x}$ we have $f^{(n)}(x)=\dfrac{n!}{(1-x)^{n+1}}$, so $f^{(n)}(0)/n!=1$: the Taylor series is the geometric series, which sums to $\dfrac1{1-x}$ exactly when $|x|\lt1$.
โš ๏ธ A smooth function that is not its Taylor series

Converging is not the same as converging to $f$. Consider $$f(x)=\begin{cases}e^{-1/x^2}, & x\ne0,\\ 0, & x=0.\end{cases}$$ For $x\ne0$ every derivative has the form $f^{(n)}(x)=P_n\!\left(\tfrac1x\right)e^{-1/x^2}$ for some polynomial $P_n$, and $e^{-1/x^2}$ goes to $0$ faster than any power of $\tfrac1x$ grows. Using the limit definition of the derivative one finds, step by step, $f^\prime(0)=f^{\prime\prime}(0)=\dots=0$ (Exercise IV.3 does the first one). So the Maclaurin series of $f$ is $$0+0x+0x^2+\cdots=0,$$ which converges for every $x$ โ€” to the zero function. But $f(x)\gt0$ for every $x\ne0$. This $f$ has derivatives of all orders yet is not analytic at $0$; here $R_n(x)=f(x)$ for all $n$, which does not tend to $0$. The moral: always check that $R_n(x)\to0$ (Theorem 9.8). For $e^x$, $\sin x$, $\cos x$ and the other functions of this chapter we have done exactly that.

Exercises

I
Find the requested Taylor polynomial.
  • 1 $p_4(x)$ for $f(x)=e^{2x}$ about $a=0$.
  • 2 $p_3(x)$ for $f(x)=\cos x$ about $a=\tfrac{\pi}{3}$.
  • 3 $p_3(x)$ for $f(x)=\sqrt x$ about $a=4$.
  • 4 $p_4(x)$ for $f(x)=\ln(1+x)$ about $a=0$.
  • 5 $p_3(x)$ for $f(x)=\dfrac1x$ about $a=2$.
  • 6 $p_3(x)$ for $f(x)=\tan x$ about $a=0$.
  • 7 $p_4(x)$ for $f(x)=xe^x$ about $a=0$.
  • 8 Use $p_2$ of $\sqrt x$ about $a=4$ to estimate $\sqrt{4.1}$, and compare with a calculator.
1 $f^{(k)}(x)=2^ke^{2x}$, so $c_k=\dfrac{2^k}{k!}$: $$p_4(x)=1+2x+2x^2+\frac43x^3+\frac23x^4.$$
2 At $\tfrac\pi3$: $f=\tfrac12$, $f^\prime=-\sin=-\tfrac{\sqrt3}{2}$, $f^{\prime\prime}=-\cos=-\tfrac12$, $f^{\prime\prime\prime}=\sin=\tfrac{\sqrt3}{2}$: $$p_3(x)=\frac12-\frac{\sqrt3}{2}\left(x-\tfrac\pi3\right)-\frac14\left(x-\tfrac\pi3\right)^2+\frac{\sqrt3}{12}\left(x-\tfrac\pi3\right)^3.$$
3 $f(4)=2$, $f^\prime=\tfrac12x^{-1/2}\to\tfrac14$, $f^{\prime\prime}=-\tfrac14x^{-3/2}\to-\tfrac1{32}$, $f^{\prime\prime\prime}=\tfrac38x^{-5/2}\to\tfrac3{256}$: $$p_3(x)=2+\frac{x-4}{4}-\frac{(x-4)^2}{64}+\frac{(x-4)^3}{512}.$$
4 $f^{(k)}(x)=\dfrac{(-1)^{k+1}(k-1)!}{(1+x)^k}$ for $k\ge1$, so $c_k=\dfrac{(-1)^{k+1}}{k}$: $$p_4(x)=x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}.$$
5 $f^{(k)}(x)=\dfrac{(-1)^kk!}{x^{k+1}}$, so $c_k=\dfrac{(-1)^k}{2^{k+1}}$: $$p_3(x)=\frac12-\frac{x-2}{4}+\frac{(x-2)^2}{8}-\frac{(x-2)^3}{16}.$$
6 $f^\prime=\sec^2x$, $f^{\prime\prime}=2\sec^2x\tan x$, $f^{\prime\prime\prime}=4\sec^2x\tan^2x+2\sec^4x$. At $0$: $f=0$, $f^\prime=1$, $f^{\prime\prime}=0$, $f^{\prime\prime\prime}=2$. So $p_3(x)=x+\dfrac{2}{3!}x^3=x+\dfrac{x^3}{3}$.
7 By induction $f^{(k)}(x)=(x+k)e^x$, so $f^{(k)}(0)=k$ and $c_k=\dfrac{k}{k!}=\dfrac{1}{(k-1)!}$ for $k\ge1$: $$p_4(x)=x+x^2+\frac{x^3}{2}+\frac{x^4}{6}.$$
8 $p_2(4.1)=2+\dfrac{0.1}{4}-\dfrac{0.01}{64}=2.024\,844$. A calculator gives $\sqrt{4.1}=2.024\,846$, an error of about $1.9\times10^{-6}$.
II
Error estimates with Taylor's theorem (Theorem 9.6).
  • 1 Bound the error when $e^{0.2}$ is approximated by $p_3(0.2)$ for $e^x$ about $0$. Compare with the actual error.
  • 2 Bound the error in $\cos x\approx1-\dfrac{x^2}{2}$ for $|x|\le0.2$.
  • 3 What is the smallest $n$ for which the Maclaurin polynomial $p_n$ of $e^x$ is guaranteed to give $e^{0.5}$ with error less than $10^{-6}$?
  • 4 Approximate $\sin(0.1)$ by $0.1-\dfrac{(0.1)^3}{6}$ and bound the error.
  • 5 Approximate $\ln(1.2)$ using $p_3$ of $\ln x$ about $a=1$ and bound the error.
  • 6 For which $x$ does $\sin x\approx x$ have error less than $0.001$, according to Taylor's theorem? Give the answer in degrees as well.
  • 7 Use $p_2$ of $f(x)=x^{1/3}$ about $a=8$ to estimate $\sqrt[3]{8.1}$, and bound the error.
  • 8 Challenge. Show that for every $n\ge0$, $$\frac{1}{(n+1)!}\lt e-\sum_{k=0}^n\frac1{k!}\lt\frac{e}{(n+1)!}.$$
Check: compare the approximation, the true value and the error bound
approximationโ€”
true valueโ€”
actual errorโ€”
Taylor boundโ€”
1 $p_3(0.2)=1+0.2+0.02+0.001\,333=1.221\,333$. $f^{(4)}(t)=e^t\le e^{0.2}\lt1.23$ on $[0,0.2]$, so $|R_3|\le\dfrac{1.23}{24}(0.2)^4\approx8.2\times10^{-5}$. Actual: $e^{0.2}=1.221\,403$, error $6.9\times10^{-5}$. โœ“
2 $1-\tfrac{x^2}{2}$ is both $p_2$ and $p_3$ of $\cos x$; as $p_3$, $|R_3(x)|\le\dfrac{\max|\cos t|}{4!}|x|^4\le\dfrac{(0.2)^4}{24}\approx6.67\times10^{-5}$ (actual at $x=0.2$: $6.66\times10^{-5}$).
3 $|R_n(0.5)|\le\dfrac{e^{0.5}}{(n+1)!}(0.5)^{n+1}\lt\dfrac{2\,(0.5)^{n+1}}{(n+1)!}$. For $n=6$: $3.1\times10^{-6}$ (not enough); for $n=7$: $1.9\times10^{-7}\lt10^{-6}$. So $n=7$. (The actual error with $n=6$ is $1.7\times10^{-6}$, so $n=6$ really fails.)
4 $0.1-0.000\,166\,7=0.099\,833\,3$. As $p_4$ of $\sin x$: $|R_4|\le\dfrac{(0.1)^5}{5!}\approx8.3\times10^{-8}$. (True value $0.099\,833\,417$.)
5 $p_3(1.2)=0.2-0.02+0.002\,667=0.182\,667$. $|f^{(4)}(t)|=6/t^4\le6$ on $[1,1.2]$, so $|R_3|\le\dfrac{6}{24}(0.2)^4=0.0004$. Actual: $\ln1.2=0.182\,322$, error $0.000\,345$. โœ“
6 $x$ is $p_2$ of $\sin x$ ($c_2=0$), so $|R_2(x)|\le\dfrac{|x|^3}{3!}$ (since $|f^{\prime\prime\prime}|=|\cos|\le1$). Need $\dfrac{|x|^3}{6}\lt0.001$, i.e. $|x|\lt\sqrt[3]{0.006}\approx0.1817$ rad $\approx10.4^\circ$.
7 $f(8)=2$, $f^\prime(8)=\tfrac13\cdot8^{-2/3}=\tfrac1{12}$, $f^{\prime\prime}(8)=-\tfrac29\cdot8^{-5/3}=-\tfrac1{144}$. $p_2(8.1)=2+\dfrac{0.1}{12}-\dfrac{0.01}{288}=2.008\,299$. $f^{\prime\prime\prime}(t)=\tfrac{10}{27}t^{-8/3}\le\tfrac{10}{27\cdot256}\approx0.001\,447$ on $[8,8.1]$, so $|R_2|\le\dfrac{0.001\,447}{6}(0.1)^3\approx2.4\times10^{-7}$. (True $\sqrt[3]{8.1}=2.008\,298\,85$.)
8 By Theorem 9.6 with $x=1$, $a=0$: $e-p_n(1)=R_n(1)=\dfrac{e^c}{(n+1)!}$ for some $0\lt c\lt1$. Since $1\lt e^c\lt e$, the two inequalities follow at once.
III
Find the Taylor series of $f$ about the given centre (give the general term) and its radius of convergence.
  • 1 $f(x)=e^{-x}$, $a=0$.
  • 2 $f(x)=\cos x$, $a=0$; also prove that the series converges to $\cos x$ for every $x$.
  • 3 $f(x)=e^x$, $a=2$.
  • 4 $f(x)=\dfrac1x$, $a=1$.
  • 5 $f(x)=\sin x$, $a=\tfrac{\pi}{2}$.
  • 6 $f(x)=2^x$, $a=0$.
  • 7 $f(x)=\ln x$, $a=2$.
  • 8 $f(x)=\sinh x=\tfrac12\left(e^x-e^{-x}\right)$, $a=0$.
1 $f^{(n)}(0)=(-1)^n$: $\displaystyle e^{-x}=\sum_{n=0}^\infty\frac{(-1)^nx^n}{n!}=1-x+\frac{x^2}{2!}-\cdots$, $R=\infty$.
2 Derivatives at $0$ cycle $1,0,-1,0$: $\displaystyle\cos x=\sum_{n=0}^\infty\frac{(-1)^nx^{2n}}{(2n)!}$; ratio test gives $\dfrac{x^2}{(2n+2)(2n+1)}\to0$, so $R=\infty$. Every derivative of $\cos$ is $\pm\sin$ or $\pm\cos$, so $|f^{(n+1)}(t)|\le1$ and $|R_n(x)|\le\dfrac{|x|^{n+1}}{(n+1)!}\to0$; by Theorem 9.8 the series equals $\cos x$.
3 $f^{(n)}(2)=e^2$: $\displaystyle e^x=\sum_{n=0}^\infty\frac{e^2}{n!}(x-2)^n$, $R=\infty$.
4 $f^{(n)}(x)=\dfrac{(-1)^nn!}{x^{n+1}}$, so $c_n=(-1)^n$: $\displaystyle\frac1x=\sum_{n=0}^\infty(-1)^n(x-1)^n$. A geometric series with ratio $-(x-1)$: $R=1$ (converges for $0\lt x\lt2$).
5 At $\tfrac\pi2$ the derivatives of $\sin$ are $1,0,-1,0,\dots$: $\displaystyle\sin x=\sum_{n=0}^\infty\frac{(-1)^n}{(2n)!}\left(x-\tfrac\pi2\right)^{2n}$, $R=\infty$. (This is $\cos\left(x-\tfrac\pi2\right)$, as it should be.)
6 $\dfrac{d^n}{dx^n}2^x=(\ln2)^n2^x$: $\displaystyle2^x=\sum_{n=0}^\infty\frac{(\ln2)^n}{n!}x^n$, $R=\infty$.
7 $f(2)=\ln2$ and for $n\ge1$, $f^{(n)}(2)=\dfrac{(-1)^{n+1}(n-1)!}{2^n}$, so $c_n=\dfrac{(-1)^{n+1}}{n\,2^n}$: $$\ln x=\ln2+\sum_{n=1}^\infty\frac{(-1)^{n+1}}{n\,2^n}(x-2)^n=\ln2+\frac{x-2}{2}-\frac{(x-2)^2}{8}+\frac{(x-2)^3}{24}-\cdots$$ Ratio test: $\dfrac{n}{n+1}\cdot\dfrac{|x-2|}{2}\to\dfrac{|x-2|}{2}$, so $R=2$.
8 $\sinh^\prime=\cosh$, $\cosh^\prime=\sinh$, and $\sinh0=0$, $\cosh0=1$, so the derivatives at $0$ are $0,1,0,1,\dots$: $\displaystyle\sinh x=\sum_{n=0}^\infty\frac{x^{2n+1}}{(2n+1)!}=x+\frac{x^3}{3!}+\frac{x^5}{5!}+\cdots$, $R=\infty$ (the sine series without the alternating signs).
IV
Theory and applications.
  • 1 Use the Maclaurin series of $e^x$ to find $f^{(10)}(0)$ for $f(x)=x^2e^x$ โ€” without differentiating ten times.
  • 2 Find $g^{(10)}(0)$ for $g(x)=x\sin x$.
  • 3 For $f(x)=e^{-1/x^2}$ ($x\ne0$), $f(0)=0$, use the definition of the derivative to show $f^\prime(0)=0$. (Hint: put $u=1/h$.)
  • 4 Applied. A car's position $s(t)$ (metres) satisfies $s(0)=0$, $s^\prime(0)=20$ m/s and $s^{\prime\prime}(0)=-2$ m/sยฒ, and its jerk satisfies $|s^{\prime\prime\prime}(t)|\le0.6$ m/sยณ for $0\le t\le2$. Estimate $s(2)$ with $p_2$ and give a guaranteed error bound.
  • 5 True or false? "If the Taylor series of $f$ about $a$ converges at $x$, then its sum is $f(x)$." Justify.
1 $x^2e^x=\displaystyle\sum_{n=0}^\infty\frac{x^{n+2}}{n!}$. The coefficient of $x^{10}$ is $\dfrac1{8!}$, and by Theorem 9.7 it equals $\dfrac{f^{(10)}(0)}{10!}$. So $f^{(10)}(0)=\dfrac{10!}{8!}=90$.
2 $x\sin x=\displaystyle\sum_{n=0}^\infty\frac{(-1)^nx^{2n+2}}{(2n+1)!}$. The $x^{10}$ term has $n=4$: coefficient $\dfrac{1}{9!}$. So $g^{(10)}(0)=\dfrac{10!}{9!}=10$.
3 $f^\prime(0)=\displaystyle\lim_{h\to0}\frac{e^{-1/h^2}-0}{h}$. With $u=1/h$ this is $\displaystyle\lim_{|u|\to\infty}\frac{u}{e^{u^2}}=0$ (by L'Hรดpital: $\lim\frac{1}{2ue^{u^2}}=0$). So $f^\prime(0)=0$.
4 $p_2(t)=0+20t-\tfrac{2}{2}t^2=20t-t^2$, so $s(2)\approx40-4=36$ m. Error: $|R_2(2)|\le\dfrac{0.6}{3!}\,2^3=0.8$ m. So $35.2\text{ m}\le s(2)\le36.8\text{ m}$.
5 False The function $e^{-1/x^2}$ (with $f(0)=0$) has Maclaurin series $0$, which converges at every $x$ โ€” but to $0$, not to $f(x)\gt0$. Convergence to $f$ needs $R_n(x)\to0$ (Theorem 9.8).
๐Ÿ”ฌ Researchโ€“Teaching NexusResearch-tutored ยท optional, about 30 minutes

Research question. How many terms of the sine series does a small embedded chip need to compute $\sin x$ to single-precision accuracy?

Why it matters. Drones, pacemakers, hearing aids and satellite attitude controllers run on tiny processors with no maths library to spare. Engineers implement $\sin x$ themselves, usually by range reduction (using symmetry to bring $x$ into $[-\tfrac\pi4,\tfrac\pi4]$) followed by a short polynomial. Every extra term costs time and energy.

What to do.

  1. Explain why, by periodicity and the identities $\sin(\tfrac\pi2-x)=\cos x$ and $\sin(-x)=-\sin x$, it is enough to compute $\sin$ and $\cos$ on $[-\tfrac\pi4,\tfrac\pi4]$.
  2. Using Theorem 9.6 with $M=1$, find the smallest degree $n$ with $\dfrac{(\pi/4)^{n+1}}{(n+1)!}\lt10^{-7}$. Remember that for $\sin x$, $p_{2m+1}=p_{2m+2}$ โ€” use the better bound.
  3. Count the non-zero terms and the multiplications needed (Horner's form: $x\left(1-\tfrac{x^2}{6}\left(1-\tfrac{x^2}{20}(\dots)\right)\right)$).
  4. In a spreadsheet, tabulate the actual error $|\sin x-p_n(x)|$ for 200 points in $[0,\tfrac\pi4]$ and find its maximum. Compare with your bound.

Tools: Calculator, spreadsheet (or Python/Octave)

Hand in: A half-page note: chosen degree, the bound and the measured maximum error, and the number of multiplications per evaluation.

Going further. Real libraries use minimax (Chebyshev-type) polynomials that spread the error evenly over the interval instead of concentrating accuracy at $x=0$. Find out how many terms a minimax polynomial needs for the same accuracy.

Instructor note: $(\pi/4)^9/9!\approx3.1\times10^{-7}$ is not enough, but $(\pi/4)^{11}/11!\approx1.8\times10^{-9}$ is, using $p_9=p_{10}$; so five terms $x-\tfrac{x^3}{3!}+\dots+\tfrac{x^9}{9!}$ suffice. The measured maximum error on $[0,\tfrac\pi4]$ is about $1.75\times10^{-9}$, attained at $x=\tfrac\pi4$ โ€” the bound is almost exactly sharp there.

๐Ÿงช Self-check quiz

0/5 correct

Q1. The coefficient of $x^4$ in the Maclaurin series of $\cos x$ is

Q2. The Taylor polynomial $p_n$ of $f$ about $a$ is the polynomial of degree at most $n$ that

Q3. Taylor's theorem guarantees that for $0\le x\le1$ the error of the Maclaurin polynomial $p_5$ of $e^x$ is at most

Q4. For $f(x)=e^{-1/x^2}$ ($x\ne0$), $f(0)=0$, the Maclaurin series

Q5. The Maclaurin series $1+x+x^2+\cdots$ of $\dfrac{1}{1-x}$ equals $\dfrac1{1-x}$ exactly for