Skip to main content

Unit 14.1 Taylor polynomials

Start with a function \(f(x)\text{.}\) Our goal will be to figure out the best approximation of \(f(x)\) (near \(x=c\)) by a polynomial of whatever degree we want (call that degree \(n\)).

\(n=1\).

When \(n=1\text{,}\) we want a degree-1 polynomial approximation. That is, we want the tangent line. So we use
\begin{equation*} P_1(x)=f(c)+f'(c)(x-c)\ \ \ . \end{equation*}

\(n=2\).

A degree-2 polynomial looks like \(q(x)=Ax^2+Bx+C\text{.}\) Since we’re interested in what happens when \(x\to c\text{,}\) let’s rewrite this form as \(q(x)=a_2(x-c)^2+a_1(x-c)+a_0\text{.}\) (The exact relationship between \(A,B,C\) and \(a_0,a_1,a_2\) isn’t important -- we just want to make sure that we’re writing everything in terms of \(c\text{.}\))
Let’s again write down our demands. We want \(f(x)\sim q(x)\text{ as }x\to c\text{,}\) i.e.,
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)}{q(x)}=1\text{.} \end{equation*}
As \(x\to c\text{,}\) \(x-c\to 0\text{.}\) So \(\displaystyle\lim_{x\to c} q(x)=a_0\text{.}\) As long as \(f\) is continuous, \(\displaystyle\lim_{x\to c}f(x)=f(c)\text{.}\) So we need \(a_0=f(c)\text{.}\)
As we did in the linear case, let’s imagine a competition among all quadratic polynomials of the form \(q(x)=a_2(x-c)^2+a_1(x-c)+f(c)\text{.}\) We demand:
\begin{align*} f(x)&\sim q(x)\text{ as }x\to c\\ f(x)&\sim a_2(x-c)^2+a_1(x-c)+f(c)\text{ as }x\to c\\ f(x)-f(c)&\sim a_2(x-c)^2+a_1(x-c)\text{ as }x\to c \end{align*}
But \(f(x)-f(c)\sim a_2(x-c)^2+a_1(x-c)\text{ as }x\to c\) just means
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)}{a_2(x-c)^2+a_1(x-c)}=1\ \ \ . \end{equation*}
We can rearrange the fraction to:
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)}{x-c}\frac{1}{a_2(x-c)+a_1}=1\ \ \ . \end{equation*}
As \(x\to c\text{,}\) \(\frac{1}{a_2(x-c)+a_1}\to\frac{1}{a_1}\text{.}\) We end up with \(a_1=f'(c)\text{.}\)
So now we know that \(q(x)=a_2(x-c)^2+f'(c)(x-c)+f(c)\text{.}\) Let’s rewrite our demands again:
\begin{align*} f(x)&\sim q(x)\text{ as }x\to c\\ f(x)&\sim a_2(x-c)^2+f'(c)(x-c)+f(c)\text{ as }x\to c\\ f(x)-f(c)-f'(c)(x-c)&\sim a_2(x-c)^2\text{ as }x\to c \end{align*}
This means we need
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)-f'(c)(x-c)}{a_2(x-c)^2}=1\ \ \ . \end{equation*}
The form of this limit is \(\frac{0}{0}\text{,}\) so we can apply L’Hôpital’s Rule. We need to be a bit careful to differentate with respect to \(x\). The numerator’s derivative is
\begin{equation*} \frac{d}{dx}\left(f(x)-f(c)-f'(c)(x-c)\right)=f'(x)-f'(c) \end{equation*}
and the denomator’s is
\begin{equation*} \frac{d}{dx}\left(a_2(x-c)^2\right)=2a_2(x-c)\ \ \ . \end{equation*}
Applying L’Hôpital’s Rule, we get
\begin{equation*} 1=\lim_{x\to c}\frac{f(x)-f(c)-f'(c)(x-c)}{a_2(x-c)^2}=\lim_{x\to c}\frac{f'(x)-f'(c)}{2a_2(x-c)}=\lim_{x\to c}\frac{1}{2a_2}\frac{f'(x)-f'(c)}{x-c}\ \ \ . \end{equation*}
So \(a_2=\frac{1}{2}f''(c)\text{.}\)
That is, the quadratic which best approximates \(f(x)\) near \(x=c\) is
\begin{equation*} P_2(x)=\frac{1}{2}f''(c)(x-c)^2+f'(c)(x-c)+f(c)\ \ \ . \end{equation*}

\(n=3\).

Now let’s approximate \(f(x)\) by a cubic of the form \(q(x)=a_3(x-c)^3+a_2(x-c)^2+a_1(x-c)+a_0\text{.}\) It probably won’t surprise you that \(a_0=f(c)\text{.}\) Let’s see about \(a_1\text{:}\)
\begin{align*} f(x)&\sim q(x)\text{ as }x\to c\\ f(x)&\sim a_3(x-c)^3+a_2(x-c)^2+a_1(x-c)+f(c)\text{ as }x\to c\\ f(x)-f(c)&\sim a_3(x-c)^3+a_2(x-c)^2+a_1(x-c)\text{ as }x\to c \end{align*}
which just means
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)}{a_3(x-c)^3+a_2(x-c)^2+a_1(x-c)}=1\ \ \ , \end{equation*}
or in other words
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)}{x-c}\frac{1}{a_3(x-c)^2+a_2(x-c)^+a_1}=1\ \ \ . \end{equation*}
Because \(\frac{1}{a_3(x-c)^2+a_2(x-c)^+a_1}\to\frac{1}{a_1}\) as \(x\to c\text{,}\) we see that \(a_1=f'(c)\text{.}\)
So now we have
\begin{align*} f(x)&\sim q(x)\text{ as }x\to c\\ f(x)&\sim a_3(x-c)^3+ a_2(x-c)^2+f'(c)(x-c)+f(c)\text{ as }x\to c\\ f(x)-f(c)-f'(c)(x-c)&\sim a_3(x-c)^3+a_2(x-c)^2\text{ as }x\to c \end{align*}
In order words, we need
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)-f'(c)(x-c)}{a_3(x-c)^3+a_2(x-c)^2}=1\ \ \ . \end{equation*}
L’Hôpital tells us that
\begin{equation*} 1=\lim_{x\to c}\frac{f(x)-f(c)-f'(c)(x-c)}{a_3(x-c)^3+a_2(x-c)^2}=\lim_{x\to c}\frac{f'(x)-f'(c)}{3a_3(x-c)^2+2a_2(x-c)}=\lim_{x\to c}\frac{f'(x)-f'(c)}{x-c}\frac{1}{3a_3(x-c)+2a_2}=\frac{f''(c)}{2a_2}\ \ \ . \end{equation*}
So \(a_2=\frac{1}{2}f''(c)\text{.}\)
Let’s update our demand:
\begin{align*} f(x)&\sim q(x)\text{ as }x\to c\\ f(x)&\sim a_3(x-c)^3+ \frac{1}{2}f''(c)(x-c)^2+f'(c)(x-c)+f(c)\text{ as }x\to c\\ f(x)-f(c)-f'(c)(x-c)-\frac{1}{2}f''(c)(x-c)^2&\sim a_3(x-c)^3\text{ as }x\to c \end{align*}
So we consider the limit
\begin{equation*} \displaystyle\lim_{x\to c}\frac{f(x)-f(c)-f'(c)(x-c)-\frac{1}{2}f''(c)(x-c)^2}{a_3(x-c)^3}=1\ \ \ . \end{equation*}
Again L’Hôpital’s Rule applies here, so we differentiate the numerator and the denominator to get:
\begin{equation*} 1=\lim_{x\to c}\frac{f'(x)-f'(c)-f''(c)(x-c)}{3a_3(x-c)^2}\ \ \ . \end{equation*}
This form is still indeterminate, so we apply L’Hôpital’s Rule again:
\begin{equation*} 1=\lim_{x\to c}\frac{f''(x)-f''(c)}{6a_3(x-c)}=\lim_{x\to c}\frac{1}{6a_3}\frac{f''(x)-f''(c)}{x-c}\ \ \ . \end{equation*}
Thus, we need to use \(a_3=\frac{1}{6}f'''(c)\text{.}\) Our approximating cubic is therefore:
\begin{equation*} P_3(x)=\frac{1}{6}f'''(c)(x-c)^3+\frac{1}{2}f''(c)(x-c)^2+f'(c)(x-c)+f(c)\ \ \ . \end{equation*}
Let’s write these out so that we can see the pattern.
\begin{align*} P_1(x)&=f(c)+f'(c)(x-c)\\ P_2(x)&=f(c)+f'(c)(x-c)+\frac{1}{2}f''(c)(x-c)^2\\ P_3(x)&=f(c)+f'(c)(x-c)+\frac{1}{2}f''(c)(x-c)^2+\frac{1}{6}f'''(c)(x-c)^3 \end{align*}
Can you see the pattern?

Checkpoint 192.

The last term of \(P_4(x)\) will look like
\begin{equation*} \frac{1}{something}f''''(c)(x-c)^4 \end{equation*}
where the something is .
Answer.
\(24\)

Definition 14.2. Taylor polynomials.

The degree-\(n\) Taylor polynomial for \(f(x)\) at \(x=c\) is
\begin{equation*} P_n(x)=f(c)+f'(c)(x-c)+\frac{1}{2}f''(c)(x-c)^2+\cdots+\frac{1}{n!}f^{(n)}(c)(x-c)^n \end{equation*}
A few observations to help you remember this formula:
  • The variable here is \(x\) -- not \(c\text{.}\)
  • In the formula for \(P_n\text{,}\) the derivatives of \(f\) are all evaluated at \(x=c\).
  • In each term, there is a derivative, a power of \(x-c\text{,}\) and a factorial. These all share the same index.
  • \(P_3(x)\) is just \(P_2(x)\) plus a term of degree 3; \(P_4(x)\) is just \(P_3(x)\) plus a term of degree 4; etc.

Example 14.3.

Compute the degree-4 Taylor polynomial for \(f(x)=\sin(x)+\cos(x)\) at \(x=\frac{\pi}{6}\text{.}\)
First, we’ll need to compute some derivatives:
\begin{align*} f(x)&=\sin(x)+\cos(x) & f\left(\frac{\pi}{6}\right)&=\frac{1}{2}+\frac{\sqrt{3}}{2}=\frac{1+\sqrt{3}}{2}\\ f'(x)&=\cos(x)-\sin(x) & f'\left(\frac{\pi}{6}\right)&=\frac{\sqrt{3}-1}{2}\\ f''(x)&=-\sin(x)-\cos(x) & f''\left(\frac{\pi}{6}\right)&=\frac{-1-\sqrt{3}}{2}\\ f'''(x)&=-\cos(x)+\sin(x) & f'''\left(\frac{\pi}{6}\right)&=\frac{-\sqrt{3}+1}{2}\\ f^{(4)}(x)&=\sin(x)+\cos(x) & f^{(4)}\left(\frac{\pi}{6}\right)&=\frac{1+\sqrt{3}}{2} \end{align*}
The formula in Definition 14.2 then yields:
\begin{equation*} P_4(x)=\frac{1+\sqrt{3}}{2}+\frac{\sqrt{3}-1}{2}(x-c)+\frac{1}{2}\frac{-1-\sqrt{3}}{2}(x-c)^2+\frac{1}{6}\frac{-\sqrt{3}+1}{2}(x-c)^3+\frac{1}{24}\frac{1+\sqrt{3}}{2}(x-c)^4 \end{equation*}
which we could simplify (if we wanted to):
\begin{equation*} P_4(x)=\frac{1+\sqrt{3}}{2}+\frac{\sqrt{3}-1}{2}(x-c)+\frac{-1-\sqrt{3}}{4}(x-c)^2+\frac{-\sqrt{3}+1}{12}(x-c)^3+\frac{1+\sqrt{3}}{48}(x-c)^4 \end{equation*}
Now you try your hand at it:

Checkpoint 193.

Compute the degree-3 Taylor polynomial for \(f(x)=\sqrt{x}\) near \(x=4\text{.}\)
Answer.
\(2+0.25\mathopen{}\left(x-4\right)-0.015625\mathopen{}\left(x-4\right)^{2}+0.00390625\mathopen{}\left(x-4\right)^{3}\)
Here’s another important property of the Taylor polynomials.

Checkpoint 194.

Differentiate the degree-4 Taylor polynomial at \(x=c\text{;}\) that is, compute
\begin{equation*} \frac{d}{dx}\left[f(c)+f'(c)(x-c)+\frac{1}{2}f''(c)(x-c)^2+\frac{1}{6}f'''(c)(x-c)^3+\frac{1}{24}f''''(c)(x-c)^4 \right] \end{equation*}
and evaluate at \(x=c\text{.}\) What do you get?
Now compute the further derivatives at \(x=c\text{:}\)
\(\frac{d^2}{dx^2}|_{x=c}P_4(x)=\)
\(\frac{d^3}{dx^3}|_{x=c}P_4(x)=\)
\(\frac{d^4}{dx^4}|_{x=c}P_4(x)=\)
\(\frac{d^5}{dx^5}|_{x=c}P_4(x)=\)
Answer 1.
\(f'\mathopen{}\left(c\right)\)
Answer 2.
\(f''\mathopen{}\left(c\right)\)
Answer 3.
\(f'''\mathopen{}\left(c\right)\)
Answer 4.
\(f''''\mathopen{}\left(c\right)\)
Answer 5.
\(0\)
This exercise shows two things:
  • where the factorial comes from in each term of the Taylor polynomial
  • that the derivatives of the Taylor polynomial are the same as the derivatives of \(f\text{,}\) at least at \(x=c\)

Definition 14.4. Maclaurin polynomials.

When we use \(c=0\text{,}\) we call the result the Maclaurin polynomials.

Example 14.5.

Let’s compute the degree-5 Maclaurin polynomial for \(f(x)=e^x\text{:}\)
\begin{align*} f(x)&=e^x & f\left(0\right)&=1\\ f'(x)&=e^x & f'\left(0\right)&=1\\ f''(x)&=e^x & f''\left(0\right)&=1\\ f'''(x)&=e^x & f'''\left(0\right)&=1\\ f^{(4)}(x)&=e^x & f^{(4)}\left(0\right)&=1\\ f^{(5)}(x)&=e^x & f^{(5)}\left(0\right)&=1 \end{align*}
So the Maclaurin polynomial is
\begin{equation*} 1+x+\frac{1}{2}x^2+\frac{1}{6}x^3+\frac{1}{24}x^4+\frac{1}{120}x^5\ \ \ . \end{equation*}