Question: df(x) The first derivative of a function f(x) at a point x = xo can be approx- dx imated with the two-point central difference

df(x) The first derivative of a function f(x) at a point x

df(x) The first derivative of a function f(x) at a point x = xo can be approx- dx imated with the two-point central difference formula: df(x) _ f(x+h)-f(xo-h) dx 2h Where h is a small number. Write a user-defined function that calculates the derivative of a math function f(x) by using the two-point central difference formula. For the user-defined function name, use dfdx=deriv (func, x0), where func is a name for the function that is passed into deriv, and x0 is the point where the derivative is calculated. Use h = 0.001 in the two-point central difference formula. Use the user-defined function deriv to calculate the following derivatives in your main script: 1. f(x)=sin(x) at x0 = 0 2. f(x)=sin(x) at x0 = pi/2 3. f(x)=x* sin(x)e* at x0 = 0.1 4. f(x)=x* at x0 = 2.3 (Note that this is hard to compute analytically, but easy to compute with MATLAB

Step by Step Solution

3.52 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we need to write a function in MATLAB named deriv that uses the twopoint centr... View full answer

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!