Programowanie w systemie UNIX/ARB: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
m →‎arb_sqrt: _printf("Computed with: \narb-%s\n Flint-%s\n MPFR-%s \n GMP-%s \n", arb_version, FLINT_VERSION ,mpfr_version, gmp_version ); //
m →‎arb_sqrt: formatted with emacs
Linia 68:
/*
 
original file :
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
This file is public domain. Author: Fredrik Johansson.
gcc s.c -larb -lflint -lgmp -lmpfr -lpthread -Wall
https://raw.githubusercontent.com/fredrik-johansson/arb/master/examples/logistic.c
./a.out
 
-----------------
relative determinate error in the square root of Q is one half the relative determinate error in Q
 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
IEEE-754 standard guarantees me that the result will be as close to the 'real result' as possible, i.e. error will be less than or equal to 1/2 unit-in-the-last-place. In particular,
gcc s.c -larb -lflint -lgmp -lmpfr -lpthread -Wall
http://stackoverflow.com/questions/22259537/guaranteed-precision-of-sqrt-function-in-c-c
./a.out
=====================
 
decimal digits required = ceil(-log10(sqrt(x+1)-sqrt(x)))
 
http://stackoverflow.com/questions/30029410/sqrt-and-decimals
./a.out
============
 
https://groups.google.com/forum/#!topic/flint-devel/yrOCnfi6DuI
 
 
-----------------
relative determinate error in the square root of Q is one half the relative determinate error in Q
 
 
IEEE-754 standard guarantees me that the result will be as close to the 'real result' as possible, i.e. error will be less than or equal to 1/2 unit-in-the-last-place. In particular,
http://stackoverflow.com/questions/22259537/guaranteed-precision-of-sqrt-function-in-c-c
=====================
decimal digits required = ceil(-log10(sqrt(x+1)-sqrt(x)))
http://stackoverflow.com/questions/30029410/sqrt-and-decimals
============
https://groups.google.com/forum/#!topic/flint-devel/yrOCnfi6DuI
I thought that the number will be decreasing but will be greater then 1.0 ( not equal to 1.0)
 
Correct.
and I will display such number ( all digits )
 
Note that the ball radius in most of your results is larger than the first nonzero digit after the 1.
 
For example, prec += 1; // "if I have the number 1.000123456.... with a ball radius of 1e-2, I will only see 1.00+/-1e-2. If I have a ball radius of 1e-5, I'll see 1.00012+/-1e-5." Bill Hart
 
In your calculation, you kept the precision at 64 bits for too long. Then you started doubling the precision unnecessarily. Try increasing the precision by 1 bit on every iteration, right from the start, instead of doubling it after the digits of interest are already gone.
Bill Hart
 
*/
Linia 90 ⟶ 120:
int main()
{
slong prec;
slong dec_digits;
slong bits; // Returns the number of bits needed to represent the absolute value of the mantissa of the midpoint of x, i.e. the minimum precision sufficient to represent x exactly.
arb_t z; // arbitrary-precision floating-point numbers with ball arithmethic
slong i =0;
 
double z0 = 2.0;
 



arb_init(z);
prec = 64;
dec_digits = (prec-3)/3.3219280948873623;
arb_set_d(z, z0); // z = 2.0
bits = arb_bits(z);
bits = arb_bits(z);
while (1)
while (1)
{
flint_printf("i = %3wd; prec = %10wd; bits = %10wd; dec_digits = %10wd; z = ", i, prec, bits, dec_digits);
while (1)
arb_printn(z, dec_digits, {0);
flint_printf("\n");
flint_printf("i = %3wd; prec = %10wd; bits = %10wd; dec_digits = %10wd; z = ", i, prec, bits, dec_digits);
arb_printn(z, dec_digits, 0);
flint_printf("\n");
//
arb_sqrt(z,z,prec); // z = sqrt(z)
bits = arb_bits(z); // Returns the number of bits needed to represent the absolute value of the mantissa of the midpoint of x, i.e. the minimum precision sufficient to represent x exactly.
//
prec += 1;
prec += 1; // "if I have the number 1.000123456.... with a ball radius of 1e-2, I will only see 1.00+/-1e-2. If I have a ball radius of 1e-5, I'll see 1.00012+/-1e-5." Bill Hart
if (i>500) break;

dec_digits = (prec-3)/3.3219280948873623;
//
i+=1;
}
printf("Computed with: \narb-%s\n Flint-%s\n MPFR-%s \n GMP-%s \n", arb_version, FLINT_VERSION ,mpfr_version, gmp_version ); //
arb_clear(z);}
flint_cleanup();
 
return 0;
printfflint_printf("Computed with: \narb-%s\n Flint-%s\n MPFR-%s \n GMP-%s \n", arb_version, FLINT_VERSION ,mpfr_version, gmp_version ); //
 
arb_clear(z);
flint_cleanup();
return 0;
}
 
</source>