Question: MATLAB (a) Develop an M-file function to evaluate the centered finite-difference approximations, starting with x = 0.5. Thus, for the first evaluation, the x values

MATLAB

(a) Develop an M-file function to evaluate the centered finite-difference approximations, starting with x = 0.5. Thus, for the first evaluation, the x values for the centered difference approximation will be x = 2 0.5 or x = 1.5 and 2.5. Then, decrease in increments of 0.1 down to a minimum value of x = 0.01.

(b) Repeat part (a) for the second-order forward and backward differences. (Note that these can be done at the same time that the centered difference is computed in the loop.)

(c) Plot the results of (a) and (b) versus x. On the same plot also show the true value of the derivative for the range of 0 to 0.5.

Use the follwing formulas:

Centered Diff: df/dx = (f(i+1) - f(i-1)) / 2dx

Forward Diff: df/dx = (-f(i+2) + 4f(i+1) - 3f(i)) / 2dx

Backward Diff: df/dx = (3f(i) - 4f(i-1) + f(i-2)) / 2dx

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