Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site vu44.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!vu44!tstorm From: tstorm@vu44.UUCP (Theo van der Storm) Newsgroups: net.math Subject: Re: Calculating Pi to Excessive Accuracy Message-ID: <680@vu44.UUCP> Date: Sat, 3-Aug-85 11:44:57 EDT Article-I.D.: vu44.680 Posted: Sat Aug 3 11:44:57 1985 Date-Received: Sun, 4-Aug-85 06:31:33 EDT References: <423@ist.UUCP> Reply-To: tstorm@vu44.UUCP Distribution: net Organization: VU Informatica, Amsterdam Lines: 51 In article <423@ist.UUCP> bco@ist.UUCP (Brian Collins) writes: >Following Ken Yap's posting, which soaks up 2 hours of CPU to >calculate Pi to 1000 decimal places, may I offer the >following sh/bc script that takes just over 6 mins on my >Pyramid. > >bc < /* Computes Pi to $1 places */ > t = 3 * 10^${1-100} > for (i = 1; t != 0; i++) { > p = p + t > t = t * (2 * i - 1) * (2 * i - 1) / (8 * i * (2 * i + 1)) > } > p >! > > ...differential of asin( x) ; asin( 0.5) = pi / 6 ... > >Any advance on 6 minutes? > >Brian Collins ...mcvax!ist!bco (bco@ist) >Imperial Software Technology, London Using Ken Yap's formula (!) here is a bc program (written by me), which is almost twice as fast as YOUR program: [Replace =+, =/, etc. by +=, /=, etc. if necessary] bc << EOF n = $1 t = 16 * (10^n) / 5 e = 1 s = 0 while (t != 0){ s =+ t / e t =/ -25 e =+ 2 } t = 4 * (10^n) / 239 e = 1 while (t != 0){ s =- t / e t =/ -57121 e =+ 2 } s Apparently, Ken Yap's implementation was not very efficient :-) -- Theo van der Storm, 052 19'08"N / 004 51'16"E UUCP: {seismo|decvax|philabs}!mcvax!vu44!tstorm UUCP: {ark|botter|klipper|tjalk|vu45|vu60}!vu44!tstorm