Skip to main content

Subsection 3.4.9 The Error in the Taylor Polynomial Approximations

Any time you make an approximation, it is desirable to have some idea of the size of the error you introduced. That is, we would like to know the difference \(R(x)\) between the original function \(f(x)\) and our approximation \(F(x)\text{:}\)

\begin{align*} R(x) &= f(x)-F(x). \end{align*}

Of course if we know \(R(x)\) exactly, then we could recover \(f(x) = F(x)+R(x)\) — so this is an unrealistic hope. In practice we would simply like to bound \(R(x)\text{:}\)

\begin{align*} |R(x)| &= |f(x)-F(x)| \leq M \end{align*}

where (hopefully) \(M\) is some small number. It is worth stressing that we do not need the tightest possible value of \(M\text{,}\) we just need a relatively easily computed \(M\) that isn't too far off the true value of \(|f(x)-F(x)|\text{.}\)

We will now develop a formula for the error introduced by the constant approximation, equation 3.4.1 (developed back in Section 3.4.1)

\begin{align*} f(x)&\approx f(a) = T_0(x) & \text{$0^\mathrm{th}$ Taylor polynomial} \end{align*}

The resulting formula can be used to get an upper bound on the size of the error \(|R(x)|\text{.}\)

The main ingredient we will need is the Mean-Value Theorem (Theorem 2.13.5) — so we suggest you quickly revise it. Consider the following obvious statement:

\begin{align*} f(x) &= f(x) & \text{now some sneaky manipulations}\\ & = f(a) + (f(x)-f(a))\\ &= \underbrace{f(a)}_{=T_0(x)} + (f(x)-f(a)) \cdot \underbrace{\frac{x-a}{x-a}}_{=1}\\ &= T_0(x) + \underbrace{\frac{f(x)-f(a)}{x-a}}_\text{looks familiar} \cdot (x-a) \end{align*}

Indeed, this equation is important in the discussion that follows, so we'll highlight it

The coefficient \(\dfrac{f(x)-f(a)}{x-a}\) of \((x-a)\) is the average slope of \(f(t)\) as \(t\) moves from \(t=a\) to \(t=x\text{.}\) We can picture this as the slope of the secant joining the points \((a,f(a))\) and \((x,f(x))\) in the sketch below.

As \(t\) moves from \(a\) to \(x\text{,}\) the instantaneous slope \(f'(t)\) keeps changing. Sometimes \(f'(t)\) might be larger than the average slope \(\tfrac{f(x)-f(a)}{x-a}\text{,}\) and sometimes \(f'(t)\) might be smaller than the average slope \(\tfrac{f(x)-f(a)}{x-a}\text{.}\) However, by the Mean-Value Theorem (Theorem 2.13.5), there must be some number \(c\text{,}\) strictly between \(a\) and \(x\text{,}\) for which \(f'(c)=\dfrac{f(x)-f(a)}{x-a}\) exactly.

Substituting this into formula 3.4.28 gives

Notice that this expression as it stands is not quite what we want. Let us massage this around a little more into a more useful form

Notice that the MVT doesn't tell us the value of \(c\text{,}\) however we do know that it lies strictly between \(x\) and \(a\text{.}\) So if we can get a good bound on \(f'(c)\) on this interval then we can get a good bound on the error.

Let us return to Example 3.4.2, and we'll try to bound the error in our approximation of \(e^{0.1}\text{.}\)

  • Recall that \(f(x) = e^x\text{,}\) \(a=0\) and \(T_0(x) = e^0 = 1\text{.}\)
  • Then by equation 3.4.30
    \begin{align*} e^{0.1} - T_0(0.1) &= f'(c) \cdot (0.1 - 0) & \text{with $0 \lt c \lt 0.1$} \end{align*}
  • Now \(f'(c) = e^c\text{,}\) so we need to bound \(e^c\) on \((0,0.1)\text{.}\) Since \(e^c\) is an increasing function, we know that
    \begin{align*} e^0 & \lt f'(c) \lt e^{0.1} & \text{ when $0 \lt c \lt 0.1$} \end{align*}
    So one is tempted to write that
    \begin{align*} |e^{0.1} - T_0(0.1)| &= |R(x)| = |f'(c)| \cdot (0.1 - 0)\\ & \lt e^{0.1} \cdot 0.1 \end{align*}
    And while this is true, it is rather circular. We have just bounded the error in our approximation of \(e^{0.1}\) by \(\frac{1}{10}e^{0.1}\) — if we actually knew \(e^{0.1}\) then we wouldn't need to estimate it!
  • While we don't know \(e^{0.1}\) exactly, we do know  19 Oops! Do we really know that \(e \lt 3\text{?}\) We haven't proved it. We will do so soon. that \(1 = e^0 \lt e^{0.1} \lt e^1 \lt 3\text{.}\) This gives us
    \begin{gather*} |R(0.1)| \lt 3 \times 0.1 = 0.3 \end{gather*}
    That is — the error in our approximation of \(e^{0.1}\) is no greater than \(0.3\text{.}\) Recall that we don't need the error exactly, we just need a good idea of how large it actually is.
  • In fact the real error here is
    \begin{align*} |e^{0.1} - T_0(0.1)| &=|e^{0.1} - 1| = 0.1051709\dots \end{align*}
    so we have over-estimated the error by a factor of 3.

But we can actually go a little further here — we can bound the error above and below. If we do not take absolute values, then since

\begin{align*} e^{0.1} - T_0(0.1) &= f'(c) \cdot 0.1 & \text{ and } 1 \lt f'(c) \lt 3 \end{align*}

we can write

\begin{align*} 1\times 0.1 \leq ( e^{0.1} - T_0(0.1) ) & \leq 3\times 0.1 \end{align*}

so

\begin{align*} T_0(0.1) + 0.1 &\leq e^{0.1} \leq T_0(0.1)+0.3\\ 1.1 &\leq e^{0.1} \leq 1.3 \end{align*}

So while the upper bound is weak, the lower bound is quite tight.

There are formulae similar to equation 3.4.29, that can be used to bound the error in our other approximations; all are based on generalisations of the MVT. The next one — for linear approximations — is

\begin{align*} f(x) & =\underbrace{f(a)+f'(a)(x-a)}_{=T_1(x)}+\half f''(c)(x-a)^2 & \text{for some } c \text{ strictly between } a \text{ and } x \end{align*}

which we can rewrite in terms of \(T_1(x)\text{:}\)

It implies that the error that we make when we approximate \(f(x)\) by \(T_1(x) = f(a)+f'(a)\,(x-a)\) is exactly \(\half f''(c)\,(x-a)^2\) for some \(c\) strictly between \(a\) and \(x\text{.}\)

More generally

\begin{align*} f(x)=& \underbrace{f(a)\!+\!f'(a)\cdot(x\!-\!a)\!+\cdots+\!\frac{1}{n!}f^{(n)}(a)\cdot(x\!-\!a)^n}_{= T_n(x)} \!+\!\frac{1}{(n\!+\!1)!}f^{(n+1)}(c)\cdot (x\!-\!a)^{n+1} \end{align*}

for some \(c\) strictly between \(a\) and \(x\text{.}\) Again, rewriting this in terms of \(T_n(x)\) gives

That is, the error introduced when \(f(x)\) is approximated by its Taylor polynomial of degree \(n\text{,}\) is precisely the last term of the Taylor polynomial of degree \(n+1\text{,}\) but with the derivative evaluated at some point between \(a\) and \(x\text{,}\) rather than exactly at \(a\text{.}\) These error formulae are proven in the optional Section 3.4.10 later in this chapter.

Approximate \(\sin 46^\circ\) using Taylor polynomials about \(a=45^\circ\text{,}\) and estimate the resulting error.

Solution

  • Start by defining \(f(x) = \sin x\) and
    \begin{align*} a&=45^\circ=45\tfrac{\pi}{180} {\rm radians}& x&=46^\circ=46\tfrac{\pi}{180} {\rm radians}\\ x-a&=\tfrac{\pi}{180} {\rm radians} \end{align*}
  • The first few derivatives of \(f\) at \(a\) are
    \begin{align*} f(x)&=\sin x &f(a)&=\frac{1}{\sqrt{2}}\\ f'(x)&=\cos x &\\ f'(a)&=\frac{1}{\sqrt{2}}\\ f''(x)&=-\sin x &\\ f''(a)&=-\frac{1}{\sqrt{2}}\\ f^{(3)}(x)&=-\cos x & f^{(3)}(a)&=-\frac{1}{\sqrt{2}} \end{align*}
  • The constant, linear and quadratic Taylor approximations for \(\sin(x)\) about \(\frac{\pi}{4}\) are
    \begin{alignat*}{2} T_0(x) &= f(a) &&= \frac{1}{\sqrt{2}}\\ T_1(x) &= T_0(x) + f'(a) \cdot(x\!-\!a) &&= \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}}\left(x\! -\! \frac{\pi}{4} \right)\\ T_2(x) &= T_1(x)\! +\! \half f''(a) \cdot(x\!-\!a)^2 &&=\! \frac{1}{\sqrt{2}} \!+\! \frac{1}{\sqrt{2}}\left(x\!-\! \frac{\pi}{4} \right) \!-\! \frac{1}{2\sqrt{2}}\left(x\! -\! \frac{\pi}{4} \right)^2 \end{alignat*}
  • So the approximations for \(\sin 46^\circ\) are
    \begin{align*} \sin46^\circ &\approx T_0\left(\frac{46\pi}{180}\right) = \frac{1}{\sqrt{2}}\\ &=0.70710678\\ \sin46^\circ &\approx T_1\left(\frac{46\pi}{180}\right) = \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}} \left(\frac{\pi}{180}\right)\\ &=0.71944812\\ \sin46^\circ&\approx T_2\left(\frac{46\pi}{180}\right) = \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}} \left(\frac{\pi}{180}\right) - \frac{1}{2\sqrt{2}}\left(\frac{\pi}{180}\right)^2\\ &=0.71934042 \end{align*}
  • The errors in those approximations are (respectively)
    \begin{alignat*}{3} &{\rm error\ in\ 0.70710678}& &=f'(c)(x-a)& &=\cos c \cdot \left(\frac{\pi}{180}\right)\\ &{\rm error\ in\ 0.71944812}& &=\frac{1}{2} f''(c)(x-a)^2& &=-\frac{1}{2} \cdot \sin c\cdot \left(\frac{\pi}{180}\right)^2\\ &{\rm error\ in\ 0.71923272}& &=\frac{1}{3!}f^{(3)}(c)(x-a)^3& &=-\frac{1}{3!}\cdot \cos c \cdot \left(\frac{\pi}{180}\right)^3 \end{alignat*}
    In each of these three cases \(c\) must lie somewhere between \(45^\circ\) and \(46^\circ\text{.}\)
  • Rather than carefully estimating \(\sin c\) and \(\cos c\) for \(c\) in that range, we make use of a simpler (but much easier bound). No matter what \(c\) is, we know that \(|\sin c|\le 1\) and \(|\cos c|\le 1\text{.}\) Hence
    \begin{alignat*}{3} &\big|{\rm error\ in\ 0.70710678}\big|& &\le \left(\frac{\pi}{180}\right)& & \lt 0.018\\ &\big|{\rm error\ in\ 0.71944812}\big|& &\le\frac{1}{2} \left(\frac{\pi}{180}\right)^2& & \lt 0.00015\\ &\big|{\rm error\ in\ 0.71934042}\big|& &\le \frac{1}{3!} \left(\frac{\pi}{180}\right)^3& & \lt 0.0000009 \end{alignat*}

In Example 3.4.31 above we used the fact that \(e \lt 3\) without actually proving it. Let's do so now.

  • Consider the linear approximation of \(e^x\) about \(a=0\text{.}\)
    \begin{align*} T_1(x) &= f(0) + f'(0)\cdot x = 1 + x \end{align*}
    So at \(x=1\) we have
    \begin{align*} e &\approx T_1(1) = 2 \end{align*}
  • The error in this approximation is
    \begin{align*} e^x - T_1(x) &= \frac{1}{2} f''(c) \cdot x^2 = \frac{e^c}{2} \cdot x^2 \end{align*}
    So at \(x=1\) we have
    \begin{align*} e - T_1(1) &= \frac{e^c}{2} \end{align*}
    where \(0 \lt c \lt 1\text{.}\)
  • Now since \(e^x\) is an increasing  20 Since the derivative of \(e^x\) is \(e^x\) which is positive everywhere, the function is increasing everywhere. function, it follows that \(e^c \lt e\text{.}\) Hence
    \begin{align*} e - T_1(1) &= \frac{e^c}{2} \lt \frac{e}{2} \end{align*}
    Moving the \(\frac{e}{2}\) to the left hand side and the \(T_1(1)\) to the right hand side gives
    \begin{gather*} \frac{e}{2} \leq T_1(1) = 2 \end{gather*}
    So \(e \lt 4\text{.}\)
  • This isn't as tight as we would like — so now do the same with the quadratic approximation with \(a=0\text{:}\)
    \begin{align*} e^x & \approx T_2(x) = 1 + x + \frac{x^2}{2}\\ \end{align*}

    So when \(x=1\) we have

    \begin{align*} e & \approx T_2(1) = 1 + 1 + \frac{1}{2} = \frac{5}{2} \end{align*}
  • The error in this approximation is
    \begin{align*} e^x - T_2(x) &= \frac{1}{3!} f'''(c) \cdot x^3 = \frac{e^c}{6} \cdot x^3 \end{align*}
    So at \(x=1\) we have
    \begin{align*} e - T_2(1) &= \frac{e^c}{6} \end{align*}
    where \(0 \lt c \lt 1\text{.}\)
  • Again since \(e^x\) is an increasing function we have \(e^c \lt e\text{.}\) Hence
    \begin{align*} e - T_2(1) &= \frac{e^c}{6} \lt \frac{e}{6} \end{align*}
    That is
    \begin{gather*} \frac{5e}{6} \lt T_2(1) = \frac{5}{2} \end{gather*}
    So \(e \lt 3\) as required.

We wrote down the general \(n^\mathrm{th}\) degree Maclaurin polynomial approximation of \(e^x\) in Example 3.4.12 above.

  • Recall that
    \begin{align*} T_n(x) &= \sum_{k=0}^n \frac{1}{k!} x^k \end{align*}
  • The error in this approximation is (by equation 3.4.33)
    \begin{align*} e^x - T_n(x) &= \frac{1}{(n+1)!} e^c \end{align*}
    where \(c\) is some number between \(0\) and \(x\text{.}\)
  • So setting \(x=1\) in this gives
    \begin{align*} e - T_n(1) &= \frac{1}{(n+1)!} e^c \end{align*}
    where \(0 \lt c \lt 1\text{.}\)
  • Since \(e^x\) is an increasing function we know that \(1 = e^0 \lt e^c \lt e^1 \lt 3\text{,}\) so the above expression becomes
    \begin{align*} \frac{1}{(n+1)!} \leq e - T_n(1) &= \frac{1}{(n+1)!} e^c \leq \frac{3}{(n+1)!} \end{align*}
  • So when \(n=9\) we have
    \begin{align*} \frac{1}{10!} \leq e - \left(1 + 1 + \frac{1}{2} +\cdots + \frac{1}{9!} \right) &\leq \frac{3}{10!} \end{align*}
  • Now \(1/10! \lt 3/10! \lt 10^{-6}\text{,}\) so the approximation of \(e\) by
    \begin{gather*} e \approx 1 + 1 + \frac{1}{2} +\cdots + \frac{1}{9!} = \frac{98641}{36288} = 2.718281\dots \end{gather*}
    is correct to 6 decimal places.
  • More generally we know that using \(T_n(1)\) to approximate \(e\) will have an error of at most \(\frac{3}{(n+1)!}\) — so it converges very quickly.

Recall  21 Now is a good time to go back and re-read it. that in Example 3.4.24 (measuring the height of the pole), we used the linear approximation

\begin{align*} f(\theta_0+\De\theta)&\approx f(\theta_0)+f'(\theta_0)\De\theta \end{align*}

with \(f(\theta)=10\tan\theta\) and \(\theta_0=30\dfrac{\pi}{180}\) to get

\begin{align*} \De h &=f(\theta_0+\De\theta)-f(\theta_0)\approx f'(\theta_0)\De\theta \quad \text{which implies that} \quad \De\theta \approx \frac{\De h}{f'(\theta_0)} \end{align*}
  • While this procedure is fairly reliable, it did involve an approximation. So that you could not 100% guarantee to your client's lawyer that an accuracy of 10 cm was achieved.
  • On the other hand, if we use the exact formula 3.4.29, with the replacements \(x\rightarrow \theta_0+\De\theta\) and \(a\rightarrow\theta_0\)
    \begin{align*} f(\theta_0+\De\theta)&=f(\theta_0)+f'(c)\De\theta & \text{for some $c$ between $\theta_0$ and $\theta_0+\De\theta$} \end{align*}
    in place of the approximate formula 3.4.3, this legality is taken care of:
    \begin{align*} \De h &=f(\theta_0\!+\!\De\theta)-f(\theta_0) =f'(c)\De\theta \quad \text{for some $c$ between $\theta_0$ and $\theta_0+\De\theta$} \end{align*}
    We can clean this up a little more since in our example \(f'(\theta) = 10\sec^2\theta\text{.}\) Thus for some \(c\) between \(\theta_0\) and \(\theta_0 + \De\theta\text{:}\)
    \begin{gather*} |\De h| = 10 \sec^2(c) |\De \theta| \end{gather*}
  • Of course we do not know exactly what \(c\) is. But suppose that we know that the angle was somewhere between \(25^\circ\) and \(35^\circ\text{.}\) In other words suppose that, even though we don't know precisely what our measurement error was, it was certainly no more than \(5^\circ\text{.}\)
  • Now on the range \(25^\circ \lt c \lt 35^\circ\text{,}\) \(\sec(c)\) is an increasing and positive function. Hence on this range
    \begin{gather*} 1.217\dots = \sec^2 25^\circ \leq \sec^2 c \leq \sec^2 35^\circ = 1.490\dots \lt 1.491 \end{gather*}
    So
    \begin{align*} 12.17 \cdot |\De \theta| &\leq |\De h| = 10 \sec^2(c) \cdot |\De \theta| \leq 14.91 \cdot | \De \theta| \end{align*}
  • Since we require \(|\De h| \lt 0.1\text{,}\) we need \(14.91 |\De \theta| \lt 0.1\text{,}\) that is
    \begin{gather*} |\De \theta| \lt \frac{0.1}{14.91} = 0.0067\dots \end{gather*}
    So we must measure angles with an accuracy of no less than \(0.0067\) radians — which is
    \begin{gather*} \frac{180}{\pi} \cdot 0.0067 = 0.38^\circ. \end{gather*}
    Hence a measurement error of \(0.38^\circ\) or less is acceptable.