meditationatae

Just another WordPress.com site

Overflow problem with C abundant numbers program, using 64-bit integers

Overflow using signed 64-bit long integers with
superabun3642a.c .

Using the PARI-gp calculator, one finds:

? p = prime(155632)
2097479

? sigma(p^2)
4399420252921 Correct

? p^2+p+1
4399420252921 Correct, equal to sigma(p*p)
? (p^3-1)/(p-1)
4399420252921 Correct, equal to sigma(p*p)
? p^3-1
9227687193256233238 Correct value of p^3 -1
? 2^63
9223372036854775808 Is less than p^3 -1
And something else:

log_2(p) =

? log(p)/log(2)
21.0002249357711447626172885407

So log_2(p^3) ~= 63.0006748 .

Attempts to calculate “p*p*p -1” using C 64-bit signed long
integers, with one sign bit, cause “overflow”, but no error
is signalled.

I’ve written a work-around that avoids the
formula:
(a^{n+1} -1)/(a – 1)
when calculating the sum of the geomtric series:

a^n + a^{n-1} + … + a^3 + a^2 + a + 1.

The fix is in:

superabun3842a.c which is in my directory:

/home/david2/eratosthenes6 .

—-

This new program, as well as the one with an integer overflow problem,
use 128-bit quadruple precision floating point numbers.

There is with this a quadmath library with, e.g. cosq, sinq, logq and
expq for cosine, sine, natural log and exponential functions for
these 128-bit floats.

The significand is 113 bits, with the initial ‘1’ bit omitted,
which packs 112 mantissa bits, and 16 bits for signs and the
“scale”, or scientific notation exponent, a power of 10, although
bitwise, it could be a power of two.

These quad-functions are more convenient to write programs with
than MPFR, in my opinion.
Cf.:

GCC 4.9.2 Quad-Precision Math Library Manual (also in PDF or PostScript or an HTML tarball)

at:

https://gcc.gnu.org/onlinedocs/index.html#dir

It seems the GNU GCC libquadmath is based in part on an extended precision
math library called Cephes…

I guessed this by Googling:

Stephen L. Moshier quadmath Cephes
If people are interested in asking me more about my experiences with
the GNU GCC libquadmath or how I got it to work, I can be
contacted by email at:

david250 (at) videotron (dot) ca
=================================
step at 1
step at 2
step at 3
step at 4
step at 5
step at 7
step at 9
step at 11
step at 15
step at 23
step at 38
step at 83
step at 283
step at 2321
step at 155632
step at 108399999201

Number of big primes used in making current n is: 108398999200
numloops = 399999

number of steps: 16
45 28 19 16 12 12 10 10 9 9 8 8 8 8 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
record_low_variation_delta = 0.045445118220046177802451895181 record_low_log2n = 28.729438970630453658466324164759

current step number = 1 quotient de Robin: 0.999999983683913240534105095792
loglog n = 28.730204950920702187611032664266

sigma(n’)/n’ = 51.170574766386741435997969117140
record step is at: 1
log(log(n’)) = 28.730204950920702187611032664266 Robin upper bound = 51.170575601290292478459083958170 sigma(n’)/n’ = 51.170574766386741435997969117140
current step number = 2 quotient de Robin: 0.999999983683911147382487405475
loglog n = 28.730204950920837265421775705861

sigma(n’)/n’ = 51.170574766386874911583942683557
record step is at: 1
log(log(n’)) = 28.730204950920837265421775705861 Robin upper bound = 51.170575601290533061822080889606 sigma(n’)/n’ = 51.170574766386874911583942683557
current step number = 3 quotient de Robin: 0.999999983683903898808922965402
loglog n = 28.730204950921007443337334696302

sigma(n’)/n’ = 51.170574766386807097088969774111
record step is at: 1
log(log(n’)) = 28.730204950921007443337334696302 Robin upper bound = 51.170575601290836161013634072446 sigma(n’)/n’ = 51.170574766386807097088969774111
current step number = 4 quotient de Robin: 0.999999983683895293183998583134
loglog n = 28.730204950921119536664700537736

sigma(n’)/n’ = 51.170574766386566388638534914111
record step is at: 1
log(log(n’)) = 28.730204950921119536664700537736 Robin upper bound = 51.170575601291035807347246118480 sigma(n’)/n’ = 51.170574766386566388638534914111
current step number = 5 quotient de Robin: 0.999999983683912700720015999718
loglog n = 28.730204950921270112287072764273

sigma(n’)/n’ = 51.170574766387725328359799458954
record step is at: 1
log(log(n’)) = 28.730204950921270112287072764273 Robin upper bound = 51.170575601291303993435074998950 sigma(n’)/n’ = 51.170574766387725328359799458954
current step number = 6 quotient de Robin: 0.999999983683908781885237846078
loglog n = 28.730204950921415135399706843583

sigma(n’)/n’ = 51.170574766387783095990184230985
record step is at: 1
log(log(n’)) = 28.730204950921415135399706843583 Robin upper bound = 51.170575601291562290100958643416 sigma(n’)/n’ = 51.170574766387783095990184230985
current step number = 7 quotient de Robin: 0.999999983683900904324515902248
loglog n = 28.730204950921515838117611667283

sigma(n’)/n’ = 51.170574766387559355504058731921
record step is at: 1
log(log(n’)) = 28.730204950921515838117611667283 Robin upper bound = 51.170575601291741648934235572568 sigma(n’)/n’ = 51.170574766387559355504058731921
current step number = 8 quotient de Robin: 0.999999983683910955484233179649
loglog n = 28.730204950921615278929188242552

sigma(n’)/n’ = 51.170574766388250790416084168351
record step is at: 1
log(log(n’)) = 28.730204950921615278929188242552 Robin upper bound = 51.170575601291918760220957171155 sigma(n’)/n’ = 51.170574766388250790416084168351
current step number = 9 quotient de Robin: 0.999999983683910631252418567357
loglog n = 28.730204950921753919799267865505

sigma(n’)/n’ = 51.170574766388481128713178262301
record step is at: 1
log(log(n’)) = 28.730204950921753919799267865505 Robin upper bound = 51.170575601292165689650662150099 sigma(n’)/n’ = 51.170574766388481128713178262301
current step number = 10 quotient de Robin: 0.999999983683899340951635361878
loglog n = 28.730204950921943375820786919836

sigma(n’)/n’ = 51.170574766388240832412234041575
record step is at: 1
log(log(n’)) = 28.730204950921943375820786919836 Robin upper bound = 51.170575601292503124545011895180 sigma(n’)/n’ = 51.170574766388240832412234041575
current step number = 11 quotient de Robin: 0.999999983683908098601293643276
loglog n = 28.730204950922168217141162268014

sigma(n’)/n’ = 51.170574766389089425053773872918
record step is at: 1
log(log(n’)) = 28.730204950922168217141162268014 Robin upper bound = 51.170575601292903583219156925329 sigma(n’)/n’ = 51.170574766389089425053773872918
current step number = 12 quotient de Robin: 0.999999983683910914425158617391
loglog n = 28.730204950922492151241330804596

sigma(n’)/n’ = 51.170574766389810462463379541014
record step is at: 1
log(log(n’)) = 28.730204950922492151241330804596 Robin upper bound = 51.170575601293480533310213579779 sigma(n’)/n’ = 51.170574766389810462463379541014
current step number = 13 quotient de Robin: 0.999999983683912839654075470824
loglog n = 28.730204950922976944043953164199

sigma(n’)/n’ = 51.170574766390772428610321893578
record step is at: 1
log(log(n’)) = 28.730204950922976944043953164199 Robin upper bound = 51.170575601294343984399404430591 sigma(n’)/n’ = 51.170574766390772428610321893578
current step number = 14 quotient de Robin: 0.999999983683914019851883786927
loglog n = 28.730204950923779795260506768487

sigma(n’)/n’ = 51.170574766392262756145719353392
record step is at: 2321
log(log(n’)) = 28.730204950923779795260506768487 Robin upper bound = 51.170575601295773920556957930649 sigma(n’)/n’ = 51.170574766392262756145719353392
current step number = 15 quotient de Robin: 0.999999983683903311710693176961
loglog n = 28.730204950925320580406050665231

sigma(n’)/n’ = 51.170574766394459064277377696965
record step is at: 2321
log(log(n’)) = 28.730204950925320580406050665231 Robin upper bound = 51.170575601298518170481735177949 sigma(n’)/n’ = 51.170574766394459064277377696965
current step number = 16 quotient de Robin: 0.999999983683914172548185010736
loglog n = 28.730204950930042533558165229522

sigma(n’)/n’ = 51.170574766403424959964399544175
record step is at: 108399999201
log(log(n’)) = 28.730204950930042533558165229522 Robin upper bound = 51.170575601306928311000008302129 sigma(n’)/n’ = 51.170574766403424959964399544175
=================================

Advertisements

Written by meditationatae

December 26, 2014 at 2:44 am

Posted in History

%d bloggers like this: