clearnew_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
MATLAB: Maclauren Series Iteration. Answer provided just having trouble getting code to run properly
#maclaureniterationMATLAB
Best Answer