Question: please complete in MATLAB. Please show code snippet and output 1.2 For the polynomial f(x)=x42x3, calculate the derivative and the 2 nd derivative analytically (the

 please complete in MATLAB. Please show code snippet and output 1.2

please complete in MATLAB. Please show code snippet and output

1.2 For the polynomial f(x)=x42x3, calculate the derivative and the 2 nd derivative analytically (the first derivative so that you can compare with your numerical derivatives to determine the error, and the second derivative might be useful for understanding your results -see equations (1.9) and (1.11)). a) Choose different step sizes h and plot a log-log graph of error vs step size to compare the numerical derivatives found using the forward, backward, and central difference formulas with the actual derivative. How accurate are the numerical derivatives at x=0,1,1.5, and 2 ? At what step sizes do you obtain the minimum errors, and what are the minimum errors (see Sauer figure 5.1)? Do you expect that this would be a problem? What if you were using single-precision floating point? (You can easily try this in Matlab by using the single() function.) b) Add some additional error to your polynomial. For example, try y= f(x)+0.001randn(size(x)); . How does the error in the numerical derivative vary with step size h ? Try changing the size of the error. Checklist Did you differentiate the function (including with added error)? Did you explain how you did it? Did you plot graphs showing the error vs step size at each point? Are your graphs and axes properly labelled? Did you discuss whether the results were what you expected? Did you discuss any unusual results? Did you include code where appropriate? Did you reference the source of any code you didn't write

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!