Question: Using the program MATLAB: Create a script that accepts a function f(x), the first derivative f ' (x), second derivative f ''(x) and stepsize h

Using the program MATLAB: Create a script that accepts a function f(x), the first derivative f ' (x), second derivative f ''(x) and stepsize h that plots the function f ' (x) (entered by user) with plots of the derivative using the forward, backward and centered difference formulas (the formulas are below). Then use the centered difference formula for the second derivative and plot this result alongside the user entered f ''(x) in a new figure.

Afterwards, run this script for h = 1, 0.1, 0.01, 0.001 and the following function: f(x) = x3+ cos(x)

Here are the formulas needed:

Using the program MATLAB: Create a script that accepts a function f(x),

Please solve this using only MATLAB! Thanks in advance!

Forward Difference Formula (1st order accurate) f(r h) -f(r) Backward Difference Formula (1st order accurate) f(r) r h) f (r) Centered Difference Formula (2nd order accurate) f (r) 2h Centered Difference Formula for 2nd Derivative (2nd order accurate f(a h) -2 (a) f( r h) f" (z) Forward Difference Formula (1st order accurate) f(r h) -f(r) Backward Difference Formula (1st order accurate) f(r) r h) f (r) Centered Difference Formula (2nd order accurate) f (r) 2h Centered Difference Formula for 2nd Derivative (2nd order accurate f(a h) -2 (a) f( r h) f" (z)

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!