> < ^ Date: Tue, 20 May 1997 14:00:00 +0100 (MET)
> < ^ From: Jean Michel <jmichel@math.jussieu.fr >
^ Subject: decimal.g, complex.g

I wrote two short gap files (less than 200 lines of gap code
altogether), which some people told me could be useful to them.
So I posted them in the pub/incoming directory of
ftp.math.rwth-aachen.de.
Below is an explanation of what they do
(taken from the comments inside them)
Jean MICHEL

```#########################################################################
#                       decimal.g
#  defines evalf(), Exp() and decimal numbers. (C) Jean MICHEL,  may 1997
#
# The main function defined in this file is a function evalf similar to
# the Maple function with the same name.
#
#   gap> evalf(1/3);
#   0.3333333333
#
# The precision (number of digits after the decimal point) should be set
# once and for all by assigning to the variable DecimalPrescision
#
#   gap> DecimalPrecision:=20;
#   20
#   gap> evalf(1/3);
#   0.33333333333333333333
#
# The result is a ``decimal number'', which is a fixed-precision real
# number for which the operations .+,-,*,/,^,< are defined.
#
#   gap> evalf(1/3)+1;
#   1.3333333333
#   gap> last^3;
#   2.3703703704
#
# The constant Pi and the function Exp are also defined by this file. The
# code of Exp provides an example of how one can use decimal numbers.
# The given Pi being only accurate to 500 places, you should limit
# DecimalPrecision to that number for now.
#
#   gap> Pi();
#   3.1415926536
#   gap> Exp(1);
#   2.7182818285
#
# It is also possible to evalf() cyclotomic numbers. For this reason
# this file needs also the file  complex.g.
#
#   gap> evalf(ER(2));
#   1.4142135623
#   gap> evalf(E(3));
#   -0.5+0.8660254038I
#   gap> last^3;
#   1
#   gap> Exp(Pi()*evalf(E(4)));
#   1
#
# There is a last function defined in this file we should mention.
# IsDecimal(x) returns true iff x is a decimal number.
#########################################################################

#########################################################################
#                       complex.g
#  defines complex numbers on an arbitrary ring. (C) Jean MICHEL,  may 1997
#
#   gap> Complex(0,1);
#   I
#   gap> last+1;
#   1+I
#   gap> last^2;
#   2I
#   gap> last^2;
#   -4
#   gap> Complex(E(3));
#   -1/2+(-1/2*E(12)^7+1/2*E(12)^11)I
#   gap> Complex(E(3)^2);
#   -1/2+(1/2*E(12)^7-1/2*E(12)^11)I
#   gap> last+last2;
#   -1
#
# It can be combined with the file ``decimal.g''
#
#   gap> Complex(E(3));
#   -1/2+(-1/2*E(12)^7+1/2*E(12)^11)I
#   gap> evalf(last);
#   0.5+0.8660254039I
#
# In addition to the function Complex, this file defines two other
# functions: ComplexConjugate and IsComplex
#
#   gap> x:=X(Rationals);;x.name:="x";;Complex(0,x);
#   xI
#   gap> last^2;
#   -x^2
#   gap> IsComplex(last);
#   true
#   gap> ComplexConjugate(last2);
#   -x^2
#
##########################################################################
```

> < [top]