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 = 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
To solve this problem we need to write a function in MATLAB named deriv that uses the twopoint centr... View full answer
Get step-by-step solutions from verified subject matter experts
