Arb [1]

właściwości

edytuj

Arb is a C library

  • automatic error bound tracking to get an output that is guaranteed to be accurate, no error analysis needs to be done by the user
  • interval arithemtic  : midpoint-radius arithmetic = ball arithmetic
    • a midpoint-radius (ball) representation of real numbers
  • arbitrary precision arithmetic

Instalacja

edytuj

Wymagania

edytuj
  • gmp
  • mpfr
  • flint
  • python
    • sphinx-build (dla dokumentacji)
  • git (do instalacji)
  • make (do budowania)
  • gcc (do kompilacji)

pakiety

edytuj
  • flint-arb


  sudo apt-get install libflint-arb-dev

instalacja

edytuj

Instalacja [2][3][4]

git clone https://github.com/fredrik-johansson/arb/
cd arb
./configure 
make
make check
sudo make install

Przykładowe programy:

 make examples

Dokumentacja

edytuj
 cd doc
 make man

Pliki będą w

 build/man.
 

więc

 man ~/arb/doc/build/man/arb.1

Plik pdf:

 make latexpdf

uaktualnienie

edytuj
 git pull


sprawdzanie

edytuj
  sudo find / -name "libarb.so"

kompilacja

edytuj
  gcc a.c -larb -lflint -lgmp  -L/usr/local/lib/ -lmpfr  -Wall
  gcc a.c -larb -lflint -lgmp  -lmpfr  -Wall

problemy

edytuj

linkowanie

edytuj
 error while loading shared libraries: libarb.so: 
 cannot open shared object file: No such file or directory

Problem: biblioteka libarb.so nie jest w katalogu wyszukiwania( ang. library path)[5]. Sprawdź zmienną LD_LIBRARY_PATH.


Rozwiązanie:[6]

  • check library is present, use below command
  • compile your program with -L option, example below
  • export Library path before running if required


 sudo find / -name "libarb.so" #
 gcc program.c -L <path to library> -larb
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path to library>

Ewentualnie użyj:

fmpcb.h

edytuj

Błąd :[7]

 fatal error: fmpcb.h: No such file or directory
  • arf_t - arbitrary-precision floats[8]
    • mag_t - unsigned floats with 30-bit precision
  • arb_t = typ dla liczb rzeczywistych ( real numbers, plik arb.h): [mid ± rad]
  • acb_t = typ dla liczb zespolonych ( acb.h ): [a ± r] + [b ± s]i
  • typy całkowite [9]
    • slong
    • ulong
    • mp_limb_t
    • mp_ptr = Pointer to a writable array of limbs.
    • mp_srcptr = Pointer to a read-only array of limbs.
    • mp_size_t = A limb count (always nonnegative).
    • mp_bitcnt_t = A bit offset within an array of limbs (always nonnegative).Arb uses the following FLINT types for exact (integral and rational) arbitrary-size values. For details, refer to the FLINT documentation.
    • fmpz_t The FLINT multi-precision integer type uses an inline representation for small integers, specifically when the absolute value is at most 262−1262−1 (on 64-bit machines) or 230−1230−1 (on 32-bit machines). It switches automatically to a GMP integer for larger values. The fmpz_t type is functionally identical to the GMP mpz_t type, but faster for small values.
    • fmpq_t = FLINT multi-precision rational number.
    • fmpz_poly_t
    • fmpq_poly_t
    • fmpz_mat_t
    • fmpq_mat_t
  • arb_poly_t, acb_poly_t - real and complex polynomials
  • arb_mat_t, acb_mat_t - real and complex matrices

Przykłady

edytuj

arb_sub

edytuj
// http://arblib.org/arb-2.14.0.pdf


# include "arb.h" 

int main() { 
  arb_t x, y; 

  // init
  arb_init(x); 
  arb_init(y);

  // set 
  arb_set_ui(x, 3); /* x = 3 */ 
  arb_const_pi(y, 128); /* y = pi, to 128 bits */ 

  // compute
  arb_sub(y, y, x, 53); /* y = y - x, to 53 bits */ 
  
  // clear
  arb_clear(x); 
  arb_clear(y); 
}

arb_sqrt

edytuj
 
Wykres funkcji y = sqrt(x)
 void arb_sqrt(arb_t z, const arb_t x, slong prec) // z = sqrt(x) 

gdzie :

  • z = wynik ( output, result)
  • x = wejście ( input)
  • prec = precyzja w bitach z jaką jest zaokrąglany wynik


/* 

   original file : 
   This file is public domain. Author: Fredrik Johansson. 
   https://raw.githubusercontent.com/fredrik-johansson/arb/master/examples/logistic.c


   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
   gcc s.c -larb -lflint -lgmp -lmpfr  -lpthread -Wall
   ./a.out


   ./a.out 



   -----------------
   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, 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.

   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 
 

*/

#include "arb.h"


int main()
{
  slong prec;
  slong dec_digits;
  slong bits; // 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);
    
    
    
        
        
  while (1)
    {
         
      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; 
      if (i>500) break; 
             
      dec_digits = (prec-3)/3.3219280948873623; 
      //
      i+=1;
             
        
    }
   

  flint_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;
}


Wynik :

i =   0;  prec =         64;  bits =          1; dec_digits =         18; z = 2.00000000000000000
i =   1;  prec =         65;  bits =         62; dec_digits =         18; z = [1.41421356237309505 +/- 1.35e-18]
i =   2;  prec =         66;  bits =         64; dec_digits =         18; z = [1.18920711500272107 +/- 3.42e-18]
i =   3;  prec =         67;  bits =         66; dec_digits =         19; z = [1.090507732665257659 +/- 2.55e-19]
i =   4;  prec =         68;  bits =         67; dec_digits =         19; z = [1.044273782427413840 +/- 3.55e-19]
i =   5;  prec =         69;  bits =         67; dec_digits =         19; z = [1.021897148654116678 +/- 2.53e-19]
i =   6;  prec =         70;  bits =         69; dec_digits =         20; z = [1.0108892860517004600 +/- 3.05e-20]
i =   7;  prec =         71;  bits =         69; dec_digits =         20; z = [1.0054299011128028213 +/- 5.67e-20]
i =   8;  prec =         72;  bits =         71; dec_digits =         20; z = [1.0027112750502024854 +/- 3.42e-20]
i =   9;  prec =         73;  bits =         70; dec_digits =         21; z = [1.00135471989210820588 +/- 4.18e-21]
i =  10;  prec =         74;  bits =         73; dec_digits =         21; z = [1.00067713069306635668 +/- 4.70e-21]
i =  11;  prec =         75;  bits =         74; dec_digits =         21; z = [1.00033850805268231295 +/- 3.94e-21]
i =  12;  prec =         76;  bits =         75; dec_digits =         21; z = [1.00016923970530223108 +/- 4.01e-21]
i =  13;  prec =         77;  bits =         71; dec_digits =         22; z = [1.000084616272694313202 +/- 8.19e-22]
i =  14;  prec =         78;  bits =         75; dec_digits =         22; z = [1.000042307241395819339 +/- 3.56e-22]
i =  15;  prec =         79;  bits =         78; dec_digits =         22; z = [1.000021153396964808094 +/- 3.08e-22]
i =  16;  prec =         80;  bits =         72; dec_digits =         23; z = [1.0000105766425497202348 +/- 7.91e-23]
i =  17;  prec =         81;  bits =         76; dec_digits =         23; z = [1.0000052883072917631114 +/- 7.15e-23]
i =  18;  prec =         82;  bits =         81; dec_digits =         23; z = [1.0000026441501501165475 +/- 1.73e-23]
i =  19;  prec =         83;  bits =         82; dec_digits =         24; z = [1.0000013220742011181771 +/- 2.50e-23]
i =  20;  prec =         84;  bits =         83; dec_digits =         24; z = [1.00000066103688207420883 +/- 6.59e-24]
i =  21;  prec =         85;  bits =         84; dec_digits =         24; z = [1.00000033051838641590253 +/- 6.33e-24]
i =  22;  prec =         86;  bits =         85; dec_digits =         24; z = [1.00000016525917955265305 +/- 5.00e-24]
i =  23;  prec =         87;  bits =         86; dec_digits =         25; z = [1.000000082629586362502256 +/- 8.71e-25]
i =  24;  prec =         88;  bits =         87; dec_digits =         25; z = [1.000000041314792327795095 +/- 6.06e-25]
i =  25;  prec =         89;  bits =         87; dec_digits =         25; z = [1.000000020657395950533544 +/- 2.37e-25]
i =  26;  prec =         90;  bits =         89; dec_digits =         26; z = [1.000000010328697921925772 +/- 5.03e-25]
i =  27;  prec =         91;  bits =         87; dec_digits =         26; z = [1.0000000051643489476276358 +/- 7.99e-26]
i =  28;  prec =         92;  bits =         91; dec_digits =         26; z = [1.0000000025821744704800054 +/- 3.90e-26]
i =  29;  prec =         93;  bits =         87; dec_digits =         27; z = [1.0000000012910872344065496 +/- 4.35e-26]
i =  30;  prec =         94;  bits =         88; dec_digits =         27; z = [1.00000000064554361699491150 +/- 9.18e-27]
i =  31;  prec =         95;  bits =         89; dec_digits =         27; z = [1.00000000032277180844536493 +/- 4.50e-27]
i =  32;  prec =         96;  bits =         90; dec_digits =         27; z = [1.00000000016138590420965976 +/- 2.25e-27]
i =  33;  prec =         97;  bits =         91; dec_digits =         28; z = [1.000000000080692952101574204 +/- 8.87e-28]
i =  34;  prec =         98;  bits =         92; dec_digits =         28; z = [1.000000000040346476049973183 +/- 4.53e-28]
i =  35;  prec =         99;  bits =         92; dec_digits =         28; z = [1.000000000020173238024783112 +/- 4.99e-28]
i =  36;  prec =        100;  bits =         95; dec_digits =         29; z = [1.000000000010086619012340686 +/- 1.95e-28]
i =  37;  prec =        101;  bits =         97; dec_digits =         29; z = [1.0000000000050433095061576255 +/- 8.41e-29]
i =  38;  prec =        102;  bits =         99; dec_digits =         29; z = [1.0000000000025216547530756334 +/- 6.42e-29]
i =  39;  prec =        103;  bits =        101; dec_digits =         30; z = [1.0000000000012608273765370218 +/- 5.50e-29]
i =  40;  prec =        104;  bits =        103; dec_digits =         30; z = [1.00000000000063041368826831221 +/- 8.57e-30]
i =  41;  prec =        105;  bits =        104; dec_digits =         30; z = [1.00000000000031520684413410643 +/- 7.11e-30]
i =  42;  prec =        106;  bits =        105; dec_digits =         31; z = [1.00000000000015760342206704079 +/- 6.05e-30]
i =  43;  prec =        107;  bits =        106; dec_digits =         31; z = [1.00000000000007880171103351729 +/- 3.19e-30]
i =  44;  prec =        108;  bits =        107; dec_digits =         31; z = [1.000000000000039400855516757870 +/- 6.77e-31]
i =  45;  prec =        109;  bits =        107; dec_digits =         31; z = [1.000000000000019700427758378741 +/- 3.99e-31]
i =  46;  prec =        110;  bits =        108; dec_digits =         32; z = [1.000000000000009850213879189322 +/- 2.18e-31]
i =  47;  prec =        111;  bits =        109; dec_digits =         32; z = [1.000000000000004925106939594649 +/- 2.39e-31]
i =  48;  prec =        112;  bits =        110; dec_digits =         32; z = [1.0000000000000024625534697973214 +/- 5.24e-32]
i =  49;  prec =        113;  bits =        111; dec_digits =         33; z = [1.0000000000000012312767348986599 +/- 5.27e-32]
i =  50;  prec =        114;  bits =        112; dec_digits =         33; z = [1.0000000000000006156383674493298 +/- 3.21e-32]
i =  51;  prec =        115;  bits =        113; dec_digits =         33; z = [1.00000000000000030781918372466484 +/- 6.23e-33]
i =  52;  prec =        116;  bits =        113; dec_digits =         34; z = [1.00000000000000015390959186233241 +/- 3.64e-33]
i =  53;  prec =        117;  bits =        116; dec_digits =         34; z = [1.00000000000000007695479593116620 +/- 2.73e-33]
i =  54;  prec =        118;  bits =        117; dec_digits =         34; z = [1.000000000000000038477397965583100 +/- 6.60e-34]
i =  55;  prec =        119;  bits =        116; dec_digits =         34; z = [1.000000000000000019238698982791550 +/- 5.23e-34]
i =  56;  prec =        120;  bits =        117; dec_digits =         35; z = [1.000000000000000009619349491395775 +/- 3.13e-34]
i =  57;  prec =        121;  bits =        118; dec_digits =         35; z = [1.000000000000000004809674745697887 +/- 5.01e-34]
i =  58;  prec =        122;  bits =        116; dec_digits =         35; z = [1.0000000000000000024048373728489437 +/- 4.78e-35]
i =  59;  prec =        123;  bits =        121; dec_digits =         36; z = [1.0000000000000000012024186864244719 +/- 7.05e-35]
i =  60;  prec =        124;  bits =        123; dec_digits =         36; z = [1.0000000000000000006012093432122359 +/- 3.68e-35]
i =  61;  prec =        125;  bits =        122; dec_digits =         36; z = [1.00000000000000000030060467160611796 +/- 8.38e-36]
i =  62;  prec =        126;  bits =        125; dec_digits =         37; z = [1.00000000000000000015030233580305898 +/- 4.19e-36]
i =  63;  prec =        127;  bits =        125; dec_digits =         37; z = [1.00000000000000000007515116790152949 +/- 2.10e-36]
i =  64;  prec =        128;  bits =        127; dec_digits =         37; z = [1.00000000000000000003757558395076475 +/- 5.45e-36]
i =  65;  prec =        129;  bits =        125; dec_digits =         37; z = [1.000000000000000000018787791975382373 +/- 7.34e-37]
i =  66;  prec =        130;  bits =        129; dec_digits =         38; z = [1.000000000000000000009393895987691186 +/- 5.12e-37]
i =  67;  prec =        131;  bits =        129; dec_digits =         38; z = [1.000000000000000000004696947993845593 +/- 2.56e-37]
i =  68;  prec =        132;  bits =        131; dec_digits =         38; z = [1.0000000000000000000023484739969227966 +/- 7.12e-38]
i =  69;  prec =        133;  bits =        130; dec_digits =         39; z = [1.0000000000000000000011742369984613983 +/- 3.63e-38]
i =  70;  prec =        134;  bits =        133; dec_digits =         39; z = [1.0000000000000000000005871184992306991 +/- 5.70e-38]
i =  71;  prec =        135;  bits =        133; dec_digits =         39; z = [1.00000000000000000000029355924961534957 +/- 8.50e-39]
i =  72;  prec =        136;  bits =        135; dec_digits =         40; z = [1.00000000000000000000014677962480767479 +/- 7.32e-39]
i =  73;  prec =        137;  bits =        132; dec_digits =         40; z = [1.00000000000000000000007338981240383739 +/- 4.63e-39]
i =  74;  prec =        138;  bits =        137; dec_digits =         40; z = [1.00000000000000000000003669490620191870 +/- 4.38e-39]
i =  75;  prec =        139;  bits =        137; dec_digits =         40; z = [1.000000000000000000000018347453100959348 +/- 6.56e-40]
i =  76;  prec =        140;  bits =        139; dec_digits =         41; z = [1.000000000000000000000009173726550479674 +/- 3.28e-40]
i =  77;  prec =        141;  bits =        138; dec_digits =         41; z = [1.000000000000000000000004586863275239837 +/- 1.64e-40]
i =  78;  prec =        142;  bits =        141; dec_digits =         41; z = [1.0000000000000000000000022934316376199185 +/- 8.20e-41]
i =  79;  prec =        143;  bits =        141; dec_digits =         42; z = [1.0000000000000000000000011467158188099593 +/- 6.53e-41]
i =  80;  prec =        144;  bits =        143; dec_digits =         42; z = [1.0000000000000000000000005733579094049796 +/- 4.55e-41]
i =  81;  prec =        145;  bits =        141; dec_digits =         42; z = [1.0000000000000000000000002866789547024898 +/- 2.28e-41]
i =  82;  prec =        146;  bits =        145; dec_digits =         43; z = [1.00000000000000000000000014333947735124491 +/- 5.93e-42]
i =  83;  prec =        147;  bits =        145; dec_digits =         43; z = [1.00000000000000000000000007166973867562245 +/- 5.69e-42]
i =  84;  prec =        148;  bits =        147; dec_digits =         43; z = [1.00000000000000000000000003583486933781123 +/- 4.03e-42]
i =  85;  prec =        149;  bits =        146; dec_digits =         43; z = [1.000000000000000000000000017917434668905613 +/- 9.22e-43]
i =  86;  prec =        150;  bits =        149; dec_digits =         44; z = [1.000000000000000000000000008958717334452807 +/- 5.18e-43]
i =  87;  prec =        151;  bits =        149; dec_digits =         44; z = [1.000000000000000000000000004479358667226403 +/- 4.81e-43]
i =  88;  prec =        152;  bits =        151; dec_digits =         44; z = [1.0000000000000000000000000022396793336132017 +/- 8.23e-44]
i =  89;  prec =        153;  bits =        146; dec_digits =         45; z = [1.0000000000000000000000000011198396668066008 +/- 7.02e-44]
i =  90;  prec =        154;  bits =        153; dec_digits =         45; z = [1.0000000000000000000000000005599198334033004 +/- 3.51e-44]
i =  91;  prec =        155;  bits =        153; dec_digits =         45; z = [1.00000000000000000000000000027995991670165021 +/- 8.32e-45]
i =  92;  prec =        156;  bits =        155; dec_digits =         46; z = [1.00000000000000000000000000013997995835082510 +/- 8.77e-45]
i =  93;  prec =        157;  bits =        154; dec_digits =         46; z = [1.00000000000000000000000000006998997917541255 +/- 4.39e-45]
i =  94;  prec =        158;  bits =        157; dec_digits =         46; z = [1.00000000000000000000000000003499498958770628 +/- 4.86e-45]
i =  95;  prec =        159;  bits =        157; dec_digits =         46; z = [1.000000000000000000000000000017497494793853138 +/- 5.96e-46]
i =  96;  prec =        160;  bits =        159; dec_digits =         47; z = [1.000000000000000000000000000008748747396926569 +/- 2.98e-46]
i =  97;  prec =        161;  bits =        157; dec_digits =         47; z = [1.000000000000000000000000000004374373698463285 +/- 6.16e-46]
i =  98;  prec =        162;  bits =        161; dec_digits =         47; z = [1.000000000000000000000000000002187186849231642 +/- 3.25e-46]
i =  99;  prec =        163;  bits =        161; dec_digits =         48; z = [1.0000000000000000000000000000010935934246158211 +/- 6.23e-47]
i = 100;  prec =        164;  bits =        163; dec_digits =         48; z = [1.0000000000000000000000000000005467967123079106 +/- 5.30e-47]

Computed with: 
arb-2.10.0
  Flint-2.5.2
 MPFR-3.1.5 
 GMP-6.1.1 

Porównaj z:


acb_sqrt

edytuj
  void acb_sqrt(acb_t r, const acb_t z, slong prec) // r = sqrt( z)


/*
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
gcc a.c -larb -lflint -lgmp -lmpfr  -lpthread -Wall
./a.out
*/

#include "arb.h"
#include <acb.h> // acb_t


int main()
{
    acb_t z;
    acb_init(z);
    
    acb_t r;
    acb_init(r);
    
    
    acb_set_d_d(z, 1.0, 1.0);

    acb_sqrt(r,z, 10); // r=sqrt(z) with precision
    flint_printf("sqrt(z) = ");
    acb_print(r); 
    flint_printf("\n");
    
        
    flint_printf("Computed with: \narb-%s\n  Flint-%s\n MPFR-%s \n GMP-%s \n", arb_version, FLINT_VERSION ,mpfr_version, gmp_version ); //
    
    acb_clear(z);
    acb_clear(r);
    
}

Wynik:

 ./a.out
sqrt(z) = ((281 * 2^-8) +/- (593337151 * 2^-38), (233 * 2^-9) +/- (630453476 * 2^-40))
Computed with: 
arb-2.10.0
  Flint-2.5.2
 MPFR-3.1.5 
 GMP-6.1.1
/*
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
gcc a.c -larb -lflint -lgmp -lmpfr  -lpthread -Wall
./a.out
*/

#include "arb.h"

int main()
{
    arb_t x;
    arb_init(x);
    arb_const_pi(x, 50 * 3.33);
    arb_printn(x, 50, 0); flint_printf("\n");
    flint_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(x);
}

Kompilacja:

 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
 gcc a.c -larb -lflint -lgmp -lmpfr  -lpthread -Wall

Użycie:

./a.out

wynik:

 [3.1415926535897932384626433832795028841971693993751 +/- 6.27e-50]
 Computed with: 
 arb-2.9.0-git
 Flint-2.5.2
 MPFR-3.1.5 
 GMP-6.1.1

liczby zespolone

edytuj
/*
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
gcc a.c -larb -lflint -lgmp -lmpfr  -lpthread -Wall
./a.out
*/

#include "arb.h"
#include <acb.h> // acb_t


int main()
{
    acb_t z;
    acb_init(z);
    
    acb_t r;
    acb_init(r);
    
    
    acb_set_d_d(z, 1.0, 1.0);

    acb_sqrt(r,z, 10); // r=sqrt(z) with precision
    flint_printf("sqrt(z) = ");
    acb_print(r); 
    flint_printf("\n");
    
        
    flint_printf("Computed with: \narb-%s\n  Flint-%s\n MPFR-%s \n GMP-%s \n", arb_version, FLINT_VERSION ,mpfr_version, gmp_version ); //
    
    acb_clear(z);
    acb_clear(r);
    
}

Kompiluj:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
gcc a.c -larb -lflint -lgmp -lmpfr  -lpthread -Wall

uruchom:

./a.out

wynik:

sqrt(z) = ((281 * 2^-8) +/- (593337151 * 2^-38), (233 * 2^-9) +/- (630453476 * 2^-40))
Computed with: 
arb-2.10.0
Flint-2.5.2
MPFR-3.1.5 
GMP-6.1.1

complex_plot

edytuj

Kompilacja:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
gcc complex_plot.c -larb -lflint -lgmp -lmpfr  -lpthread -lm -Wall -o complex_plot

Użycie:

complex_plot [-range xa xb ya yb] [-size xn yn] [-color n] <func>

Domyślne parametry:

[-10,10] + [-10,10]i 
xn = yn = 512


Gotowe funkcje:[10]

  • gamma - Gamma function
  • digamma - Digamma function
  • lgamma - Logarithmic gamma function
  • zeta - Riemann zeta function
  • erf - Error function
  • ai - Airy function Ai[11]
  • bi - Airy function Bi
  • besselj - Bessel function J_0
  • bessely - Bessel function Y_0
  • besseli - Bessel function I_0
  • besselk - Bessel function K_0
  • modj - Modular j-function[12][13]
  • modeta - Dedekind eta function
  • barnesg - Barnes G-function
  • agm - Arithmetic geometric mean


Przykład użycia:

./complex_plot gamma

Tekstowy wynik:

row 480
row 448
row 416
row 384
row 352
row 320
row 288
row 256
row 224
row 192
row 160
row 128
row 96
row 64
row 32
row 0
cpu/wall(s): 2.069 2.076

oraz plik arbplot.ppm

logistic

edytuj

Oblicza n-tą iterację odwzorowania logistycznego[14]

   
    


     export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
   ./logistic 0 0.5 3.75 10
   ./logistic: error while loading shared libraries: libarb.so.2: cannot open shared object file: No such file or directory
   a@zelman:~/arb/build/examples$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
   ~/arb/build/examples$ ./logistic 0 0.5 3.75 10Trying prec=64 bits...success!
   cpu/wall(s): 0 0
   x_0 = 0.5000000000
   ~/arb/build/examples$ ./logistic 1 0.5 3.75 10
   Trying prec=64 bits...success!
   cpu/wall(s): 0 0.001
   x_1 = 0.9375000000
   ~/arb/build/examples$ ./logistic 100 0.5 3.75 10
   Trying prec=64 bits...ran out of accuracy at step 18
   Trying prec=128 bits...ran out of accuracy at step 53
   Trying prec=256 bits...success!
   cpu/wall(s): 0 0
   x_100 = [0.8882939923 +/- 1.60e-11]
   ~/arb/build/examples$ ./logistic 1000 0.5 3.75 100
   Trying prec=64 bits...ran out of accuracy at step 4
   Trying prec=128 bits...ran out of accuracy at step 5
   Trying prec=256 bits...ran out of accuracy at step 6
   Trying prec=512 bits...ran out of accuracy at step 99
   Trying prec=1024 bits...ran out of accuracy at step 369
   Trying prec=2048 bits...ran out of accuracy at step 906
   Trying prec=4096 bits...success!
   cpu/wall(s): 0.003 0.003
   x_1000 = [0.7917467409224436376869853580586396204499342746098639418369939567972864824346152847471492894632044257 +/- 4.39e-101]

Zobacz również

edytuj

Źródła

edytuj
  1. Arb by Fredrik Johansson
  2. stackexchange questions : how-can-i-link-my-c-program-against-the-arb-library
  3. Modular forms in arb
  4. askubuntu questions : libarb-so-libflint-so-13-cannot-open-shared-object-file-no-such-file-or-dire
  5. askubuntu question libarb-so-libflint-so-13-cannot-open-shared-object-file-no-such-file-or-dire
  6. stackoverflow question : libarb-so-cannot-open-shared-object-file-no-such-file-or-directory
  7. unix SE question: how-can-i-link-my-c-program-against-the-arb-library
  8. Fundamental algorithms in Arb
  9. arb : Integer types
  10. fredrikj phaseful-plots
  11. fredrik j airy-in-the-library
  12. fredrik j modular-forms-in-arb/
  13. The j-invariant magnified 100 orders of magnitude (10x zoom per second) by Fredrik Johansson
  14. wikipedia : Odwzorowanie logistyczne