Question: P3) We wish to write a program that can find the approximate derivative of a function specified through a function handle. (a) Write a MATLAB
P3) We wish to write a program that can find the approximate derivative of a function specified through a function handle. (a) Write a MATLAB function defined below: function [appDerv, exDerv, et]- myDervwithFuncHandle (func, x, h) %Function file: myDervWithFuncHandle.m Purpose : % Calculate approximate derivative using (f(x+h)-f(x))/h, exact % derivative f"(x) and true percentage relative error of a function % specified in func Record of revisions (Date I Programmer I Change): % Date | Name | Original program %inputs : % func- [fx, dfx-func-name (x) function handle defined as for calculating f (x) and x % x- (1x1) value of x where derivative needs to be calculated % h- (1x1) step size used in approximate derivative formula Outputs: % appDerv- % exDerv- % et approximate derivative calculated as exact derivative (f(x+h)-f(x))/h (1x1) (1x1) (1x1) true percentage relative error (b) Using function handles to myF1 and myt2 as inputs for myDervWithFuncHandle, calculate the approximate derivative, exact derivative and true percentage relative error of (x)-r'e and f(x)-7 sin(x)e-x-1 at x = 1 with h = 0.05
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
