Question: The function y = c o s x can be approximated by the polynomial: = 1 - x 2 4 + x 4 2 4
The function can be approximated by the polynomial: provided that is reasonably close to We wish to write a function file to approximate the function but we need to take advantage of the periodicity of to reduce the errors.
a Write a function file called to do the following:
i Test to see that is positive, and if it is not, stop the function.
ii While is still greater than subtract from
iii After this is done, should be between and Use the above degree polynomial to estimate
b Write a program file that does the following.
i Set up a vector of values from o to in steps of
ii Use a ForLoop to go through the vector of values
iiiAt each value call your function on that value. Call the Matlab function and subtract the two to find the error. Divide the actual value of and multiply by to find the percentage error. Display both the value and the percentage error. Note that percentage error is given by:
Sometimes this will be positive and sometimes it will be negative and this is expected.
iv Plot the percentage error on a graph
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
