In: Advanced Math
Write and submit at a Matlab function that sums up a specified number of odd-power terms from the Maclaurin series of sin(x) using following function format
function s = etaylor(x, n)
% Sum of first n non-vanishing terms of Maclaurin series of
sin(x)
% For example, etaylor(0.5, 1) should be 0.5, and etaylor(0.5, 2)
should be 23/48
Hey,
Note: Brother function file are not meant to be run
directly they are either run through the command window or some
script and should be saved with the same name mentioned below. In
case of any queries brother just comment in box I would be very
happy to assist all your queries.
===================================
Save file as etaylor.m
==================================
function s = etaylor(x, n)
s=0;
for i=1:n
s=s+((-1)^(i+1))*(x^(2*i-1))/factorial(2*i-1);
end
end
=====================================
Executable command to test
=====================================
etaylor(0.5,1)
Kindly revert for any queries
Thanks.