I want to approximate pi/4 by using the infinite sum pi/4=((-1)^(n))/(2*n+1) from 0 to infinity. Here is my MATLAB code:
if true tol = 10^(-5) %Up to five correct decimals d=1; %Arbitrarily chosen, only condition is that d>tol at the start sn=0; %Initial starting value n=0; while d>tol
sn = ((-1)^(n))/(2*n+1); This is the approximation for pi/4.
d=abs(pi/4-sn); Value that decides whether the loop continues. n=sn; I'm not sure but I want n to increase by one each
time to prevent circular calculations.
Why do I get Inf+ Nani?
No products are associated with this question.