Lecture 20 Taylor Polynomials
Text References: Course notes pp. 75-100 & Rogawski 4.8, 10.7
20.1 Recap
Last time, we learned a method to fit a polynomial of degree \(n\) to a set of \(n+1\) points.
20.2 Learning Objectives
- Find the \(n\)th order Taylor polynomial for a given function.
20.3 Motivation
To motivate Taylor polynomials, let’s think back to a few key ideas we’ve discussed so far.
The first idea is that of linear approximations. We’ve seen that the linear approximation of a function \(f(x)\) at \(x_0)\) is given by \(y=f(x_0)+\dfrac{\Delta y}{\Delta x}(x-x_0)\). Note that as we take the limit \(\Delta x \to 0\) of \(\dfrac{\Delta y}{\Delta x}\), we get the derivative of \(f\), so the linear approximation can be written as \(y=f(x_0)+f'(x_0)(x-x_0)\).
What if we want to approximate our function with polynomials instead? For simplicity, let’s start by trying to approximate a function using a parabola. Here’s where our second key idea of the Newton Forward Difference Formula comes in.
Suppose that we have a function at the equidistant points \(x_0\), \(x_1=x_0+\Delta x\), and \(x_2 = x_0 +2 \Delta x\). The corresponding \(y\) values will be \(y_0=f(x_0)\), \(y_1 = f(x_1)=f(x_0+\Delta x)\), and \(y_2=f(x_2)=f(x_0+2\Delta x)\). We can apply the Newton Forward Difference Formula to get the equation of the parabola that joins these three points: \[y=y_0+\frac{\Delta y_0}{\Delta x}(x-x_0)+ \frac{1}{2}\frac{\Delta^2 y_0}{(\Delta x)^2}(x-x_0)(x-x_1)\]
Now, let’s take the limit as \(\Delta x \to 0\). We already know that \(\dfrac{\Delta y_0}{\Delta x}\to f'(x_0)\); you might guess (correctly!) that \(\dfrac{\Delta^2 y_0}{\Delta x^2}\to f''(x_0)\). Finally, we have that \(x_1\to x_0\). Putting everything together, we get a quadratic approximation to \(f(x)\): \[y= f(x_0)+f'(x_0)(x-x_0)+\frac{1}{2}f''(x_0)(x-x_0)^2\]
The following interactive applet is designed to give you an intuition for what’s going on both with the linear approximation and the quadratic approximation. Use the checkbox to display either the linear or quadratic approximation of the function. Use the slider to shorten the distance between the points \(x_0\), \(x_1\) (and \(x_2\) for the quadratic approximation). Notice what happens to the approximations as \(\Delta x \to 0\).
20.4 Taylor Polynomials
Now that we’ve got the flavour of things. we can extend this idea to a polynomial of degree \(n\). The n-th order Taylor Polynomial centred at \(x_0\) is \[P_{n, x_0}(x)= f(x_0)+f'(x_0)(x-x_0)+\frac{1}{2!}f''(x_0)(x-x_0)^2+\cdots+\frac{1}{n!}f^{(n)}(x_0)(x-x_0)^n\]
We can also write it more concisely using summation notation: \[P_{n, x_0}(x)= \sum_{k=0}^n \frac{f^{(k)}(x_0)}{k!}(x-x_0)^k\]
As you might expect, higher degree polynomial approximations typically give better approximations.
This interactive applet demonstrates how the Taylor polynomial can be used to approximate functions. Try a few functions out for yourself!
Exercise 20.1 Find the 3rd-order Taylor polynomial for \(f(x)=\sqrt{x+1}\) centred at \(3\).
Solution. We have \[f'(x)=\frac{1}{2}(x+1)^{-1/2}, \quad f''(x)= -\frac{1}{4}(x+1)^{-3/2}, \quad f'''(x)= \frac{3}{8}(x+1)^{-5/2}\]
Evaluating at \(x=3\), we get \[f'(3)=\frac{1}{4}, \quad f''(3) = -\frac{1}{32}, \quad f'''(3) = \frac{3}{256}\]
The Taylor polynomial is given by
\[\begin{align*} P_{3,3}(x) &= 2+ \dfrac{1}{4}(x-3)+\frac{1}{2!}\frac{1}{32}(x-3)^2+ \frac{1}{6}\frac{3}{256}(x-3)^3\\ &= 2+ \frac{1}{4}(x-3)-\frac{1}{64}(x-3)^2+\frac{1}{512}(x-3)^3 \end{align*}\]
Exercise 20.2 Find the 4th-order Taylor polynomial for \(f(x)=\dfrac{1}{1-x}\) centred at \(0\).
Solution. We have \[f'(x)=\frac{1}{(1-x)^2}, \quad f''(x) = \frac{2}{(1-x)^3}, \quad f'''(x)=\frac{6}{(1-x)^4}, \quad f^{(4)}(x) = \frac{24}{(1-x)^5}\]
and \[f'(0)=1, \quad f''(0)=2, \quad f'''(0)=6, \quad f^{(4)}(x)=24\]
then,
\[\begin{align*} P_{4,0}(x) &= 1+1\cdot x + \frac{1}{2!}2x^2+\frac{1}{3!}6x^3+\frac{1}{4!}24x^4\\ &= 1+x+x^2+x^3+x^4 \end{align*}\]