<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE Book SYSTEM "gapdoc.dtd" [
 <!ENTITY see '<Alt Only="LaTeX">$\to$</Alt><Alt Not="LaTeX">--&tgt;</Alt>'>
 <#Include Label="Version">
]>
<Book Name="FLOAT">

<TitlePage>
  <Title>Floating-point numbers</Title>
  <Version>Version &Version;</Version>
  <TitleComment>
    MPFR- and CXSC-based library for GAP
  </TitleComment>
  <Author>Laurent Bartholdi
          <Email><Alt Only="HTML">laurent.bartholdi@gmail.com</Alt>
		 <Alt Not="HTML">laurent.bartholdi@gmail.com</Alt></Email> 
	  <Homepage>http://www.uni-math.gwdg.de/laurent/</Homepage>
  </Author>
  <Date>&Date;</Date>
  <Address>
  Mathematisches Institut<Br/>Bunsenstraße 3-5<Br/>D-37073 Göttingen<Br/>Germany
  </Address>
  <Abstract>
    This document describes the package <Package>Float</Package>, which
    implements in &GAP; arbitrary-precision floating-point numbers.
  <Alt Only="HTML">
  <P/>
  The computer algebra system &GAP; is available at
  <URL>http://gap-system.org</URL>.
  <P/>
  This documentation for <Package>Float</Package> is available at
  <URL>http://www.gap-system.org/Manuals/pkg/float-&Version;/doc/manual.pdf</URL> in PDF format, and may be
  accessed online at <URL>http://gap-packages.github.io/float/</URL>.
  <P/>
  The latest release of the package may be downloaded as
  <URL>https://github.com/gap-packages/float/releases/download/v&Version;/float-&Version;.tar.gz</URL> (tar, gzipped).
  The latest repository version (possibly unstable) may be downloaded as
  <URL>https://github.com/gap-packages/float/tarball/master</URL> (tar, gzipped),
  <URL>https://github.com/gap-packages/float.git</URL> (git repository),
  <URL>https://packages.debian.org/search?keywords=gap-float&amp;searchon=names&amp;suite=all&amp;section=all</URL> (debian package), or
  explored at <URL>https://github.com/gap-packages/float/tree/master/</URL>.
  </Alt>
  <P/>
    For comments or questions on <Package>Float</Package> please contact
    the author.
  </Abstract>
  <Copyright>&copyright; 2011-2016 by Laurent Bartholdi
  </Copyright>
  <Acknowledgements>Part of this work is supported by the "Swiss
  National Fund for Scientific Research (SNF)", the "German National Science Foundation (DFG)",
  and the Courant Research Centre "Higher Order Structures" of the University of Göttingen.
  </Acknowledgements>

</TitlePage>

<TableOfContents/>

<Body>

<Chapter><Heading>Licensing</Heading>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or any
later version.

<P/> This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

<P/> You should have received a copy of the GNU General Public
License along with this program, in the file COPYING.  If not, see
<URL>http://www.gnu.org/licenses/</URL>.

</Chapter>

<Chapter Label="floatpackage"><Heading>Float package</Heading>

<Section Label="sample"><Heading>A sample run</Heading>

The extended floating-point capabilities of &GAP; are installed by loading the package
via <C>LoadPackage("float");</C> and selecting new floating-point handlers via
<C>SetFloats(MPFR)</C>, <C>SetFloats(MPFI)</C>, <C>SetFloats(MPC)</C> or<C>SetFloats(CXSC)</C>,
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:
<Example><![CDATA[
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> MinimalPolynomial(Rationals,Sqrt(2.0));
-2*x_1^2+1
gap> Cyc(last);
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
]]></Example>

</Section>

</Chapter>

<Chapter Label="poly"><Heading>Polynomials</Heading>

<Section><Heading>The Floats pseudo-field</Heading>

Polynomials with floating-point coefficients may be manipulated in
&GAP;; though they behave, in subtle ways, quite differently than
polynomials over rings.
<P/>

The "pseudo-field" of floating-point numbers is an object in &GAP;,
called <C>FLOAT_PSEUDOFIELD</C>. (It is not really a field,
e.g. because addition of floating-point numbers in not
associative). It may be used to create indeterminates, for example as
<Example><![CDATA[
gap> x := Indeterminate(FLOAT_PSEUDOFIELD,"x");
x
gap> 2*x^2+3;
2.0*x^2+3.0
gap> Value(last,10);
203.0
]]></Example>

</Section>

<Section><Heading>Roots of polynomials</Heading>

The Jenkins-Traub algorithm has been implemented, in arbitrary
precision for MPFR and MPC.
<P/>
Furthermore, CXSC can provide complex enclosures for the roots of a
complex polynomial.

</Section>

<Section><Heading>Finding integer relations</Heading>
<#Include Label="PSLQ">
</Section>

<Section><Heading>LLL lattice reduction</Heading>

A faster implementation of the LLL lattice reduction algorithm has
also been implemented. It is accessible via the commands
<C>FPLLLReducedBasis(m)</C> and 
<C>FPLLLShortestVector(m)</C>.
<P/>

</Section>

</Chapter>

<Chapter Label="impl"><Heading>Implemented packages</Heading>

<Section><Heading>MPFR</Heading>
<#Include Label="IsMPFRFloat">
</Section>

<Section><Heading>MPFI</Heading>
<#Include Label="IsMPFIFloat">
</Section>

<Section><Heading>MPC</Heading>
<#Include Label="IsMPCFloat">
</Section>

<Section><Heading>CXSC</Heading>
<#Include Label="IsCXSCFloat">
</Section>

<Section><Heading>FPLLL</Heading>
<#Include Label="FPLLL">
</Section>

</Chapter>

</Body>

<Bibliography Databases="floatbib.xml"/>
<TheIndex/>

</Book>
