'============================================================================ ' G.H. George 1992 JUL 17 ' SALAMIN.BAS Modified 1998 APR 27 ' - Gauss-Salamin algorithm for the value of Pi. ' From the Mathematical Gazette, Vol. 76 (Number 476), pages 231-242, ' 1992 July. '============================================================================= ' Procedures: ' ' Variables: ' a, b, c, x, y: variables in the algorithm ' Iteration: loop counter = number of iterations DEFDBL A-Z DIM Iteration AS INTEGER CLS PRINT "Gauss-Salamin Estimation of Pi:" PRINT LET a = 1 LET b = 1 / SQR(2) LET c = 1 / 4 LET x = 1 PRINT "Iteration", "Estimate of Pi": PRINT FOR Iteration = 1 TO 10 LET y = a LET a = (a + b) / 2 LET b = SQR(y * b) LET c = c - x * (a - y) * (a - y) LET x = 2 * x PRINT Iteration, (a + b) * (a + b) / (4 * c) NEXT Iteration END '============================================================================ 'Iteration Estimate of pi ' 1 3.140579250522169 ' 2 3.141592646213542 ' 3 3.141592653589794 ' 4 3.141592653589794 ' 5 3.141592653589794 ' 6 3.141592653589794 ' 7 3.141592653589794 ' 8 3.141592653589794 ' 9 3.141592653589794 ' 10 3.141592653589794 pi = 3.141 592 653 589 794