x = pi/4;i = 2;term(1) = -0.080746;while term(i-1) >= 0.0001 term(i) = ((-1)^i/factorial(2*i+1))*x^(2*i+1) i = i+1endterm1(1) = -0.080746;a = 2;while term1(a-1) >= 1*10^-10 term1(a) = ((-1)^a/factorial(2*a+1))*x^(2*a+1) a = a+1endfprintf('It takes %i terms',i)fprintf('It takes %i terms',a)
My code is above and what follows is the question. I do not understand why this is not working. The first while loop works correctly but the second does not. Also, would a correct answer for the last part be "You can make it so that if 'i' reaches a certain number, break the loop."
Thanks for any help…
Best Answer