SSCLN - some CLN programs to calculate mathematical constants
=============================================================
Package version: 1.02 for Unix and Linux
First version: 2007-09-26
Latest update: 2007-10-28
Author
======
Stefan Spaennare, Lund, Sweden
E-mail: stefan@spaennare.se
Home page:
http://www.spaennare.se/index.html
Please download the package from the web-page:
http://www.spaennare.se/ssprog.html
Contents
========
1. Something about the programs
2. Disclaimer
3. How to use the programs
4. How to compile the programs
5. Short about installing GMP
6. Short about installing CLN
7. Some benchmark results
8. References
9. Package history
1. Something about the programs
===============================
The author is very grateful to the CLN and GMP teams for making these
powerful packages!
The C++ programs in this package use functions in the CLN package to calculate
some mathematical constants. It is recommended to also use the GMP package
(optional). See the references.
The reason why the author made these CLN programs was to verify the results
of his own programs in the SSPROG package.
The short programs clnpi.cc, clne.cc, clnln2.cc, clngamma.cc, clncatalan.cc,
clnzeta.cc and clnsqrt.cc use very fast special functions in CLN to calculate
these constants. The time complexity for the programs are O(n*ln(n)^2) or
O(n*ln(n)^3) where n is the numbers of digits. Actually they are significantly
faster than the author's own programs.
The programs clngam13.cc and clngam14.cc calculates Gamma(1/3) and Gamma(1/4)
and are more complicated and also slower. Never the less they have a time
complexity of O(n*ln(n)^3).
The programs zeta0.cc, zeta1.cc and zeta2.cc are slower programs that
calculate zeta(s) non recursively with about O(n^2) time complexity.
The program khintch.cc is an attempt to calculate Khintchine's constant.
The program is very slow with a time complexity worse than O(n^3). Thus
only a few thousand digits can be calculated on a fast computer.
2. Disclaimer
=============
The following statement is valid for all the programs in this package:
I make no warranties that this program is (1) free of errors, (2) consistent
with any standard merchantability, or (3) meeting the requirements of
a particular application. This software shall not, partly or as a whole,
participate in a process, whose outcome can result in injury to a person or
loss of property. It is solely designed for analytical work. Permission to
use, copy, and distribute is hereby granted without fee, providing that the
header above including this notice appears in all copies.
3. How to use the programs
==========================
The programs calculate 2^power-of-2 decimal digits and the result is printed
to standard output. The CPU-time can be measured with the "time" function
in Unix and Linux.
To for example calculate Pi, zeta(3) and sqrt(2) with 2^20=1048576 digits type
the following at the prompt. All printed digits are supposed to be correct.
>time clnpi 20 >pi.txt
>time clnzeta 3 20 >zeta3.txt
>time clnsqrt 2 20 >sqrt2.txt
4. How to compile the programs
==============================
After a successful installation of GMP and CLN (see below) all the programs
in this package can be compiled using the script "compall" (it takes a
minute or so). It has been successfully tested on a Intel Celeron computer
(1400 MHz, 768 Mbyte SDRAM) with Fedora 7 Linux and GNU g++ 4.1.2. If the
script doesn't work perhaps the directory paths for libcln.a and libgmp.a
must be changed in the script.
>chmod +x compall
>compall
The executables can be removed by.
>chmod +x rmfiles
>rmfiles
5. Short about installing GMP
=============================
Before installing CLN it is recommended to install GMP. In the best of
worlds to following should work. It works well on the computer mentioned in
section 3 and GMP 4.2.2. Always use the latest version of GMP available. For
more detailed information see the documentation that comes with the GMP
package. Important note, if "make check" fails you should hesitate to use
the package!
>./configure
>make /* This step takes a couple of minutes. */
>make check /* Very important! */
>make install /* As root. */
>make gmp.ps /* Optional, set up the documentation. */
6. Short about installing CLN
=============================
Then install CLN. In the best of worlds to following should work. It works
well on the computer mentioned in section 3 and CLN 1.1.13. Always use
the latest version of CLN available. For more detailed information see the
documentation that comes with the CLN package. Important note, if "make check"
fails you should hesitate to use the package!
>./configure --with-gmp /* The option "--with-gmp" invokes the GMP package. */
>make /* This step takes a couple of minutes. */
>make check /* Very important! */
>make install /* As root. */
7. Some benchmark results
=========================
The CPU times are given for an Intel Celeron computer at 1400 MHz measured
with the "time" function in Linux. The computer has 768 Mbyte SDRAM memory
and 100 MHz memory bus. The cache memory is 256 kbyte (Advanced Transfer)
at full CPU speed. The operating system was Fedora 7 Linux with the GNU g++
4.2.1 C++ compiler. The CPU load was on average 1.00 (i.e. no other programs
running). The programs were compiled using the line:
g++ -O2 -o program program.cc /usr/local/lib/libcln.a /usr/local/lib/libgmp.a -lm
Benchmark results for the cln* programs:
Program \ Digits 2^17 2^20 2^24
-----------------------------------------------------------------
pi 1.88 s 33.22 s 1060.19 s
e 1.04 s 16.70 s 482.66 s
ln2 3.98 s 73.32 s 2332.73 s
gamma 90.12 s 1431.65 s ---
gam13 72.24 s 1321.16 s ---
gam14 31.96 s 629.28 s ---
catalan 32.98 s 652.21 s ---
zeta 3 67.58 s 1169.24 s ---
zeta 10 187.98 s 3061.44 s ---
sqrt 3 0.77 s 11.39 s 334.66 s
sqrt 10 0.74 s 11.47 s 344.00 s
Benchmark results for the zeta* programs:
Program \ Digits 2^11 2^12
-----------------------------------------------------------------
zeta0 3 3.36 s 21.31 s
zeta1 3 4.48 s 28.97 s
zeta2 3 15.22 s 102.88 s
zeta0 10 5.73 s 35.67 s
zeta1 10 7.33 s 46.27 s
zeta2 10 28.86 s 185.40 s
Benchmark results for the khintch program:
Program \ Digits 2^8 2^9 2^10
-----------------------------------------------------------------
khintch 6.88 s 74.16 s 951.07 s
8. References
=============
The CLN and GMP packages can be downloaded from references 1 and 2.
Under reference 3 is found very good information how to calculate
different mathematical constants.
1. CLN Class Library for Numbers
http://www.ginac.de/CLN/
2. GMP GNU Multiple Precision Arithmetic Library
http://gmplib.org/
3. Mathematical constants and computation
http://numbers.computation.free.fr/Constants/constants.html
9. Package history
==================
2007-10-28, 1.02: A disclaimer notice and some benchmark results added to
this file. The program clnkhintch.cc is now renamed to khintch.cc.
2007-09-28, 1.01: Minor changes to this readme.txt file and the text header
of all programs in the package.
2007-09-26, 1.00: First version of the package.
---------------------------------------------------------------------
End of readme.txt file.