Maclauren Series Iteration. Answer provided just having trouble getting code to run properly
Show older comments
clear
new_cos=1;
x=pi/3;
stop=cos(x);
es=0.5;
ea=100;
et=100;
n=1;
nmax=1000;
while es<ea && stop~=new_cos%(stop<=new_cos) && (es<ea)%(n<nmax)
%while (es<ea) && (n<nmax)
old_cos=new_cos;
new_cos=(old_cos-(x^n))/(factorial(n));
et=abs(((stop-new_cos)/stop)*100);
ea=abs(((new_cos-old_cos)/new_cos)*100);
n=n+1;
%if new_cos~=0
%ea=abs(((new_cos-old_cos)/new_cos)*100);
%end
disp(new_cos)
disp(et)
disp(ea)
end

Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!