i = 2 j = 1 a(2, 1) = 4 # decimal digits = 1 enter another set (n to quit)? y i = 2 j = 2 a(2, 2) = 16 # decimal digits = 2 enter another set (n to quit)? y i = 2 j = 3 a(2, 3) = 65536 # decimal digits = 5 enter another set (n to quit)? y i = 2 j = 4 a(2, 4) = 200352993040684646497907235156025575044782547556975141926501697371089\ 405955631145308950613088093334810103823434290726318182294938211881266886\ 950636476154702916504187191635158796634721944293092798208430910485599057\ 015931895963952486337236720300291696959215610876494888925409080591145703\ 767520850020667156370236612635974714480711177481588091413574272096719015\ 183628256061809145885269982614142503012339110827360384376787644904320596\ 037912449090570756031403507616256247603186379312648470374378295497561377\ 098160461441330869211810248595915238019533103029216280016056867010565164\ ... 506264233788565146467060429856478196846159366328895429978072254226479040\ 061601975197500746054515006029180663827149701611098795133663377137843441\ 619405312144529185518013657555866761501937302969193207612000925506508158\ 327550849934076879725236998702356793102680413674571895664143185267905471\ 716996299036301554564509004480278905570196832831363071899769915316667920\ 895876857229060091547291963638167359667395997571032601557192023734858052\ 112811745861006515259888384311451189488055212914577569914657753004138471\ 712457796504817585639507289533753975582208777750607233944558789590571915\ 6736 # decimal digits = 19729 enter another set (n to quit)?
/*
** Computation of Akermann's super
** exponential function by James
** Pate Williams, Jr. (c) Tuesday,
** August 27, 2024 lip version
*/
#include <stdio.h>
#include "lip.h"
verylong Ackermann(verylong zi, verylong zj) {
verylong a = 0;
if (zscompare(zi, 1) == 0) {
verylong ztwo = 0;
zintoz(2, &ztwo);
zexp(ztwo, zj, &a);
return a;
}
else if (zscompare(zj, 1) == 0)
{
verylong ztwo = 0, ziminus1 = 0;
zintoz(2, &ztwo);
zsadd(zi, -1, &ziminus1);
return Ackermann(ziminus1, ztwo);
}
else if (
zscompare(zi, 2) >= 0 &&
zscompare(zj, 2) >= 0) {
verylong ziminus1 = 0;
verylong zjminus1 = 0;
verylong temp = 0;
zsadd(zi, -1, &ziminus1);
zsadd(zj, -1, &zjminus1);
if (zscompare(ziminus1, 1) >= 0 &&
zscompare(zjminus1, 1) >= 0) {
return
Ackermann(ziminus1, Ackermann(zi, zjminus1));
}
}
return 0;
}
int DigitCount(verylong za) {
int count = 0;
while (zscompare(za, 0) > 0) {
zsdiv(za, 10, &za);
count++;
}
return count;
}
int main(void) {
for (;;) {
char buffer[256] = { '\0' };
int i = 0, j = 0, number = 0;
verylong za = 0, zi = 0, zj = 0;
buffer[0] = '\0';
printf_s("i = ");
scanf_s("%d", &i);
printf_s("j = ");
scanf_s("%d", &j);
zintoz(i, &zi);
zintoz(j, &zj);
printf_s("a(%d, %d) = \n", i, j);
za = Ackermann(zi, zj);
zwriteln(za);
number = DigitCount(za);
printf_s("# decimal digits = %d\n",
number);
printf_s("enter another set (n to quit)? ");
scanf_s("%s", buffer, sizeof(buffer));
zfree(&za);
if (buffer[0] == 'n')
break;
}
return 0;
}
On Wednesday, October 16, 2024, I bought an Amazon Kindle book named “Modern Quantum Chemistry: Introduction to Advanced Electronic Structure Theory” by Attila Szabo and Neil S. Ostlund. It cost me $10.69 which is a real bargain. In Appendix B there is a listing for a FORTRAN program to perform an ab initio Hartree-Fock Self Consistent Field calculation for a two-electron heteronuclear molecule namely the helium-hydrogen cation. I successfully translated the program from FORTRAN to C++. I had to remember that FORTRAN stores matrices in column major order and C/C++ stores matrices in row major order. I took the transposes of two FORTRAN COMMON matrices to get the correct C++ storage. The authors of the book did an extensive treatment of the test calculation. The application is only 823 lines of monolithic C++ source code. I used FORTRAN like array indexing starting at 1 instead of the C initial beginning index of 0. I think I will try to get in touch with the authors to get permission to post the source code and results on my blog.
P. S. I got permission from Dover Books to publish my source code and results. I think I will reconsider posting the C++ source code. The actual ground state energy of the cation is -2.97867. My calculation and the book’s computation are in percentage errors of about 4%. The book’s value is a little closer to the exact value than my result. The book calculation was done in FORTRAN double precision on a Digital Equipment Corporation PDP-10 minicomputer. My recreation of the book’s endeavor was executed on an Intel Itanium Core 7 and Windows 10 Professional machine using Win32 C++. The C++ compiler was from Microsoft Visual Studio 2019 Community Version.
Note I added a calculation for a homonuclear molecule, namely, the hydrogen diatomic molecule.
I became fascinated with secret key cryptography as a child. Later, as an adult, in around 1979, I started creating crude symmetric cryptographic algorithms. I became further enthralled with cryptography and number theory in 1996 upon reading Applied Cryptography, Second Edition: Protocols, Algorithms, and Source Code inC by Bruce Schneier and later the Handbook of Applied Cryptography by Alfred J. Menezes, Paul C. van Oorschot, and Scott A. Vanstone. After implementing many of the algorithms in both tomes, I communicated my results to two of the authors namely Bruce Schneier and Professor Alfred J. Menezes. In 1997 I developed a website devoted to constraint satisfaction problems and their solutions, cryptography, and number theory. I posted legal C and C++ source code. Professor Menezes advertised my website along with his treatise. See the following blurb:
In the spirit of my twin scientific infatuations, I offer yet another C integer factoring implementation utilizing the Free Large Integer Package (known more widely as lip) which was created by Arjen K. Lenstra (now a Professor Emeritus). This implementation includes Henri Cohen’s Trial Division algorithm, the Brent-Cohen-Pollard rho method, the Cohen-Pollard p – 1 stage 1 method, and the Lenstra lip Elliptic Curve Method. If I can get the proper authorization, I will later post the source code.
total time required for initialization: 0.056000 seconds
enter number below:
2^111+2
== Menu ==
1 Trial Division
2 Pollard-Brent-Cohen rho
3 p - 1 Pollard-Cohen
4 Lenstra's Elliptic Curve Method
5 Pollard-Lenstra rho
1
2596148429267413814265248164610050
number is composite
factors:
total time required factoring: 0.014000 seconds:
2
5 ^ 2
41
397
2113
enter number below:
0
total time required for initialization: 0.056000 seconds
enter number below:
2^111+2
== Menu ==
1 Trial Division
2 Pollard-Brent-Cohen rho
3 p - 1 Pollard-Cohen
4 Lenstra's Elliptic Curve Method
5 Pollard-Lenstra rho
2
2596148429267413814265248164610050
number is composite
factors:
total time required factoring: 1.531000 seconds:
2
5 ^ 2
41
397
2113
415878438361
3630105520141
enter number below:
0
total time required for initialization: 0.055000 seconds
enter number below:
2^111+2
== Menu ==
1 Trial Division
2 Pollard-Brent-Cohen rho
3 p - 1 Pollard-Cohen
4 Lenstra's Elliptic Curve Method
5 Pollard-Lenstra rho
3
2596148429267413814265248164610050
number is composite
factors:
total time required factoring: 0.066000 seconds:
2
5 ^ 2
41
838861
415878438361
3630105520141
enter number below:
0
total time required for initialization: 0.056000 seconds
enter number below:
2^111+2
== Menu ==
1 Trial Division
2 Pollard-Brent-Cohen rho
3 p - 1 Pollard-Cohen
4 Lenstra's Elliptic Curve Method
5 Pollard-Lenstra rho
4
2596148429267413814265248164610050
number is composite
factors:
total time required factoring: 0.013000 seconds:
2
5
205
838861
415878438361
3630105520141
enter number below:
0