Closed gambiteer closed 7 years ago
I guess I really don't know what's going on, it seemed to merge my current pull request with my previous one, which was not my intention.
At any rate, here is a new program using binary splitting and the Chudnovsky brothers algorithm for computing PI.
One should use the built-in function exact-integer-sqrt to define pi.scm's square-root and quartic-root procedures and use the built-in quotient instead of div (this program needs only quotient). It is a question of what one means to test, and I think one should test the built-in bignum functions.
The program "root" in this function is a relatively inefficient implementation. Yet the "root" function is faster, by far, than Larceny's implementation of the required R7RS procedure exact-integer-sqrt; the new pi.scm on Larceny takes
./bench larceny pi
Testing pi under Larceny Compiling... Running... Running pi:50:500:50:2 Elapsed time: 785.895248 seconds (786.0) for pi:50:500:50:2
real 13m6.824s user 13m6.708s sys 0m0.044s
whereas the original pi.scm on Larceny gives
firefly:~/programs/larceny-orig/test/Benchmarking/R7RS> ./bench larceny pi
Testing pi under Larceny Compiling... Running... Running pi:50:500:50:2 Elapsed time: 5.66577 seconds (6.0) for pi:50:500:50:2
real 0m6.619s user 0m6.600s sys 0m0.012s
The new version on Gambit runs in
firefly:~/programs/r7rs-benchmarks> ./bench gambitc pi
Testing pi under GambitC Including prelude /home/lucier/programs/r7rs-benchmarks/src/GambitC-prelude.scm Compiling... Running... Running pi:50:500:50:2 Elapsed time: .03590083122253418 seconds (0.) for pi:50:500:50:2 +!CSVLINE!+gambitc-v4.8.5,pi:50:500:50:2,.03590083122253418
real 0m0.043s user 0m0.036s sys 0m0.004s
But I think the new version is overall better because it should test the built-in procedures, like exact-integer-sqrt, instead of trying to write more more efficient replacements for them, and in this case failing, at least for Gambit.
The Gambit implementation of exact-integer-sqrt is based on a paper by Paul Zimmermann and is not very complicated.
Brad