Question: Create a function, mynumdiff ( f , x ) to compute the derivative of the function f ( x ) where x is the grid

Create a function, mynumdiff (f,x) to compute the derivative of the function f(x) where x is the
grid on which f(x) has been computed. Assume f(x)=sin(x)(Groups I,II),f(x)=cos(x)(Groups
III,IV) and f(x)=exp(x)(Groups V,VI,VII). Call mynumdiff (f,x) between the limits of x as ,
2 pi] having grid points equally spaced at a distance dx .(20 marks)
a. Compute the derivative using the forward difference, backward difference and central
difference formula and plot the analytical derivative on the same graph.
b. Compute the error at each point for different values of dx (varying by atleast 2 orders
of magnitude) and plot on a separate log-log graph for each difference formula.
c. Plot max error in the entire domain as function of dx for all the three difference
formulae on the same graph. What do you observe?
Create a function, mynumdiff ( f , x ) to compute

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 Programming Questions!