Motivating Questions
What is a Taylor polynomial? For what purposes are Taylor polynomials used?
How do we determine the accuracy when we use a Taylor polynomial to approximate a function?
What is a Taylor polynomial? For what purposes are Taylor polynomials used?
How do we determine the accuracy when we use a Taylor polynomial to approximate a function?
Polynomial functions are the simplest possible functions in mathematics, in part because they require only addition and multiplication to evaluate. Consequently, in practical applications, it is often useful to approximate complicated functions using polynomials. In this section we will learn how to obtain polynomial approximations of functions, and how to determine how good an approximation is.
As an example, consider the geometric series
Here we see something very interesting: because a geometric series converges whenever its ratio \(r\) satisfies \(|r|\lt 1\text{,}\) and the sum of a convergent geometric series is \(\frac{a}{1-r}\text{,}\) we can say that for \(|x| \lt 1\text{,}\)
Equation(7.22) states that the non-polynomial function \(\frac{1}{1-x}\) on the right is equal to the infinite polynomial expresssion on the left. Because the terms on the left get very small as \(k\) gets large, we can truncate the series and say, for example, that
for small values of \(x\text{.}\) This shows one way that a polynomial function can be used to approximate a non-polynomial function; such approximations are one of the main themes in this section and the next.
In Example7.52, we begin our exploration of approximating functions with polynomials.
Example7.20 showed how we can approximate the number \(e\) using linear, quadratic, and other polynomial functions; we then used similar ideas in Example7.35 to approximate \(\ln(2)\text{.}\) In this example, we review and extend the process to find the best
quadratic approximation to the exponential function \(e^x\) around the origin. Let \(f(x) = e^x\) throughout this example.
Find a formula for \(P_1(x)\text{,}\) the linearization of \(f(x)\) at \(x=0\text{.}\) (We label this linearization \(P_1\) because it is a first degree polynomial approximation.) Recall that \(P_1(x)\) is a good approximation to \(f(x)\) for values of \(x\) close to \(0\text{.}\) Plot \(f\) and \(P_1\) near \(x=0\) to illustrate this fact.
Since \(f(x) = e^x\) is not linear, the linear approximation eventually is not a very good one. To obtain better approximations, we want to develop a different approximation that bends
to make it more closely fit the graph of \(f\) near \(x=0\text{.}\) To do so, we add a quadratic term to \(P_1(x)\text{.}\) In other words, we let
for some real number \(c_2\text{.}\) We need to determine the value of \(c_2\) that makes the graph of \(P_2(x)\) best fit the graph of \(f(x)\) near \(x=0\text{.}\)
Remember that \(P_1(x)\) was a good linear approximation to \(f(x)\) near \(0\text{;}\) this is because \(P_1(0) = f(0)\) and \(P'_1(0) = f'(0)\text{.}\) It is therefore reasonable to seek a value of \(c_2\) so that
Remember, we are letting \(P_2(x) = P_1(x) + c_2x^2\text{.}\)
Calculate \(P_2(0)\) to show that \(P_2(0) = f(0)\text{.}\)
Calculate \(P'_2(0)\) to show that \(P'_2(0) = f'(0)\text{.}\)
Calculate \(P''_2(x)\text{.}\) Then find a value for \(c_2\) so that \(P''_2(0) = f''(0)\text{.}\)
Explain why the condition \(P''_2(0) = f''(0)\) will put an appropriate bend
in the graph of \(P_2\) to make \(P_2\) fit the graph of \(f\) around \(x=0\text{.}\)
We know that
Since \(P_1(0) = f(0) = 1\) and \(P'_1(0) = f'(0) = 1\text{,}\) the graphs of \(P_1\) and \(f\) agree at \(x=a\) and have the same slope at \(x=0\) (which means they go in the same direction at \(x=0\)). This is why \(P_1(x)\) is a good approximation to \(f(x)\) for values of \(x\) close to \(0\text{.}\)
Since
we have that
as desired.
A simple calculation shows \(P'_2(x) = P'1(x) + 2c_2x\text{.}\) So \(P'_2(0) = P'_1(0) = 1 = f'(0)\) as desired.
A simple calculation shows \(P''_2(x) = 2c_2\text{.}\) So \(P''_2(0) = 2c_2\text{.}\) To have \(P''_2(0) = f''(0)\) we must have \(2c_2 = f''(0)\) or \(c_2 = \frac{f''(0)}{2} = \frac{1}{2}\text{.}\)
The second derivative of a function tells us the concavity of the function. Concavity measures how the slopes of the tangent lines to the graph of the function are changing. This tells us how much bend there is in the graph. So if \(P''_2(0) = f''(0)\text{,}\) then \(P_2\) will have the same bend in it at \(x=0\) as \(f\) does. This will make the graph of \(P_2\) mold to the graph of \(f\) around \(x=0\text{.}\)
Example7.52 illustrates the first steps in the process of approximating functions with polynomials. Using this process we can approximate trigonometric, exponential, logarithmic, and other nonpolynomial functions as closely as we like (for certain values of \(x\)) with polynomials. This is extraordinarily useful in that it allows us to calculate values of these functions to whatever precision we like using only the operations of addition, subtraction, multiplication, and division, which can be easily programmed in a computer.
We next extend the approach in Example7.52 to arbitrary functions at arbitrary points. Let \(f\) be a function that has as many derivatives as we need at a point \(x=a\text{.}\) Recall that \(P_1(x)\) is the tangent line to \(f\) at \((a,f(a))\) and is given by the formula
\(P_1(x)\) is the linear approximation to \(f\) near \(a\) that has the same slope and function value as \(f\) at the point \(x = a\text{.}\)
We next want to find a quadratic approximation
so that \(P_2(x)\) more closely models \(f(x)\) near \(x=a\text{.}\) Consider the following calculations of the values and derivatives of \(P_2(x)\text{:}\)
To make \(P_2(x)\) fit \(f(x)\) better than \(P_1(x)\text{,}\) we want \(P_2(x)\) and \(f(x)\) to have the same concavity at \(x=a\text{,}\) in addition to having the same slope and function value. That is, we want to have
This implies that
and thus
Therefore, the quadratic approximation \(P_2(x)\) to \(f\) centered at \(x=a\) is
This approach extends naturally to polynomials of higher degree. We define polynomials
and in general
The defining property of these polynomials is that for each \(n\text{,}\) \(P_n(x)\) and all its first \(n\) derivatives must agree with those of \(f\) at \(x = a\text{.}\) In other words we require that
for all \(k\) from 0 to \(n\text{.}\)
To see the conditions under which this happens, suppose
Then
and, in general,
So having \(P^{(k)}_n(a) = f^{(k)}(a)\) means that \(k!c_k = f^{(k)}(a)\) and therefore
for each value of \(k\text{.}\) Using this expression for \(c_k\text{,}\) we have found the formula for the polynomial approximation of \(f\) that we seek. Such a polynomial is called a Taylor polynomial.
The \(n\)th order Taylor polynomial of \(f\) centered at \(x = a\) is given by
This degree \(n\) polynomial approximates \(f(x)\) near \(x=a\) and has the property that \(P_n^{(k)}(a) = f^{(k)}(a)\) for \(k = 0, 1, \ldots, n\text{.}\)
Determine the third order Taylor polynomial for \(f(x) = e^x\text{,}\) as well as the general \(n\)th order Taylor polynomial for \(f\) centered at \(x=0\text{.}\)
We know that \(f'(x) = e^x\) and so \(f''(x) = e^x\) and \(f'''(x) = e^x\text{.}\) Thus,
So the third order Taylor polynomial of \(f(x) = e^x\) centered at \(x=0\) is
In general, for the exponential function \(f\) we have \(f^{(k)}(x) = e^x\) for every positive integer \(k\text{.}\) Thus, the \(k\)th term in the \(n\)th order Taylor polynomial for \(f(x)\) centered at \(x=0\) is
Therefore, the \(n\)th order Taylor polynomial for \(f(x) = e^x\) centered at \(x=0\) is
We have just seen that the \(n\)th order Taylor polynomial centered at \(a = 0\) for the exponential function \(e^x\) is
In this example, we determine small order Taylor polynomials for several other familiar functions, and look for general patterns.
Let \(f(x) = \frac{1}{1-x}\text{.}\)
Calculate the first four derivatives of \(f(x)\) at \(x=0\text{.}\) Then find the fourth order Taylor polynomial \(P_4(x)\) for \(\frac{1}{1-x}\) centered at \(0\text{.}\)
Based on your results from part (i), determine a general formula for \(f^{(k)}(0)\text{.}\)
Let \(f(x) = \cos(x)\text{.}\)
Calculate the first four derivatives of \(f(x)\) at \(x=0\text{.}\) Then find the fourth order Taylor polynomial \(P_4(x)\) for \(\cos(x)\) centered at \(0\text{.}\)
Based on your results from part (i), find a general formula for \(f^{(k)}(0)\text{.}\) (Think about how \(k\) being even or odd affects the value of the \(k\)th derivative.)
Let \(f(x) = \sin(x)\text{.}\)
Calculate the first four derivatives of \(f(x)\) at \(x=0\text{.}\) Then find the fourth order Taylor polynomial \(P_4(x)\) for \(\sin(x)\) centered at \(0\text{.}\)
Based on your results from part (i), find a general formula for \(f^{(k)}(0)\text{.}\) (Think about how \(k\) being even or odd affects the value of the \(k\)th derivative.)
\(f^{(k)}(0) = k! \text{.}\)
\(f^{k}(0) = 0\) if \(k\) is odd, and \(f^{2k}(0) = (-1)^k\text{.}\)
\(P_n(x) = 1 - \frac{x^2}{2} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots + (-1)^{n/2}\frac{x^n}{n!}\) if \(n\) is even and \(P_n(x) = 1 - \frac{x^2}{2} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots + (-1)^{(n-1)/2}\frac{x^(n-1)}{(n-1)!}\) if \(n\) is odd.
\(f^{k}(0) = 0\) if \(k\) is even and \(f^{2k+1}(0) = (-1)^k \text{.}\)
\(P_n(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots + (-1)^{(n-1)/2}\frac{x^n}{n!}\) if \(n\) is odd and \(P_n(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots + (-1)^{n/2+1}\frac{x^{n-1}}{(n-1)!}\) if \(n\) is even.
The first four derivatives of \(f(x)\) at \(x=0\) are
It appears that the pattern is
The \(n\)th order Taylor polynomial for \(f\) at \(x=0\) is
This makes sense since \(f(x)\) is the sum of the geometric series with ratio \(x\text{,}\) so the \(n\)th order Taylor polynomial should just be the \(n\)th partial sum of this geometric series.
The first four derivatives of \(f(x)\) at \(x=0\) are
It appears that the odd derivatives of \(f(x)\) are all plus or minus \(\sin(x)\) and so have values of 0 at \(x=0\) and the even derivatives are \(\pm \cos(x)\) and have alternating values of 1 and \(-1\) at \(x-0\text{.}\) Since the even numbers can be represented in the form \(2k\) where \(k\) is an integer we have \(f^{k}(0) = 0\) if \(k\) is odd and \(f^{2k}(0) = (-1)^k\text{.}\)
Based on the previous part of this problem the \(n\)th order Taylor polynomial for \(\cos(x)\) is
if \(n\) is even and
if \(n\) is odd.
The first four derivatives of \(f(x)\) at \(x=0\) are
It appears that the even derivatives of \(f(x)\) are all plus or minus \(\sin(x)\) and so have values of 0 at \(x=0\) and the odd derivatives are \(\pm \cos(x)\) and have alternating values of 1 and \(-1\) at \(x=0\text{.}\) Since the odd numbers can be represented in the form \(2k+1\) where \(k\) is an integer we have \(f^{k}(0) = 0 \) if \(k\) is even and \(f^{2k+1}(0) = (-1)^k\text{.}\)
Based on the previous part of this problem the \(n\)th order Taylor polynomial for \(\sin(x)\) is
if \(n\) is odd and
if \(n\) is even.
It is possible that an \(n\)th order Taylor polynomial is not a polynomial of degree \(n\text{;}\) that is, the order of the approximation can be different from the degree of the polynomial. For example, in Example7.56 we found that the second order Taylor polynomial \(P_2(x)\) centered at \(0\) for \(\sin(x)\) is \(P_2(x) = x\text{.}\) In this case, the second order Taylor polynomial is a degree 1 polynomial.
We can use Taylor polynomials to approximate functions. This allows us to approximate values of functions using only addition, subtraction, multiplication, and division of real numbers. The \(n\)th order Taylor polynomial centered at \(x=a\) of a function \(f\) is