Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am trying to find the error in my code...I am trying to write the macla

ID: 3528449 • Letter: H

Question

Hello, I am trying to find the error in my code...I am trying to write the maclaurin series with max interactions of 100 and relative error of .000001. The problem with my code is that it does not change with error?? Please Help!!!!!!!!!!!! x=pi/3; error=.000001; N=100; sum=0; for k=0:1:100 k1=((-1)^k)*(x^(2*k)/(factorial(2*k))); sum =sum+k1; if (((abs(sum-k)/(sum))*100 <=R_error)) break end end fprintf('It took %d terms before the error was within %f of cos(x)',k,error); disp('This is the estimated answer') sum

Explanation / Answer

x=pi/3;
error=.000001;
N=100;
sum=0;
for k=0:1:100
k1=((-1)^k)*(x^(2*k)/(factorial(2*k)));
sum =sum+k1;
if (((abs(sum-k)/(sum))*100 <=R_error))
break ;
end
end
fprintf('It took %d terms before the error was within %f of cos(x)',k,error);
disp('This is the estimated answer') ;
sum ;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote