Answer to Question #301289 in Calculus for Harsh

Question #301289

The function sin(x) can be written as a Taylor series by:




 



Write a user-defined function file that calculates sin(x) by using the Taylor series. For the function name and arguments use y = Tsin(x,n). The input arguments are the angle x in degrees and n the number of terms in the series. Use the function to calculate sin(150 ) using R no of terms (where R is last digit of registation no; use 10 if last digit zero & use 11 if last digit is 1)


1
Expert's answer
2022-02-23T13:42:35-0500
%the file with function
function y = Tsin(x,n)
for j = 1:n
fact=1;
max=2*n+1;
for j = 1:max
    fact=fact*j;
end
elem=(-1)^n*x^(2*n+1)/fact
y=y+elem;
end
%the calling of the function in other file
R=8; %the example
Tsin(150,R);
%the result
ans = -0.714876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS