Taylor Series
Learning Objectives
- Approximate a function using a Taylor series
- Approximate function derivatives using a Taylor series
- Quantify the error in a Taylor series approximation
Polynomial Overview
Degree n Polynomial
A polynomial in a variable \(x\) can always be written (or rewritten) in the form
where \(a_{i}\) (\(0 \le i \le n\)) are constants.
Using the summation notation, we can express the polynomial concisely by
If \(a_n \neq 0\), the polynomial is called an \(n\)-th degree polynomial.
Degree n Polynomial as a Linear Combination of Monomials
A monomial in a variable \(x\) is a power of \(x\) where the exponent is a nonnegative integer (i.e. \(x^n\) where \(n\) is a nonnegative integer). You might see another definition of monomial which allows a nonzero constant as a coefficient in the monomial (i.e. \(a x^n\) where \(a\) is nonzero and \(n\) is a nonnegative integer). Then an \(n\)-th degree polynomial
can be seen as a linear combination of monomials \({x^i\ |\ 0 \le i \le n}\).
Taylor Series Expansion
Taylor Series Expansion: Infinite
A Taylor series is a representation of a function as an infinite sum of terms that are calculated from the values of the function's derivatives at a single point. The Taylor series expansion about \(x=x_0\) of a function \(f(x)\) that is infinitely differentiable at \(x_0\) is the power series
Using the summation notation, we can express the Taylor series concisely by
(Recall that \(0! = 1\))
The infinite Taylor series expansion of any polynomial is the polynomial itself.
Taylor Series Expansion: Finite
In practice, however, we often cannot compute the (infinite) Taylor series of the function, or the function is not infinitely differentiable at some points. Therefore, we often have to truncate the Taylor series (use a finite number of terms) to approximate the function.
Taylor Series Approximation of Degree n
If we use the first \(n+1\) terms of the Taylor series, we will get
which is called a Taylor polynomial of degree \(n\).
The finite Taylor series expansion of degree \(n\) for any polynomial is the polynomial itself truncated to degree \(n\).
Examples
Example of a Taylor Series Expansion
How would we expand \(f(x) = \cos x\) about the point \(x_0 = 0\), following the formula
\[f(x) = f(x_0)+\frac{ f'(x_0) }{1!}(x-x_0)+\frac{ f''(x_0) }{2!}(x-x_0)^2+\frac{ f'''(x_0) }{3!}(x-x_0)^3+\dotsb\]Answer
Well, we need to compute the derivatives of \(f(x)\) = cos \(x\) at \(x = x_0\). $$ \begin{align} f(x_0) &= \cos(0) = 1\\ f'(x_0) &= -\sin(0) = 0\\ f''(x_0) &= -\cos(0) = -1\\ f'''(x_0) &= \sin(0) = 0\\ f^{(4)}(x_0) &= \cos(0) = 1\\ &\vdots \end{align} $$ Then $$ \begin{align} \cos x &= f(0)+\frac{f'(0)}{1!}x+\frac{f''(0)}{2!}x^2+\frac{f'''(0)}{3!}x^3+\dotsb\\ &= 1 + 0 - \frac{1}{2}x^2 + 0 +\dotsb\\ &= \sum_{k=0}^{\infty} \frac{(-1)^k}{(2k)!}x^{2k} \end{align} $$Example of Using a Truncated Taylor Series to Approximate a Function
How would we approximate \(f(x) = \sin x\) at \(x = 2\) using a degree-4 Taylor polynomial about (centered at) the point \(x_0 = 0\), following the formula
Answer
Well, we need to compute the first 4 derivatives of \(f(x)\) = sin \(x\) at \(x = x_0\).Taylor Series Error
Error Bound when Truncating a Taylor Series
Suppose that \(f(x)\) is an \(n+1\) times differentiable function of \(x\), and \(T_n(x)\) is the Taylor polynomial of degree \(n\) for \(f(x)\) centered at \(x_0\). Then when \(h = |x-x_0| \to 0\), we obtain the truncation error bound by \[ \left|f(x)-T_n(x)\right|\le C \cdot h^{n+1} = O(h^{n+1}) \]
We will see the exact expression of \(C\) in the next section: Taylor Remainder Theorem.
Taylor Remainder Theorem
Suppose that \(f(x)\) is an \(n+1\) times differentiable function of \(x\). Let \(R_n(x)\) denote the difference between \(f(x)\) and the Taylor polynomial of degree \(n\) for \(f(x)\) centered at \(x_0\). Then
for some \(\xi\) between \(x\) and \(x_0\). Thus, the constant \(C\) mentioned above is
.
Note that this value is equivalent to the next term of the Taylor series.
Asymptotic behavior of the error
Let's say we have \(f(x)\) approximated using \(t_n(x)\). Suppose the given interval is \(h_1\) between \(x_0\) and \(x\) and the error associated with it is \(e_1\). Let's say we have another interval \(h_2\) and we need to find the error \(e_2\) associated with it.
Using the formula \(e = O(h^{n+1})\), we get
\[e_1 \propto {h_1}^{n+1}\] \[e_2 \propto {h_2}^{n+1}\]\[ \frac{e_1}{e_2} = (\frac{h_1}{h_2})^{n+1} \]
\[e_2 = (\frac{h_2}{h_1})^{n+1}e_1\]Examples
Example of an Error Bound
Suppose we want to approximate \(f(x) = \sin x\) using a degree-4 Taylor polynomial expanded about the point \(x_0 = 0\). How would we compute the error bound for this approximation, following the Taylor Remainder Theorem:
for some \(\xi\) between \(x_0\) and \(x\).
Answer
If we want to find the upper bound for the absolute error, we are looking for an upper bound for \( \vert f^{(5)}(\xi)\vert \).Since \( f^{(5)}(x) = \cos x \)
\( |f^{(5)}(\xi)|\le \cos(0) \rightarrow |f^{(5)}(\xi)|\le 1 \)
Then:
\( |R_4(x)| = \left|\frac{f^{(5)}(\xi)}{5!} (x-x_0)^{5}\right| = \frac{|f^{(5)}(\xi)|}{5!} |x|^{5} \le \frac{1}{120} |x|^{5} \)
Example of Error Predictions
Suppose you expand \(\sqrt{x - 10}\) in a Taylor polynomial of degree 3 about the center \(x_0 = 12\). For \(h_1 = 0.5\), you find that the Taylor truncation error is about \(10^{-4}\). How would you find the Taylor truncation error for \(h_2 = 0.25\)?
Answer
We can use the formula \(e_2 = (\frac{h_2}{h_1})^{n+1}e_1\) to find the Taylor truncation error for \(h_2 = 0.25\).Here, \(n = 3\) and hence \(e_2 = (\frac{0.25}{0.5})^{4} \cdot 10^{-4} = 0.625 \cdot 10^{-5}\).
Review Questions
- What is the general form of a Taylor series?
- How do you use a Taylor series to approximate a function at a given point?
- How can you approximate the derivative of a function using Taylor series?
- How can you approximate the integral of a function using Taylor series?
- Given a function and a center, can you write out the n-th degree Taylor polynomial?
- For an n-th degree Taylor polynomial, what is the bound on the error of your approximation as a function of distance from the center?
- For simple functions, can you find the constant C in the Taylor error bound?
- Be able to determine how many terms are required for a Taylor series approximation to have less than some given error.