Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
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