Number Pi
PROBLEM Compute the number Pi to thousand decimal places.
ALGORITHM
Algorithm of J. M. Borwein and P. B. Borwein for computation of Pi number starts with the initializations X=SQRT(2); Pi=2+X; Y=SQRT(X)
and then repeats the iteration
IMPLEMENTATION
Unit: internal function, external function without procedure statement
Interface: SQRT function Parameter: a positive integer P  number of digits of Pi, implicit P=9 Returns: the first P significant decimal digits of Pi, default is 9
There is an another way to obtain the value of the number Pi: we can compute the number Pi only once and save its value into the text of the function. The following PICONST function can be used to computing of the first P decimal digits of Pi, for P=1,...,200. It was created automatically by the program, see Technique: Beforehand computed constants.
The statement Number_Pi=PI(1000) computes 10 times loop in PI function and requires 79 seconds.
CONNECTIONS
Square root of positive number
Technique: Beforehand computed constants P+n trick by Walter Pachl in Reflexio Literature
Press W.H., Teukolsky S.A., Vetterling W.T., Flannery B.P. Numerical Recipes in C : the art of scientific computing  2nd ed. University Press, Cambridge, 1992
