1 Polynomials can approximate some functions
In our study of mathematics, we’ve found that some functions are easier to work with than others. For instance, if you are doing calculus, typically polynomials are “easy” to work with because they are easy to differentiate and integrate. Other functions, like
are more difficult to work with. However, there are polynomials that mimic the behavior of \(f\) near zero.
Above we see a graph of \(f\) along with the polynomial
As we see, this polynomial approximates \(f\) very well near zero. There are times when we would much rather work with a polynomial than any other type of function. Many of the ideas we discuss in this section should remind you of our work with linear approximation. In the case of linear approximation, we replaced a difficult function with a line, and used this line to approximate the function. Now, we want to replace our complicated function with a polynomial. This leads us to a question.
1.1 How do we produce approximating polynomials?
Cutting straight to the point, the approximating polynomials we’ll discuss are called Taylor polynomials and Maclaurin polynomials.
- The Taylor polynomial of degree \(n\) of \(f\) at \(x=c\) is \begin{align*} p_n(x) = f(c) &+ f'(c)(x-c) \\ &+ \frac {f''(c)}{2!}(x-c)^2 \\ &+\frac {f'''(c)}{3!}(x-c)^3 \\ &\ \vdots \\ &+\frac {f^{(n)}(c)}{n!}(x-c)^n. \end{align*}
- A special case of the Taylor polynomial is the Maclaurin polynomial, where \(c=0\). That is, the Maclaurin polynomial of degree \(n\) of \(f\) is \begin{align*} p_n(x) = f(0) &+ f'(0)x \\ &+\frac {f''(0)}{2!}x^2\\ &+\frac {f'''(0)}{3!}x^3\\ &\ \vdots \\ &+\frac {f^{(n)}(0)}{n!}x^n. \end{align*}
We say these polynomials have a center of \(x=c\), and so Maclaurin polynomials are Taylor polynomials centered at zero.
and evaluate each of these at \(x=0\). Write with me. \begin{align*} f(0) &= \answer [given]{1},\\ f'(0) &= \answer [given]{1},\\ f''(0) &= \answer [given]{2},\\ f'''(0) &=\answer [given]{2\cdot 3},\\ f^{(4)}(0) &= \answer [given]{2\cdot 3\cdot 4}. \end{align*}
Now, plugging this into our formula above we see
As usual, it’s a good idea to check and make sure that the formula we found for the \(n\)-th derivative works for \(n=1\) through \(n=5\). Now, we evaluate each of these derivatives at \(x=1\). Write with me. \begin{align*} f(1) &= \answer [given]{0},\\ f'(1) &= \answer [given]{1},\\ f''(1) &= \answer [given]{-1},\\ f'''(1) &= \answer [given]{2},\\ f^{(4)}(1) &= \answer [given]{-6},\\ f^{(5)}(1) &= \answer [given]{24},\\ &\vdots \\ f^{(n)}(1) &= (-1)^{n-1}\cdot (n-1)! \end{align*}
Finally, plugging this into our formula above we see
In the previous example, why did we choose to use \(x=1\) for the center? There are several reasons. We often like to use \(x=0\) for the center of a Taylor polynomial (which is why such polynomials have a special name). In the case of \(f(x) = \ln (x)\), however, \(f(0)\) is undefined. So, we must choose a different center. Since we have to evaluate the function at the center, any center point we choose should be a value for which we know and can easily compute the function value. In the case of \(f(x) = \ln (x)\), the value we know best is \(f(1) = 0\), so \(x=1\) is a good choice for the center. Of course, in general we can choose any center we like, but this will give us a different polynomial (and may make our calculations more difficult.)
This is a good approximation as a calculator shows that \(\ln (1.5) \approx 0.4055.\)
This approximation is not terribly impressive: a hand held calculator shows that \(\ln (2) \approx 0.693147\). Surprisingly enough, even the \(20\)th degree Taylor polynomial fails to approximate \(\ln (x)\) for \(x>2\). We’ll soon discuss why this is.
You may be wondering, how exactly Taylor polynomials and Maclaurin polynomials approximate these functions. Here’s the idea: Suppose you have two functions \(f\) and \(g\) which are each as differentiable as we need them to be. If for some specific value \(x=c\) we have that \begin{align*} f(c) &= g(c)\\ f'(c) &= g'(c)\\ f''(c) &= g''(c)\\ f'''(c) &= g'''(c)\\ &\vdots \end{align*}
then it makes sense that
for all \(x\). The more derivatives we use, the better our approximation (usually) is. In that sense, we are just working with a better version of linear approximation – we could call this polynomial approximation! The Taylor and Maclaurin polynomials are “cooked up” so that their value and the value of their derivatives equals the value of the related function at \(x=c\). Check it out: here we see the third Maclaurin polynomial for \(f(x) = \sin (x)\):
we see \begin{align*} p_3(0) = 0 &= f(0) = \sin (0)\\ p_3'(0) = 1 &= f'(1) = \cos (0)\\ p_3''(0) = 0 &= f''(0) = -\sin (0)\\ p_3'''(0) = -1 &= f'''(0) = -\cos (0)\\ p_3^{(4)}(0) = 0 &= f^{(4)}(0) = \sin (0)\\ p_3^{(5)}(0) = 0 &\ne f^{(5)}(0) = \cos (0) \end{align*}
Note that in the case of sine,
shares the function’s value at \(x=0\) and shares the first \(4\) derivatives, though the \(5\)th derivative is different. Let’s see a graph to help us understand what is going on.
We can see that \(p_3\) is a good approximation for \(\sin (x)\) near \(x=0\). Next, we quantify exactly how good our approximation is.
2 Taylor’s theorem
Again, let’s get to the point by stating Taylor’s theorem (which is a generalization of the mean value theorem):
The first part of Taylor’s theorem states that \(f(x) = p_n(x) + R_n(x)\), where \(p_n(x)\) is the \(n\)th order Taylor polynomial and \(R_n(x)\) is the remainder, or error, in the Taylor approximation. The second part gives bounds on how big that error can be. If the \((n+1)\)th derivative is large, the error may be large; if \(x\) is far from \(c\), the error may also be large. However, the \((n+1)!\) term in the denominator tends to ensure that the error gets smaller as \(n\) increases.
The following example computes error estimates for the approximations of \(\ln (1.5)\) and \(\ln (2)\) made earlier.
Remember, of course, that this bound on the error is only accurate on our interval \(I\).
We practice again. This time, we use Taylor’s theorem to find \(n\) that guarantees our approximation is within a certain amount.
3 Connections to differential equations
Our final example gives a brief introduction for using Taylor polynomials to solve differential equations.
- \(y(0) = f(0) = 1\), and
- \(y'= y^2\).
Find the degree \(3\) Maclaurin polynomial \(p_3(x)\) of \(y=f(x)\).
Now we find information about \(y''\). Starting with \(y'=y^2\), take derivatives of both sides, with respect to \(x\). That means we must use implicit differentiation. \begin{align*} y' &= \answer [given]{y^2}\\ \frac {d}{dx}(y') &= \frac {d}{dx}(y^2)\\ y'' &= \answer [given]{2y}\cdot y'. \end{align*}
Now evaluate both sides at \(x=0\): \begin{align*} y''(0) &= 2y(0)\cdot y'(0)\\ y''(0) &= \answer [given]{2} \end{align*}
We repeat this once more to find \(y'''(0)\). We again use implicit differentiation; this time the Product Rule is also required. \begin{align*} \frac {d}{dx}(y'') &= \frac {d}{dx} (2yy')\\ y''' &= 2y'\cdot y' + 2y\cdot y''. \end{align*}
Now evaluate both sides at \(x=0\): \begin{align*} y'''(0) &= 2y'(0)^2 + 2y(0)y''(0)\\ y'''(0) &= \answer [given]{6} \end{align*}
In summary, we have:
Taylor polynomials are very useful approximation in two basic situations:
- (a)
- When \(f\) is known, but perhaps “hard” to compute directly. For instance, we can define \(y=\cos (x)\) as either the ratio of sides of a right triangle (“adjacent over hypotenuse”) or with the unit circle. However, neither of these provides a convenient way of computing \(\cos (2)\). A Taylor polynomial of sufficiently high degree can provide a reasonable method of computing such values using only operations usually hard-wired into a computer (\(+\), \(-\), \(\times \) and \(\div \)). However, even though Taylor polynomials could be used in calculators and computers to calculate values of trigonometric functions, in practice they generally aren’t. Other more efficient and accurate methods have been developed, such as the CORDIC algorithm.
- (b)
- When \(f\) is not known, but information about its derivatives is known. This occurs more often than one might think, especially in the study of differential equations.