Question: Q 1 ) In this question, you will approximate the function f ( x ) = e 4 x using Taylor's approximation in Python. Follow

Q1) In this question, you will approximate the function f(x)=e4x using Taylor's approximation
in Python. Follow these steps:
Write the fourth order Taylor's approximation of f(x) around xi=0. Do this by hand.
In Python, create an array named x containing 50 numbers evenly distributed between 0
and 0.5.
For each value in x, plot f(x) and its Taylor approximations at the 0 th,1 st,2nd,3rd, and
4th orders, all around xi=0. See the hint at the end of the question. Include this plot in
your report.
Discuss how the accuracy of the approximation changes as you increase the order of the
Taylor approximations.
For each point in x, plot the percentage of the absolute value of relative error for each
Taylor approximation order (0th to 4th) of f(x) around xi=0. Add this plot to your
report.
Describe how the error changes as the value of x increases.
Include the Python code used for these steps in your report.
Hint:
You can compute and plot e4x using the following commands:
from math import factorial
import matplotlib.pyplot as plt
import numpy as np
# Create an array X with 50 numbers evenly distributed between and 0.5
x=np.linspace(0,0.5,50)
Y=np*exp(4**x) # Function f(x)=e???(4x)
plt.figure()
plt.plot (X, Y, label="f(x)=e???(4x), color="black")
plt.xlabel("x")
plt.ylabel("f(x)")
plt. legend()
plt.grid(True)
plt.show()Q1) In this question, you will approximate the function f(x)=e4x using Taylor's approximation
in Python. Follow these steps:
Write the fourth order Taylor's approximation of f(x) around xi=0. Do this by hand.
In Python, create an array named x containing 50 numbers evenly distributed between 0
and 0.5.
For each value in x, plot f(x) and its Taylor approximations at the 0 th,1 st,2nd,3rd, and
4th orders, all around xi=0. See the hint at the end of the question. Include this plot in
your report.
Discuss how the accuracy of the approximation changes as you increase the order of the
Taylor approximations.
For each point in x, plot the percentage of the absolute value of relative error for each
Taylor approximation order (0th to 4th) of f(x) around xi=0. Add this plot to your
report.
Describe how the error changes as the value of x increases.
Include the Python code used for these steps in your report.
Hint:
You can compute and plot e4x using the following commands:
from math import factorial
import matplotlib.pyplot as plt
import numpy as np
# Create an array X with 50 numbers evenly distributed between and 0.5
x=np.linspace(0,0.5,50)
Y=np*exp(4**x) # Function f(x)=e???(4x)
plt.figure()
plt.plot (X, Y, label="f(x)=e???(4x), color="black")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.legend()
plt.grid(True)
plt.show ()
You can compute (4x)22! using the following command:
Y2nd=Y1st+(4**x)****2factorial(2)
Calculate each term in Taylor's approximation using similar commands. Then, sum up the
terms to compute the Taylor's approximation.
 Q1) In this question, you will approximate the function f(x)=e4x using

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!