I'm completely stuck on this While Loop using Taylor Series.
x = input('Input the angle in radians: ');Cos_Estimate = 0;k = 0;Errrr = 1while Errrr > .000001if mod(k,2) Sign = 1; else Sign = -1; end k = k + 2; Cos_Estimate = Cos_Estimate + (x^k/(factorial(k)*Sign)); Errrr = abs(Cos_Estimate - cos(x));enderr = abs(Cos_Estimate - cos(x));fprintf('The estimated cosine value based on the Taylor Series is: %0.6f \n',Cos_Estimate)fprintf('The actual cosine value is : %0.6f \n',cos(x))fprintf('The estimation error is: %0.6f \n',err)fprintf('The number of terms required was: \n',term)
Now I am getting NaN for my variable. I'm stuck.
Best Answer