Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

Q2: In this question, you will use Python to numerically differentiate the function f(x) = ex. 1- Create an array of 100 equally spaced numbers between 0.001 and 1 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 marks) 3- Compute the backward 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 backward difference approximation for every step-size in H. Plot the percentage of relative error versus H. Include the plot in your report. (3 marks) 4- 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. (3 marks) 5- What will happen as the step-size decreases? (0.5 marks) 6- Which approximation is more accurate? (0.5 marks) Hint: H=np.linspace(0.001, 1, 100);#creates an array of equally spaced numbers between 0.001 and 1 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 forward approximation for step-size H[i]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions