Question: a) Write a MATLAB function that computes the Absolute Relative Error between two functions. The functions, for which the error is being computed, are to

a) Write a MATLAB function that computes the Absolute Relative Error between two functions. The functions, for which the error is being computed, are to be passed into the function you are creating. A Template for the function call is below:

function [Error,x,y1,y2] = AbsRelativeError( NumberOfPoints, ... StartingValue, StoppingValue, ... Function1, Function2 )

%

% [Error,x,y1,y2] = AbsRelativeError( NumberOfPoints, StartingValue,... StoppingValue, Function1, Function2 );

%

% Computes the absolute relative error, between two functions.

% The error is computed at N incremental steps between Start and Stop.

% Inputs: NumberOfPoints - Number of points to be compared. StartingValue - Starting point for the comparison. StoppingValue - Stopping point for the comparison. Function1 - a function (i.e. @sin ) for comparison. Function2 - the second function in the comparison, also assumed to be the more accurate of the two functions

% Outputs: Error - the ARE between the two functions. x - the values where the comparisons occurred. y1 - values of Function1 at x ( Function1(x) ). y2 - values of Function2 at x ( Function2(x) )

%

b) Use this function to compute the error in the approzimation of sin(x)=x for |x|

c) Save the values computed for x, sin(x) and ARE into a file, and plot this data. This requires multiple plotes, all with different scales and views, to properly display the x and sin(x) relationship. Be sure to indicate the error bound (0.001) on any plot that contains ARE.

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!