\defC{\mathbb C}
We document here various utility functions defined by VKCURVE package and which may be useful also in other contexts.
Deriv( v )
v is a vector representing the coefficients of a polynomial. Returns a vector representing the coefficients of the derivative of that polynomial.
gap> Deriv([1,1,1,1,1]); [ 1, 2, 3, 4 ]
This function requires the package "vkcurve" (see RequirePackage).
Horner( v, x )
v is a vector representing the coefficients of a polynomial. Returns the value of that polynomial at x, using Horner' s scheme.
gap> v:=List("abcde",x->Mvp([x])); [ a, b, c, d, e ] gap> Horner(v,2); a+2b+4c+8d+16e
This function requires the package "vkcurve" (see RequirePackage).
BigNorm(c)
Given a complex
number c with real part r and imaginary part j,
returns a "cheap substitute" to the norm of c given by r
+j
.
gap> BigNorm(Complex(-1,-1)); 2
This function requires the package "vkcurve" (see RequirePackage).
DecimalLog(r)
Given a rational number r, returns an integer k such that 10k<
r
≤ 10k+1.
gap> List([1,1/10,1/2,2,10],DecimalLog); [ -1, -2, -1, 0, 1 ]
This function requires the package "vkcurve" (see RequirePackage).
DecimalToRat(d)
d is a decimal
number. The function returns the rational number
which is actually represented by d
gap> evalf(1/3); 0.3333333333 gap> DecimalToRat(last); 33333333333/100000000000
This function requires the package "vkcurve" (see RequirePackage).
ComplexToComplexRat(c)
c is a complex
numbers with decimal
real and imaginary part.
This functions returns the corresponding rational complex number.
gap> evalf(E(3)); -0.5+0.8660254038I gap> ComplexToComplexRat(last); -1/2+86602540379/100000000000I
This function requires the package "vkcurve" (see RequirePackage).
Dispersal(v)
v is a list of complex
numbers representing points in the real plane.
The result is a pair whose first element is the minimum distance between
two elements of v, and the second is a pair of indices [i,j]
such that
v[i]
, v[j]
achieves this minimum distance.
gap> Dispersal([Complex(1,1),Complex(0),Complex(1)]); [ 1, [ 1, 3 ] ]
This function requires the package "vkcurve" (see RequirePackage).
ConjugatePresentation(p [,conjugation])
This program modifies a presentation by conjugating a generator by
another. The conjugaction to apply is described by a length-3 string of
the same style as the result of DisplayPresentation
, that is "abA"
means replace the second generator by its conjugate by the first, and
"Aba"
means replace it by its conjugate by the inverse of the first.
gap> F:=FreeGroup(4);; gap> p:=PresentationFpGroup(F/[F.4*F.1*F.2*F.3*F.4*F.1^-1*F.4^-1* > F.3^-1*F.2^-1*F.1^-1,F.4*F.1*F.2*F.3*F.4*F.2*F.1^-1*F.4^-1*F.3^-1* >F.2^-1*F.1^-1*F.3^-1,F.2*F.3*F.4*F.1*F.2*F.3*F.4*F.3^-1*F.2^-1* >F.4^-1*F.3^-1*F.2^-1*F.1^-1*F.4^-1]); gap> DisplayPresentation(p); 1: dabcd=abcda 2: dabcdb=cabcda 3: bcdabcd=dabcdbc gap> DisplayPresentation(ConjugatePresentation(p,"cdC")); #I there are 4 generators and 3 relators of total length 36 1: cabdca=dcabdc 2: dcabdc=bdcabd 3: cabdca=abdcab
This function requires the package "vkcurve" (see RequirePackage).
TryConjugatePresentation(p [,goal [,printlevel]])
This program tries to simplify group presentations by applying conjugations to the generators. The algorithm depends on random numbers, and on tree-searching, so is not reproducible. By default the program stops as soon as a shorter presentation is found. Sometimes this does not give the desired presentation. One can give a second argument goal, then the program will only stop when a presentation of length less than goal is found. Finally, a third argument can be given and then all presentations the programs runs over which are of length less than or equal to this argument are displayed. Due to the non-deterministic nature of the program, it may be useful to run it several times on the same input. Upon failure (to improve the presentation), the program returns p.
gap> Display(p); 1: ba=ab 2: dbd=bdb 3: cac=aca 4: bcb=cbc 5: dAca=Acad 6: dcdc=cdcd 7: adad=dada 8: dcDbdc=bdcbdB 9: dcdadc=adcdad 10: adcDad=dcDadc 11: BcccbdcAb=dcbACdddc gap> p:=TryConjugatePresentation(p); #I there are 4 generators and 11 relators of total length 100 #I there are 4 generators and 11 relators of total length 120 #I there are 4 generators and 10 relators of total length 100 #I there are 4 generators and 11 relators of total length 132 #I there are 4 generators and 11 relators of total length 114 #I there are 4 generators and 11 relators of total length 110 #I there are 4 generators and 11 relators of total length 104 #I there are 4 generators and 11 relators of total length 114 #I there are 4 generators and 11 relators of total length 110 #I there are 4 generators and 11 relators of total length 104 #I there are 4 generators and 8 relators of total length 76 #I there are 4 generators and 8 relators of total length 74 #I there are 4 generators and 8 relators of total length 72 #I there are 4 generators and 8 relators of total length 70 #I there are 4 generators and 7 relators of total length 52 # d->adA gives length 52 << presentation with 4 gens and 7 rels of total length 52 >> gap> Display(p); 1: ba=ab 2: dc=cd 3: aca=cac 4: dbd=bdb 5: bcb=cbc 6: adad=dada 7: aBcADbdac=dBCacbdaB gap> TryConjugatePresentation(p,48); #I there are 4 generators and 7 relators of total length 54 #I there are 4 generators and 7 relators of total length 54 #I there are 4 generators and 7 relators of total length 60 #I there are 4 generators and 7 relators of total length 60 #I there are 4 generators and 7 relators of total length 48 # d->bdB gives length 48 << presentation with 4 gens and 7 rels of total length 48 >> gap> Display(last); 1: ba=ab 2: bcb=cbc 3: cac=aca 4: dbd=bdb 5: cdc=dcd 6: adad=dada 7: dAbcBa=bAcBad
This function requires the package "vkcurve" (see RequirePackage).
FindRoots(p, approx)
p should be an Mvp
in x with rational, gaussian rational or
Complex
rational coefficients or a list of rationals, gaussian
rationals or Complex
rationals which represents the coefficients of a
complex polynomial. The function returns rational approximations to the
roots of p which are better than approx (a positive rational).
Contrary to the functions SeparateRoots
, etc... described in the
previous chapter, this function handles quite well polynomials with
multiple roots. We rely on the algorithms explained in detail in
HSS01.
gap> FindRoots((x-1)^5,1/100000000000); [ 6249999999993/6250000000000+29/12500000000000I, 12499999999993/12500000000000-39/12500000000000I, 12500000000023/12500000000000+11/6250000000000I, 12500000000023/12500000000000+11/6250000000000I, 312499999999/312500000000-3/6250000000000I ] gap> List(last,evalf); [ 1, 1, 1, 1, 1 ] gap> FindRoots(x^3-1,1/10); [ -1/2-108253175473/125000000000I, 1, -1/2+108253175473/125000000000I ] gap> List(last,x->x^3); [ 31249999999964386321187/31250000000000000000000 -1285097940594250451183/1953125000000000000000000000000000I, 1, 31249999999964386321187/31250000000000000000000 +1285097940594250451183/1953125000000000000000000000000000I ] gap> List(last,evalf); [ 1, 1, 1 ]
This function requires the package "vkcurve" (see RequirePackage).
Cut(string s [, int width [, string cutplaces [, string file]]])
This function prints its string argument s on several lines not
exceeding width (if not given width is taken to be equal to 78),
similar to whar GAP does, excepted no continuation line characters are
printed. The user can specify after which characters to cut the string.
The defaut is cutplaces=","
, but some other characters can be used
(e.g. a good choice could be ",+-"
). If a last filename argument is
given, the result is appended to that file instead of written to
standard output. This function is quite useful for dumping some GAP\
values to a file for later re-reading.
gap> Cut("an, example, with, plenty, of, commas\n",10); an, example, with, plenty, of, commas gap>
This function requires the package "vkcurve" (see RequirePackage).
GAP 3.4.4