GAP (FLOAT) - Chapter 2: Float package

Goto Chapter: Top 1 2 3 4 Bib Ind
[Top of Book] [Contents] [Previous Chapter] [Next Chapter]

2 Float package
2.1 A sample run

### 2 Float package

#### 2.1 A sample run

The extended floating-point capabilities of GAP are installed by loading the package via `LoadPackage("float");` and selecting new floating-point handlers via `SetFloats(MPFR)`, `SetFloats(MPFI)`, `SetFloats(MPC)` or`SetFloats(CXSC)`, depending on whether high-precision real, interval or complex arithmetic are desired, or whether a fast package containing all four real/complex element/interval arithmetic is desired:

    gap> LoadPackage("float");
    Loading FLOAT 0.7.0 ...
    true
    gap> SetFloats(MPFR); # floating-point
    gap> x := 4*Atan(1.0);
    .314159e1
    gap> Sin(x);
    .169569e-30
    gap> SetFloats(MPFR,1000); # 1000 bits
    gap> x := 4*Atan(1.0);
    .314159e1
    gap> Sin(x);
    .125154e-300
    gap> String(x,300);
    ".3141592653589793238462643383279502884197169399375105820974944592307816406286\
    208998628034825342117067982148086513282306647093844609550582231725359408128481\
    117450284102701938521105559644622948954930381964428810975665933446128475648233\
    78678316527120190914564856692346034861045432664821339360726024914127e1"
    gap>
    gap> SetFloats(MPFI); # intervals
    gap> x := 4*Atan(1.0);
    .314159e1(99)
    gap> AbsoluteDiameter(x); Sup(x); Inf(x);
    .100441e-29
    .314159e1
    .314159e1
    gap> Sin(x);
    -.140815e-29(97)
    gap> 0.0 in last;
    true
    gap> 1.0; # exact representation
    .1e1(∞)
    gap> IncreaseInterval(last,0.001); # now only 8 significant bits
    .1e1(8)
    gap> IncreaseInterval(last,-0.002); # now becomes empty
    ∅
    gap> r2 := Sqrt(2.0);
    .141421e1(99)
    gap> MinimalPolynomial(Rationals,r2);
    -2*x_1^2+1
    gap> Cyc(r2);
    E(8)-E(8)^3
    gap>
    gap> SetFloats(MPC); # complex numbers
    gap> z := 5.0-1.0i;
    .5e1-.1e1i
    gap> (1+1.0i)*last^4*(239+1.0i);
    .228488e6
    gap> Exp(6.2835i);
    .1e1+.314693e-3i

[Top of Book] [Contents] [Previous Chapter] [Next Chapter]
Goto Chapter: Top 1 2 3 4 Bib Ind

generated by GAPDoc2HTML