Write a program (using a loop) the dertimes the expression: sqrt 12 Sigma (m on top) (n=0 on bottom) ((-1/3)^n) / (2*n+1) Run the program with m=5 m=10 and m=20. Compare the results with pi (Use Long format).
this is what I have done
format long S=0 m=input('Input a value for m=') for n=0:m S(1:m)=sqrt(12)*(S+((-1/3)^n)/(2*n+1))end
not sure if this is right
run program for m=5 m=10 m= 20
my results m =
5s =Columns 1 through 4 3.464101615137754 3.464101615137754 3.464101615137754 3.464101615137754Column 5 3.464101615137754s =Columns 1 through 411.615099820540248 11.615099820540248 11.615099820540248 11.615099820540248Column 511.615099820540248s =Columns 1 through 440.312866084211663 40.312866084211663 40.312866084211663 40.312866084211663Column 540.312866084211663s =1.0e+002 *Columns 1 through 4 1.396295359331753 1.396295359331753 1.396295359331753 1.396295359331753Column 5 1.396295359331753s =1.0e+002 *Columns 1 through 4 4.836956528011152 4.836956528011152 4.836956528011152 4.836956528011152Column 5 4.836956528011152s =1.0e+003 *Columns 1 through 4 1.675569596143254 1.675569596143254 1.675569596143254 1.675569596143254Column 5 1.675569596143254
Best Answer