Home /
Expert Answers /
Computer Science /
problem-1-source-of-the-problem-matlab-an-introduction-with-application-by-gilat-3-text-pa507
(Solved):
Problem 1 (Source of the problem: MATLAB: An Introduction with Application by Gilat, \( 3^{\text { ...
Problem 1 (Source of the problem: MATLAB: An Introduction with Application by Gilat, \( 3^{\text {rd }} \) edition, p. 230) The Taylor's series expansion for \( \cos (x) \) is: \[ \cos (x)=1-\frac{x^{2}}{2 !}+\frac{x^{4}}{4 !}-\frac{x^{6}}{6 !}+\cdots+\frac{(-1)^{n}}{(2 n) !} x^{2 n}+\cdots \] where \( x \) is in radians. Write a user-defined function that estimates \( \cos (x) \) using Taylor's series expansion. For function name and arguments use \( \mathrm{y}=\cos \) Taylor \( (\mathrm{x}) \), where the input argument \( \mathrm{x} \) is the angle in degrees and the output argument \( \mathrm{y} \) is the value of for \( \cos (x) \). In the program of the user-defined function use a loop for adding the terms of the Taylor's series. If \( a_{n} \) is the nth term in the series, the sum \( S_{n} \) of the \( \mathrm{n} \) terms is \( S_{n}=S_{n-1}+a_{n} \). In each pass, calculate the estimated error \( E \) given by: \[ E=\left|\frac{S_{n}-S_{n-1}}{S_{n-1}}\right| \] Stop adding terms when \( E \leq 0.000001 \) Test the program by calculating \( \cos \left(55^{\circ}\right) \) and \( \cos \left(190^{\circ}\right) \)