Question: 2. Write a function that computes the approximate value of cos x using Taylor's series cosx = 1 - x x x6 2! 4!


2. Write a function that computes the approximate value of cos x 

2. Write a function that computes the approximate value of cos x using Taylor's series cosx = 1 - x x x6 2! 4! 6! +... The function should use the while loop, which is terminated when the magnitude of the last term becomes smaller than 10%. The function should output the value of the truncated series as well as, as an option, the number of terms myvec (1) and compare the result to cos(x) that were used in the calculation. Use your function for x evaluated in Matlab. Is the difference smaller than 10-8?

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 Programming Questions!