../_images/book_cover.jpg

This notebook contains an excerpt from the Python Programming and Numerical Methods - A Guide for Engineers and Scientists, the content is also available at Berkeley Python Numerical Methods.

The copyright of the book belongs to Elsevier. We also have this interactive book online for a better learning experience. The code is released under the MIT license. If you find this content useful, please consider supporting the work on Elsevier or Amazon!

< 18.3 Discussion on Errors | Contents | CHAPTER 19. Root Finding >

Summary

  1. Some functions can be perfectly represented by a Taylor series, an infinite sum of polynomials.

  2. Functions that have a Taylor series expansion can be approximated by truncating its Taylor series.

  3. The linear approximation is a common local approximation for functions.

  4. The truncation error can be estimated using the Taylor Remainder Estimation Theorem.

  5. Be mindful of the round-off error in the Taylor series.

Problems

  1. Use Taylor series expansions to show that \(e^{ix} = \cos(x) + i\sin(x)\), where \(i = \sqrt{-1}\).

  2. Use the linear approximation of \(\sin(x)\) around \(a = 0\) to show that \(\frac{\sin(x)}{x} \approx 1\) for small \(x\).

  3. Write the Taylor series expansion for \(e^{x^2}\) around \(a = 0\). Write a function my_double_exp(x, n), which computes an approximation of \(e^{x^2}\) using the first \(n\) terms of the Taylor series expansion. Be sure that my_double_exp can take array inputs.

  4. Write a function that gives the Taylor series approximation to the np.exp function around 0 for order 1 through 7. Calculate the truncation error bound for order 7.

  5. Compute the fourth order Taylor expansion for \(\sin(x)\) and \(\cos(x)\) and \(\sin(x)\cos(x)\) around 0. Which produces less error for \(x = \pi/2\): computing the Taylor expansion for \(\sin\) and \(\cos\) separately then multiplying the result together, or computing the Taylor expansion for the product first then plugging in \(x\)?

  6. Use the 4th order Taylor series to approximate \(cos(0.2)\) and determine the truncation error bound.

  7. Write a function my_cosh_approximator(x, n), where output is the \(n\)-th order Taylor Series approximation for \(\text{cosh}(x)\), the hyperbolic cosine of \(x\), taken around \(a = 0\). You may assume that \(x\) is an array and \(n\) is a positive integer (including 0). Recall that $\( {\rm cosh}(x) = (e^x + e^{-x})/2. \)\( Warning: The approximations for \)n = 0\( and \)n = 1\( will be equivalent, the approximations for \)n = 2\( and \)n = 3$ will be equivalent, and so on.

< 18.3 Discussion on Errors | Contents | CHAPTER 19. Root Finding >