Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python programming is required and try using Jupyter notebook if possible. Also

ID: 3757420 • Letter: P

Question

Python programming is required and try using Jupyter notebook if possible. Also use LaTeX style for the math equations used in codes.

Part 2 In this section, we will try to quantify the error in calculating values of functions which are error prone due to the limits of machine precision. Let us revisit the example we encountered in clas. 1. Plot the function g(r)for different ranges of z. After you have explored the function behavior for different ranges of r, focus on the values of r 0. What happens if you decrease r to magnitudes comparable to machine epsilon? 2. Write down the Taylor expansion for this function by first expanding the function f(r) log(1 +z) upto power 4 (one more term added to the series on Week 4 notes) and then calculating g(x)-f(x)/a. Show your full calculation. Use the LaTeX functionality of the markdown cells in Jupyter to show your calculations. Don't skip steps. I want to see the details

Explanation / Answer

Following are the python commands for executing the program for plotting the function in jupyter notebook and rendering the function statements in latex. The cells are separated using "---".

---

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

---

t = np.arange(0.00005, 5., 0.02)

---

f1 = lambda x : 1 + x

---

plt.plot(np.log(f1(t))/t)

---

plt.show()

---

%%latex

$f(x) = f(a) + f^{'}(a)(x-a) + rac{f^{''}(a)}{2!}(x-a)^{2} + rac{f^{'''}(a)}{3!}(x-a)^{3} + rac{f^{''''}(a)}{4!}(x-a)^{4} ...$

---

%%latex

$f(x) = log_{e}(1 + x) = x - rac{x^{2}}{2} + rac{x^{3}}{3} - rac{x^{4}}{4} ... $

---

%%latex

$g(x) = rac{f(x)}{x} = rac{1}{x} * f(x) = rac{1}{x} * (x - rac{x^{2}}{2} + rac{x^{3}}{3} - rac{x^{4}}{4} .. ) $

---

%%latex

$ = 1 - rac{x}{2} + rac{x^{2}}{3} - rac{x^{3}}{4} .. $

---