Home /
Expert Answers /
Advanced Math /
in-this-problem-we-approximate-f-x-cos-x-using-taylor-series-a-how-many-terms-in-the-taylor-s-pa221
(Solved): In this problem, we approximate f(x)=cos(x) using Taylor series. (a) How many terms in the Taylor s ...
In this problem, we approximate f(x)=cos(x) using Taylor series. (a) How many terms in the Taylor series approximation to f(x)=cos(x) do I need to make sure that my error is less than 2×10?8 for x?[0,?/2] ? Use the Taylor approximation error of En?(x)=(n+1)!(x?c)n+1?f(n+1)(?) to derive your answer, or another another theorem from calculus. If you expand cos(x) around c=0, then the Taylor series will have some zero terms. You should count these terms towards the n in your answer. (b) Write a function called my_cos which takes in two arguments: a number x and a positive integer n. Your function should approximate cos(x) using a Taylor series approximation of order n. The function should return the approximate value.
c) Now we experimentally verify the bound from part (a) in Matlab using your function from part (b). Define a vector x of 100 equally spaced points between [0,?/2]. For each of these points, compute the error, ???cos(x)?m??_cos(x,n)???, using two different values of n : - n=3 - Value of n that you compute in part (a) Plot the errors (I recommend a logarithmic vertical axis) for both these values of n against the vector x. Is your error below the bound in part (a) at all these points for the two values of n ?