I want to implement taylor series for sinx with loop.
So , :
angle=input('Insert angle in degrees\n');x=angle*2*pi/360; %convert to radians because the equation is in radians
eps=0.000001;%accuracy
sumation=0;err=1;%error
n=0;while err>eps term=((((-1)^n)/factorial(2*n+1))*(x^2*n +1)); sumation=sumation+term; err=abs((sumation-term)/term); n=n+1; end result=sumation
I think the problem is in computing the error.The error = ((sum(n)-sum(n-1))/sum(n-1)). I tried it also with sumation as a vector but still with no success.
Thanks!
Best Answer