Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The derivative of a continuous function f(x) is defined by the equation: d/dx f(

ID: 3540118 • Letter: T

Question

The derivative of a continuous function f(x) is defined by the equation:



d/dx f(x) =lim{h->0) ( f(x+h) - f(x) ) / h



Assume that a vector vect contains nsamp samples of a function taken at a sapcing of dx per sample. Write a function that will calculate the derivative of this vector from the equation. The function should check to make sure that h is greater than zero to prevent divide-by-zero errors in the function.


To check your function, you should generate a data set whose derivative is known and compare the result of the function with the known correct answer. A good choice for a test function is sin x. From elementary calculus, we know that d/dx sin x = cos x.


Generate an input vector containing 100 values of the function sin x starting at x=0 and using a step size h of 0.07. Take the derivative of the vector with your function and then compare the resulting answers to the known correct answer. How close did your function come to calculating the correct value for the derivative?



This question comes directly from MATLAB Programming For Engineers, 1st edition. Question 7.15.


Please code the function separately from a main program. The main program will call the function, and the function will return the derivative. The main program will plot the original function and its derivative.



Explanation / Answer

plz repost it. i am working on it