Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Taylor\'s series expansion for sinx about x 0 is given by 57 2n+1 Sin x wher

ID: 2082302 • Letter: T

Question

The Taylor's series expansion for sinx about x 0 is given by 57 2n+1 Sin x where x is in radians. Write a user-defined function that determines sinx using Taylor's series expansion. For function name and arguments, use y sin Tay (x) where the input argument x is the angle in degrees and the output argument y is the value of sinx. Inside the user-defined function, use a loop for adding the terms of the Taylor's series. If an is the nth term in the series, then the sum Sn of the n terms is s, a In each pass, cal culate the estimated error E given by E ST-S, Stop adding terms when IS Sm-1 E50.000001. Since sin 6 sin ot 360n) (n is an integer) write the user defined function such that if the angle is larger than smaller than 360°, then the Taylor series will be calculated using the smallest number of terms (using a value for r that is closest to 0) Use sinTay for calculating: (a) sin 39 (b) sin 205 (c) sin( 70°) (d) sin 754. (e) sin 19000° (f) sin( 7480) values obtained Compare the values calculated using sinTay with the by using MATLAB's built-in sind function. Answer part a sin Tav(39)

Explanation / Answer

Matlab Script:

function y = sinTay(x)
if x>360%converts given value to nearest 0
x=x-(floor(x/360)*360);
end
x = x*pi/180;
sinx_prev = x;
sign1 = -1;
n=3;%power of x in each term
while 1==1
sinx_next = sinx_prev+sign1*(x^n)/factorial(n);
n = n+2;
if (abs(sinx_next-sinx_prev)/(sinx_prev))<=0.000001%checking for estimated error
y = sinx_next;
break;
end
sinx_prev = sinx_next;
sign1 = sign1*-1;
  
end
end

command window log:

>> clear all
>> sinTay(39)

ans =

0.629320391412846

>> sind(39)

ans =

0.629320391049837

>> sind(205)

ans =

-0.422618261740699

>> sinTay(205)

ans =

-0.422618269813407

>> sinTay(-70)

ans =

-0.939692618631544

>> sind(-70)

ans =

-0.939692620785908

>> sinTay(754)

ans =

0.559192892745078

>> sind(754)

ans =

0.559192903470747

>> sinTay(19000)

ans =

-0.984807763499073

>> sind(19000)

ans =

-0.984807753012208

>> sinTay(-748)

ans =

-0.469471555535443

>> sind(-748)

ans =

-0.469471562785891

>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote