Question: The derivative of a function is given as, df = lim f(x+x)f(x). dx x0 x If f is a reasonably smooth function then x does

The derivative of a function is given as, df = lim f(x+x)f(x). dx x0 x If f is a reasonably smooth function then x does not have to be very small to approach the correct limit. A numerical approximation for finite x is, df |approx.= f(x+x)f(x) = df +x1d2 f +O(x2) dx xdx2dx2 The leading error term depends on what the second derivative of the function d2 f is like dx2 and scales as O(x). Code to use this simple approximation at one point is shown below: // derivative of y at x=x[1] dydx[1] = (y[2]-y[1])/deltax; Starting with ploty.c, change the code to plot a different function f (x) = 1 x + 3 x2 x3 in the interval from x = 0 to x = 1. Adjust the arguments to cpgenv appropriately to ensure the whole curve fits vertically on the plot. Add code to generate the derivative of f(x) using finite differences. Take special care near the end points so that you arent using values outside the array bounds. Plot the derivative of f (x) on the same axes by calling the cpgline subroutine. Adjust the arguments to cpgenv again to ensure both curves fit vertically on the plot. Use an identical number of intervals n = 20 and so forth. Change the color using cpgsci so you can tell the difference between the curves.

USING C PROGRAMMING

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!