Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started