MATLAB: Infinite series for pi

infinite series

Hi I am trying to create an infinite series for pi using INF SIGMA http://mathworld.wolfram.com/images/equations/PiFormulas/NumberedEquation14.gif
I am having a hard time figuring out how to even start this….
i have tried…..
value=0;
k=1;
for k=1:3;
if k<=3;
value= .0625^k
n=n+1;
end
end
for the first part but it says "unexpected expression error". I have to have it go up to 20 terms from 0. Can someone please help me with this. I am new to MATLAB and having a hard time doing this series. Thank You. This is the student version of MATLAB

Best Answer

Hint:
theSum = 0.0;
r = -41.2; % I have no idea what r is supposed to be.
% Plug in the correct value for r.
for k = 1 : 14 % or whatever k you want to stop at
term1 = (4 + 8*r) / (8*k + 1);
term2 = -8*r / (8*k+2);
term3 = -4*r / (8*k+3);
term4 = -(2+8*r) / (8*k+4);
term5 = -(1+2*r) / (8*k+5);
term6 = -(1+2*r) / (8*k+6);
term7 = r / (8*k+7);
term8 = (1/16)^k;
thisSum = (term1+term2+term3+term4+term5+term6+term7)*term8;
theSum = theSum + thisSum
end