Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1) In this question, you will use Python to approximate the function f(x)=e3x using Taylor's approximation. 1. Compute the forth order Taylor's approximation of f(x)
Q1) In this question, you will use Python to approximate the function f(x)=e3x using Taylor's approximation. 1. Compute the forth order Taylor's approximation of f(x) around xi=0. (Calculate the Taylor's expansion on the paper) 2. In Python, generate an array of 50 equally-spaced numbers between 0 and 0.5 and name it 3. For every point in X, plot f(x) and its 0th order, 1 st order, 2nd order, 3rd order and 4th order Taylor's approximations around xi=0. See the hint at the end of the question. Include the plot in your report. 4. What will happen as the order of approximation increases? 5. For every point in X, plot the percentage of the absolute value of the true relative error of the 0th order, 1st order, 2nd order, 3rd order and 4th order Taylor's approximations of f(x) around xi=0. Include the plot in your report. 6. What will happen to the error as x increases? Include your code in your report. Hint: 1-you can compute and plot e3x using the following commands: import numpy as np import matplotlib.pyplot as plt x=np.linspace (0.01,0.5,50) y=np.exp(3x) \# multiplies each element of x by 3 and computes the exponential of the result. plt.plot (x,y, label ="f(x)") \#plots y as a function of x and labels it as f(x) plt.legend()\#plots the label plt.figure() \#creates a new figure 2- you can compute 2!x2 using the following command: a) y2=np.power (x,2)/ np.math.factorial(2)\#raises each element of x to the power of 2 and divides the result by 2 ! 3-Calculate each term in Taylor's approximation using the command above. Then, sum up the terms to compute the Taylor's approximation
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started