Problem 2 Understanding Errors Using Example Cosine Series See Hw01 Pre Lab Exercise 2 Ref Q43883895
PLease help me solve this matlab problem. Thank you
Problem 2: Understanding of errors (using an example of the cosine series) See HW01 Pre-Lab Exercise 2 for reference The algorithm for the cosine Taylor series expansion is given as follows: 1. x² X4 X6 (-1)*+1x(2k-2) cos(x) = 1- 16 2 (2k – 2)! a) Create a user defined function to approximate the value of cosine using the provided algorithm using a while loop to ensure that the algorithm runs until the percent error is below a given error tolerance (maxtol). A partially completed code has been provided (remove the part from the function handle before running). b) Test the function created in part (a) by evaluating at x = 7 and maxtol = le-4. c) Modify (slightly) the MATLAB function cosine_taylorN so that the while-loop checks both the error tolerance and the maximum number of iterations (maxitr). In other words, the loop terminates when either the error is sufficiently small or the maximum number of iterations is exceeded. The required inputs and outputs for the function are given below. function [y,N] = cosine_taylorN(x, maxtol, maxitr) d) Test the function again by evaluating at x = 7, maxtol = le-4, and maxitr = 20. What happens if maxitr = 10? Show transcribed image text Problem 2: Understanding of errors (using an example of the cosine series) See HW01 Pre-Lab Exercise 2 for reference The algorithm for the cosine Taylor series expansion is given as follows: 1. x² X4 X6 (-1)*+1x(2k-2) cos(x) = 1- 16 2 (2k – 2)! a) Create a user defined function to approximate the value of cosine using the provided algorithm using a while loop to ensure that the algorithm runs until the percent error is below a given error tolerance (maxtol). A partially completed code has been provided (remove the part from the function handle before running). b) Test the function created in part (a) by evaluating at x = 7 and maxtol = le-4. c) Modify (slightly) the MATLAB function cosine_taylorN so that the while-loop checks both the error tolerance and the maximum number of iterations (maxitr). In other words, the loop terminates when either the error is sufficiently small or the maximum number of iterations is exceeded. The required inputs and outputs for the function are given below. function [y,N] = cosine_taylorN(x, maxtol, maxitr) d) Test the function again by evaluating at x = 7, maxtol = le-4, and maxitr = 20. What happens if maxitr = 10?
Expert Answer
Answer to Problem 2: Understanding of errors (using an example of the cosine series) See HW01 Pre-Lab Exercise 2 for reference The…
OR