34. The Taylor series expansion for sin x about x = 0 is given by:
sin
x
=
x
−
x
3
3
!
+
x
5
5
!
−
x
57
7
!
+
....
=
∑
n
=
0
∞
(
−
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 y=sinTay (x), where the input argument x is the angle in degrees and the output argument y is the value of sins, inside the user-defined function, use a loop for adding the terms of the Taylor series. If anis the nth term in the series, then the sum Snof the n terms is Sn= Sn-1+ an. in each pass, calculate the estimated error F given by
E
=
S
n
−
S
n
−
1
S
n
−
1
. Stop adding terms when
E
≤
0.000001
. Since
sin
θ
=
sin
(
θ
±
360
n
)
(n is an integer) write the user- defined function such that if the angle is larger than 360°, or smaller than -360°, then the Taylor series will be calculated using the smallest number of terms (using a value for x that is closest to 0).
Use sinTay for calculating:
(a) sin39° (h) sin205° (c) sin(-70°)
(c) sin 754° (e) sin 19,000° (d) sin(-748°)
Compare the values calculated using sinTay with the values obtained by using MATLAB’s built-in sind function.