Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Taylor Series sine(x) infinite sum
I am writing a function that should be able to return to me the sine value of x using taylor series given x, and N which is how many terms
I have written my code
but I am not sure that it is correct. Can someone tell me if I wrote it correctly, and if not, how can I fix it.
[code]function output = sin_inf(x,n)
% result is the series approximation
result = x;
for i = 1:n
%the use of (-1)^i is to ensure that the method
%will add and subtract at the approriate interval
result = result + ( ( (-1).^i ) .* (x).^(2.*i + 1) )./factorial(2.*i + 1);
output = result;[/code]