In article <fsg4bp$24pj$>
(Richard Tobin) writes:
> In article <>,
> CBFalconer <> wrote:
> >I haven't the vaguest idea of the algorithm.
>
> See http://www.mathpropress.com/stan/bib...phy/spigot.pdf
....
> A similar algorithm for calculating the digits of e - also given in
> the same paper - is much easier to understand.
Right. When I wrote the program originally with a cow-orker the idea
was to see how the algorithm we knew for a long time for 'e' work out
for 'pi'. However, the algorithm for 'pi' is much shakier than that
for 'e'. In order to let it work correctly you should ensure that the
"digits" are always within certain bounds. For 'e' that is simple, it
is assured by the series development for 'e'. For 'pi' that is not the
case. And indeed, if you increase the arrays and the loop length etc.
you will find that at a certain point the program will start to give
wrong results. Once we had the program working I thought to decrease
its size and obfuscate the program as much as possible (although the
decrease in size was the most important for me). It had gone to a point
where even the C-beautifier of that time did not know what to do with it.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland;
http://www.cwi.nl/~dik/