pi-calculator/0000755000175000001440000000000010365257022013507 5ustar sebastianuserspi-calculator/CVS/0000755000175000001440000000000010365257022014142 5ustar sebastianuserspi-calculator/CVS/Root0000644000175000001440000000006710365257022015013 0ustar sebastianuserskickino@cvs.savannah.nongnu.org:/sources/pi-calculator pi-calculator/CVS/Repository0000644000175000001440000000001610365257022016241 0ustar sebastianuserspi-calculator pi-calculator/CVS/Entries0000644000175000001440000000012110365257022015470 0ustar sebastianusers/COPYING/1.1/Sat Jan 7 18:43:25 2006// /README/1.2/Mon Jan 23 22:50:01 2006// D pi-calculator/CVS/Entries.Log0000644000175000001440000000001410365257022016211 0ustar sebastianusersA D/src//// pi-calculator/src/0000755000175000001440000000000010365257022014276 5ustar sebastianuserspi-calculator/src/CVS/0000755000175000001440000000000010365257022014731 5ustar sebastianuserspi-calculator/src/CVS/Root0000644000175000001440000000006710365257022015602 0ustar sebastianuserskickino@cvs.savannah.nongnu.org:/sources/pi-calculator pi-calculator/src/CVS/Repository0000644000175000001440000000002210365257022017025 0ustar sebastianuserspi-calculator/src pi-calculator/src/CVS/Entries0000644000175000001440000000071510365257022016270 0ustar sebastianusers/Makefile/1.2/Sun Jan 8 14:54:16 2006// /bbp.cpp/1.2/Wed Jan 11 09:22:52 2006// /françois_viète.cpp/1.2/Wed Jan 11 09:22:52 2006// /gottfried_wilhelm_leibniz.cpp/1.2/Wed Jan 11 09:22:52 2006// /johann_heinrich_lambert.cpp/1.2/Wed Jan 11 09:22:52 2006// /john_wallis.cpp/1.2/Wed Jan 11 09:22:52 2006// /leonhard_euler.cpp/1.2/Wed Jan 11 09:22:52 2006// /main.cpp/1.2/Wed Jan 11 09:22:52 2006// /srinivasa_aiyangar_ramanujan.cpp/1.2/Wed Jan 11 09:22:52 2006// D pi-calculator/src/Makefile0000644000175000001440000000154410360223630015733 0ustar sebastianusersSHELL = /bin/sh .SUFFIXES: .cpp .o CFLAGS = -g ALL_CFLAGS = -I. $(CFLAGS) # Common prefix for installation directories. # NOTE: This directory must exist when you start the install. prefix = /usr/local datarootdir = $(prefix)/share datadir = $(datarootdir) exec_prefix = $(prefix) # Where to put the executable for the command `gcc'. bindir = $(exec_prefix)/bin # Where to put the directories used by the compiler. libexecdir = $(exec_prefix)/libexec # Where to put the Info files. infodir = $(datarootdir)/info .cpp.o: $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< all: françois_viète johann_heinrich_lambert leonhard_euler gottfried_wilhelm_leibniz john_wallis \ srinivasa_aiyangar_ramanujan bbp main clean: rm -rf françois_viète johann_heinrich_lambert leonhard_euler gottfried_wilhelm_leibniz \ john_wallis srinivasa_aiyangar_ramanujan bbp main # rm -rf *.o pi-calculator/src/bbp.cpp0000644000175000001440000000431310361147154015546 0ustar sebastianusers/*********************************************************/ /* Bailey-Borwein-Plouffe formula to calculate Pi by */ /* David H. Bailey, Peter Borwein and Simon Plouffe ('97)*/ /* http://en.wikipedia.org/wiki/BBP_formula */ /* http://crd.lbl.gov/~dhbailey/pi/pi-alg */ /* http://mathworld.wolfram.com/BBP-TypeFormula.html */ /* ----------------------------------------------------- */ /* Autor: Sebastian Wieseler */ /* Mail: programming@kickino.org */ /* Web: http://www.kickino.org/ */ /* IRC: #uscc @ irc.forkbomb.ch:6668 (ssl only) */ /* ----------------------------------------------------- */ /* Date: 2006-01-03 */ /* Last Change: 2006-01-06 */ /* CVS-Version: 1.1 */ /* ----------------------------------------------------- */ /* tested OS: GNU/Linux */ /* Copyright: 2006 by Sebastian Wieseler */ /* ----------------------------------------------------- */ /* License: GNU General Public License v2 or any later */ /* ----------------------------------------------------- */ /* NO WARRANTY! */ /*********************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include long double exp(long double a, long double b) { if (b==0) return 1; // a^0 = 1 long double help=a; for (int i=1; i /* was my first try to run viete_formula :-) long double viete_formula0(int n) { // you need a 'const int pass=30' e.g. for doing this // never tried to implement argc[1] for that, sorry man :( long double a[pass]; if (n==1) return sqrt(2); // a[1]=sqrt(2) a[n] = sqrt( 2 + viete_formula0(n-1) ); // a[n] = sqrt(2 + a[n-1]); return a[n]; } */ long double viete_formula1(long double n) { if (n==1) return sqrt(2); // a[1]=sqrt(2) return sqrt( 2 + viete_formula1(n-1) ); } int main(int argc, char *argv[]) { long double two_over_pi = sqrt(2)/2; for (long double i=2; i<=(atoi(argv[1])); i++) { two_over_pi *= viete_formula1(i) / 2; printf ("%6.0Lf : %.62Lf \n", i, 2/two_over_pi ); } } pi-calculator/src/gottfried_wilhelm_leibniz.cpp0000644000175000001440000000365610361147154022240 0ustar sebastianusers/*********************************************************/ /* Leibniz formula for pi */ /* http://en.wikipedia.org/wiki/Leibniz_formula_for_pi */ /* ----------------------------------------------------- */ /* Autor: Sebastian Wieseler, Pascal Fricke */ /* Mail: programming@kickino.org */ /* Web: http://www.kickino.org/ */ /* IRC: #uscc @ irc.forkbomb.ch:6668 (ssl only) */ /* ----------------------------------------------------- */ /* Date: 2005-12-29 */ /* Last Change: 2006-01-06 */ /* CVS-Version: 1.1 */ /* ----------------------------------------------------- */ /* tested OS: GNU/Linux */ /* Copyright: 2005,2006 by Sebastian Wieseler */ /* ----------------------------------------------------- */ /* License: GNU General Public License v2 or any later */ /* ----------------------------------------------------- */ /* NO WARRANTY! */ /*********************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include int main(int argc, char *argv[]) { long double quarter_of_pi=0; for (int i=0; i // Pi = 4./(n+1); // i = atoi(argv[1]) -- counter; long double lambert_algo(float n, long double i) { if (n < i) return ((n*n)/(((2*n)+1)+lambert_algo(n+1,i))); else if (n == i) // should be else return 1; } int main(int argc, char *argv[]) { for (long double i=1; i<=atoi(argv[1]); i++) { printf ("%6.0Lf : %.62Lf \n", i, 4./(lambert_algo(1,i)+1) ); } } pi-calculator/src/john_wallis.cpp0000644000175000001440000000355010361147154017316 0ustar sebastianusers/*********************************************************/ /* Wallis product to calculate Pi */ /* http://en.wikipedia.org/wiki/Wallis_product */ /* ----------------------------------------------------- */ /* Autor: Sebastian Wieseler */ /* Mail: programming@kickino.org */ /* Web: http://www.kickino.org/ */ /* IRC: #uscc @ irc.forkbomb.ch:6668 (ssl only) */ /* ----------------------------------------------------- */ /* Date: 2005-12-25 */ /* Last Change: 2006-01-06 */ /* CVS-Version: 1.1 */ /* ----------------------------------------------------- */ /* tested OS: GNU/Linux */ /* Copyright: 2005,2006 by Sebastian Wieseler */ /* ----------------------------------------------------- */ /* License: GNU General Public License v2 or any later */ /* ----------------------------------------------------- */ /* NO WARRANTY! */ /*********************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include int main(int argc, char *argv[]) { long double two_over_pi=1; for (long double i=1;i<=atoi(argv[1]);i++) { two_over_pi *= (1 - 1./(4*i*i)) ; printf ("%6.0Lf : %.60Lf \n", i, 2./two_over_pi ); } } pi-calculator/src/leonhard_euler.cpp0000644000175000001440000000353510361147154020000 0ustar sebastianusers/*********************************************************/ /* Euler's algorithm to calculate Pi */ /* http://en.wikipedia.org/wiki/Riemann_zeta_function */ /* ----------------------------------------------------- */ /* Autor: Sebastian Wieseler, Pascal Fricke */ /* Mail: programming@kickino.org */ /* Web: http://www.kickino.org/ */ /* IRC: #uscc @ irc.forkbomb.ch:6668 (ssl only) */ /* ----------------------------------------------------- */ /* Date: 2005-12-25 */ /* Last Change: 2006-01-06 */ /* CVS-Version: 1.1 */ /* ----------------------------------------------------- */ /* tested OS: GNU/Linux */ /* Copyright: 2005,2006 by Sebastian Wieseler */ /* ----------------------------------------------------- */ /* License: GNU General Public License v2 or any later */ /* ----------------------------------------------------- */ /* NO WARRANTY! */ /*********************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include int main(int argc, char *argv[]) { double pi=0; for (long double i=1; i<=atoi(argv[1]); i++) { pi += (1./(i*i)); printf ("%6.0Lf : %.60f \n", i, sqrt(6*pi) ); } } pi-calculator/src/main.cpp0000644000175000001440000000660610361147154015736 0ustar sebastianusers/*********************************************************/ /* Main file to execute some alogrithm of our project */ /* to calculate Pi */ /* ----------------------------------------------------- */ /* Autor: Sebastian Wieseler, Pascal Fricke */ /* Mail: programming@kickino.org */ /* Web: http://www.kickino.org/ */ /* IRC: #uscc @ irc.forkbomb.ch:6668 (ssl only) */ /* ----------------------------------------------------- */ /* Date: 2006-01-06 */ /* Last Change: 2006-01-11 */ /* CVS-Version: 1.2 */ /* ----------------------------------------------------- */ /* tested OS: GNU/Linux */ /* Copyright: 2006 by Sebastian Wieseler */ /* ----------------------------------------------------- */ /* License: GNU General Public License v2 or any later */ /* ----------------------------------------------------- */ /* NO WARRANTY! */ /*********************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include char *decission_algo() { int algo_count; char *argv[0]; printf("%s " , "Which algorithm do you want to use for the calculation?"); scanf("%d" , &algo_count); switch(algo_count) { case 1 : argv[0] = "./bbp"; break; case 2 : argv[0] = "./leonhard_euler"; break; case 3 : argv[0] = "./johann_heinrich_lambert"; break; case 4 : argv[0] = "./gottfried_wilhelm_leibniz"; break; case 5 : argv[0] = "./srinivasa_aiyangar_ramanujan"; break; case 6 : argv[0] = "./françois_viète"; break; case 7 : argv[0] = "./john_wallis"; break; // default: printf("%s \n", "You should enter a number from above."); break; } return argv[0]; } void print_menu() { printf("\n %s \n", "PI - Calculator - (C) 2005,2006 Sebastian Wieseler [GPL]"); printf(" %s\n\n" , "========================================================"); printf("%s \n", " 1) Bailey-Borwein-Plouffe formula"); printf("%s \n", " 2) Euler formula"); printf("%s \n", " 3) Lambert formula"); printf("%s \n", " 4) Leibnitz formula"); printf("%s \n", " 5) Ramanujan formula"); printf("%s \n", " 6) Viète formula"); printf("%s \n", " 7) Wallis formula"); printf("\n"); } int main() { char *argv[3], *envp[1]; char algo_run[0]; // print the menu print_menu(); // ask what algorithm to use argv[0] = decission_algo(); // ask how many runs we should do with our algorithm printf("%s ", "How many runs?"); scanf("%s" , algo_run); argv[1] = algo_run; argv[2] = 0; /* terminate argv list */ envp[0] = 0; /* empty environment for argv[0] */ // execute my algorithm execve(argv[0],argv,envp); // print the bad truth - we are not perfect :( printf("%s %.62f \n", " The original Pi is:", 3.141592653589793238462643383279502884197169399375); return 0; } pi-calculator/src/srinivasa_aiyangar_ramanujan.cpp0000644000175000001440000000450710361147154022716 0ustar sebastianusers/*********************************************************/ /* Ramanujan's algorithm to calculate Pi */ /* http://en.wikipedia.org/wiki/Ramanujan#Mathematical_achievements */ /* ----------------------------------------------------- */ /* Autor: Sebastian Wieseler */ /* Mail: programming@kickino.org */ /* Web: http://www.kickino.org/ */ /* IRC: #uscc @ irc.forkbomb.ch:6668 (ssl only) */ /* ----------------------------------------------------- */ /* Date: 2005-12-31 */ /* Last Change: 2006-01-06 */ /* CVS-Version: 1.1 */ /* ----------------------------------------------------- */ /* tested OS: GNU/Linux */ /* Copyright: 2005,2006 by Sebastian Wieseler */ /* ----------------------------------------------------- */ /* License: GNU General Public License v2 or any later */ /* ----------------------------------------------------- */ /* NO WARRANTY! */ /*********************************************************/ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include long double fac(long double i) { if(i==0) return 1; else return i*fac(i-1); } long double exp(long double a, long double b) { if (b==0) return 1; // a^0 = 1 long double help=a; for (int i=1; i Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pi-calculator/README0000644000175000001440000000316610365256631014402 0ustar sebastianusersAbout the project: | ==================== The main goal of the project is to calculate Pi. Project website : http://pi.kickino.org/ | http://nanofortnight.org/Pi Project on SV : https://savannah.nongnu.org/projects/pi-calculator/ CVS : https://savannah.nongnu.org/cvs/?group=pi-calculator (anonymouse) : cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/pi-calculator co pi-calculator (for SV member): cvs -z3 -d @cvs.savannah.nongnu.org:/sources/pi-calculator co pi-calculator References: | ============= (English) http://en.wikipedia.org/wiki/Pi (German) http://de.wikipedia.org/wiki/Kreiszahl [Content of the Wikipedia was released under the terms of the GNU FDL] Thanks: | ========= Special thanks to Pascal Fricke, who helped me to understand almost all of the algorithms to calculate Pi. Usefull Links of this topic: | ============================== Have a look at the source code of each algorithm, the URIs of the Wikipedia articels were included there. Furthermore have a look at: # Pi to one million decimal places (http://3.141592653589793238462643383279502884197169399375105820974944592.com/) # Pi to 206 billion decimal places (http://pi.lacim.uqam.ca/piDATA/pi206billion.txt) # Table of current records for the computation of constants (http://pi.lacim.uqam.ca/eng/records_en.html) # Search the first four billion binary digits of Pi for a string (http://pi.nersc.gov/) # David H. Bailey website (http://crd.lbl.gov/~dhbailey/) describs the BBP algorithm # Kanada Laboratory home page (http://www.super-computing.org/) includes Pi to one trillion digits (http://www.super-computing.org/pi_current.html)