Hi! I'm using MATLAB and I want to store or print some particular decimal digits of pi, from 9901 to 10000. I'm using the algorithm below (Brent-Salamin algorithm) to print the first 10000 digits but I can't find out a way to save and print only the decimal digits from 9901 to 10000. What function can I use? Any ideas?(adsbygoogle = window.adsbygoogle || []).push({});

http://en.wikipedia.org/wiki/Gauss–Legendre_algorithmCode (Text):function P = agm_pi(d)

% AGM_PI Arithmetic-geometric mean for pi.

% Brent-Salamin algorithm.

% agm_pi(d) produces d decimal digits.

% See Cleve's Corner, "Computing Pi",

% http://www.mathworks.com/company/ ...

% newsletters/news_notes/2011/

% Copyright 2011 MathWorks, Inc.

digits(d)

a = vpa(1,d);

b = 1/sqrt(vpa(2,d));

s = 1/vpa(4,d);

p = 1;

n = ceil(log2(d));

for k = 1:n

c = (a+b)/2;

b = sqrt(a*b);

s = s - p*(c-a)^2;

p = 2*p;

a = c;

end

P = a^2/s;

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Print particular digits of pi

Loading...

Similar Threads - Print particular digits | Date |
---|---|

LaTeX Printing Code from Python in Latex via "minted" | Sep 7, 2017 |

Mathematica: Duplex Printing from button inside DialogNotebook on Mac | Jun 19, 2013 |

Printing only integer values for some equation using MATHEMATICA. | Sep 27, 2012 |

Printing Matlab figure as Eps | Aug 3, 2012 |

Particular environment LaTeX help | Sep 8, 2006 |

**Physics Forums - The Fusion of Science and Community**