Question: Q2: In this question, you will use Python to numerically differentiate the function f(x)=e4x. 1- Create an array of 100 equally spaced numbers between 0.001

 Q2: In this question, you will use Python to numerically differentiate

Q2: In this question, you will use Python to numerically differentiate the function f(x)=e4x. 1- Create an array of 100 equally spaced numbers between 0.001 and 0.5 and name it H. Each element in H will be a step-size for the numerical differentiation. See the hint at the end. 2- Compute the forward difference approximation of f(x) at xi=0 for every step-size in H. Compute the percentage of the absolute value of relative error of forward difference approximation for every step-size in H. Plot the percentage of relative error versus H. Include the plot in your report. 3- Compute the backward difference approximation of f(x) at xi=0 for every step-size in H. 4- Compute the percentage of the absolute value of relative error of backward difference approximation for every step-size in H. Plot the percentage of relative error versus H. Include the plot in your report. 5- Compute the centred difference approximation of f(x) at xi=0 for every step-size in H. Compute the percentage of the absolute value of relative error of centred difference approximation for every step-size in H. Plot the percentage of relative error versus H. Include the plot in your report. 6- What will happen as the step-size decreases 7- Which approximation is more accurate? Include your code in your report. Hint: import numpy as np import matplotlib.pyplot as plt H=np.linspace(0.001, 0.5, 100);\#creates an array of equally spaced numbers between 0.001 and 0.5 FM=np.zeros(100);# creates an array of 100 zeros. BM= np.zeros(100);\#creates an array of 100 zeros. CM=np.zeros(100); \# creates an array of 100 zeros. for i in range(0,100): FM[i]= \#write your code for computing the forward approximation for step-size H[i] BM[i]= \#write your code for computing the backward approximation for step-size H[i] CM[i]= \#write your code for computing the centred approximation for step-size H[i]

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!