(Solved):
Problem 5 (6 points): The Taylor series expansion for \( \sin x \) is given by: \[ \sin x=x-\fra ...
Problem 5 (6 points): The Taylor series expansion for \( \sin x \) is given by: \[ \sin x=x-\frac{x^{3}}{3 !}+\frac{x^{5}}{5 !}-\frac{x^{57}}{7 !}+\ldots .=\sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2 n+1) !} x^{2 n+1} \] where \( x \) is in radians. Write a user-defined function that determines \( \sin x \) using Taylor's series expansion. For function name and arguments, use \( \mathrm{y}=\sin \operatorname{Taylor}(\mathrm{x}) \), where the input argument \( x \) is the angle in degrees and the output argument \( y \) is the value of \( \sin x \). Inside the user-defined function, use a loop for adding the terms of the Taylor series. If \( a_{n} \) is the \( \mathrm{n}^{\text {th }} \) term in the series, then the sum \( S_{n} \) of the \( \mathrm{n} \) terms is \( S_{n}=S_{n-1}+a_{n} \). In each
iteration, calculate the estimated error E given by \( E=\left|\frac{\sin ^{-} s_{n-1}}{s_{n-1}}\right| \). Stop adding terms when \( E \leq 0.000001 \). Since \( \operatorname{Sin}(x)=\sin (x \pm 360 n) \) ( \( \mathrm{n} \) is an integer) write the user defined function such that it first checks if the angle \( x \) is greater than \( 360^{\circ} \) or smaller than \( -360^{\circ} \). If the angle \( x \) is greater than \( 360^{\circ} \) or smaller than \( -360^{\circ} \), the Taylor series will be calculated using the remainder when \( \mathrm{x} \) is divided by 360 . Use you sinTaylor function to calculate: (a) \( \sin 45^{\circ} \) (b) \( \sin 215^{\circ} \) (c) \( \sin \left(-1255^{\circ}\right) \) (d) \( \sin 15000^{\circ} \). Compare the values calculated using the sinTaylor function with the values obtained by using MATLAB's built-in \( \operatorname{sind}() \) function. Note: If \( \mathrm{x} \) is in degrees, then \( \mathrm{x} \) in radians is \( \mathrm{x}^{*} \mathrm{pi} / 180 \).