Home
User`s Guide to Pari-GP
Contents
1. 101 NfeltpowW ssaa ee a A 101 nfeltpowmodpr 101 nfeltreduce 101 nfeltreducemodpr 101 nieltvVal aceso ed a ee ee Ps 101 DEFACLOD edo on alan eben et eect 102 105 nffactormod 102 nfgaloisapply 102 NEPALCOISCON ic dete eos a tk a a coed 102 nihermite sic bd 103 nfhermitemod copie secta 103 DE DIIDEEE u dox m aor a ih eon Ee ea 103 DEDOD god we ee we A e R 103 nfbnfiod s is s soa sa kored a eb 103 NMEIDIG sa e 79 103 107 108 D IDICO s a a rd on 105 nfisidead ces aa a a oes 105 DESC L e cas taa Se Le 105 DE TSISOM lt a o 2 EAA A CK 105 DEKSrmOdpT ss sss sepa ee Ree ie 105 DEMO hd uta wie rd o E 101 nfmodprinit 100 101 105 nfnewprec 0 104 105 nfreducemodpr2 101 D TOOES ac sa ew Bae ARR KAS 2 106 nfrootsofl s s a se art a ee d a aoe ee Bs 106 NESMICO gt aro eR o ds dae 106 DE SM ias a Se ae Be 106 nfsolvemodpr 106 nfsubfields 105 NO 20h e Hae whe OS FR we OE oes 81 DOT soe 6 8 eek ewe eo RO ee be e ea 52 mormalize ad eok o Be e a w 192 216 normalizepol e serres tamaa 192 DOrmL2 soe em a e Re a a Se we a 52 THOU eee AS ete oh Eo es BP a pa a 45 MUCOMP sk Mekal a eg a he Set ae a 69 DUAUPL cu cor ew RE a 69 DUMDI V soe e aoras oe He we we we a 68 number field 22 MUMGAV eras a ee a 68 NUMCY necia A ew 52 NU
2. Lr poldivres s rsrsr nasas eo mee aa 193 poleval se ss bani ee rios 116 polini sopor Gh is Goda es a he ee 92 polgalois sss ae esa a 107 polint marca ae e 117 polinterpolate 117 polisirreducible 117 Pollard Rho 62 66 poll ad y his Sime Goes Gee a 117 pollegendre 117 polmidd 3 naar aaa 5 22 165 polmodrecip ooo gg polrecip 2 6 6 uac i ag i e 117 polred s esse iaa te BS we 4 107 108 polrod ici ek Shah dao E dE eS 108 polredabs s a sac tonas a8 eb e as 108 polredabsO sso i bee ee bee es 108 POLrEdOrd ssas al adas ee ahah RE ae 108 polresultant 118 polresultantO 118 POLST koe do urira deed a BS 47 POLTOOtS 3 as Soe daa Gok eee 118 polrootsmod io eb ae es 118 polrootspadic 118 polsturm ssa sarraa wae we ee 118 polsubcyclo s 2506862 ee 91 118 polsylvestermatrix 119 POlS M ao Ge doe wR Se wes 119 poltchebl ssc eased s Ee eh ws 119 poltschirnhaus 108 POLUM e eae ee en oe ee nek Re Wa 150 167 polva eteina ad ek ws 167 POL ae ke ete ese Gea ae 150 167 POLYLOB secca e aara wee ees 60 polylogO 246d bb ee bee a pss 60 polynomial 5 6 23 165 polzag 2 4624 Bee ee ias 119 polzagier 2 2 nies be ee da mest 119 POlZapreed ro esha ve oes oka eee 119 POStScript 2 4 04 2 posts wee a es 136 powell marcos kee doe bee es org power series
3. 89 Tead ee coe Ga wee d aed Dee eae 20 TOA rr pe eh dae eas 36 146 readline 39 real number 5 21 164 r al oe sop ate a a a 53 realprecision 17 20 FOalZzerO usa aa Be Ae Be es 175 FOCIP secarse Ra GR waa aa 119 recursion depth 32 recursion soa s eoa e e a a T a e a 32 TOCUFSIVE POl s e so a ode he Ge ask doo a 137 recursivenesS 4 redi ag dsc Se ea e 70 Tedreal 70 Tedrealmod 70 reduceddiscsmith 117 TEGUCHION es cine pak ee a 69 70 reference Card 19 TOR ideas FS ew ee a ws 81 reg la e a a a ke eR a 12 regulator s sesso a ta oed eaa 87 removeprimes a2 reorder sed ah Aon BR wh es 29 50 146 resultant2 118 YOGUN a 4 etas Bose a Bk 142 147 rhoreal 00004 70 rhorealnod 4 70 Riemann zeta function 31 62 Wife ag Sask eke tem aes Be 79 rafalgtobasisS e ek hk saca s 108 Tnfbasis seas ra Sie Pe Bie es 108 rnfbasistoalg 109 rnfcharpoly ses ne swr os eee a we 109 rnfcondiuctor om moss 109 rnfdedekidd cs soseo e da a 109 rafdet se s ici a ld ea 109 THEATISC 2 5 iaa a a 109 mitdisce estos aa ata De 109 rnfelementabstorel 109 rnfelementdown 110 rnfelementreltoabs 110 rnfelementup 110 rnfeltabstorel 4 68 rba a wees 109 rnfeltdown
4. 118 scientific format 15 secure saga tire de 0 pki ee ee Ef SO Ti hak eis a Gee o e a 48 S6rconvol ui ira da ke es ites 119 seriesprecision 17 20 serlaplace o ccoo ee bE ee ee 119 Se rreverses ici ee ee 119 DOG hi cet aco eh es Gok a Ge da Mh ek ani hed 48 SOT RDO cc cr ss a 164 166 185 setintersect 129 Setisset imss ee aa eee GE 129 SO E us bebe dee Rs 163 175 185 setlgef psd wie be Ba wie 166 167 185 setlgefint r ej aaa ee 164 185 Stark units e ati apt a ee Es 71 91 setminus 130 Staru ase ein kid Gosh whew i 36 S tprecp mesias 165 185 Stderr kosa a ace Ye ee ak eee Gas 171 Setran 4 sts 20 6 4 Se ead oh 146 Stdout 640 ech A a 171 setsearch o 130 Steinitz class oo 114 setsigne 164 166 185 SLOT fa ce th hoe a E tia 156 186 SCULYP ooa aiu Sb ew eck ee 163 185 STE nicas Aa 34 35 48 SeCtunion c ee 130 Stritime 64 26 ween 2 ee we 13 16 Setvalp pe s 26k Boe wwe als 165 166 185 strictmatch Ir SOVATO a pe i n E ea oR E 166 185 string contett s sao sd sesed onst e 34 SRANKS aiea eona ee ea 62 69 70 string o oo uaaa 5 24 34 S IE y pb e ete rd de 45 SUEBOCGEN 65 54 ae 4 4 5 e an 48 A IA 186 SUrUOGENStr irradia 48 SHITCL aa a a aea g oe ee Bok oe a 183 EDE 1 e a a ras A OER o a 118 SAT IO Liers ee RS ee a 183 StUrMpart ao a a a 118 SHIfCMUL d s cui o e e a 45 A 119
5. 24 167 character 87 89 91 characteristic polynomial 121 charpoly s s sew wwe e Hw 121 charpolyQ gs gar ae band 141 Chebyshev o o 119 CHINESE ias dea wl Bes 63 CHINOS 4 egue a a Ge eh we che Gg 63 ClaSSNO cs sioe nora moade Ee we 69 CIASSNO 4 se ee CR Re Be 69 ElPe e ch be eee ke we ee feo ee 81 GELESP os sag Gh se is a a e 36 AA eS ER 150 155 CMPld eae a a 187 CMPIT e hoe o a we ee t o 187 CMPIS ica a pofon eA a eo eG 187 CUPL a ewe wea Be Se ee eG 187 CMPEL ii al a ee a we 187 CAPES i rs a a 187 CAPS lt i mein wy E a Ease ds 187 CAPSE ea ae a a 187 CAPSS i ic a Glee a A eG 187 COG aida O arte aden ASS ere 190 code words e s si o 50 COI saaa be eee Rae Bee 81 coeff ocena am BOR Ee we 51 151 189 COLOTS wea is sisi 13 column vector 5 23 166 comparison operators 45 compatible 14 completion Loser el Ba ees 39 complex number 9 6 22 105 COMPO a 2 ee dP ae Eee be 50 189 component 50 COMPONENTS eco io be ce ee A we eos 50 COMPOSITION so gon we tio bow Hoe Ok ae ee 69 COMPIAW lt gaos ok Goce ek ee Be A 69 COMIDIESS is isk ts ol aa Bete ae ol BP es os 20 concat Leite oe 121 122 COM Way aie ht ht an oe ee eae os es ee A 5l CONIVEC 4 da s ma wok E a ee Be ee 5l Conrad iu aon la a Be oe 73 Content Losa Phe a aes 64 192 CONL TAC 4 Aad aca ee 65464 54 64 C
6. cocos vada eee eas 59 local saupres mea t ER eai 29 30 33 localreduction ose 6 4 we Ed SG Te MOG ara 8 sy 15 19 20 59 146 logfile cima a Siew a ew eee a 146 logfile en s e ek oe a ie 15 LONG_IS64BIT o 3 8 owe we ee ee 152 IPO scan eh Ae tee ea dk ee E 151 Ls6riesell ssc 66 44 6 8 sorisa 77 M Mica AA 51 151 pael 6 ng ee er ao Fh a 189 makebigbnf 87 Mat 44 oa eee dee das 24 47 121 Matadjoint 0 123 Matalgtobasis 99 Matbasistoalg 2 sse ee 2 220 140 99 MAtbrUvte reccs amp hoe Es wl dae Se y 170 Matcompanion 123 Matdet corr coeur ee 123 matdetint ce rre a 123 Matdiagonal lt lt 0 0 sa 123 mateigen 124 MALbeXtract si wa sisas 131 Mathes cios ee da o dee aad E 75 MAtHeSS esa sae Aw Ga a Re Rw 124 tathilbert ssc Bok wre dd oe Botte ws 124 Mathnt fp gia ae Gk Meee ae ee 120 124 MathnfO caia 6 a 4 eck A ee Woe ea 124 mathnfmod se sa sss ned sa ia 124 Mathnfmodid sa secre s su i sa wa 124 MAtid seen seene thee a 124 MAtiMage ose ra ee paek es 125 matimage0 125 matimagecompl 125 matindexrank 125 MAtCINEErSECE ons ben Ee hoe eek a 125 matinverseimage 125 matisdiagonal 125 Mather bss al ed ae elk Me oe 125 MatkerO 2 4 56 8 2 ee a 125 Mabkerint 2s eee ees awed ee 125 Matkerintes wo ues cow ed ede Goa eo aed 126
7. 4 5 2 Type t_REAL real number this type has a second codeword z 1 which also encodes its sign obtained or set using the same functions as for the integers and a biased binary exponent i e the actual exponent value plus some constant bias actually a power of 2 whose value is given by HIGHEXPOBIT This exponent can be handled using the following macros long expo GEN z returns the true unbiased exponent of z This is defined even when z is equal to zero see Section 1 2 6 3 void setexpo GEN z long e sets the exponent of z to e of course after adding the bias Note the functions long gexpo GEN z which tries to return an exponent for z even if z is not a real number long gsigne GEN z which returns a sign for z even when z is neither real nor integer a rational number for instance The real zero is characterized by having its sign equal to 0 However usually the first mantissa word z 2 is defined and equal to 0 This fact must never be used to recognize a real 0 If z is not equal to 0 the first mantissa word z 2 is normalized i e its most significant bit is 1 The mantissa is z 2 z 3 z 1g z 1 in base 2 BITS_IN_LONG Here z 2 is the most significant 164 longword and the mantissa takes values between 1 included and 2 excluded Thus assume that sizeof long is 32 and the length is 4 the real number 3 5 is represented as z 0 encoding type t_REAL lg 4 z 1 encoding sign 1 expo 1
8. The library syntax is corediscO n flag Also available are coredisc n coredisc n 0 and coredisc2 n coredisc n 1 64 3 4 14 dirdiv x y x and y being vectors of perhaps different lengths but with y 1 4 0 considered as Dirichlet series computes the quotient of x by y again as a vector The library syntax is dirdiv z y 3 4 15 direuler p a b expr c computes the Dirichlet series to b terms of the Euler product of expression expr as p ranges through the primes from a to b expr must be a polynomial or rational function in another variable than p say X and expr X is understood as the Dirichlet series or more precisely the local factor expr p If c is present output only the first c coefficients in the series The library syntax is direuler entree ep GEN a GEN b char expr see the section on sums and products for explanations of this 3 4 16 dirmul x y x and y being vectors of perhaps different lengths considered as Dirichlet series computes the product of x by y again as a vector The library syntax is dirmul z y 3 4 17 divisors x creates a row vector whose components are the positive divisors of the integer x in increasing order The factorization of x as output by factor can be used instead The library syntax is divisors z 3 4 18 eulerphi z Euler s totient function of x in other words Z xZ x must be of type integer The library syntax is phi z 3 4
9. r2 matrices T2 where T2 is an n x n matrix equal to the real part of the product MC M which is a real positive definite matrix vm 4 is the n x n matrix T whose entries are the relative traces of wiw expressed as polmods in nf where the w are the elements of the relative integral basis Note that the j th embedding of T is equal to MC My and in particular will be equal to T2 if r2 0 Note also that the relative ideal discriminant of L K is equal to det T times the square of the product of the ideals in the relative pseudo basis in rnf 7 2 The last 3 entries vm 5 vm 6 and vm 7 are linked to the different as in nfinit but have not yet been implemented rnf 6 is a row vector with r r2 entries the j th entry being the row vector with r1 r2 j entries of the roots of the j th embedding of the relative polynomial pol rnf 7 is a two component row vector where the first component is the relative integral pseudo basis expressed as polynomials in the variable of pol with polmod coefficients in nf and the second component is the ideal list of the pseudobasis in HNF rnf 8 is the inverse matrix of the integral basis matrix with coefficients polmods in nf rnf 9 may be the multiplication table of the integral basis but is not implemented at present rnf 10 is nf 112 rnf 11 is a vector vabs with 5 entries describing the absolute extension L Q vabs 1 is an absolute equation vabs 2 expresses
10. 0 a new stack of size 16 1 16 bytes will be allocated all the PARI data on the old stack will be moved to the new one and the old stack will be discarded If x 0 the size of the new stack will be twice the size of the old one Although it is a function this must be the last instruction in any GP sequence The technical reason is that this routine usually moves the stack so objects from the current sequence might not be correct anymore Hence to prevent such problems this routine terminates by a longjmp just as an error would and not by a return The library syntax is allocatemoremem z where x is an unsigned long and the return type is void GP uses a variant which ends by a longjmp 143 UNIX 3 11 2 4 default key val flag sets the default corresponding to keyword key to value val val is a string which of course accepts numeric arguments without adverse effects due to the expansion mechanism See Section 2 1 for a list of available defaults and Section 2 2 for some shortcut alternatives Typing default or Md yields the complete default list as well as their current values If val is omitted prints the current value of default key If flag is set returns the result instead of printing it 3 11 2 5 error str outputs its argument list each of them interpreted as a string then interrupts the running GP program returning to the input prompt Example error n n is not squarefree
11. 3 3 29 hyperu a b x U confluent hypergeometric function with parameters a and b The pa rameters a and b can be complex but the present implementation requires x to be positive The library syntax is hyperu a b x prec 3 3 30 incgam s x y incomplete gamma function x must be positive and s real The result returned is dE eTtts 1 dt When y is given assume of course without checking that y T s For small x this will tremendously speed up the computation The library syntax is incgam s x prec and incgam4 s x y prec respectively There exist also the functions incgam1 and incgam2 which are used for internal purposes 3 3 31 incgamc s x complementary incomplete gamma function The arguments s and x must be positive The result returned is de etts 1 dt when zx is not too large The library syntax is incgam3 s x prec 59 3 3 32 log z flag 0 principal branch of the natural logarithm of x i e such that Im In x 7 1 The result is complex with imaginary part equal to 7 if x Rand z lt 0 p adic arguments are also accepted for x with the convention that In p 0 Hence in particular exp In x x will not in general be equal to 1 but to a p 1 th root of unity or 1 if p 2 times a power of p If flag is equal to 1 use an agm formula suggested by Mestre when zx is real otherwise identical to log The library syntax is glog x prec or glogagm z prec 3 3 33
12. int subll int x int y subtracts the ulongs x and y returns the lower BIL bits and put the carry borrow bit into overflow int subllx int x int y subtracts overflow from the difference of the ulongs x and y returns the lower BIL bits and puts the carry borrow bit into overflow int shiftl ulong x ulong y shifts the ulong x left by y bits returns the lower BIL bits and stores the high order BIL bits into hiremainder We must have 1 lt y lt BIL In particular y must be non zero the caller is responsible for testing this int shiftlr ulong x ulong y shifts the ulong x lt lt BIL right by y bits returns the higher BIL bits and stores the low order BIL bits into hiremainder We must have 1 lt y lt BIL In particular y must be non zero int bfffo ulong x returns the number of leading zero bits in the ulong x i e the number of bit positions by which it would have to be shifted left until its leftmost bit first becomes equal to 1 which can be between 0 and BIL 1 for nonzero x When x is 0 BIL is returned 183 int mulll ulong x ulong y multiplies the ulong x by the ulong y returns the lower BIL bits and stores the high order BIL bits into hiremainder int addmul ulong x ulong y adds hiremainder to the product of the ulongs x and y returns the lower BIL bits and stores the high order BIL bits into hiremainder int divll ulong x ulong y returns the Euclidean quotient of hiremainder lt lt BIL x and
13. local y y charpoly A y gcd y y The value of flag is only significant for matrices If flag 0 the method used is essentially the same as for computing the adjoint matrix i e computing the traces of the powers of A If flag 1 uses Lagrange interpolation which is almost always slower If flag 2 uses the Hessenberg form This is faster than the default when the coefficients are integermod a prime or real numbers but is usually slower in other base rings The library syntax is charpoly0 A v flag where v is the variable number Also available are the functions caract A v flag 1 carhess A v flag 2 and caradj A v pt where in this last case pt is a GEN which if not equal to NULL will receive the address of the adjoint matrix of A see matadjoint so both can be obtained at once 121 3 8 3 concat z y concatenation of x and y If x or y is not a vector or matrix it is considered as a one dimensional vector All types are allowed for x and y but the sizes must be compatible Note that matrices are concatenated horizontally i e the number of rows stays the same Using transpositions it is easy to concatenate them vertically To concatenate vectors sideways i e to obtain a two row or two column matrix first transform the vector into a one row or one column matrix using the function Mat Concatenating a row vector to a matrix having the same number of columns will add the row to the m
14. might work but should be frowned upon We can t predict whether avma is going to be evaluated after or before the call to anything it depends on the compiler If we are out of luck it will be after the call so the result will belong to the garbage zone and the gerepile statement becomes equivalent to avma ltop Thus we would return a pointer to random garbage e A simple variant is GEN gerepileupto long ltop GEN q 158 which cleans the stack between 1top and the connected object q and returns q updated For this to work q must have been created before all its components otherwise they would belong to the garbage zone Documented PARI functions guarantee this If you stumble upon one that does not consider it a bug worth reporting e To cope with complicated cases where many objects have to be preserved you can use void gerepilemany long ltop GEN gptr long n which cleans up the most recent part of the stack between 1top and avma All the GENs pointed at by the elements of the array gptr of length n are updated A copy is done just before the cleaning to preserve them so they don t need to be connected before the call This is the most robust of the gerepile functions the less prone to user error but also the slowest e More efficient but trickier to use is void gerepilemanysp long ltop long lbot GEN gptr long n which cleans the stack between lbot and ltop and updates the GENs pointed at by the eleme
15. wp function and its derivative If z is in the lattice defining E over C the result is the point at infinity 0 The library syntax is pointell z prec 3 6 Functions related to general number fields In this section can be found functions which are used almost exclusively for working in general number fields Other less specific functions can be found in the next section on polynomials Functions related to quadratic number fields can be found in the section Section 3 4 Arithmetic functions We shall use the following conventions e nf denotes a number field i e a 9 component vector in the format output by nfinit This contains the basic arithmetic data associated to the number field signature maximal order discriminant etc e bnf denotes a big number field i e a 10 component vector in the format output by bnfinit This contains nf and the deeper invariants of the field units class groups as well as a lot of technical data necessary for some complex fonctions like bnfisprincipal e bnr denotes a big ray number field i e some data structure output by bnrinit even more complicated than bnf corresponding to the ray class group structure of the field for some modulus e rnf denotes a relative number field see below e ideal can mean any of the following a Z basis in Hermite normal form HNF or not In this case x is a square matrix an idele i e a 2 component vector the first being an ideal
16. 1 which may occur in the expression as 1 X 2 2 The library syntax is sumalt entree ep GEN a char expr long flag long prec 3 9 9 sumdiv n X expr sum of expression expr over the positive divisors of n Arithmetic functions like sigma use the multiplicativity of the underlying expression to speed up the computation In the present version 2 0 19 there is no way to indicate that expr is multi plicative in n hence specialized functions should be prefered whenever possible The library syntax is divsum entree ep GEN num char expr 3 9 10 suminf X a expr infinite sum of expression expr the formal parameter X starting at a The evaluation stops when the relative error of the expression is less than the default precision The expressions must always evaluate to a complex number The library syntax is suminf entree ep GEN a char expr long prec 134 3 9 11 sumpos X a expr flag 0 numerical summation of the series expr which must be a series of terms having the same sign the formal variable X starting at a The algorithm used is Van Wijngaarden s trick for converting such a series into an alternating one and is quite slow Beware that the stopping criterion is that the term gets small enough hence terms which are equal to 0 will create problems and should be removed If flag 1 use slightly different polynomials Sometimes faster The library syntax is sumpos entree ep GEN a char expr lo
17. 5 6 23 166 POWETIOS 245 sue Saws PR wees A 45 56 PONIAN 2 be bead eee Ed ate a 69 PESCA skya dee Ge ee ee ak eee 55 PIECISION ee r a e e a we we 55 precision csse sesde wake es 52 191 precision s em roeg a a we i 53 E ioa osos sinaia E 165 184 precprime o oo 68 preferences file 11 12 36 180 prettymatriz format o o 16 prettyprint format o o o o 16 prettyprinter 16 PEINS csi A 68 PrimefoOrMm fk eas e oa ae 70 primelimit os sss sea ese pa tan 16 prines sarsie ew Oa ee ewe ee 68 principal ideal 98 principalideal 97 principalidele 99 PLING uri Pew ad 34 36 146 PINTI 4 2S oa ete A teehee baa e 146 PINGI week AH we eek ee a ck a Iyi PELDUP pru e a oe ey ee E Bs 146 PERIDEPDL 02 toa a Seine ad ek 146 Printte isa a a 146 PEOI Dra a id a 25 Prod iii ii a a 133 prodeuler 133 prodinf ges miea Che ee Ee 133 prodintk es Bet ees Ge 133 product 44 224 44 Pee en eh es 44 PLOT diri ca we ete x 133 programming 28 141 PLOMPU aaa ih sk ee o ae es ee 16 Podran a pa olen od BD Ge 140 pseudo basis o o 80 pseudo matriz 2 2 ee ee es 80 psfile Laserna redes Bw 17 136 Pi hee eee Se bk ae ee 60 PSPLOtM p g os a ot o Be a 140 psplothraw 141 pvalUation sere es ta s ee wh a 191 Python a e a pa e Rea eae 36 Q QED a pie he a Goeth A at Se 62 QEDO 00600 06
18. GEN opi GEN x creates the result of op applied to the integer x GEN opr GEN x creates the result of op applied to the real x GEN mpopz GEN x GEN z assigns the result of applying op to the integer or real x into the integer or real z 186 Remark it has not been considered useful to include the functions void opsz long GEN void opiz GEN GEN and void oprz GEN GEN The above prototype schemes apply to the following operators op neg negation x The result is of the same type as x op abs absolute value x The result is of the same type as x In addition there exist the following special unary functions with assignment void mpinvz GEN x GEN z assigns the inverse of the integer or real x into the real z The inverse is computed as a quotient of real numbers not as a Euclidean division void mpinvsr long s GEN z assigns the inverse of the long s into the real z void mpinvir GEN x GEN z assigns the inverse of the integer x into the real z void mpinvrr GEN x GEN z assigns the inverse of the real x into the real z 5 2 6 Comparison operators long mpcmp GEN x GEN y compares the integer or real x to the integer or real y The result is the sign of x y long cmpss long s long t returns the sign of s t long cmpsi long s GEN x compares the long s to the integer x long cmpsr long s GEN x compares the long s to the real x long cmpis GEN x long s compares the integer x to the long s long
19. If you really want a reducible fraction under GP you must use the type function see Sec tion 3 11 2 26 by typing type x FRACN Be warned however that this function must be used with extreme care 2 3 5 Complex numbers type t_COMPLEX to enter x iy type x I y not x ix y The letter I stands for y 1 Recall from Chapter 1 that x and y can be of type t_INT t_REAL t_INTMOD t_FRAC t_FRACN or t_PADIC 2 3 6 p adic numbers type t_PADIC to enter a p adic number simply write a rational or integer expression and add to it O p k where p and k are integers This last expression indicates three things to GP first that it is dealing with a t_PADIC type the fact that p is an integer and not a polynomial which would be used to enter a series see Section 2 3 10 secondly the prime p note that it is not checked whether p is indeed prime you can work on 10 adics if you want but beware of disasters as soon as you do something non trivial like taking a square root and finally the number of significant p adic digits k Note that 0 25 is not the same as 0 572 you probably want the latter For example you can type in the 7 adic number 2x7 1 3 4 7 24772 0 773 exactly as shown or equivalently as 905 7 0 773 2 3 7 Quadratic numbers type t_QUAD first you must define the default quadratic order or field in which you want to work This is done using the quadgen function in the following way Write somethi
20. Note that due to the automatic concatenation of strings you could in fact use only one argument just by suppressing the commas 3 11 2 6 extern str the string str is the name of an external command i e one you would type from your UNIX shell prompt This command is immediately run and its input fed into GP just as if read from a file 3 11 2 7 getheap returns a two component row vector giving the number of objects on the heap and the amount of memory they occupy in long words Useful mainly for debugging purposes The library syntax is getheap 3 11 2 8 getrand returns the current value of the random number seed Useful mainly for debugging purposes The library syntax is getrand returns a C long 3 11 2 9 getstack returns the current value of top avma i e the number of bytes used up to now on the stack Should be equal to 0 in between commands Useful mainly for debugging purposes The library syntax is getstack returns a C long 3 11 2 10 gettime returns the time in milliseconds elapsed since either the last call to get time or to the beginning of the containing GP instruction if inside GP whichever came last The library syntax is gettime returns a C long 3 11 2 11 global list of variables declares the corresponding variables to be global From now on you will be forbidden to use them as formal parameters for function definitions or as loop indexes This is especially useful when
21. The function used to manipulate these values is called default which is described in Sec tion 3 11 2 4 The basic syntax is default def value which sets the default def to value In interactive use most of these can be abbreviated using historic GP metacommands mostly starting with which we shall describe in the next section 12 UNIX UNIX Here we will only describe the available defaults and how they are used Just be aware that typing default by itself will list all of them as well as their current values see Xd Just after the default name we give between parentheses the initial value when GP starts assuming you did not tamper with it using command line switches or a gprc Note the suffixes k or M can be appended to a value which is a numeric argument with the effect of multiplying it by 10 or 10 respectively Case is not taken into account there so for instance 30k and 30K both stand for 30000 This is mostly useful to modify or set the defaults primelimit or stacksize which typically involve a lot of trailing zeroes somewhat technical Note As we will see in Section 2 6 5 the second argument to default will be subject to string context expansion which means you can use run time values In other words something like a 3 default logfile some filename a log will work and log the output in some filename3 log Some defaults will be expanded further when the values are used after the above ex
22. The library syntax is quadray D f flag 71 3 4 57 quadregulator regulator of the quadratic field of positive discriminant x Returns an error if x is not a discriminant fundamental or not or if x is a square See also quadclassunit if x is large The library syntax is regula z prec 3 4 58 quadunit x fundamental unit of the real quadratic field Q x where zx is the positive discriminant of the field If x is not a fundamental discriminant this probably gives the fundamental unit of the corresponding order x must be of type integer and the result is a quadratic number The library syntax is fundunit z 3 4 59 removeprimes x removes the primes listed in x from the prime number table In particular removeprimes addprimes empties the extra prime table x can also be a single integer List the current extra primes if x is omitted The library syntax is removeprimes z 3 4 60 sigma z k 1 sum of the k t powers of the positive divisors of x 2 must be of type integer The library syntax is sumdiv x sigma x or gsumdivk z k sigma z k where k is a C long integer 3 4 61 sqrtint x integer square root of x which must be of PARI type integer The result is non negative and rounded towards zero A negative x is allowed and the result in that case is I sqrtint x The library syntax is racine z 3 4 62 znlog x g g must be a primitive root mod a prime p and the result is the discret
23. a vector giving the structure of the class group as a product of cyclic groups 70 e v 3 a vector giving generators of those cyclic groups as binary quadratic forms e v 4 omitted if D lt 0 the regulator computed to an accuracy which is the maximum of an internal accuracy determined by the program and the current default note that once the regulator is known to a small accuracy it is trivial to compute it to very high accuracy see the tutorial e v 5 a measure of the correctness of the result If it is close to 1 the result is correct under GRH If it is close to a larger integer this shows that the class number is off by a factor equal to this integer and you must start again with a larger value for c or a different random seed In this case a warning message is printed The library syntax is quadclassunit0 D flag tech Also available are buchimag D c1 cz and buchreal D flag ci c2 3 4 52 quaddisc x discriminant of the quadratic field Q x where x Q The library syntax is quaddisc z 3 4 53 quadhilbert D flag 0 relative equation defining the Hilbert class field of the quadratic field of discriminant D If flag is non zero and D lt 0 outputs form root form to be used for constructing subfields Uses complex multiplication in the imaginary case and Stark units in the real case The library syntax is quadhilbert D flag prec 3 4 54 quadgen x creates the quadratic number w
24. aag is Pa deed a Sirs Ges 192 gmax ll o Ae wks oR a sE 192 MAM do cite gee eee a cae ee 46 emings 2 isos erne ae 192 gminsg z 192 Eminiz e e eii e GS 182 o A 45 gmodeslZl ieee dade peas oS 194 gmodsel2l avn eke Pook E 194 gmodulcp 0 4 47 190 EMOJULES i aone wisg eA DS He eae o 190 gmodulo Vias wee 47 190 SMOGUISS soa se o o dd aa 190 amsdtal o da aa ds di Ce eS 194 fille o s poa a Ree do 44 A A a Heh ae E it 45 175 gmul2nlzl sos sees aa ee wee wa 193 emuleslz e nak eee ek 1 ee Be 193 Smee 2 s m wage eo ss ete es 193 gmllel soria 193 A 6 sb are vin hd So ee Hoa Bk es 45 A k eon E a nd E ida 44 COT wie ta ad PA Powe eo ee 29 a 2 sisa poa eee a Ye oe eee bs 52 a 2 y oo whe Ge eo we a ae A 52 175 EDOT end a a wk a eee a aS 45 BOT av ba eee eb ae ee ka e 45 A onto Be u ue aoe de oe 11 Sphel A 19 BPI se bbe be ee oe i ds 203 epolval rs arica ay 6g ote dacs 2 AN 54 EDO ora oe RE ee aS 45 56 194 BPOWES aww Pa oie he ue ee eS 194 EDIG as Weve Gok She wl Be hb eh cee ok He he 36 EDG e s eda a ee ee 12 GPR c s ece a Bua o eg a Ea a ew i 37 q ga gia a e ek we ee Gt 53 EPS e oa e a Bese a RB A 60 pral 2 the yuk Pee doe be be eos 53 O as et ge 165 166 gred z so a ce ee dada ee ba dana 192 groffe os bie bE eRe ee es 190 PLCS ho gies a artis Mine oe So E 194 GRH ssi ke oo 70 71 82 83 85 113 120 BINdtOl fe gk er Ree es 53 192 STOUNG 4 ubica p el ce 53 192 escal
25. by St fane Fermigier fermigie math jussieu fr Finaly Michael Stoll Michael_Stoll math uni bonn de has integrated PARI into CLISP which is a Common Lisp implementation by Bruno Haible Marcus Daniels and others These provide interfaces to GP functions for use in perl python or Lisp programs To our knowledge only the python and perl interfaces have been upgraded to version 2 0 of PARI the CLISP one being still based on version 1 39 02 see http nswt tuwien ac at 8000 htdocs internet unix perl math pari html see http www math jussieu fr fermigie PariPython readme html 36 2 8 The preferences file When GP is started it looks for a customization file or gprc in the following places in this order only the first one found will be read e On the Macintosh only GP looks in the directory which contains the GP executable itself for a file called gprc No other places are examined e If the operating system supports environment variables essentially anything but MacOS GP checks whether the environment variable GPRC is set Under DOS you can set it in AUTOEXEC BAT On Unix this can be done with something like GPRC my dir anyname export GPRC in sh syntax for instance in your profile setenv GPRC my dir anyname in csh syntax in your login or cshrc file If so the file named by GPRC is the gprc e If GPRC is not set and if the environment variable HOME is defined GP then tries HOME gprc on a U
26. series rational function vector or matrix the lift is done for each coefficient Forbidden types for x are reals and p adics The library syntax is liftO x v where v is a long and an omitted v is coded as 1 Also available is lift x 1i t0 x 1 3 2 29 norm x algebraic norm of zx i e the product of x with its conjugate no square roots are taken or conjugates for polmods For vectors and matrices the norm is taken componentwise and hence is not the L norm see norm12 Note that the norm of an element of R is its square so as to be compatible with the complex norm The library syntax is gnorm z 3 2 30 norml2 2 square of the L norm of x x must be a row or column vector The library syntax is gnorml2 z 3 2 31 numerator x numerator of x When z is a rational number or function the meaning is clear When zx is an integer or a polynomial the result is x itself When zx is a vector or a matrix then numerator x is defined to be denominator x x All other types are forbidden The library syntax is numer z 3 2 32 numtoperm n k generates the k th permutation as a row vector of length n of the numbers 1 to n The number k is taken modulo n i e inverse function of permtonun The library syntax is permute n k where n is a long 3 2 33 padicprec x p absolute p adic precision of the object x This is the minimum precision of the components of x The result is VERYBIGINT 2 1 for 32 bit machin
27. time 3 335 ms 7 prodti 1 100 1 X i 1 0 X 101 time 43 ms 42 1 X X72 X75 X77 X 12 X715 X722 X 26 X 35 X740 X 51 X 57 X 70 X 77 X792 X7100 0 X 101 The library syntax is produit entree ep GEN a GEN b char expr GEN x 3 9 4 prodeuler X a b expr product of expression expr initialized at 1 i e to a real number equal to 1 to the current realprecision the formal parameter X ranging over the prime numbers between a and b The library syntax is prodeuler entree ep GEN a GEN b char expr long prec 3 9 5 prodinf X a expr flag 0 infinite product of expression expr the formal parameter X starting at a The evaluation stops when the relative error of the expression minus 1 is less than the default precision The expressions must always evaluate to an element of C If flag 1 do the product of the 1 expr instead The library syntax is prodinf entree ep GEN a char expr long prec flag 0 or prodinf1 with the same arguments flag 1 3 9 6 solve X a b expr find a real root of expression expr between a and b under the condition expr X a x expr X b lt 0 This routine uses Brent s method and can fail miserably if expr is not defined in the whole of a b try solve x 1 2 tan x The library syntax is zbrent entree ep GEN a GEN b char expr long prec 133 3 9 7 sum X a b expr x 0 sum of expression expr initialize
28. 110 rnfeltreltoabs 110 THPeLtup 2k ss eek ee be eo ees 110 TNPFCQUATTON ss ss ee kk 106 110 rnfequationO ea ee cs eb ee a as 110 rnfhermitebasiS 110 rnfhnfbasis 110 rnfidealabstorel 110 111 rnfidealdown 111 rnfidealhermite 111 219 rnfidealhnf s e r 4 404 4 6 we Ba es 111 rnfidealmul 111 rnfidealnormabs 111 rnfidealnormrel 111 rnfidealreltoabs 111 rnfidealtwoelement 111 rnfidealtwoelt 111 rnfidealup 111 112 PONTING unos ss a bk 112 Tnftinitalg 2 25 hee bee bee es 113 mnfisfiree sos eurae ada ee 113 THFUSHOTM 2 40 Pa be Gs E o 113 rnfkummer cornisa a 113 rnflllgram 113 114 TH NOTMSLOUP sorc oa sen e 114 rnfpolr d eii poe kh eRe ae Rw A 114 rnfpolredabs ssd sra ei 2 4 5 114 rnfpseudobasis 114 TfsteinitZ see eek AY a 114 FOOtMOd 5 2 eee Sere a ss Se 118 TOOtMOd ewok od a ec ad Boe Sg 118 Tootpadic inma Gee eee GS 118 FOOLS year eS ey Gee a as 73 81 118 TOOESO L ocaso 106 FOOUSOUG amp gown se wows Se e 118 round 2 s koed o oma e ea i e oA A 99 TOUNG 4 desa ba due ED 99 100 116 FOUNd 2 6 644 4 6206 eck PKR ee 6 53 row vector 5 23 166 EtOdDL yerse Bee ee oe bel a 8 156 190 S scalar product sea evia daoi eag 44 scalar type sposa escea ee ee 6 Sch nhage o o
29. 142 Hermite normal form A 2 4 Ae ee hw A oP a ee wee 124 hexadecimal tree 171 A eee hs ae ak eae Me aie ede he Ee 67 Hilbert class field 71 Hilbert matrix 124 Hilbert symbol 67 103 Hilbert pe b e boa ew aca wR ee ee Se 67 HistsiZe e gog wd Soe Bek wd hee OE 15 Haf ic a eR Ge ae a gs 124 Hnfall oras esas ea bee Sos 124 hnfMoOd ee 4 ee He Be ew a a e 124 Hnfmodid s yass ena a ds 124 hotoyal s dui ala Ene EKRE 116 Hurwitz class number 69 hyper io a oe eRe ds ws 59 I Ty ee ea et ee ee 22 21 00 ideal list o o oo 80 AAC macs Ps a BG as 79 idealadd 94 idealaddtoone 94 idealaddtooneO 94 1dealappE s s ura ceee eH Sk ea a 94 Adealapprorc ses eae ke os bok Ge EG gs 95 idealchinese 95 idealcoprime 95 idealdiY seccatid ds wd 95 WdealdivOv e ccoo yk ee a ee 95 idealdivexact 95 idealfactor 95 idealhermite 95 idealhnf escisiones 95 idealhnfO 95 idealintersect 96 125 Veal ANY ao Fe aces SS Ged we eo ee 96 104 ideallist e was Bila a assess 96 ideallistO 96 ideallistarch gt oaas 00 8 foe e 96 ideallistarchO 96 ideallllred 98 ideallog 6 ee Gee eee ss 96 idealmin emos secr moe OR we 96 idealmul 2 0 0 048 97 idealmu
30. 143 allocatemem 16 143 allocatemoremem 143 174 alternating series 134 and ae dd Koga STR ewe eA 45 and we et wae ee ee ee ee 48 anell soe s konaa aow AE ee Re a 74 apell 2 pk bie dd a 74 apelli cc a ad a a 74 206 APPIN kG e a eo sia e a eg 116 appren ok ee Ra ee ek ede g 116 aea i auros ia momik Be ee a we ee 73 OE sku Mw eck ee ae ee ee wo 57 Artin L function 91 Artin root number 91 As og A ORS ERR ES Dl ASIA o nee ea sta a or assignment s s s sea e e k e E a 154 ASEMAL Josce pinoia OR Re ee Se we 123 Stam tha A eee oo ee we a ae E 57 atanh os A R a Ged or automatic simplification 17 available commands 19 AMM Ss eek Hed a Seed 155 156 B backslash character 27 Dase sosea moa a A 100 Dase t aoii a eck eS Oe ee a ew 100 basist alg be ee ee Re es 100 Berlekamp 000 67 Bern 4 5 a ak amp A ae PA Ba ee 203 bernfrac e ea ew ee ae a ee a Or Bernoulli numbers Bf 62 Derntedll ocio coran 57 Dorny ares Ewe ee ea we dk ee 57 58 besseljh 2444 2 ave 44 4 eee ees 58 Bessel ks 4 hace ae ath ey ee we et G 58 bestappr sss sa m Dadaan a 63 DeZOUb abs 63 beZOULres deis e He 63 D TLO soeg aot sad ate A A 183 BIGDEFAULTPREC 152 BIGINT xe diac aaa a Se 166 167 bigomega s 2 bese cspero itka 63 bidhel isis doe Bo Bre GOR RS de 74 Dinaire peak Gk Pe Had Hee ale oa 48 binar
31. Equivalent to but much faster than x matdiagonal d The library syntax is matmuldiagonal z d 3 8 31 matmultodiagonal z y product of the matrices x and y knowing that the result is a diagonal matrix Much faster than x x y in that case The library syntax is matmultodiagonal z y 3 8 32 matpascal x q creates as a matrix the lower triangular Pascal triangle of order x 1 ie with binomial coefficients up to x If q is given compute the q Pascal triangle i e using g binomial coefficients The library syntax is matqpascal x q where x is a long and q NULL is used to omit q Also available is matpascalx 3 8 33 matrank zx rank of the matrix z The library syntax is rank x and the result is a long 3 8 34 matrixqz x p x being an m x n matrix with m gt n with rational or integer entries this function has varying behaviour depending on the sign of p If p gt 0 x is assumed to be of maximal rank This function returns a matrix having only integral entries having the same image as x such that the GCD of all its n x n subdeterminants is equal to 1 when p is equal to 0 or not divisible by p otherwise Here p must be a prime number when it is non zero However if the function is used when p has no small prime factors it will either work or give the message impossible inverse modulo and a non trivial divisor of p If p 1 this function returns a matrix whose columns form a basis of the lattice equal t
32. It is supposed to be used in conjunction with bnfmake The output is a 12 component vector v as follows Let bnf be the result of a full bnfinit complete with units Then v 1 is the polynomial P v 2 is the number of real embeddings r v 3 is the field discriminant v 4 is the integral basis v 5 is the list of roots as in the sixth component of nfinit v 6 is the matrix MD of nfinit giving a Z basis of the different v 7 is the matrix W bnf 1 v 8 is the matrix matalpha bnf 2 v 9 is the prime ideal factor base bnf 5 coded in a compact way and ordered according to the permutation bnf 6 v 10 is the 2 component vector giving the number of roots of unity and a generator expressed on the integral basis v 11 is the list of fundamental units expressed on the integral basis v 12 is a vector containing the algebraic numbers alpha corresponding to the columns of the matrix matalpha expressed on the integral basis Note that all the components are exact integral or rational except for the roots in v 5 In practice this is the only component which a user is allowed to modify by recomputing the roots to a higher accuracy if desired Note also that the member functions will not work on sbnf you have to use bnfmake explicitly first The library syntax is bnfinitO P flag tech prec 3 6 6 bnfisintnorm bnf x computes a complete system of solutions modulo units of positive norm of the absolute norm equation Norm a x
33. The library syntax is sturmpart pol a b Use NULL to omit an argument sturm pol is equivalent to sturmpart pol NULL NULL The result is a long 3 7 22 polsubcyclo n d Lv x gives a polynomial in variable v defining the sub Abelian extension of degree d of the cyclotomic field Q C where d n Z nZ has to be cyclic i e n 2 4 p or 2p for an odd prime p The function galoissubcyclo covers the general case The library syntax is subcyclo n d v where v is a variable number 3 7 23 polsylvestermatrix z y forms the Sylvester matrix corresponding to the two polynomi als x and y where the coefficients of the polynomials are put in the columns of the matrix which is the natural direction for solving equations afterwards The use of this matrix can be essential when dealing with polynomials with inexact entries since polynomial Euclidean division doesn t make much sense in this case The library syntax is sylvestermatrix z y 3 7 24 polsym x n creates the vector of the symmetric powers of the roots of the polynomial x up to power n using Newton s formula The library syntax is polsym z 3 7 25 poltchebi n v x creates the nt Chebyshev polynomial in variable v The library syntax is tchebi n v where n and v are long integers v is a variable number 3 7 26 polzagier n m creates Zagier s polynomial P used in the functions sumalt and sumpos with flag 1 The exact defini
34. a ies oe ds oh eee ae as ee 36 147 TYPCCESt s cs s ee ee ae kee a 150 ID A is winch dl oe da 4 LCD aa 6 e Hoe Me 3 te 5 23 166 t COMPLEX sierva 5 22 165 t FRAC 2 ge bc ew ee 5 21 165 GOPRACN ce aa orn ae 5 21 165 GLUINT coros aa 5 21 163 EINTMOD tetitas 5 21 165 GOLIST os os 6k a oe 5 24 167 EMAT cursos saton 5 24 166 BELPADIC 5 6 4 kgr ee i 5 22 165 POL o hah a es ee es he we 5 23 165 t_POLMOD 304 5 en eb ee RE o 5 22 165 COFRE bch s esac Foe ae wl fe 5 23 166 OPR oo Se a Bek HE a 5 23 166 tlQUAD 244 eee eS sas e 5 22 165 GOREAL fs be ee we Re 5 21 164 TLRERAG ci ok ke ww R a 5 23 166 221 E RERACN os te a eR Ge we ed 5 23 166 ESER sacs Caw Sao wh A 5 23 166 BOO TR ns Bae a Oe ea D 24 167 TEVEC 2 6 as a ee ie BR 5 23 166 U WONG iio deb Ree ee we Se 183 UH bw wee Se eo Bw oe Be awl ae eo 151 universal object 203 UNTIL ica a a ee Ow 142 user defined functions 30 V Valla ma E rd E E 186 Valp e e sace a ae e we ad n 165 166 184 VALS ok bs ee ee Spee ss b e t 186 valuation 04 54 Varenbries g a vce a Bae Be aw 167 variable special is 062 sa ww 27 variable temporary 168 variable user 167 168 variable number 166 167 178 variable 22 20 25 28 150 variable rta a we wR oe a wo 54 Vaca A dl ee a eee 166 184 NOG 0 3 65 ah EA aw GS ee 23 48 vecbezout 2 004 63 ve
35. an expression such as x 1 1 3 4 1 would be perfectly valid assuming of course that all matrices along the way have the correct dimensions Note We ll see in Section 2 6 3 that it is possible to restrict the use of a given variable by declaring it to be global or local This can be useful to enforce clean programming style but is in no way mandatory Technical Note Variables are numbered in the order that they appear since the beginning of the session and the main variable of an expression is always the lowest numbered variable Hence if you are working with expressions involving several variables and want to have them ordered in a specific manner in the internal representation the simplest is just to write down the variables one after the other under GP before starting any real computations If you already have started working and want to change the names of the variables in an object use the function changevar If you only want to have them ordered when the result is printed you can also use the function reorder but this won t change anything to the internal representation Very technical Note Each variable has a stack of values implemented as a linked list When a new scope is entered during a function call which uses it as a parameter or if the variable is used as a loop index see Section 2 6 3 and Section 3 11 the value of the actual parameter is pushed on the stack If the parameter is not supplied a special 0 value c
36. de 101 element_mulmodpr 101 element_pow 08 101 element_powmodpr 101 element_reduce 101 element_val 101 CL da ge ek ee ese HE eee ee 33 ClPAdG cid Bik Ae we dd a ee T3 CLITA ce aiir o on e y a So 73 ellan pierda a woi 74 OLLA sore ne a e ee A 74 ellapoO pei eo ee we ai 74 CLIDEL oy ge bok oa ln Be a ae OK Be a 74 ellchangecurve 74 ellchangepoint 74 elleisnum 74 elleta sb foe desd BB Eee 74 75 ellglopal ed yos ace a a Goa a o a 75 ellhgight s ici i padi iw ee de as 75 ellheightd imc oe e ee SS 75 ellheightmatrix 75 eL iaa Ak T3 19 eklinit gt geek 2 Bow side 76 ellisoncurve 76 BUG a a s Mk dns hk ood Bs ee A 76 ellllocalred 2 2 65 in Sd Re ee eee 76 elllseries 0 0 Ul eLLOFdeE eek ge aoe g ia ee ee a ies ellordinate kek ew ee re Ti 209 elIp inttoZ p ecr ee aos we es te CIIPOW eno aa GaP ed rag ellrootno Ths TS ellsigma ss seire tae ee ek ee 78 ETUSUD idea te ds a aa Bh ee A 78 elltaniyama 78 ClltOrs 345 42 42485446 6266845 5 78 elltorsO 2 00 ee a 78 SL WP opo p ee a ee a ea 78 ellwpO 3 22 geek eee dae 79 ellZ ta pant wit dak eae we haha dS 79 ellZtopoint sogor sopa 44 4 2 ee Ba aes 19 EMacs 4 40 42 406 amp dg 4 a ahaa 38 WU ob ocd a h a ee kee ee 4 11 GUtLES 4 Ae oes ee we eo ee A 33 179 env
37. e the relative order o of s is its order in the quotient group G s1 5 1 with the same exceptions e for any x G there exists an unique family e1 eg such that no exceptions 93 for 1 lt 1 lt g we have 0 lt e lt 0 Gh gy Gn In this implementation the o are prime powers It can be relaxed in the future If present den must be a suitable value for gal 5 The library syntax is galoisinit gal den 3 6 35 galoispermtopol gal perm gal being a galois field as output by galoisinit and perm a element of gal group return the polynomial defining the Galois automorphism as output by nfgaloisconj associated with the permutation perm of the roots gal roots perm can also be a vector or matrix in this case galoispermtopol is applied to all components recursively Note that G galoisinit pol galoispermtopol G G 6 is absolutely equivalent to nf galoisconj pol if degree of pol is greater or equal to 2 The library syntax is galoispermtopol gal perm 3 6 36 galoissubcyclo n H Z v compute a polynomial defining the subfield of Q fixed by the subgroup H of Z nZ The subgroup H can be given by a generator a set of generators given by a vector or a HNF matrix If present Z must be znstar n currently it is used only when H is a HNF matrix If v is given the polynomial is given in the variable v The following function can be used to compute all subfields of Q of order le
38. else for i 0 i lt n i lbot avma y gsqr y gt return gerepile ltop lbot y A few remarks once again First note the use of the function gscalmat with the following syntax GEN gscalmat GEN x long m The effect of this function is to create the m x m scalar matrix whose diagonal entries are x Hence the length of the matrix including the codeword will in fact be m 1 There is a corresponding function gscalsmat which takes a long as a first argument If we refer to what has been said above the main loop should be self evident When we do the final squarings according to the fundamental dogma on the use of gerepile we keep the value of avma in 1bot just before the squaring so that if it is the last one 1bot will indeed be the bottom address of the garbage pile and gerepile will work Note that it takes a completely negligible time to do this in each loop compared to a matrix squaring However when n is initially equal to 0 no squaring has to be done and we have our final result ready but we lost the address of the bottom of the garbage pile Hence we use the trick of copying y again to the top of the stack This is inefficient but does the trick If we wanted to avoid this using only gerepile the best thing to do would be to put the instruction 1bot avma just before both occurrences of the instruction y gadd p2 y Of course we could also rewrite the last block as follows 176 now square back n times
39. for i 0 i lt n i y gsqr y return gerepileupto ltop y because it does not matter to gerepileupto that we have lost the address just before the final result note that the loop is not executed if n is 0 It is safe to use gerepileupto here as y will have been created by either gsqr or gadd both of which are guaranteed to return suitable objects Remarks As such the program should work most of the time if x is a square matrix with real or complex entries Indeed since essentially the first thing that we do is to multiply by the real number 1 the program should work for integer real rational complex or quadratic entries This is in accordance with the behavior of transcendental functions Furthermore since this program is intended to be only an illustrative example it has been written a little sloppily In particular many error checks have been omitted and the efficiency is far from optimal An evident improvement would be the use of gerepileupto mentioned above Another improvement is to multiply the matrix x by the real number 1 right at the beginning speeding up the computation of the L norm in many cases These improvements are included in the version given in Appendix B Still another improvement would come from a better choice of n If the reader takes a look at the implementation of the function mpexp1 in the file basemath trans1 c he can make the necessary changes himself Finally there exist other algorithms of a diffe
40. forsubgroup H G 2 print mathnf concat G H 2 1 O 1 1 0 O 2 2 0 O 1 1 0 O 1 Note that in this last representation the index G H is given by the determinant 3 11 1 7 forvec X v seq flag 0 v being an n component vector where n is arbitrary of two component vectors a b for 1 lt i lt n the seg is evaluated with the formal variable X 1 going from a to b1 X n going from an to bn The formal variable with the highest index moves the fastest If flag 1 generate only nondecreasing vectors X and if flag 2 generate only strictly increasing vectors X 3 11 1 8 if a seq1 seq2 if a is non zero the expression sequence seq is evaluated otherwise the expression seq2 is evaluated Of course seq or seg2 may be empty so if a seq evaluates seq if a is not equal to zero you don t have to write the second comma and does nothing otherwise whereas if a seq evaluates seq if a is equal to zero and does nothing otherwise You could get the same result using the not operator if a seq Note that the boolean operators amp amp and are evaluated according to operator precedence as explained in Section 2 4 but that contrary to other operators the evaluation of the arguments is stopped as soon as the final truth value has been determined For instance if reallydoit amp amp longcomplicatedfunction is a perfectly safe statement Recall that functions such
41. matmuldiagonal 126 matmultodiagonal 126 Matpascal o o o ooo 126 matqpascal oo 126 Mabrank Vii A II 126 MALTACE sod ga wk ee o Mob we Ge 133 MATIX su aK ee GO Gee a 5 6 24 35 166 HACI oF koe sirds Boe we oe a e toz MOD TUR hc cc ta Ean 126 MAtriXGZO 2 coe ee e ee a 126 MALSIZES q e cc s g be wR ae E Be 126 MASHE elisa ra Soe os eed 126 MabsntO giv gaa ee o a ce amp Seu 127 Mabsolve tse fi eet Ao ace et Ate es 127 matsolvemod 127 matsolvemodO 127 matsupplement t27 mattranspose 127 MAM arte nas ey SiS ck ace r vir Ge GR ee Rov Goes 46 MaxXprime gt s soroa cd Ee 149 203 MAXVARN 2 150 167 MEDDEFAULTPREC 152 member functions 33 13 81 MED o gee Oe dee RE 46 215 minideal mesa eet Ge Ges ak a a a 97 MINIM euro a ey ee ky we Gow i 129 MINIM ss we we A a a a a a 129 minimal polynomial 121 Mod ga celal ah heaton Sosa ue ke Be ata Me G 47 Moda e ol le cr A A 47 MOd2 20 curada 164 MO A we A ew a 164 MOAGA sope e wed e Sadi ge OS 164 DOPE sp ecse Ba ed be ES So eh wg 105 MOAULEVETSS e ort doe amp ee a A we a 99 Modubarged i694 e a we e ae 67 modules secas De ew a 80 Moebius se s s st aaas sodara 62 68 MOCDIUS seca g a 62 68 Mordell Weil group ooa aaa E Mpadd ceses ea be Gwe ee aa 151 Mpatt 26 0 4 Ae tit POE ae ee A 185 MpberM fac h
42. note that only the first call will actually compute the constant unless a higher precision is required Finally one has access to a table of differences of primes through the pointer diffptr This is used as follows when void pari_init long size long maxprime is called this table is initialized with the successive differences of primes up to just a little beyond maxprime see Section 4 1 maxprime has to be less than 436272744 whatever memory is available A difference of 0 means we have reached the end of the table The largest prime computable using this table is available as the output of ulong maxprime Here s a small example byteptr d diffptr 203 ulong p 0 if maxprime lt goal err primer1 not enough primes while p lt goal run through all primes up to goal p d Here we use the general error handling function err see Section 4 7 3 with the codeword primer1 This will just print the error message not enough precomputed primes and then abort the computations You can use the function initprimes from the file arith2 c to compute a new table on the fly and assign it to diffptr or to a similar variable of your own Beware that before changing diffptr you should really free the malloced precomputed table first and then all pointers into the old table will become invalid PARI currently guarantees that the first 6547 primes up to and including 65557 will
43. pr 3 6 101 polcompositum z y flag 0 x and y being polynomials in Z X in the same vari able outputs a vector giving the list of all possible composita of the number fields defined by x and y if x and y are irreducible or of the corresponding tale algebras if they are only square free Returns an error if one of the polynomials is not squarefree When one of the polynomials is irreducible say x it is often much faster to use nffactor nfinit x y then rnfequation If flag 1 outputs a vector of 4 component vectors z a b k where z ranges through the list of all possible compositums as above and a resp b expresses the root of x resp y as a polmod in a root of z and k is a small integer k such that a kb is the chosen root of z The compositum will quite often be defined by a complicated polynomial which it is advisable to reduce before further work Here is a simple example involving the field Q 5 51 106 z polcompositum x 5 5 polcyclo 5 1 1 pol z 1 pol defines the compositum 2 x720 5 x719 15 x718 35 x717 70 x716 141 x715 260 x714 355 x713 95 x712 1460 x711 3279 x710 3660 x79 2005 x78 705 x77 9210 x76 13506 x75 7145 x74 2740 x73 1040 x72 320 x 256 a z 2 a5 5 a is a fifth root of 5 3 0 z polredabs pol 1 look for a simpler polynomial pol z 1 D x720 25 x710 5 a subst a pol x z 2
44. prints the time taken by the latest computation Useful when you forgot to turn on the timer 2 3 Input formats for the PARI types Before describing more sophisticated functions in the next section let us see here how to input values of the different data types known to PARI Recall that blanks are ignored in any expression which is not a string see below 2 3 1 Integers type t_INT type the integer with an initial or if desired with no decimal point 2 3 2 Real numbers type t_REAL type the number with a decimal point The internal precision of the real number will be the supremum of the input precision and the default precision For example if the default precision is 28 digits typing 2 will give a number with internal precision 28 but typing a 45 significant digit real number will give a number with internal precision at least 45 although less may be printed You can also use scientific notation with the letter E or e like 6 02 E 23 or 1e 5 2 3 3 Integermods type t_INTMOD to enter n mod m type Mod n m not n m see Chapter 3 21 2 3 4 Rational numbers types t_FRAC and t_FRACN under GP all fractions are automatically reduced to lowest terms so it is in principle impossible to work with reducible fractions of type t_FRACN although of course in library mode this is easy To enter n m just type it as written As explained in Section 3 1 4 division will not be performed only reduction to lowest terms
45. s iess o aek AES wee ee 89 bnrclassno 40 89 bnrclassnolist 89 bnrcondiuctor i026 6 644 ade 89 bnrconductorofchar 89 PRESO 4 x44 a cn eh Se do 89 bnrdiscO 242 26 ii4 4248 6444 4 4 89 bnrdisclist mom ponia Bs 90 bnrdisclistO 90 a pa sars ace e sa ES Se a Rees 70 90 DACIDICO esoo E a ees we 90 bnrisconductor 90 bnrisprincipal 90 e A ee RR ee as 87 88 bnrrootnumber 91 207 bnrstark ccs a Sete o lk 71 91 92 boolean operators 0 45 brace characters 0 28 break loop os eri 4 aa 147 lA 141 147 Breull Ls ga ta ee db 73 A EN 170 172 buchfu micro o ee eee a a 87 DUCHIMAR e Toe soues e ee ee eS al Buchmann 82 83 97 116 Buchmann McCurley 70 buchnarrow 4 4 5 ata bog 2 ee GG 87 buchr al s easi ema daa doe a a es 71 buffersize o 13 C Cantor Zassenhaus 66 CARAC a a ay eS ad 121 caradj 2664446 iaaa e a 121 CAarhesS 4 Als feck oS As a e 2 case distinction 0 27 Geile os wk hk oa ea he tee ge a 49 centerliftt 4 4 24444 98 oe ay G 50 centerliftO 50 certifybuchall 83 COTE Dior eee ta 153 154 162 185 COL La a ee a ees 153 185 CEBO suma Ge a See 189 CROCI ece cata Pa ee eb a 153 185 COL u c odd de m i op BR a we OE we ae 157 185 changevar 2 66 fb eee 2 10 29 50 character string
46. t with rational components It gives a coordinate change for E over Q such that the resulting model has integral coefficients is everywhere minimal a is 0 or 1 az is 0 1 or 1 and az is 0 or 1 Such a model is unique and the vector v is unique if we specify that u is positive To get the new model simply type ellchangecurve E v Finally c is the product of the local Tamagawa numbers cp a quantity which enters in the Birch and Swinnerton Dyer conjecture The library syntax is globalreduction F 3 5 11 ellheight E z flag 0 global N eron Tate height of the point z on the elliptic curve E The vector E must be a long vector of the type given by ellinit with flag 1 If flag 0 this computation is done using sigma and theta functions and a trick due to J Silverman If flag 1 use Tate s 4 algorithm which is much slower E is assumed to be integral given by a minimal model The library syntax is ellheight0 E z flag prec The Archimedean contribution alone is given by the library function hell E z prec Also available are ghell E z prec flag 0 and ghell2 E z prec flag 1 3 5 12 ellheightmatrix E x x being a vector of points this function outputs the Gram matrix of x with respect to the N ron Tate height in other words the i j component of the matrix is equal to el1bi1 4 x 1 1 x 31 The rank of this matrix at least in some approximate sense gives the rank of the set of points and if x i
47. the binary bits of y are read from right to left but correspond to taking the components from left to right For example if y 13 1101 2 then the components 1 3 and 4 are extracted If y is a vector which must have integer entries these entries correspond to the component numbers to be extracted in the order specified If y is a string it can be e a single non zero index giving a component number a negative index means we start counting from the end e a range of the form a b where a and b are indexes as above Any of a and b can be omitted in this case we take as default values a 1 and b 1 i e the first and last components respectively We then extract all components in the interval a b in reverse order if b lt a In addition if the first character in the string is the complement of the given set of indices is taken If z is not omitted must be a matrix y is then the line specifier and z the column specifier where the component specifier is as explained above 130 v la b c d el vecextract v 5 mask 41 a c vecextract v 4 2 1 component list 42 d b a vecextract v 2 4 interval 43 b c d vecextract v 1 3 interval reverse order 14 e d c vecextract 1 2 3 2 complement 5 1 3 vecextract matid 3 2 76 o 1 0 0 0 1 The library syntax is extract x y or matextract z y z 3
48. the ulong divisor y and stores the remainder into hiremainder An error occurs if the quotient cannot be represented by a ulong i e if hiremainder gt y initially 5 2 Level 1 kernel operations on longs integers and reals In this section as elsewhere long denotes a BIL bit signed C integer integer denotes a PARI multiprecise integer type t_INT real denotes a PARI multiprecise real type t_REAL Refer to Chapters 1 2 and 4 for general background Note Many functions consist of an elementary operation immediately followed by an assignment statement All such functions are obtained using macros see the file paricom h hence you can easily extend the list Below they will be introduced like in the following example GEN gadd z GEN x GEN y GEN z followed by the explicit description of the function GEN gadd GEN x GEN y which creates its result on the stack returning a GEN pointer to it and the parts in brackets indicate that there exists also a function void gaddz GEN x GEN y GEN z which assigns its result to the pre existing object z leaving the stack unchanged 5 2 1 Basic unit and subunit handling functions long typ GEN x returns the type number of x The header files included through pari h will give you access to the symbolic constants t_INT etc so you should never need to know the actual numerical values long lg GEN x returns the length of x in BIL bit words long lgef GEN x returns
49. where a is an integer in bnf If bnf has not been certified the correctness of the result depends on the validity of GRH The library syntax is bnfisintnorm bnf x 85 3 6 7 bnfisnorm bnf x flag 1 tries to tell whether the rational number x is the norm of some element y in bnf Returns a vector a b where x Norm a xb Looks for a solution which is an S unit with S a certain set of prime ideals containing among others all primes dividing z If bnf is known to be Galois set flag 0 in this case x is a norm iff b 1 If flag is non zero the program adds to S the following prime ideals depending on the sign of flag If flag gt 0 the ideals of norm less than flag And if flag lt 0 the ideals dividing flag If you are willing to assume GRH the answer is guaranteed i e x is a norm iff b 1 if S contains all primes less than 12 log disc Bnf where Bnf is the Galois closure of bnf The library syntax is bnfisnorm bnf x flag prec where flag and prec are longs 3 6 8 bnfissunit bnf sfu x bnf being output by bnfinit sfu by bnfsunit gives the column vector of exponents of x on the fundamental S units and the roots of unity If x is not a unit outputs an empty vector The library syntax is bnfissunit bnf sfu x 3 6 9 bnfisprincipal bnf x flag 1 bnf being the number field data output by bnfinit and x being either a Z basis of an ideal in the number field not necessarily in HNF or a prime i
50. 1 As PSLa 5 60 1 1 Gro 72 1 1 Ss PGLa 5 120 1 1 Ag 360 1 1 Se 720 1 1 In degree 7 C7 7 1 1 D7 14 1 1 Mai 21 1 1 Mas 42 1 1 PSZL2 7 PSLa 2 168 1 1 A7 2520 1 1 S7 5040 1 1 The method used is that of resolvent polynomials and is sensitive to the current precision The precision is updated internally but in very rare cases a wrong result may be returned if the initial precision was not sufficient The library syntax is galois x prec 107 3 6 103 polred z flag 0 fp finds polynomials with reasonably small coefficients defining subfields of the number field defined by x One of the polynomials always defines Q hence is equal to x 1 and another always defines the same number field as x if x is irreducible All x accepted by nfinit are also allowed here e g non monic polynomials nf bnf x Z_K_basis The following binary digits of flag are significant 1 does a partial reduction only This means that only a suborder of the maximal order may be used 2 gives also elements The result is a two column matrix the first column giving the elements defining these subfields the second giving the corresponding minimal polynomials If p is given it is assumed that it is the two column matrix of the factorization of the discrim inant of the polynomial zx The library syntax is polredO z flag p prec where an omitted p is co
51. 1 i e in beautified format s t idem in T X format Dic argument has a default value The format to indicate a default value atom starts with a D is Dvalue type where type is the code for any mandatory atom previous group value is any valide GP expression which is converted according to type and the ending comma is mandatory For instance DO L stands for this optional argument will be converted to a long and is O by default So if the user given argument reads 1 3 at this point long 4 is sent to the function via itos and long 0 if the argument is ommitted The following special syntaxes are available DG optional GEN send NULL if argument omitted D amp optional GEN send NULL if argument omitted DV optional entree send NULL if argument omitted DI optional char send NULL if argument omitted Dn optional variable number 1 if omitted e Automatic arguments f Fake long C function requires a pointer but we don t use the resulting long p real precision default realprecision P series precision default seriesprecision global variable precd1 for the library e Return type GEN by default otherwise the following can appear anywhere in the code string 1 return long v return void No more than 8 arguments can be given syntax requirements and return types are not con sidered as arguments This is currently hardcoded but can trivially be changed by modifying the 178 definition of argv
52. 13 1 logfile switches log mode on and off If a logfile argument is given change the default logfile name to logfile and switch log mode on 2 2 14 m as a but using prettymatrix format 2 2 15 o n sets output mode to n 0 raw 1 prettymatrix 2 prettyprint 2 2 16 p n sets realprecision to n decimal digits Prints its current value if n is omitted 2 2 17 ps n sets seriesprecision to n significant terms Prints its current value if n is omitted 2 2 18 q quits the GP session and returns to the system Shortcut for the function quit see Section 3 11 2 20 2 2 19 r filename reads into GP all the commands contained in the named file as if they had been typed from the keyboard one line after the other Can be used in combination with the w command see below Related but not equivalent to the function read see Section 3 11 2 21 in particular if the file contains more than one line of input there will be one history entry for each of them whereas read would only record the last one If filename is omitted re read the previously used input file fails if no file has ever been successfully read in the current session This command accepts compressed files in compressed Z or gzipped gz or z format They will be uncompressed on the fly as GP reads them without changing the files themselves 2 2 20 s prints the state of the PARI stack and heap This is used primarily as a debugging device for PARI and
53. 19 factor x lim 1 general factorization function If x is of type integer rational polynomial or rational function the result is a two column matrix the first column being the irreducibles dividing x prime numbers or polynomials and the second the exponents If x is a vector or a matrix the factoring is done componentwise hence the result is a vector or matrix of two column matrices By definition 0 is factored as 0 If x is of type integer or rational an argument lim can be added meaning that we look only for factors up to lim or to primelimit whichever is lowest except when lim 0 where the effect is identical to setting lim primelimit Hence in this case the remaining part is not necessarily prime See factorint for more information about the algorithms used The polynomials or rational functions to be factored must have scalar coefficients In particular PARI does not know how to factor multivariate polynomials Note that PARI tries to guess in a sensible way over which ring you want to factor Note also that factorization of polynomials is done up to multiplication by a constant In particular the factors of rational polynomials will have integer coefficients and the content of a polynomial or rational function is discarded and not included in the factorization If you need it you can always ask for the content explicitly factor t 2 5 2 t 1 1 2xt 1 1 t 2 1 65 content t72 5 2 t
54. 191 CMP du eects o ee ee ee 45 191 ECMPES serie be ee a BG we 191 ECMPSE 2 26 eb Swe ke be ee eo 191 BCmp lath aa Ye a ates Ba ee Be ECMPL sr aa te ee Ae ee ae 45 ECO 2 ff be ee ee 8 be eb Oe ol ECOPDY ww Ebo do pa ara 155 156 189 ECOS eae caga eR A e a ws 58 ECO cvs eR eee es 58 PCVLOU fics da o Be pa a Kins 54 192 BCVLOP fan bee ee Dee eed aw a 190 BABE ores bie eee Bo ge ae ae ee 194 PACU ies Ged ah Go eo GS ee a Be 149 BIV banda ne be wha Se ae we 44 gdiventir e sns d 2k Eo ip e 44 gdiventgs z sa sor kw ee walk Bae ae 193 gdiventres 45 193 gdiventsg z 193 pdivent z via Soe ed Ge Go od are 193 gdivgs z s gt reseta ra ds 193 POIVISE o oee ra ee 194 gdivmod s e a s mosok poa a ish p OE kok 193 gdivround 45 194 pdivsg 2 ba o ee eae Sa ewe a Be 193 POE oa paa og ee ees 193 ESHAL ocre be ew Re ws 45 191 PCBAlBS ess sod aa Cee be ewe wos 191 gegalsg 1 kon E 2 20 0006 191 gen member function 81 GEN dub See ke oe WE et de E 5 149 Sener Gri Rees te heed Gre Goa a Ge 12 generic MATIK ae ss Gab acri as 35 GenmMsptimer soi soor asr ae ee 172 genrand 0 555004 53 pentimer a si ee baw GRO aR ws 2 GENtOSTE 2 iaa sa be ee es 48 171 BCG f0nch es a a 45 gerepile 154 157 176 185 p repilemany nario sub kw ee 161 gerepilemany 159 gerepilemanysp 159 gerepileupto 158 177 Petheap
55. 192 BaddZ co o 151 155 162 gadd z lt ecs s oeoa sorteos 184 192 Aae A r dah a ord 154 155 191 gal SE 22220 Fe oe Saw e 155 191 GALOS as stn eR Es 85 102 107 113 galois nk do ce Ow we ek Bae 107 galoisapply 102 galoisconj 2 2 ie eee ba eg asa 103 GalovsconjO sea sao we bk we es a 103 BalOisconj2 nie Ge ba we eb ee as 103 galoisconj4 0 103 galoisfixedfield 92 galoisinit 93 94 galoispermtopol 94 galoissubcyclo 91 94 118 SAMA pF Sa ic e oe A we a 59 gammab 2 2b eon Pop Pe Pe ae 59 gand Ga doce sercks vis hes By A ek 45 garbage collecting 156 SITE i gee bg a ae Oe ee ae 57 Cash iia hee oe Boe was ee 57 GaASIN fos a ee See a Ee ow ee 57 gatah ik ee eee e 57 Babi nen pia gee is Di eb 57 GAUSS oe ew ae sa 127 gaussmodulo i sa s srs sot naa dos ni 127 PAaUSSMOGULO ps aere e a Gr Gk AH 127 gbezout p coe poa e a es 63 194 gbitand oce acers Rae AR a e 49 A op kas ke ea a a ke E 49 gbitnegimply 49 GOGO meros pepa 49 ODIA uo 49 SHOUNICE si g pie nas eae a ar S 64 gcarrecomplet 68 gcarrepar ialit 68 1 A owe Sok GA aE s 67 CAO tama be bie heehee Pas 67 A pakaa oes ba Ba ae eae E AQ 192 ECE ri a e aes 64 ECT rar cas Pee wb 64 BCH mir a e eels 58 eclone 324 x e668 2 ER 155 156 190 ECP e kee Adee ee ea ee eed 45 191 ECMPO a se eb ae ea We Po es 45 46
56. 2 0 When you kill a variable all objects that used it become invalid You can still display them even though the killed variable will be printed in a funny way following the same convention as used by the library function fetch_var see Section 4 6 For example 7T a2 1 1 a 2 1 kill a 145 UNIX hl 92 lt 1 gt 2 1 If you simply want to restore a variable to its original value monomial of degree one use the quote operator a a 3 11 2 15 print str outputs its string arguments in raw format ending with a newline 3 11 2 16 print1 str outputs its string arguments in raw format without ending with a newline note that you can still embed newlines within your strings using the n notation 3 11 2 17 printp str outputs its string arguments in prettyprint beautified format ending with a newline 3 11 2 18 printp1 str outputs its string arguments in prettyprint beautified format without ending with a newline 3 11 2 19 printtex str outputs its string arguments in T X format This output can then be used in a TEX manuscript The printing is done on the standard output If you want to print it to a file you should use writetex see there Another possibility is to enable the log default see Section 2 1 You could for instance do default logfile new tex default log 1 printtex result You can use the automatic string expansion concatenat
57. 2 aa e aa aa 6 LEAVeS 2 44 4406 605 HA ee eae How 5 Legendre polynomial 117 Legendre symbol 68 legendre oops hab eee as 117 length e244 0 44 ra ra ee eae 163 length o 5l Lenstra csoda resi sarino 66 116 LEX error a 46 o 1s ke ha eae ok ark a 4 46 191 LOXSOTt a codorna e e we eS 131 lira ee Re a 163 174 184 LE obi Be gla aS BS a 166 167 184 lgefint rise Ha GR eke A 164 184 LEETE 22 82 bv eee eH ee ee ee a 153 leoli aro as Ge tia Gee ee Ge ey eee ae 153 214 ABCC ei gg eS ee ee Be eg 153 library mode 149 LIDIA gece a eR ew aA ees 66 DAE sy od Bei ech ee ae 8 A 51 52 is isc cia a a a a 52 Lindep eb Wa Be e 122 lindepO 234545 68 bea ae totta 12 line editor o o 39 linear dependence 122 VANES op eh eB eh ee eea 15 WT has Sak eh ae Se Ee Ge ex a 11 180 LISCXPY esa csee Pa Ge RG eos 169 JisGEN seas Dawe aw de eS 169 173 DISP e sore Roa WR ee ew we a 36 L ISSEA oe 2 dk ee ae ee be ee 169 WSU a aaee Bt ee he e 5 24 167 Lita Saab sd e re i aoe A 47 listcreate o emission es 122 listinsert irc ee a hrs 122 av s ers ae i a a oae 125 TESCDUG or ga od ad a ee 123 LISESOTL ii o a ee es 123 LLL 84 97 103 120 122 124 125 128 VW wiih ee be a Be eae 128 TT gram A 129 Illgpramint ri hosts be o ce cae ah ek 129 lllgramkerim 129 ADDING ee we we rea SR ee a a 128 ILTRETIM wk ew eee ka 128 INGaMMa
58. 4445 94 a A 131 T SOT 2 gates Be ee eh ee ee eee Es 61 Bared ais eee uh a ee a a 127 12 is a eee Ba week Se AS a ck Be e 81 SOE ye ei aa ey Ges tS Been g 61 taille Liu id pis a Se ae ae A 54 190 SQICING oe s eon Pe Be a ee ws 72 taille og ak wee he He Ee EE ss 54 a aor Ba be a Hk Bek keel Be a 67 talker sucias Tyl SUCK s eos ag aaae ad A A a a 149 Tamagawa number 19 ET Stack od a 20 203 GAN 6 egy Ree Awe Gohe Hed 61 Stack Jim gi bb wa ee heey ee g 162 anhe Gk Bee edo ee ee Ge eh ke ee g 61 220 Taniyama s sos soa a i a ae 78 Taniyama Weil conjecture 73 MAGE 2 ena a 72 tate e es ah SR e a a 73 tayl pe eta eee eek ee eee a we 120 Taylor series 44 AY DAR E 73 taylor ser ie A 120 a o 2 46 6 giidi aiana Ei Bee eos 119 LOL sos ea Mek at ee ela 61 teichmuller 61 GOXPLANE ce ias oa ai o he be 170 Theta gee eid eae ee ere Be eh we 61 thetanullk 61 A A ees 120 GHUCINIT yas sos m aon a ee Do 120 time expansion 13 timer mee ar eG ee ee A 18 172 TIMSE2 osas ed an OR a a Ea 172 TACO sona a nee be Rhee Be we 130 CHAP so oaa s ven Sb ew ee ee A 36 146 truecoeff mic 50 116 189 truedvmdii 188 EEUDICILS s e conog BO eR Ee a 54 ESCOHIFNDGUS wok Ge ee wie Gas E 108 Dl coania aa a a Y 81 CURU See Sh ee ee oe a ee ee a 81 tutorial 19 CYP we be a a de toe eae ee E ea 163 184 type number 163 CYC
59. 6 3 and special variables Please note that from version 1 900 on there is a distinction between lowercase and uppercase Also note that outside of constant strings blanks are completely ignored in the input to GP The special variable names known to GP are Euler Euler s constant y 0 577 I the square root of 1 Pi 3 14 which could be thought of as functions with no arguments and which may therefore be invoked without parentheses and O which obeys the following syntax O Cerpr k When expr is an integer or a rational number this creates an expr adic number zero in fact of precision k When ezpr is a polynomial a power series or a rational function whose main variable is X say this creates a power series also zero of precision v k where v is the X adic valuation of expr see 2 3 6 and 2 3 9 2 5 2 Special editing characters A GP program can of course have more than one line Since GP executes your commands as soon as you have finished typing them there must be a way to tell it to wait for the next line or lines of input before doing anything There are three ways of doing this The first one is simply to use the backslash character at the end of the line that you are typing just before hitting lt Return gt This tells GP that what you will write on the next line is the physical continuation of what you have just written In other words it makes GP forget your newline character For example if
60. 8 55 vecsort z k flag 0 sorts the vector x in ascending order using the heapsort method x must be a vector and its components integers reals or fractions If k is present and is an integer sorts according to the value of the k th subcomponents of the components of x k can also be a vector in which case the sorting is done lexicographically according to the components listed in the vector k For example if k 2 1 3 sorting will be done with respect to the second component and when these are equal with respect to the first and when these are equal with respect to the third The binary digits of flag mean e 1 indirect sorting of the vector x i e if x is an n component vector returns a permutation of 1 2 n which applied to the components of x sorts x in increasing order For example vecextract x vecsort x 1 is equivalent to vecsort x e 2 sorts x by ascending lexicographic order as per the lex comparison function The library syntax is vecsortO z k flag To omit k use NULL instead You can also use the simpler functions sort 1 vecsort0 x NULL 0 indexsort x vecsort0 z NULL 1 lexsort x vecsort0 x NULL 2 Also available are sindexsort and sindexlexsort which return a vector type t_VEC of C long integers v where v 1 v n contain the indices Note that the resulting v is not a valid PARI object but is in general easier to use in C programs 131 3 9 Sums produc
61. E 16 form a basis of the complex lattice defining E E omega with 7 TA having positive imaginary part E 17 and E 18 are the corresponding values 7 and na such that m w2 naw1 ir and both can be retrieved by typing E eta as a row vector whose components are the m Finally E 19 E area is the volume of the complex lattice defining E e When F is defined over Q the p adic valuation of j must be negative Then E 14 E roots is the vector with a single component equal to the p adic root of the associated Weierstrass equation corresponding to 1 under the Tate parametrization E 15 is equal to the square of the u value in the notation of Tate 16 is the u value itself if it belongs to Qp otherwise zero 17 is the value of Tate s q for the curve E tate will yield the three component vector u u q E E E E 18 E w is the value of Mestre s w this is technical and E 19 is arbitrarily set equal to Zero For all other base fields or rings the last six components are arbitrarily set equal to zero see also the description of member functions related to elliptic curves at the beginning of this section The library syntax is ellinitO EF flag prec Also available are initell E prec flag 0 and smallinitell E prec flag 1 3 5 14 ellisoncurve E z gives 1 i e true if the point z is on the elliptic curve E 0 otherwise If E or z have imprecise coefficients an attempt is made to ta
62. Finally bnf 10 is unused and set equal to 0 but it is essential that this component be present because PARI distinguishes a number field nf from a big number field bnf by the number of its components e The less technical components are as follows bnf 7 or bnf nf is equal to the number field data nf as would be given by nfinit bnf 8 is a vector containing the last 6 components of bnfclassunit 1 i e the classgroup bnf clgp the regulator bnf reg the general check number which should be close to 1 the num ber of roots of unity and a generator bnf tu the fundamental units bnf fu and finally the check on their computation If the precision becomes insufficient GP outputs a warning fundamental units too large not given and does not strive to compute the units by default flag 0 When flag 1 GP insists on finding the fundamental units exactly the internal precision being doubled and the computation redone until the exact results are obtained The user should be warned that this can take a very long time when the coefficients of the fundamental units on the integral basis are very large When flag 2 on the contrary it is initially agreed that GP will not compute units When flag 3 computes a very small version of bnfinit a small big number field or sbnf for short which contains enough information to recover the full bnf vector very rapidly but which is much smaller and hence easy to store and print
63. If x is a row or column vector then x n represents the nt component of x i e compo x n It is more natural and shorter to write If x is a matrix x m n represents the coefficient of row m and column n of the matrix x m represents the m row of x and x n represents the n column of z Finally note that in library mode the macros coeff and mael are available to deal with the non recursivity of the GEN type from the compiler s point of view See the discussion on typecasts in Chapter 4 3 2 21 conj x conjugate of x The meaning of this is clear except that for real quadratic numbers it means conjugation in the real quadratic field This function has no effect on integers reals integermods fractions or p adics The only forbidden type is polmod see conjvec for this The library syntax is gconj x 3 2 22 conjvec x conjugate vector representation of x If x is a polmod equal to Mod a q this gives a vector of length degree q containing the complex embeddings of the polmod if q has integral or rational coefficients and the conjugates of the polmod if q has some integermod coefficients The order is the same as that of the polroots functions If x is an integer or a rational number the result is x If x is a row or column vector the result is a matrix whose columns are the conjugate vectors of the individual elements of x The library syntax is conjvec z prec 3 2 23 denominator x lowest denominator of x The m
64. If x is of type t_COMPLEX returns the minimum of the precisions of the real and imaginary part Otherwise returns 0 which stands in fact for infinite precision 5 3 2 Comparison operators and valuations int gcmpO GEN x returns 1 true if x is equal to 0 0 false otherwise int isexactzero GEN x returns 1 true if x is exactly equal to 0 0 false otherwise Note that many PARI functions will return a pointer to gzero when they are aware that the result they return is an exact zero so it is almost always faster to test for pointer equality first and call isexactzero or gempO only when the first test fails int gcmpl GEN x returns 1 true if x is equal to 1 0 false otherwise int gcmp _1 GEN x returns 1 true if x is equal to 1 0 false otherwise long gcmp GEN x GEN y comparison of x with y returns the sign of x y long gcmpsg long s GEN x comparison of the long s with x long gcmpgs GEN x long s comparison of x with the long s long lexcmp GEN x GEN y comparison of x with y for the lexicographic ordering long gegal GEN x GEN y returns 1 true if x is equal to y 0 otherwise long gegalsg long s GEN x returns 1 true if the long s is equal to x 0 otherwise long gegalgs GEN x long s returns 1 true if x is equal to the long s 0 otherwise long iscomplex GEN x returns 1 true if x is a complex number of component types embed dable into the reals but is not itself real 0 if x is a real
65. Ingamma z principal branch of the logarithm of the gamma function of x Can have much larger arguments than gamma itself In the present version 2 0 19 the p adic Ingamma function is not implemented The library syntax is glngamma z prec 3 3 34 polylog m x flag 0 one of the different polylogarithms depending on flag If flag 0 or is omitted mt polylogarithm of x i e analytic continuation of the power series Lin x 0 5 2 n The program uses the power series when x lt 1 2 and the power series expansion in log x otherwise It is valid in a large domain at least x lt 230 but should not be used too far away from the unit circle since it is then better to use the functional equation linking the value at x to the value at 1 x which takes a trivial form for the variant below Power series polynomial rational and vector matrix arguments are allowed For the variants to follow we need a notation let Rm denotes R or S depending whether m is odd or even If flag 1 modified m polylogarithm of zx called D x in Zagier defined for x lt 1 by m l k e m 1 Rm CPI cas Del log 1 a k If flag 2 modified m polylogarithm of x called Dm x in Zagier defined for z lt 1 by oe E Ca cee l l lt k 2 m If flag 3 another modified m polylogarithm of x called Pm x in Zagier defined for x lt 1 by m l ok aay 2 B i 2 Bm M Rm A E log x Lim
66. K nf 3 contains the discriminant d K nf disc of K nf 4 contains the index of nf 1 i e Zx Z 0 where 0 is any root of nf 1 nf 5 is a vector containing 7 matrices M MC T2 T MD TI MDI useful for certain computations in the number field K e M is the r1 r2 xn matrix whose columns represent the numerical values of the conjugates of the elements of the integral basis e MC is essentially the conjugate of the transpose of M except that the last r2 columns are also multiplied by 2 e 72 is an nxn matrix equal to the real part of the product MC M which is a real positive definite symmetric matrix the so called T gt matrix nf t2 e T is the n x n matrix whose coefficients are Tr w w where the w are the elements of the integral basis Note that T MC M and in particular that T Ta if the field is totally real in practice T will have real approximate entries and T will have integer entries Note also that det T is equal to the discriminant of the field K e The columns of MD nf diff express a Z basis of the different of K on the integral basis e TI is equal to d K T which has integral coefficients Note that understood as as ideal the matrix T generates the codifferent ideal e Finally MDI is a two element representation for faster ideal product of d K times the codifferent ideal nf disc nf codiff which is an integral ideal MDI is only used in idealinv nf 6 is
67. SQUFOF factoring method the Pollard rho factoring method the Lucas Lehmer primality test for Mersenne numbers and a simple general class group and fundamental unit algorithm much worse than the built in bnfinit See the file examples EXPLAIN for some explanations 4 4 EMACS If you want to use gp under GNU Emacs read the file emacs pariemacs txt If you are familiar with Emacs we suggest that you do so 4 5 The PARI Community There are three mailing lists devoted to the PARI GP package run courtesy of Dan Bernstein and most feedback should be directed to those They are e pari announce to announce major version changes You can t write to this one but you should probably subscribe e pari dev for everything related to the development of PARI including suggestions tech nical questions bug reports or patch submissions e pari users for everything else To subscribe send empty messages respectively to pari announce subscribe list cr yp to 199 pari users subscribe list cr yp to pari dev subscribe list cr yp to If you are not a member of any of those lists and don t want to become one you can write to us at the address pari math u bordeaux fr At the very least we will forward you mail to the lists above and correct faulty behaviour if necessary But we cannot promise you will get an individual answer Last but not least PARI home page maintained by Gerhard Nicklasch can be found at http www parigp hom
68. a yx 2 where a 0 if x 0mod4 a 1 if zx 1 mod4 so that 1 w is an integral basis for the quadratic order of discriminant x x must be an integer congruent to 0 or 1 modulo 4 The library syntax is quadgen x 3 4 55 quadpoly D v x creates the canonical quadratic polynomial in the variable v corresponding to the discriminant D i e the minimal polynomial of quadgen x D must be an integer congruent to 0 or 1 modulo 4 The library syntax is quadpoly0 z v 3 4 56 quadray D f flag 0 relative equation for the ray class field of conductor f for the quadratic field of discriminant D which can also be a bnf For D lt 0 flag has the following meaning if it s an odd integer outputs instead the vector of ideal corresponding root If flag 0 or 1 uses the o function while if flag gt 1 uses the Weierstrass p function which is less efficient and may disappear in future versions not all special cases have been implemented in this case Finally flag can also be a two component vector flag where flag is as above and A is the technical element of bnf necessary for Schertz s method using o In that case returns 0 if A is not suitable For D gt 0 if flag is non zero try hard to get the simplest modulus See bnrstark for more details If D gt 0 the function may fail with the following message Cannot find a suitable modulus in FindModulus See the comments in bnrstark about this problem
69. a Z generating set If this is not the case you must absolutely change it into a Z generating set the simplest manner being to use idealhnf nf x Concerning relative extensions some additional definitions are necessary e A relative matrix will be a matrix whose entries are elements of a given number field nf always expressed as column vectors on the integral basis nf zk Hence it is a matrix of vectors e An ideal list will be a row vector of fractional ideals of the number field nf e A pseudo matriz will be a pair A J where A is a relative matrix and J an ideal list whose length is the same as the number of columns of A This pair will be represented by a 2 component row vector e The module generated by a pseudo matrix A T is the sum J ajA where the a are the ideals of J and A is the j th column of A e A pseudo matrix A 1 is a pseudo basis of the module it generates if A is a square matrix with non zero determinant and all the ideals of J are non zero We say that it is in Hermite Normal Form HNF if it is upper triangular and all the elements of the diagonal are equal to 1 e The determinant of a pseudo basis A I is the ideal equal to the product of the determinant of A by all the ideals of J The determinant of a pseudo matrix is the determinant of any pseudo basis of the module it generates Finally when defining a relative extension the base field should be defined by a variable having a lower priori
70. a good idea to try and plot the same curve with slightly different parameters The other values toggle various display options e 8 do not print the x axis e 16 do not print the y axis e 32 do not print frame e 64 only plot reference points do not join them e 256 use splines to interpolate the points e 512 plot no x ticks e 1024 plot no y ticks e 2048 plot all ticks with the same length 3 10 10 plothraw listz listy flag 0 given listr and listy two vectors of equal length plots in high precision the points whose x y coordinates are given in listx and listy Automatic positioning and scaling is done but with the same scaling factor on x and y If flag is non zero join points 3 10 11 plothsizes return data corresponding to the output window in the form of a 6 component vector window width and height sizes for ticks in horizontal and vertical directions this is intended for the gnuplot interface and is currently not significant width and height of characters 138 3 10 12 plotinit w x y initialize the rectwindow w to width x and height y and position the virtual cursor at 0 0 This destroys any rect objects you may have already drawn in w The plotting device imposes an upper bound for x and y for instance the number of pixels for screen output These bounds are available through the plothsizes function The following sequence initializes in a portable way i e independant of the output
71. a in the new coordinates 6 Mod 5 22 x719 1 22xx 14 123 22xx 9 9 11 x 4 x 20 25 x710 5 The library syntax is polcompositum0 z y flag 3 6 102 polgalois x Galois group of the non constant polynomial x Q X In the present version 2 0 19 x must be irreducible and the degree of x must be less than or equal to 7 On certain versions for which the data file of Galois resolvents has been installed available in the Unix distribution as a separate package degrees 8 9 10 and 11 are also implemented The output is a 3 component vector n s k with the following meaning n is the cardinality of the group s is its signature s 1 if the group is a subgroup of the alternating group An s 1 otherwise and k is the number of the group corresponding to a given pair n s k 1 except in 2 cases Specifically the groups are coded as follows using standard notations see GTM 138 quoted at the beginning of this section In degree 1 S 1 1 1 In degree 2 S2 2 1 1 In degree 3 43 C3 3 1 1 S3 6 1 1 In degree 4 C4 4 1 1 Va 4 1 1 Da 8 1 1 44 12 1 1 S4 24 1 1 In degree 5 Cs 5 1 1 Ds 10 1 1 Mao 20 1 1 As 60 1 1 S5 120 1 1 In degree 6 Cg 6 1 1 S3 6 1 2 De 12 1 1 A4 12 1 1 Gig 18 1 1 Sy 41 4 x C2 24 19 S 24 1 1 Gon 36 1 1 G 86 1 1 S4 x Cy 48 1
72. a is known to be simply a p adic number type t_PADIC the syntax apprgen pol a can be used 116 3 7 7 polcoeff xz s v coefficient of degree s of the polynomial x with respect to the main variable if v is omitted with respect to v otherwise The library syntax is polcoeff0 x s v where v is a long and an omitted v is coded as 1 Also available is truecoeff z v 3 7 8 poldegree z v degree of the polynomial x in the main variable if v is omitted in the variable v otherwise This is to be understood as follows When x is a polynomial or a rational function it gives the degree of x the degree of 0 being 1 by convention When x is a non zero scalar it gives 0 and when zx is a zero scalar it gives 1 Return an error otherwise The library syntax is poldegree z v where v and the result are longs and an omitted v is coded as 1 Also available is degree x which is equivalent to poldegree x 1 3 7 9 polcyclo n v x n th cyclotomic polynomial in variable v x by default The integer n must be positive The library syntax is cyclo n v where n and v are long integers v is a variable number usually obtained through varn 3 7 10 poldisc pol v discriminant of the polynomial pol in the main variable is v is omitted in v otherwise The algorithm used is the subresultant algorithm The library syntax is poldiscO z v Also available is discsr 1 equivalent to poldisc0 x 1 3 7 11 poldisc
73. and subsection 6 5 5 in particular bnf 1 contains the matrix W i e the matrix in Hermite normal form giving relations for the class group on prime ideal generators p 1 lt i lt r bnf 2 contains the matrix B i e the matrix containing the expressions of the prime ideal factorbase in terms of the p It is an r x c matrix bnf 3 contains the complex logarithmic embeddings of the system of fundamental units which has been found It is an r r2 x r 12 1 matrix bnf 4 contains the matrix M amp of Archimedean components of the relations of the matrix M except that the first r r2 1 columns are suppressed since they are already in bnf 3 bnf 5 contains the prime factor base i e the list of k prime ideals used in finding the relations bnf 6 contains the permutation of the prime factor base which was necessary to reduce the relation matrix to the form explained in subsection 6 5 5 of GTM 138 i e with a big c x c identity matrix on the lower right Note that in the above mentioned book the need to permute the rows of the relation matrices which occur was not emphasized bnf 9 is a 3 element row vector obtained as follows Let b u7 bnf 1 uz obtained by applying the Smith normal form algorithm to the matrix W bnf 1 Then bnf 9 u1 uz bj Note that the final class group generators given by bnfinit or bnfclassunit are obtained by LLL reducing the generators whose list is b 84
74. and the result is a row vector a a with two components such that x aZk aZx and a Z where a is the one passed as argument if any If x is given by at least two generators a is chosen to be the positive generator of z N Z Note that when an explicit a is given we use an asymptotically faster method however in practice it is usually slower The library syntax is ideal_two_eltO nf x a where an omitted a is entered as NULL 3 6 59 idealval nf x vp gives the valuation of the ideal x at the prime ideal vp in the number field nf where vp must be a 5 component vector as given by idealprimedec The library syntax is idealval nf x vp and the result is a long integer 98 3 6 60 ideleprincipal nf x creates the principal idele generated by the algebraic number x which must be of type integer rational or polmod in the number field nf The result is a two component vector the first being a one column matrix representing the corresponding principal ideal and the second being the vector with r r2 components giving the complex logarithmic embedding of x The library syntax is principalidele nf x 3 6 61 matalgtobasis nf x nf being a number field in nfinit format and x a matrix whose coefficients are expressed as polmods in nf transforms this matrix into a matrix whose coefficients are expressed on the integral basis of nf This is the same as applying nfalgtobasis to each entry but it would be dangerous to use the
75. are integers or longs op sub subtraction x y The result is real unless both x and y are integers or longs op mul multiplication x y The result is real unless both x and y are integers or longs OR if x or y is the integer or long zero op div division x y In the case where x and y are both integers or longs the result is the Euclidean quotient where the remainder has the same sign as the dividend x If one of x or y is real the result is real unless x is the integer or long zero A division by zero error occurs if y is equal to zero op res remainder x y This operation is defined only when x and y are longs or integers The result is the Euclidean remainder corresponding to div i e its sign is that of the dividend x The result is always an integer op mod remainder x y This operation is defined only when x and y are longs or integers The result is the true Euclidean remainder i e non negative and less than the absolute value of y 5 2 8 Division with remainder the following functions return two objects unless specifically asked for only one of them a quotient and a remainder The remainder will be created on the stack and a GEN pointer to this object will be returned through the variable whose address is passed as the r argument GEN dvmdss long s long t GEN r creates the Euclidean quotient and remainder of the longs s and t If r is not NULL or ONLY_REM this puts the remainder in
76. as break and next operate on loops such as forxxx while until The if statement is not a loop obviously 3 11 1 9 next n 1 interrupts execution of current seg resume the next iteration of the innermost enclosing loop within the current fonction call or top level loop If n is specified resume at the n th enclosing loop If n is bigger than the number of enclosing loops all enclosing loops are exited 142 3 11 1 10 return z 0 returns from current subroutine with result x 3 11 1 11 until a seq evaluates expression sequence seg until a is not equal to 0 i e until a is true If a is initially not equal to 0 seq is evaluated once more generally the condition on a is tested after execution of the seq not before as in while 3 11 1 12 while a seq while a is non zero evaluate the expression sequence seg The test is made before evaluating the seq hence in particular if a is initially equal to zero the seg will not be evaluated at all 3 11 2 Specific functions used in GP programming In addition to the general PARI functions it is necessary to have some functions which will be of use specifically for GP though a few of these can be accessed under library mode Before we start describing these we recall the difference between strings and keywords see Section 2 6 5 the latter don t get expanded at all and you can type them without any enclosing quotes The former are dynamic objects where everything o
77. as output by bnrinit 1 finds a relative equation for the class field corresponding to the modulus in bnr and the given congruence subgroup using Stark units set subgroup 0 if you want the whole ray class group The main variable of bnr must not be x and the ground field and the class field must be totally real and not isomorphic to Q over the rationnals use polsubcyclo or galoissubcyclo flag is optional and may be set to 0 to obtain a reduced relative polynomial 1 to be satisfied with any relative polynomial 2 to obtain an absolute polynomial and 3 to obtain the irreducible relative polynomial of the Stark unit 0 being default Example bnf bnfinit y 2 3 bnr bnrinit bnf 5 1 bnrstark bnr 0 returns the ray class field of Q V3 modulo 5 91 Remark The result of the computation depends on the choice of a modulus verifying special conditions By default the function will try few moduli choosing the one giving the smallest result In some extreme cases where the result is however very large you can tell the function to try more moduli by adding 4 to the value of flag Whether this flag is set or not the function may fail returning the error message Cannot find a suitable modulus in FindModule In this case the corresponding congruence group is a product of cyclic groups and for the time being the class field has to be obtained by splitting this group into its cyclic components The library syntax is bnrsta
78. be present in the table even if you set maxnum to zero In addition some single or double precision real numbers are predefined and their list is in the file paricom h 204 205 Index Some Word refers to PARI GP concepts SomeWord is a PARI GP keyword SomeWord is a generic index entry A Abelian extension 109 114 ADS fe he ee ee RE ee eee 56 ACCULACY sc ener Re 7 ACOs 6 8 be firs Rae oe ee Rw ee 56 O he oe a woe BK a 57 addell sirios 84 04 os 73 addhelp 244 4448244 8 65444 4 4 180 addhelp 0040 35 143 addii e m s srt a de a 151 o A Sk oer Go oe ged 151 addis is ieee A eae oe bee eee 151 adal i i aaa ack ey Gh ow oe ey Gree 183 addllX fees ee eee ee Dee ee 183 addmul sos a sor be ee we s 184 addprimes 62 63 e ton Got glace Ble Me ee oe be ke 151 addrr sg 45 eae dn ab A ee 151 addsil 2a Aeeeak sae bd aes 2a 189 adj se sean wee ae ee ae 123 adjoint matrix 123 AFFILE co aoe we GR A Go E 186 Affi fone ghira A Bake Oe hee Eee 186 o e eg G S 1 e a yani x oe ey Grdes 186 Fa i a a iore ndase antaya 186 BLES pss Are SAR AO Ae 186 affs a deso ow eee fe Se aed 185 LESY ies Ble Ey oe ete Se ale 186 atisZ o eine be eS EA A Ee 185 OPM wb ee eee ee ae ee ee 57 akell s peat de sr 73 algdep os eb ese ee sis 120 121 aledepO 4 s re BRS ge be Swe 121 algebraic dependence 120 algtobasiS o mm ee pa ss 99 alias mu 0 RG RA 4 36
79. bnfisprincipal That is a 3 component vector v where v 1 is the vector of components of x on the ray class group generators v 2 gives on the integral basis an element a such that z a g Finally v 3 indicates the number of bits of accuracy left in the result In any case the result is checked for correctness but v 3 is included to see if it is necessary to increase the accuracy in other computations If flag 0 outputs only v The settings flag 2 or 3 are not available in this case The library syntax is isprincipalrayall bnr x flag 3 6 28 bnrrootnumber bnr chi flag 0 if x chi is a not necessarily primitive character over bnr let L s x X q x id N id be the associated Artin L function Returns the so called Artin root number i e the complex number W x of modulus 1 such that A 8 x W x A s X where A s x A x 7 s L s x is the enlarged L function associated to L The generators of the ray class group are needed and you can set flag 1 if the character is known to be primitive Example bnf bnfinit x 2 145 bnr bnrinit bnf 7 1 bnrrootnumber bnr 5 returns the root number of the character x of Cl7 Q V145 such that x g where g is the generator of the ray class field and e 7 N where N is the order of g N 12 as bnr cyc readily tells us The library syntax is bnrrootnumber bnf chi flag 3 6 29 bnrstark bnr subgroup flag 0 bnr being
80. called diffptr of type byteptr pointer to unsigned char Its use is described in appendix C e access to all the built in functions of the PARI library These are declared to the outside world when you include pari h but need the above things to function properly So if you forget the call to pari_init you will immediately get a fatal error when running your program usually a segmentation fault 4 2 Important technical notes 4 2 1 Typecasts We have seen that due to the non recursiveness of the PARI types from the compiler s point of view many typecasts will be necessary when programming in PARI To take an example a vector V of dimension 2 two components will be represented by a chunk of memory pointed to by the GEN V V O contains coded information in particular about the type of the object its length etc V 11 and V 2 contain pointers to the two components of V Those coefficients V i themselves are in chunks of memory whose complexity depends on their own types and so on This is where typecasting will be necessary a priori V i for i 1 2 is a long but we will want to use it as a GEN The following two constructions will be exceedingly frequent x and V are GENs V il long x x GEN VLil Note that a typecast is not a valid lvalue cannot be put on the left side of an assignment so GEN V i x would be incorrect though some compilers may accept it Due to this annoyance the PARI functions and v
81. can avoid gerepile altogether by creating sufficiently large objects at the beginning using cgetg and then using assignment statements and operations ending with z such as gaddz Coming back to our first example note that if we know that x and y are of type real and of length less than or equal to 5 we can program without using gerepile at all z cgetr 5 ltop avma p1 gsqr x p2 gsqr y gaddz p1 p2 z avma ltop This practice will usually be slower than a craftily used gerepile though and is certainly more cumbersome to use As a rule assignment statements should generally be avoided Thirdly the philosophy of gerepile is the following keep the value of the stack pointer avma at the beginning and just before the last operation Afterwards it would be too late since the lower end address of the garbage zone would have been lost Of course you can always use gerepileupto but you will have to assume that the object was created before its components Finally if everything seems hopeless at the expense of speed you can do the following after saving the value of avma in 1top perform your computation as you wish in any order leaving a messy stack Let z be your result Then write the following z gerepileupto ltop gcopy z 162 The trick is to force a copy of z to be created at the bottom of the stack hence all the rest including the initial z becomes connected garbage If you need to keep more than one resul
82. can be of any type If n is given and an exact square root had to be computed in the checking process puts that square root in n This is in particular the case when x is an integer or a polynomial This is not the case for intmods use quadratic reciprocity or series only check the leading coefficient The library syntax is gcarrecomplet x amp n Also available is gcarreparfait x 3 4 33 issquarefree zx true 1 if x is squarefree false 0 if not Here x can be an integer or a polynomial The library syntax is gissquarefree x but the simpler function issquarefree x which returns a long should be used if x is known to be of type integer This issquarefree is just the square of the Moebius function and is computed as a multiplicative arithmetic function much like the latter 3 4 34 kronecker x y Kronecker i e generalized Legendre symbol 2 x and y must be of type integer The library syntax is kronecker z y the result 0 or 1 is a long 3 4 35 lem x y least common multiple of x and y i e such that lem x y egcd z y abs x y The library syntax is glem z y 3 4 36 moebius z Moebius y function of x z must be of type integer The library syntax is mu z the result 0 or 1 is a long 3 4 37 nextprime z1 finds the smallest prime greater than or equal to x x can be of any real type Note that if x is a prime this function returns and not the smallest prime strictly larger than z T
83. charac ters is typed by the user at the GP prompt This can be either aX command a function definition an expression or a sequence of expressions i e a program In the latter two cases after the last expression has been computed its result is put into an internal history array and printed The successive elements of this array are called 1 42 As a shortcut the latest computed expression can also be called the previous one the one before that and so on If you want to suppress the printing of the result for example because it is a long unimportant intermediate result end the expression with a sign This same sign is used as an instruction separator when several instructions are written on the same line note that for the pleasure of BASIC addicts the sign can also be used but we will try to stick to C style conventions in this manual The final expression computed even if not printed will still be assigned to the history array so you may have to pay close attention when you intend to refer back to it by number since this number does not appear explicitly Of course if you just want to use it on the next line use as usual Any legal expression can be typed in and is evaluated using the conventions about operator priorities and left to right associativity see the previous section using the available operator symbols function names including user defined functions and member functions see Section 2
84. comments if keyword is not defined and read normally otherwise The condition can be negated using either if not or if Only two keywords are recognized EMACS defined if GP is running in an Emacs shell see Section 2 9 READL defined if GP is compiled with readline support see Section 2 10 1 For instance you could set your prompt in the following portable way self modifying prompt looking like 18 03 gp gt 37 prompt R e imgp e m gt readline wants non printing characters to be braced between A B pairs Hif READL prompt R Alde lim Bgp Alelm B gt escape sequences not supported under emacs Hif EMACS prompt R gp gt After the preprocessing there remain two types of lines e lines of the form default value where default is one of the available defaults see Section 2 1 which will be set to value on actual startup Don t forget the quotes around strings e g for prompt or help e lines of the form read some_GP_file where some_GP_file is a regular GP script this time which will be read just before GP prompts you for commands but after initializing the defaults This is the right place to input files containing alias commands or your favorite macros A sample gprc file called gprc dft is provided in the standard distribution in directory lib It s a good idea to have a look at it and customize it to your needs 2 9 Using GP under GNU Emacs Thanks to th
85. containing in this order z p4 p3 p2 p1 The garbage here consists of p1 and p3 which are separated by p2 But if we compute p3 before p2 then the garbage becomes connected and we get the following program with garbage collecting ltop avma pl gsqr x p3 gsqr y lbot avma z cgetg 3 t_VEC z 1 ladd pl y z 2 ladd p3 x z gerepile ltop lbot z Finishing by z gerepileupto ltop z would be ok as well But when you have the choice it s usually clearer to brace the garbage between 1top 1bot pairs Beware that ltop avma pl gadd gsqr x y p3 gadd gsqr y x z cgetg 3 t_VEC z 1 Clong pl z 2 long p3 z gerepileupto ltop z WRONG x would be a disaster since p1 and p3 would be created before z so the call to gerepileupto would overwrite them leaving z 1 and z 2 pointing at random data We next want to write a program to compute the product of two complex numbers x and y using a method which takes only 3 multiplications instead of 4 Let z xy and set x 71 2 and similarly for y and z The well known trick is to compute p r Yr po Ui Yi P3 r zi Yr yi and then we have zr pi po zi p3 p p2 The program is essentially as follows ltop avma pi gmul x 1 y 1 p2 gmul x 21 y 21 p3 gmul gadd x 1 x 2 gadd y 1 y 2 160 p4 gadd p1 p2 lbot avma z cgetg 3 t_COMPLEX z 1 lsu
86. definitely advisable to install Linux or FreeBSD on your machine Note added in version 2 0 12 Most UNIX goodies are now available for DOS OS 2 and Windows 3 1 thanks to the EMX runtime package install excluded under DOS since DLLs are not supported by the OS For Windows 95 98 and NT you can use the EMX binary in a DOS Window or re compile a native one using the Cygwin package None of these versions has been tested extensively If you have GNU Emacs you can work in a special Emacs shell see Section 2 9 which is started by typing M x gp where as usual M is the Meta key if you accept the default stack prime and buffer sizes or C u M x gp which will ask you for the name of the gp executable the stack size the prime limit and the buffer size Specific features of this Emacs shell will be indicated by an EMACS sign If a preferences file or gprc to be discussed in Section 2 8 can be found GP will then read it and execute the commands it contains This provides an easy way to customize GP without having to delve into the code to hardwire it to your likings A copyright message then appears which includes the version number Please note this number so as to be sure to have the most recent version if you wish to have updates of PARI The present manual is written for version 2 0 19 and has undergone major changes since the 1 39 xx versions On the Macintosh even after clicking on the gp icon once in the MPW Shell you st
87. differently e If the argument is a polynomial power series or rational function it is if necessary first converted to a power series using the current precision held in the variable precd1 Under GP this again is transparent to the user When programming in library mode however the global variable precdl must be set before calling the function if the argument has an exact type i e not a power series Here precdl is not an argument of the function but a global variable Then the Taylor series expansion of the function around X 0 where X is the main variable is computed to a number of terms depending on the number of terms of the argument and the function being computed e If the argument is a vector or a matrix the result is the componentwise evaluation of the function In particular transcendental functions on square matrices which are not implemented in the present version 2 0 19 see Appendix B however will have a slightly different name if they are implemented some day 3 3 1 If y is not of type integer x y has the same effect as exp y 1n x It can be applied to p adic numbers as well as to the more usual types The library syntax is gpow x y prec 3 3 2 Euler Euler s constant 0 57721 Note that Euler is one of the few special reserved names which cannot be used for variables the others are I and Pi as well as all function names The library syntax is mpeuler prec where prec must be given Note that thi
88. does not have to match the one used in library mode but consistency is nice It has to be a valid GP identifier i e use only alphabetic characters digits and the underscore character _ the first character being alphabetic Then you have to figure out the correct parser code corresponding to the function prototype This has been explained above Section 4 9 2 Now assuming your Operating System is supported by install simply write a GP script like the following install name code gpname library addhelp gpname some help text see Section 3 11 2 1 and 3 11 2 13 The addhelp part is not mandatory but very useful if you want others to use your module Read that file from your GP session from your preferences file for instance see Section 2 8 and that s it you can use the new function gpname under GP and we would very much like to hear about it 4 9 5 Integration the hard way If install is not available for your Operating System it s more complicated you have to hardcode your function in the GP binary or install Linux Here s what needs to be done In the definition of functions basic file language init c add your entry in exact alpha betical order by its GP name note that digits come before letters in a line of the form gpname V void libname secno code cbr where libname is the name of your function in library mode gpname the name that you have chosen to call it under GP secno i
89. ee 81 ZEST com goon ded ah Ho GS we Re GS 81 ZOOS marisco BR ae wes i ZNOTACY Ha goa os Be ee ek we Bs 12 ZNPT IMTOOD como comas mess 12 ZOSTIO 2 6 6 na os aia E a 72 222
90. gceil x 3 2 18 centerlift x v lifts an element x a mod n of Z nZ to a in Z and similarly lifts a polmod to a polynomial This is the same as 1ift except that in the particular case of elements of Z nZ the lift y is such that n 2 lt y lt n 2 If x is of type fraction complex quadratic polynomial power series rational function vector or matrix the lift is done for each coefficient Real and p adics are forbidden The library syntax is centerliftO z v where v is a long and an omitted v is coded as 1 Also available is centerlift x centerlift0 x 1 3 2 19 changevar z y creates a copy of the object x where its variables are modified according to the permutation specified by the vector y For example assume that the variables have been introduced in the order x a b c Then if y is the vector x c a b the variable a will be replaced by c b by a and c by b x being unchanged Note that the permutation must be completely specified e g c a b would not work since this would replace x by c and leave a and b unchanged as well as c which is the fourth variable of the initial list In particular the new variable names must be distinct The library syntax is changevar z y 3 2 20 components of a PARI object There are essentially three ways to extract the components from a PARI object The first and most general is the function component x n which extracts the n component of x This is to be under
91. given as a Z basis the second being a r rg component row vector giving the complex logarithmic Archimedean information 79 a Zk generating system for an ideal a column vector x expressing an element of the number field on the integral basis in which case the ideal is treated as being the principal idele or ideal generated by zx a prime ideal i e a 5 component vector in the format output by idealprimedec a polmod z i e an algebraic integer in which case the ideal is treated as being the principal idele generated by zx an integer or a rational number also treated as a principal idele ea character on the Abelian group Q Z N Z g is given by a row vector x a an such that x 9 exp 2i7 gt ain N Warnings 1 An element in nf can be expressed either as a polmod or as a vector of components on the integral basis nf zk It is absolutely essential that all such vectors be column vectors 2 When giving an ideal by a Zx generating system to a function expecting an ideal it must be ensured that the function understands that it is a Z generating system and not a Z generating system When the number of generators is strictly less than the degree of the field there is no ambiguity and the program assumes that one is giving a Zx generating set When the number of generators is greater than or equal to the degree of the field however the program assumes on the contrary that you are giving
92. ideallllred nf x vdir prec where an omitted vdir is coded as NULL 3 6 57 idealstar nf flag 1 nf being a number field and J either and ideal in any form or a row vector whose first component is an ideal and whose second component is a row vector of r 0 or 1 outputs necessary data for computing in the group Zx 1 If flag 2 the result is a 5 component vector w w 1 is the ideal or module I itself w 2 is the structure of the group The other components are difficult to describe and are used only in conjunction with the function ideallog If flag 1 default as flag 2 but do not compute explicit generators for the cyclic components which saves time If flag 0 computes the structure of Zg I as a 3 component vector v v 1 is the order v 2 is the vector of SNF cyclic components and v 3 the corresponding generators When the row vector is explicitly included the non zero elements of this vector are considered as real embeddings of nf in the order given by polroots i e in nf 6 nf roots and then J is a module with components at infinity To solve discrete logarithms using ideallog you have to choose flag 2 The library syntax is idealstar0 nf J flag 3 6 58 idealtwoelt nf x a computes a two element representation of the ideal x in the number field nf using a straightforward exponential time search x can be an ideal in any form including perhaps an Archimedean part which is ignored
93. in issquare z amp e 3 1 Standard monadic or dyadic operators 3 1 1 The expressions x and zx refer to monadic operators the first does nothing the second negates 2 The library syntax is gneg x for 2 3 1 2 The expression x y is the sum and x y is the difference of x and y Among the prominent impossibilities are addition subtraction between a scalar type and a vector or a matrix between vector matrices of incompatible sizes and between an integermod and a real number The library syntax is gadd z y x y gsub z y for x y 3 1 3 The expression x y is the product of x and y Among the prominent impossibilities are multiplication between vector matrices of incompatible sizes between an integermod and a real number Note that because of vector and matrix operations is not necessarily commutative Note also that since multiplication between two column or two row vectors is not allowed to obtain the scalar product of two vectors of the same length you must multiply a line vector by a column vector if necessary by transposing one of the vectors using the operator or the function mattranspose see Section 3 8 If x and y are binary quadratic forms compose them See also qfbnucomp and qfbnupor The library syntax is gmul x y for x y Also available is gsqr x for x x faster of course 3 1 4 The expression x y is the quotient of x and y In addition to the impossibilities for multip
94. is less than b In both these cases x is assumed to have integral entries and the function searches for the minimal non zero vectors whenever b 0 If flag 2 x can have non integral real entries but b 0 is now meaningless uses Fincke Pohst algorithm The library syntax is qfminimoO zx b m flag also available are minim x b m flag 0 minim2 x b m flag 1 and finally fincke_pohst z b m prec flag 2 3 8 46 qfperfection x x being a square and symmetric matrix with integer entries representing a positive definite quadratic form outputs the perfection rank of the form That is gives the rank of the family of the s symmetric matrices v vt where s is half the number of minimal vectors and the v 1 lt i lt s are the minimal vectors As a side note to old timers this used to fail bluntly when x had more than 5000 minimal vectors Beware that the computations can now be very lengthy when x has many minimal vectors The library syntax is perf x 3 8 47 qfsign x signature of the quadratic form represented by the symmetric matrix x The result is a two component vector The library syntax is signat x 3 8 48 setintersect x y intersection of the two sets x and y The library syntax is setintersect z y 129 3 8 49 setisset 1 returns true 1 if x is a set false 0 if not In PARI a set is simply a row vector whose entries are strictly increasing To convert any vector and other objects
95. is not intended for the casual user 20 2 2 21 Xt prints the internal longword format of all the PARI types The detailed bit or byte format of the initial codeword s is explained in Chapter 4 but its knowledge is not necessary for a GP user 2 2 22 Mu prints the definitions of all user defined functions 2 2 23 um prints the definitions of all user defined member functions 2 2 24 v prints the version number and implementation architecture 680x0 Sparc Alpha other of the GP executable you are using In library mode you can use instead the two character strings PARIVERSION and PARIINFO which correspond to the first two lines printed by GP just before the Copyright message 2 2 25 w n filename writes the object number n n into the named file in raw format If the number n is omitted writes the latest computed object If filename is omitted appends to logfile the GP function write is a trifle more powerful as you can have filenames whose first character is a digit 2 2 26 x prints the complete tree with addresses and contents in hexadecimal of the internal representation of the latest computed object in GP As for s this is used primarily as a debugging device for PARI However used on a PARI integer it can be used as a decimal hexadecimal converter 2 2 27 y n switches simplify on 1 or off 0 If n is explicitly given set simplify to n 2 2 28 switches the timer on or off 2 2 29
96. it is identical to Pol The library syntax is gtopolyrev z v where v is a variable number 3 2 6 Ser z v x transforms the object x into a power series with main variable v x by default If x is a scalar this gives a constant power series with precision given by the default serieslength corresponding to the C global variable precd1 If x is a polynomial the precision is the greatest of precdl and the degree of the polynomial If x is a vector the precision is similarly given and the coefficients of the vector are understood to be the coefficients of the power series starting from the constant term i e the reverse of the function Pol The warning given for Pol applies here this is not a substitution function The library syntax is gtoser z v where v is a variable number i e a C integer 3 2 7 Set x converts x into a set i e into a row vector with strictly increasing entries x can be of any type but is most useful when x is already a vector The components of x are put in canonical form type t_STR so as to be easily sorted To recover an ordinary GEN from such an element you can apply eval to it The library syntax is gtoset z 3 2 8 Str x flag 0 converts x into a character string type t_STR the empty string if x is omitted To recover an ordinary GEN from a string apply eval to it The arguments of Str are evaluated in string context see Section 2 6 5 If flag is set treat x as a filena
97. loop We then take the square root of s in precision 3 the smallest possible The prec argument of transcendental functions here 3 is only taken into account when the arguments are exact objects and thus no a priori precision can be determined from the objects themselves To cater for this possibility if s is of type t_REAL we use the function setlg which effectively sets the precision of s to the required value Note that here since we are using a numeric value for a cget function the program will run slightly differently on 32 bit and 64 bit machines we want to use the smallest possible bit accuracy and this is equal to BITS_IN_LONG Note that the matrix x is allowed to have complex entries but the function gnorm12 guarantees that s is a non negative real number not necessarily of type t_REAL of course If we had not known this fact we would simply have added the instruction s greal s just after the for loop Note also that the function gnorml2 works as desired on matrices so we really did not need this loop at all s gnorm12 x would have been enough but we wanted to give examples of function usage Similarly it is of course not necessary to take the square root for testing whether the norm exceeds 1 In the fifth place note that we initialized the sum s to gzero which is an exact zero This is logical but has some disadvantages if all the entries of the matrix are integers or rational numbers the computation will
98. number but the converse is forbidden For that you must use the truncation or rounding function of your choice see section 3 2 It can also happen that y is not large enough or does not have the proper tree structure to receive the object x As an extreme example assume y is the zero integer with length equal to 2 Then all assignments of a non zero integer into y will result in an error message since y is not large enough to accommodate a non zero integer In general common sense will tell you what is possible keeping in mind the PARI philosophy which says that if it makes sense it is legal For instance the assignment of an imprecise object into a precise one does not make sense However a change in precision of imprecise objects is allowed 4 5 All functions ending in z such as gaddz see Section 4 2 2 implicitly use this function In fact what they exactly do is record avma see Section 4 4 perform the required operation gaffect the result to the last operand then restore the initial avma You can assign ordinary C long integers into a PARI object not necessarily of type t_INT Use the function gaffsg with the following syntax void gaffsg long s GEN y Note due to the requirements mentionned above it s usually a bad idea to use gaffect statements Two exceptions e for simple objects e g leaves whose size is controlled they can be easier to use than gerepile and about as efficient e to coerce an inexact ob
99. of the object x on the heap GEN greffe GEN x long 1 int use_stack applied to a polynomial x type t_POL creates a power series type t_SER of length 1 starting with x but without actually copying the coefficients just the pointers If use_stack is zero this is created through malloc and must be freed after use Intended for internal use only double rtodbl GEN x applied to a real x type t_REAL converts x into a C double if possible GEN dbltor double x converts the C double x into a PARI real double gtodouble GEN x if x is a real number but not necessarily of type t_REAL converts x into a C double if possible long gtolong GEN x if x is an integer not a C long but not necessarily of type t_INT converts x into a C long if possible GEN gtopoly GEN x long v converts or truncates the object x into a polynomial with main variable number v A common application would be the conversion of coefficient vectors GEN gtopolyrev GEN x long v converts or truncates the object x into a polynomial with main variable number v but vectors are converted in reverse order GEN gtoser GEN x long v converts the object x into a power series with main variable number v GEN gtovec GEN x converts the object x into a row vector GEN co8 GEN x long 1 applied to a quadratic number x type t_QUAD converts x into a real or complex number depending on the sign of the discriminant of x to precision 1 BIL bit words GEN gcvtop GEN
100. of the setting of this default an object can be printed in any of the three formats at any time using the commands Na m and b respectively see below 2 1 15 parisize default 1M bytes on the Mac 4M otherwise GP and in fact any program using the PARI library needs a stack in which to do its computations parisize is the stack size in bytes It is strongly recommended you increase this default using the s command line switch or a gprc if you can afford it Don t increase it beyond the actual amount of RAM installed on your computer or GP will spend most of its time paging In case of emergency you can use the allocatemem function to increase parisize once the session is started GP will try to double the stack size by itself when memory runs low during a computation but this very computation will then be lost and you will have to type the command again 2 1 16 path default gp on UNIX systems C C GP on DOS OS 2 and Windows and otherwise This is a list of directories separated by colons semicolons in the DOS world since colons are pre empted for drive names When asked to read a file whose name does not contain i e no explicit path was given GP will look for it in these directories in the order they were written in path Here as usual means the current directory and its immediate parent Tilde expansion is performed 2 1 17 prettyprinter default the name of a
101. of the stack pi gsqr x p2 gsqr y lbot avma keep the address of the bottom of the garbage pile z gadd p1 p2 z is now the last object on the stack z gerepile ltop lbot z garbage collecting Of course the last two instructions could also have been written more simply z gerepile ltop lbot gadd p1 p2 In fact gerepileupto is even simpler to use because the result of gadd will be the last object on the stack and gadd is guaranteed to return an object suitable for gerepileupto 159 ltop avma z gerepileupto ltop gadd gsqr x gsqr y As you can see in simple conditions the use of gerepile is not really difficult However make sure you understand exactly what has happened before you go on use the figure from the preceding section Important remark as we will see presently it is often necessary to do several gerepiles during a computation However the fewer the better The only condition for gerepile to work is that the garbage be connected If the computation can be arranged so that there is a minimal number of connected pieces of garbage then it should be done that way For example suppose we want to write a function of two GEN variables x and y which creates the vector x y y x Without garbage collecting one would write p1 gsqr x p2 gadd p1 y p3 gsqr y p4 gadd p3 x z cgetg 3 t_VEC z 1 long p2 z 2 long p4 This leaves a dirty stack
102. or negative exponents This yields an element such that for all prime ideals p occurring in x vp a is equal to the exponent of p in x and for all other prime ideals Up a gt 0 This generalizes idealappr nf x 0 since zero exponents are allowed Note that the algorithm used is slightly different so that idealapp nf idealfactor nf x may not be the same as idealappr nf x 1 The library syntax is idealapprO nf x flag 3 6 40 idealchinese nf x y x being a prime ideal factorization i e a 2 by 2 matrix whose first column contain prime ideals and the second column integral exponents y a vector of elements in nf indexed by the ideals in x computes an element b such that Up b Yp gt Up x for all prime ideals in x and vp b gt 0 for all other p The library syntax is idealchinese nf x y 3 6 41 idealcoprime nf x y given two integral ideals x and y in the number field nf finds a 8 in the field expressed on the integral basis nf 7 such that 8 y is an integral ideal coprime to zx The library syntax is idealcoprime nf x 3 6 42 idealdiv nf x y flag 0 quotient x y of the two ideals x and y in the number field nf The result is given in HNF If flag is non zero the quotient x y is assumed to be an integral ideal This can be much faster when the norm of the quotient is small even though the norms of x and y are large The library syntax is idealdivO nf x y flag Also available are ideald
103. performed This is no longer true when more than two arguments are involved If the exponent is not of type integer this is treated as a transcendental function see Sec tion 3 3 and in particular has the effect of componentwise powering on vector or matrices The library syntax is gpow x n prec for x7n 3 1 10 shift x n or x lt lt n x gt gt n shifts x componentwise left by n bits if n gt 0 and right by n bits if n lt 0 A left shift by n corresponds to multiplication by 2 A right shift of an integer x by n corresponds to a Euclidean division of x by 2 with a remainder of the same sign as x hence is not the same in general as 112 The library syntax is gshift x n where n is a long 3 1 11 shiftmul x n multiplies x by 2 The difference with shift is that when n lt 0 ordinary division takes place hence for example if x is an integer the result may be a fraction while for shift Euclidean division takes place when n lt 0 hence if x is an integer the result is still an integer The library syntax is gmul2n x n where n is a long 45 3 1 12 Comparison and boolean operators The six standard comparison operators lt lt gt gt are available in GP and in library mode under the names gle glt gge get geq gne respectively The library syntax is co x y where co is the comparison operator The result is 1 as a GEN if the comparison is true 0 as a GEN if it is fals
104. s ds wa ae eee wh ee eB SES 144 211 SSCR ANG n 2 ries in ys Sy GE ee E 144 getstack o cas oered aouu ess 144 pettine a ees ru ote a A e 144 get timer co ree ee eK a 172 GCuLer usina eaa a 203 A ss sebe siaa ee ee 116 BERD Ae m a ale Bae ee E e 59 173 SOXPO o r ca e Bee wk 164 184 190 Bloor 2 eke eek pe we ee tia Dl 192 BIAC as a tea ao RRA ol 192 SEAM fo ha oe Rh o he Ae Ge cle 59 BSAMMA se kk bee ew ER wee ww SE 59 OSC oe 2 wiki a eet a ere eet Grate Gate 67 194 EGE nee oa Oe a he BS as 45 SEprecision sse ryssar eee es 53 ggrandocp du iia daa ke E 115 SED be in e ge ee es 45 a ap yee poa ae Be a ere 54 191 Chal Lua wh Boe eh ee 149 ghell guidance SO he aM ee ae eo 75 ghell2 24s ee he eae e 75 ea AE E tga a ds a E 149 GIMAS so secre oa HG e o e 5l BIN e epa ee de ee Sa aE is Bg 192 SAD VMOd e take ik Soak Gs ie A Ele 194 gisfundamental 67 gisirreducible 117 SISPCMO vay a ee a gd wi ek Ke 67 S SPSP fb eee ee eee we ee as 67 gissquarefree 68 Slambd aks eae oe Ja eo ts ee Ee 115 SLOM ie isk a o wk eee S 68 194 B O beh Be wc Be a we 45 SION EN pee gs wll as a et as Gea ae Gh Hh eG 5l gliigamma 2 00 mima e E aE a 60 global ui moi omiy HWE ap oaie d 33 global ag ea eels aed E ra na 29 144 globalreduction 75 Blog e sat ee don a 59 glo gag eredes spp ooa eh Bl a 59 Elo aoee agga ee OHA a E E i 45 MX aaa a a 46 smaxgs ZI se oir a e 192 emaxse ZI
105. same name The library syntax is matalgtobasis nf 1 3 6 62 matbasistoalg nf x nf being a number field in nfinit format and x a matrix whose coefficients are expressed as column vectors on the integral basis of nf transforms this matrix into a matrix whose coefficients are algebraic numbers expressed as polmods This is the same as applying nfbasistoalg to each entry but it would be dangerous to use the same name The library syntax is matbasistoalg nf x 3 6 63 modreverse a a being a polmod A X modulo T X finds the reverse polmod B X modulo Q X where Q is the minimal polynomial of a which must be equal to the degree of T and such that if 0 is a root of T then 0 B a for a certain root a of Q This is very useful when one changes the generating element in algebraic extensions The library syntax is polmodrecip z 3 6 64 newtonpoly x p gives the vector of the slopes of the Newton polygon of the polynomial x with respect to the prime number p The n components of the vector are in decreasing order where n is equal to the degree of x Vertical slopes occur iff the constant coefficient of x is zero and are denoted by VERYBIGINT the biggest single precision integer representable on the machine 231 1 resp 283 1 on 32 bit resp 64 bit machines see Section 3 2 43 The library syntax is newtonpoly z p 3 6 65 nfalgtobasis nf x this is the inverse function of nfbasistoalg Given an object x whose
106. since loop variables are not visible outside their loops the variable j need not be declared in the protoype of our zet function above zet s sumalt j 1 1 j 1 j7 s 1 27 1 s would be a perfectly sensible and in fact better definition Since local global scope is a very tricky point here s one more example What s wrong with the following definition first_prime_div x local p forprime p 2 x if x p 0 break 31 P first_prime_div 10 11 0 Answer the index p in the forprime loop is local to the loop and is not visible to the outside world Hence it doesn t survive the break statement More precisely at this point the loop index is restored to its preceding value which is 0 local variables are initialized to 0 by default To sum up the routine returns the p declared local to it not the one which was local to forprime and ran through consecutive prime numbers Here s a corrected version first_prime_div x forprime p 2 x if x fp 0 return p Again it is strongly recommended to declare all other local variables that are used inside a function if a function accesses a variable which is not one of its formal parameters the value used will be the one which happens to be on top of the stack at the time of the call This could be a global value or a local value belonging to any function higher in the call chain So be warned Recursive functions can easily be wr
107. star and x being a non necessarily integral element of nf which must have valuation equal to 0 at all prime ideals dividing J bid 1 computes the discrete logarithm of x on the generators given in bid 2 In other words if g are these generators of orders d respectively the result is a column vector of integers 1 such that 0 lt x lt di and z o mod I Note that when is a module this implies also sign conditions on the embeddings The library syntax is zideallog nf x bid 96 3 6 50 idealmin nf x vdir computes a minimum of the ideal x in the direction vdir in the number field nf The library syntax is minideal nf x vdir prec where an omitted vdir is coded as NULL 3 6 51 idealmul nf x y flag 0 ideal multiplication of the ideals x and y in the number field nf The result is a generating set for the ideal product with at most n elements and is in Hermite normal form if either x or y is in HNF or is a prime ideal as output by idealprimedec and this is given together with the sum of the Archimedean information in x and y if both are given If flag is non zero reduce the result using idealred The library syntax is idealmul nf x y flag 0 or idealmulred nf x y prec flag 0 where as usual prec is a C long integer representing the precision 3 6 52 idealnorm nf x computes the norm of the ideal x in the number field nf The library syntax is idealnorm nf x 3 6 53 ide
108. symbolic form see Section 4 5 for the list of these The precise effect of this function is as follows it first creates on the PARI stack a chunk of memory of size length longwords and saves the address of the chunk which it will in the end return If the stack has been used up a message to the effect that the PARI stack overflows will be printed and an error raised Otherwise it sets the type and length of the PARI object In effect it fills correctly and completely its first codeword z 0 or z Many PARI objects also have a second codeword types t_INT t_REAL t_PADIC t_POL and t_SER In case you want to produce one of those from scratch this should be exceedingly rare it is your responsibility to fill this second codeword either explicitly using the macros described in Section 4 5 or implicitly using an assignment statement using gaffect Note that the argument length is predetermined for a number of types 3 for types t_INTMOD t_FRAC t_FRACN t_COMPLEX t_POLMOD t_RFRAC and t_RFRACN 4 for type t_QUAD and t_QFI and 5 for type t_PADIC and t_QFR However for the sake of efficiency no checking is done in the function cgetg so disasters will occur if you give an incorrect length 153 Notes 1 The main use of this function is to prepare for later assigments see Section 4 3 2 Most of the time you will use GEN objects as they are created and returned by PARI functions In this case you don t need to use cgetg to c
109. the GP parser itself would This means it takes care of whitespace etc in the input and can do computations e g matid 2 or 1 0 0 1 are equally valid inputs Finally sor is the general output routine We have chosen to give d significant digits since this is what was asked for Note that there is a trick hidden here if a negative d was input then the computation will be done in precision 3 i e about 9 7 decimal digits for 32 bit machines and 19 4 for 64 bit machines and in the function sor giving a negative third argument outputs all the significant digits which is entirely appropriate Now let us attack the main course the function matexp GEN matexp GEN x long prec long 1x 1g8 x i k n 1bot ltop avma GEN y r s p1 p2 check that x is a square matrix if typ x t_MAT err talker this expression is not a matrix if 1x 1 return cgetg 1 t_MAT if 1x 1g x 11 err talker not a square matrix compute the Lo norm of x s gzero for i 1 i lt lx i s gadd s gnorml2 GEN x i if typ s t_REAL setlg s 3 s gsqrt s 3 we do not need much precision on s if s lt 1 we are happy k expo s if k lt 0 n 0 pt x else n k 1 pl gmul2n x n setexpo s 1 Before continuing several remarks are in order First before starting this computation which will produce garbage on the stack we have carefully saved the value of the stack po
110. the PARI stack GEN cgetg long n long t allocates memory on the PARI stack for an object of length n and type t and initializes its first codeword GEN cgeti long n allocates memory on the PARI stack for an integer of length n and initializes its first codeword Identical to cgetg n t_INT GEN cgetr long n allocates memory on the PARI stack for a real of length n and initializes its first codeword Identical to cgetg n t_REAL void cgiv GEN x frees object x if it is the last created on the PARI stack otherwise disaster occurs GEN gerepile long p long q GEN x general garbage collector for the PARI stack See Sec tion 4 4 for a detailed explanation and many examples 185 5 2 3 Assignments conversions and integer parts void mpaff GEN x GEN z assigns x into z where x and z are integers or reals void affsz long s GEN z assigns the long s into the integer or real z void affsi long s GEN z assigns the long s into the integer z void affsr long s GEN z assigns the long s into the real z void affii GEN x GEN z assigns the integer x into the integer z void affir GEN x GEN z assigns the integer x into the real z void affrs GEN x long s assigns the real x into the long s not This is a forbidden assign ment in PARI so an error message is issued void affri GEN x GEN z assigns the real x into the integer z no it doesn t This is a forbidden assignment in PARI so an error message is issued vo
111. the cursor Only the part of the rectangle which is in w is drawn The virtual cursor does not move 3 10 21 plotrecth w X a b ezpr flag 0 n 0 writes to rectwindow w the curve output of ploth w X a b expr flag n 3 10 22 plotrecthraw w data flag 0 plot graph s for data in rectwindow w flag has the same significance here as in ploth though recursive plot is no more significant data is a vector of vectors each corresponding to a list a coordinates If parametric plot is set there must be an even number of vectors each successive pair corresponding to a curve Otherwise the first one containe the x coordinates and the other ones contain the y coordinates of curves to plot 3 10 23 plotrline w dx dy draw in the rectwindow w the part of the segment x1 yl x1 dx yl dy which is inside w where x1 y1 is the current position of the virtual cursor and move the virtual cursor to x1 dx yl dy even if it is outside the window 3 10 24 plotrmove w dx dy move the virtual cursor of the rectwindow w to position x1 dx yl dy where x1 yl is the initial position of the cursor i e to position dx dy relative to the initial cursor 3 10 25 plotrpoint w dx dy draw the point x1 dx yl dy on the rectwindow w if it is inside w where x1 yl is the current position of the cursor and in any case move the virtual cursor to position x1 dx yl dy 3 10 26 plotscale w
112. the effective length of the polynomial x in BIL bit words long lgefint GEN x returns the effective length of the integer x in BIL bit words long signe GEN x returns the sign 1 0 or 1 of x Can be used for integers reals polynomials and power series for the last two types only 0 or 1 are possible long gsigne GEN x same as signe but also valid for rational numbers and marginally less efficient for the other types long expo GEN x returns the unbiased binary exponent of the real number x long gexpo GEN x same as expo but also valid when x is not a real number When x is an exact 0 this returns HIGHEXPOBIT long expi GEN x returns the binary exponent of the real number equal to the integer x This is a special case of gexpo above covering the case where x is of type t_INT 184 long valp GEN x returns the unbiased 16 bit p adic valuation for a p adic or X adic valuation for a power series taken with respect to the main variable of x long precp GEN x returns the precision of the p adic x long varn GEN x returns the variable number of x between 0 and MAXVARN Should be used only for polynomials and power series long gvar GEN x returns the main variable number when any variable at all occurs in the composite object x the smallest variable number which occurs and BIGINT otherwise void settyp GEN x long s sets the type number of x to s This should be used with extreme care since usually the ty
113. the generator a of the number field nf as a polynomial modulo the absolute equation vabs 1 vabs 3 is a small integer k such that if 8 is an abstract root of pol and a the generator of nf the generator whose root is vabs will be 6 ka Note that one must be very careful if k 4 0 when dealing simultaneously with absolute and relative quantities since the generator chosen for the absolute extension is not the same as for the relative one If this happens one can of course go on working but we strongly advise to change the relative polynomial so that its root will be 6 ka Typically the GP instruction would be pol subst pol x x k Mod y nf pol Finally vabs 4 is the absolute integral basis of L expressed in HNF hence as would be output by nfinit vabs 1 and vabs 5 the inverse matrix of the integral basis allowing to go from polmod to integral basis representation The library syntax is rnfinitalg nf pol prec 3 6 131 rnfisfree bnf x given a big number field bnf as output by bnfinit and either a polynomial x with coefficients in bnf defining a relative extension L of bnf or a pseudo basis x of such an extension returns true 1 if L bnf is free false 0 if not The library syntax is rnfisfree bnf x and the result is a long 3 6 132 rnfisnorm bnf ext el flag 1 similar to bnfisnorm but in the relative case This tries to decide whether the element el in bnf is the norm of some y in ext bnf is as output by
114. the monic mono mials of degrees 0 and 1 in v varentries v and polvar v The latter two are only meaningful to GP but they have to be set nevertheless All of them must be properly defined before you can use a given integer as a variable number Initially this is done for 0 the variable x under GP and MAXVARN which is there to address the need for a temporary new variable which would not be used in regular objects created by the library We call the latter type a temporary variable The regular variables meant to be used in regular objects are called user variables 4 6 2 1 User variables When the program starts x is the only user variable number 0 To define new ones use long fetch_user_var char s which inspects the user variable named s creating it if needed and returns its variable number long v fetch_user_var y GEN gy polx v This function raises an error if s is already known as a function name to the interpreter Caveat it is possible to use flissexpr see Section 4 7 1 to execute a GP command and create GP variables on the fly as needed GEN gy flissexpr y supposedly returns polx v for some v long v gvar gy This is dangerous especially when programming functions that will be used under GP The code above reads the value of y as it is currently known by the GP interpreter possibly creating it in the process All is well and good if y hasn t been tampered w
115. the usual way the recovery sequence rec is executed if the error occurs and the evaluation of rec becomes the result of the command If e is omitted all exceptions are trapped Note in particular that hitting C Control C raises an exception trap division by 0 inv x trap gdiver2 INFINITY 1 x inv 2 1 1 2 inv 0 2 INFINITY If seq is omitted defines rec as a default action when encountering exception e The error message is printed as well as the result of the evaluation of rec and the control is given back to the GP prompt In particular current computation is then lost The following error handler prints the list of all user variables then stores in a file their name and their values trap print reorder write crash reorder write crash eval reorder If no recovery code is given rec is omitted a so called break loop will be started During a break loop all commands are read and evaluated as during the main GP loop except that no history of results is kept To get out of the break loop you can use next break or return reading in a file by r will also terminate the loop once the file has been read read will remain in the break loop If the error is not fatal C is the only non fatal error next will continue the computation as if nothing had happened except of course you may have changed GP state during the break loop otherwise control will come back to the GP pro
116. to 1 i e n In z In 2 if z gt 1 and n 0 otherwise Then the series will converge at least as fast as the usual one for et and the cutoff error will be easy to estimate In fact a larger value of n would be preferable but this is slightly machine dependent and more complicated and will be left to the reader Let us start writing our program So as to be able to use it in other contexts we will structure it in the following way a main program which will do the input and output and a function which we shall call matexp which does the real work The main program is easy to write It can be something like this include lt pari h gt GEN matexp GEN x long prec int main long d prec 3 GEN x take a stack of 10 bytes no prime table pari_init 1000000 2 printf precision of the computation in decimal digits n d itos lisGEN stdin if d gt 0 prec long d pariK1 3 printf input your matrix in GP format n x matexp lisGEN stdin prec 173 sor x e d 0 exit 0 The variable prec represents the length in longwords of the real numbers used pariKl is a constant defined in paricom h equal to In 10 In 2 x BITS_IN_LONG which allows us to convert from a number of decimal digits to a number of longwords independently of the actual bit size of your long integers The function lisGEN reads an expression here from standard input and converts it to a GEN like
117. way The library syntax is mathnf0 z flag Also available are hnf x flag 0 and hnfall z flag 1 To reduce huge say 400 x 400 and more relation matrices sparse with small entries you can use the pair hnfspec hnfadd Since this is rather technical and the calling interface may change they are not documented yet Look at the code in basemath alglin1 c 3 8 19 mathnfmod x d if x is a not necessarily square matrix of maximal rank with integer entries and d is a multiple of the non zero determinant of the lattice spanned by the columns of x finds the upper triangular Hermite normal form of z If the rank of x is equal to its number of rows the result is a square matrix In general the columns of the result form a basis of the lattice spanned by the columns of x This is much faster than mathnf when d is known The library syntax is hnfmod z d 124 3 8 20 mathnfmodid z d outputs the upper triangular Hermite normal form of x concate nated with d times the identity matrix The library syntax is hnfmodid z d 3 8 21 matid n creates the n x n identity matrix The library syntax is idmat n where n is a long Related functions are gscalmat x n which creates x times the identity matrix x being a GEN and n a long and gscalsmat x n which is the same when z is a long 3 8 22 matimage z flag 0 gives a basis for the image of the matrix x as columns of a matrix A priori the matrix can have entries o
118. x qfbred z rhoreal x qfbred z 1 redrealnod z sq qfbred z 2 isqrtD rhorealnod z sq qfbred z 3 isqrtD The library syntax is primeform z p prec where the third variable prec is a long but is only taken into account when x gt 0 3 4 51 quadclassunit D flag 0 tech Buchmann McCurley s sub exponential algo rithm for computing the class group of a quadratic field of discriminant D If D is not fundamental the function may or may not be defined but usually is and often gives the right answer a warning is issued The more general function bnrinit should be used to compute the class group of an order This function should be used instead of qfbclassno or quadregula when D lt 10 D gt 101 or when the structure is wanted If flag is non zero and D gt 0 computes the narrow class group and regulator instead of the ordinary or wide ones In the current version 2 0 19 this doesn t work at all use the general function bnfnarrow Optional parameter tech is a row vector of the form c1 c2 where c and cz are positive real numbers which control the execution time and the stack size To get maximum speed set co c To get a rigorous result under GRH you must take cp 6 Reasonable values for c are between 0 1 and 2 The result of this function is a vector v with 4 components if D lt 0 and 5 otherwise The correspond respectively to e v 1 the class number e v 2
119. x GEN p long 1 converts x into a p adic number of precision 1 GEN gmodulcp GEN x GEN y creates the object Mod x y on the PARI stack where x and y are either both integers and the result is an integermod type t_INTMOD or x is a scalar or a polynomial and y a polynomial and the result is a polymod type t_POLMOD GEN gmodulgs GEN x long y same as gmodulcp except y is a long GEN gmodulss long x long y same as gmodulcp except both x and y are longs GEN gmodulo GEN x GEN y same as gmodulcp except that the modulus y is copied onto the heap and not onto the PARI stack long gexpo GEN x returns the binary exponent of x or the maximal binary exponent of the coefficients of x Returns HIGHEXPOBIT if x has no components or is an exact zero 190 long gsize GEN x returns 0 if x is exactly 0 Otherwise returns gexpo x multiplied by log p 2 This gives a crude estimate for the maximal number of decimal digits of the components of x long gsigne GEN x returns the sign of x 1 0 or 1 when x is an integer real or irreducible or reducible fraction Raises an error for all other types long gvar GEN x returns the main variable of x If no component of x is a polynomial or power series this returns BIGINT int precision GEN x If x is of type t_REAL returns the precision of x the length of x in BIL bit words if x is not zero and a reasonable quantity obtained from the exponent of x if x is numerically equal to zero
120. you have typed the command name will be completed If not either the list of commands starting with the letters you typed will be displayed in a separate window which you can then kill by typing as usual C x 1 or by typing in more letters or no match found will be displayed in the Emacs command line If your GP was linked with the readline library read the section on completion in the section below the paragraph on online help is not relevant Note that if for some reason the session crashes due to a bug in your program or in the PARI system you will usually stay under Emacs but the GP buffer will be killed To recover it simply type again M x gp or C u M x gp and a new session of GP will be started after the old one so you can recover what you have typed Note that this will of course not work if for some reason you exited Emacs before coming back except for the C z temporary stopping command You also have at your disposal a few other commands and many possible customizations colours prompt Read the file emacs pariemacs txt in standard distribution for details 2 10 Using GP with readline Thanks to the initial help of Ilya Zakharevich there is a possibility of line editing and command name completion outside of an Emacs buffer if you have compiled GP with the GNU readline library If you don t have Emacs available or can t stand using it we really advise you to make sure you get this very useful library before c
121. z where v is the number of the variable y 3 7 31 taylor x y Taylor expansion around 0 of x with respect to the simple variable y x can be of any reasonable type for example a rational function The number of terms of the expansion is transparent to the user under GP but must be given as a second argument in library mode The library syntax is tayl z y n where the long integer n is the desired number of terms in the expansion 3 7 32 thue inf a sol solves the equation P x y a in integers x and y where tnf was created with thueinit P sol if present contains the solutions of Norm a modulo units of positive norm in the number field defined by P as computed by bnfisintnorm If tnf was computed without assuming GRH flag 1 in thueinit the result is unconditional For instance here s how to solve the Thue equation 13 5y 3 4 tnf thueinit x 13 5 thue tnf 4 1 1 11 Hence assuming GRH the only solution is x 1 y 1 The library syntax is thue tnf a sol where an omitted sol is coded as NULL 3 7 33 thueinit P flag 0 initializes the tnf corresponding to P It is meant to be used in conjunction with thue to solve Thue equations P x y a where a is an integer If flag is non zero certify the result unconditionnaly Otherwise assume GRH this being much faster of course The library syntax is thueinit P flag prec 120 3 8 Vectors matrices linear algebr
122. z GEN x long s GEN z yields the maximum of the object x and the long s GEN gmin z GEN x GEN y GEN z yields the minimum of the objects x and y if they can be compared GEN gminsg z long s GEN x GEN z yields the minimum of the long s and the object x GEN gmings z GEN x long s GEN z yields the minimum of the object x and the long s GEN gadd z GEN x GEN y GEN z yields the sum of the objects x and y GEN gaddsg z long s GEN x GEN z yields the sum of the long s and the object x GEN gaddgs z GEN x long s GEN z yields the sum of the object x and the long s GEN gsublz GEN x GEN y GEN z yields the difference of the objects x and y GEN gsubgs z GEN x long s GEN z yields the difference of the object x and the long s GEN gsubsgl z long s GEN x GEN z yields the difference of the long s and the object x GEN gmul z GEN x GEN y GEN z yields the product of the objects x and y GEN gmulsg z long s GEN x GEN z yields the product of the long s with the object x GEN gmulgs z GEN x long s GEN z yields the product of the object x with the long s GEN gshift z GEN x long n GEN z yields the result of shifting the components of x left by n if n is non negative or right by n if n is negative Applies only to integers reals and vectors matrices of such For other types it is simply multiplication by 2 GEN gmul2n z GEN x long n GEN z yields the produc
123. z z ar los e These three functions satisfy the functional equation fm 1 x 1 fm z The library syntax is polylog0 m x flag prec 60 3 3 35 psi x the function of zx i e the logarithmic derivative D 1 D x The library syntax is gpsi z prec 3 3 36 sin x sine of x The library syntax is gsin z prec 3 3 37 sinh x hyperbolic sine of x The library syntax is gsh z prec 3 3 38 sqr x square of x This operation is not completely straightforward i e identical to xxx since it can usually be computed more efficiently roughly one half of the elementary multiplications can be saved Also squaring a 2 adic number increases its precision For example 1 0 2 4 2 41 1 0 275 1 0 2 4 1 0 274 42 1 0 274 Note that this function is also called whenever one multiplies two objects which are known to be identical e g they are the value of the same variable or we are computing a power x 1 0 2 4 x x 3 1 0 275 1 0 274 74 4 1 0 276 note the difference between 2 and 3 above The library syntax is gsqr z 3 3 39 sqrt x principal branch of the square root of x i e such that Arg sqrt x 7 2 7 2 or in other words such that R sqrt x gt 0 or R sqrt x 0 and S sqrt 1 gt 0 If x R and x lt 0 then the result is complex with positive imaginary part Integermod a prime and p adics are allowed as argu
124. 040 62 qfbclassno airis 69 qfbclassnoO o o 69 Qibcompraw o ooo ooo 69 qEbhclassmo os osas gaga ok el 69 218 QfbnUCOMP sss e wee a a 69 QEONUPOW essa ek ei 69 qfbpowraw a se Eaa E 69 qfbprimeform 69 Q DESA ira a e as et oat we A 70 ALDEA e lc o i a ee der 70 qfeval 244 40 8 bea a 8 tenira 116 qfgaussred o ooo o 127 Qfie 2 26 sra rd e Beg 62 a lA we A ee ee ee ee 127 GELLL fn eis wh ae hw ek aes 120 128 BEI hk aa Ss as 4 ocd OS Se 128 Gilllgram ai fea eh wb a a x 128 Gill gramO ss eS tee ae Wt oe ade es a 128 QEMINAM ee e dos a ae ii wo 129 QEMUM IMO e o oie de oe A EL He 129 qfperfection se scasc satsa 129 QIE amanea Be an bs amp tho a 62 GESTION 2 0d in e io ch A 129 quadclassunit 70 quadclassunitO 71 quaddis 2 54664 4 4694 ab ees val qUadgen iio a SE a aoe a ee i 2202 quadhilbert 71 quadpody sewe saa ae e a quadpolyO g eos opo d oo E E d g quadratic number 5 6 22 165 Quadray exo es eb Sc Ge Sp ays ral quadregulator 71 guadu nit s ss sa sa ee ee ee 72 A 20 146 GUO iva a ees G 146 quotient uds sona Aisi God Go ee da 44 R Rabin Miller 62 PACING awe has dik Ges oe Se ae 12 Lando edad o e a 53 TANK A EE ES 126 rational function 5 23 166 rational number 5 21 165 TOW FOTMOL econ a e 15 TAYCLASSNO poc ka a a e 89 rayclassnolist
125. 1 12 1 2 See also factornf The library syntax is factor0 x lim where lim is a C integer Also available are factor x factor0 x 1 smallfact x factor0 zx 0 3 4 20 factorback f nf f being any factorization gives back the factored object If a second argument nf is supplied f is assumed to be a prime ideal factorization in the number field nf The resulting ideal is given in HNF form The library syntax is factorback f nf where an omitted nf is entered as NULL 3 4 21 factorcantor x p factors the polynomial z modulo the prime p using distinct degree plus Cantor Zassenhaus The coefficients of x must be operation compatible with Z pZ The result is a two column matrix the first column being the irreducible polynomials dividing x and the second the exponents If you want only the degrees of the irreducible polynomials for example for computing an L function use factormod z p 1 Note that the factormod algorithm is usually faster than factorcantor The library syntax is factcantor z p 3 4 22 factorff x p a factors the polynomial x in the field F defined by the irreducible poly nomial a over Fp The coefficients of x must be operation compatible with Z pZ The result is a two column matrix the first column being the irreducible polynomials dividing x and the second the exponents It is recommended to use for the variable of a which will be used as variable of a polmod a name distinct from the ot
126. 10 7 plotdraw list physically draw the rectwindows given in list which must be a vector whose number of components is divisible by 3 If list wl a1 yl w2 x2 y2 the windows w1 w2 etc are physically placed with their upper left corner at physical position xl yl x2 y2 respectively and are then drawn together Overlapping regions will thus be drawn twice and the windows are considered transparent Then display the whole drawing in a special window on your screen 3 10 8 plotfile s set the output file for plotting output Special filename redirects to the same place as PARI output 3 10 9 ploth X a b expr flag 0 n 0 high precision plot of the function y f z represented by the expression expr x going from a to b This opens a specific window which is killed whenever you click on it and returns a four component vector giving the coordinates of the bounding box in the form xmin zmaz ymin ymaz Important note Since this may involve a lot of function calls it is advised to keep the current precision to a minimum e g 9 before calling this function n specifies the number of reference point on the graph 0 means use the hardwired default values that is 1000 for general plot 1500 for parametric plot and 15 for recursive plot If no flag is given expr is either a scalar expression f X in which case the plane curve y f X will be drawn or a vector f1 X f X and then all the c
127. 16 fetch user yar i gtd ew o e 168 fetch var si ra oa aa dens a 168 FLINGG se aos toee md aa aa 92 TADO a Saree a a Be we 67 fibonacci sa sosa ss ak oS 67 field discriminant 100 filename 13 TIGER fag ee ca a amp arse ee eee 169 fincke_pohst 244 eksera eS 129 finite field 4 4 4 4 8 amp Boe Bw Se 22 fixed floating point format 15 ELISOXPT oso GRRE ws 169 ELISEO ec ee HR ee ae 169 EL ESOXPT 2 bee ee De eee es 168 PIOOY cosas ge PG ee ek eee ee 51 TOO emma e a we E e a we a 43 TO Lu rasa aa 141 forcecopy 155 156 189 Ford 3 5 Gack aaa a a aa ae eR 99 fOFdiV hacen eee awe aha eea ds 141 formal integration 116 1OPMBt s sers acns g oa es Gah os 170 172 format 2 4868 6 eee o 15 TORPRAIMES dosis dada de 141 TOFSTED cu a eo ws ek Be Ae 141 forsubgroup 2 445 iae ante ee 141 forvet 2 6 wb o Ep ia gee ws 142 EPYINGLSrY s a isa ale Grae 172 179 frac aeea Grint BIR eG Aye Se Sn ate Bay Ge Gos 51 Bree BoD a cra a ada amp a 11 TU vee A NA 81 fundamental units 72 81 83 f nd nit s 22 he eee ee eee ee 12 TOTU 2 2 2 8 ee kw aE a a a ERS 81 210 gabs e eee a e o E ae we OR a 56 gach sor gineta ea 57 Sacos ua a e E e e 57 gadd nas a a as as e 44 Baddgs mii ra ee me to 151 BaddgsZ ee ee bg nee ee Pe a bees a 151 gaddgs z co sa ce bees ewe SS 193 gaddse sa cane SR bow wR Ba we 151 SaddSSZ 20000002000 daa 151 saddsglZl Lois pci Bae go as
128. 27 matisdiagonal z returns true 1 if x is a diagonal matrix false 0 if not The library syntax is isdiagonal x and this returns a long integer 3 8 28 matker z flag 0 gives a basis for the kernel of the matrix x as columns of a matrix A priori the matrix can have entries of any type If x is known to have integral entries set flag 1 Note The library function ker_mod p x p where x has integer entries and p is prime which is equivalent to but many orders of magnitude faster than matker x Mod 1 p and needs much less stack space To use it under GP type install ker_mod_p GG first The library syntax is matker0 x flag Also available are ker x flag 0 keri x flag 1 and ker_mod_p z p 125 3 8 29 matkerint x flag 0 gives an LLL reduced Z basis for the lattice equal to the kernel of the matrix x as columns of the matrix x with integer entries rational entries are not permitted If flag 0 uses a modified integer LLL algorithm If flag 1 uses matrixqz x 2 If LLL reduction of the final result is not desired you can save time using matrixqz matker x 2 instead If flag 2 uses another modified LLL In the present version 2 0 19 only independent rows are allowed in this case The library syntax is matkerint0 x flag Also available is kerint x flag 0 3 8 30 matmuldiagonal z d product of the matrix x by the diagonal matrix whose diagonal entries are those of the vector d
129. 47 qfbnupow x n n th power of the primitive positive definite binary quadratic form x using the NUCOMP and NUDUPL algorithms see qfbnucomp The library syntax is nupow z n 3 4 48 qfbpowraw z 7 n th power of the binary quadratic form x computed without doing any reduction i e using gfbcompraw Here n must be non negative and n lt 2 The library syntax is powraw x n where n must be a long integer 69 3 4 49 qfbprimeform z p prime binary quadratic form of discriminant x whose first coefficient is the prime number p Returns an error if x is not a quadratic residue mod p In the case where x gt 0 the distance component of the form is set equal to zero according to the current precision 3 4 50 qfbred z flag 0 D isqrtD sqrtD reduces the binary quadratic form x flag can be any of 0 default behaviour uses Shanks distance function d 1 uses d but performs only a single reduction step 2 does not compute the distance function d or 3 does not use d single reduction step D isqrtD sqrtD if present supply the values of the discriminant VD and VD respectively no checking is done of these facts If D lt 0 these values are useless and all references to Shanks s distance are irrelevant The library syntax is qfbredO z flag D isqrtD sqrtD Use NULL to omit any of D isqrtD sqrtD Also available are redimag x qfbred x where x is definite and for indefinite forms redreal
130. 4ac gt 0 initialize Shanks distance function to D The library syntax is QfbO a b c D prec Also available are qfi a b c when b 4ac lt 0 and qfr a b c d when b 4ac gt 0 62 3 4 2 addprimes x adds the primes contained in the vector x or the single integer x to the table computed upon GP initialization by pari_init in library mode and returns a row vector whose first entries contain all primes added by the user and whose last entries have been filled up with 1 s In total the returned row vector has 100 components Whenever factor or smallfact is subsequently called first the primes in the table computed by pari_init will be checked and then the additional primes in this table If x is empty or omitted just returns the current list of extra primes The entries in x are not checked for primality They need only be positive integers not divisible by any of the pre computed primes It s in fact a nice trick to add composite numbers which for example the function factor x 0 was not able to factor In case the message impossible inverse modulo some integermod shows up afterwards you have just stumbled over a non trivial factor Note that the arithmetic functions in the narrow sense like eulerphi do not use this extra table The present PARI version 2 0 19 allows up to 100 user specified primes to be appended to the table This limit may be changed by altering NUMPRTBELT in file init c To re
131. Another tricky point here assume you did not assign a value to aaa in a GP expression before Then typing aaa by itself in a string context will actually produce the correct output i e the string whose content is aaa but in a fortuitous way This aaa gets expanded to the monomial of degree one in the variable aaa which is of course printed as aaa and thus will expand to the three letters you were expecting e Since there are cases where expansion is not really desirable we now distinguish between Keywords and Strings String is what has been described so far Keywords are special relatives of Strings which are automatically assumed to be quoted whether you actually type in the quotes or not Thus expansion is never performed on them They get concatenated though The analyzer supplies automatically the quotes you have forgotten and treats Keywords just as normal strings otherwise For instance if you type a b b in Keyword context you will get the string whose contents are ab b In String context on the other hand you would get a2xb All GP functions have prototypes described in Chapter 3 below which specify the types of arguments they expect either generic PARI objects GEN or strings or keywords or unevaluated expression sequences In the keyword case only a very small set of words will actually be meaningful the default function is a prominent example Let s now try some not so stupid exercises to get the h
132. LIST All the remaining elements of list from position n 1 onwards are shifted to the right This and listput are the only commands which enable you to increase a list s effective length as long as it remains under the maximal length specified at the time of the listcreate This function is useless in library mode 3 8 7 listkill list kill list This deletes all elements from list and sets its effective length to 0 The maximal length is not affected This function is useless in library mode 3 8 8 listput list x n sets the n th element of the list list which must be of type t_LIST equal to x If n is omitted or greater than the list current effective length just appends x This and listinsert are the only commands which enable you to increase a list s effective length as long as it remains under the maximal length specified at the time of the listcreate If you want to put an element into an occupied cell i e if you don t want to change the effective length you can consider the list as a vector and use the usual list n x construct This function is useless in library mode 3 8 9 listsort list flag 0 sorts list which must be of type t_LIST in place If flag is non zero suppresses all repeated coefficients This is much faster than the vecsort command since no copy has to be made This function is useless in library mode 3 8 10 matadjoint x adjoint matrix of x i e the matrix y of cofactors of x satis
133. MEPAtOK aose ras Se ee a ew 52 numerical integration 132 DUMtOPerDO 2 4 sesa ew REE Ee 52 NUPOW oi a a a ee A 69 N ron Tate height 75 O AA A ee ee te eer E 27 115 OMA ooh ee G4 eB SY AEE ES yall OMEGA o ewe ae ee HE 68 73 OCULTO pea a Awe ks Soe ole Sd 76 OPEO kos edo a hk e GOR eS a 24 OM dabu ade 5 ta des Sev aS ses we see GS 45 DE dias bt Ta aa He ke cea 49 ordell tua a dt a ed Ne OTOT usara ra T2 orderell aa ressora reerrraa TT ordre ss p etos oag Aos ahga oge bed 108 QUEDESAUL s ka dk Be ade 170 QUEDTIES singa e wack Bea S 170 OUCTING so puelic Ta aa hk ow A 171 QUEMAD bee a de oe eh 170 output formats s s acas ga eai eiea 12 OUtp b sa sa saoe remato e a 170 OQUCPUE 24 ee e aa 15 20 170 172 P p adic number 9 22 165 padicappr 2 4 se 64644 0 lt 20000 s 116 PAdicprel saae e santos mes ew 52 parametric plot s sses ssiscce rs 137 Parcial 4 ee pri eee e 149 PariErT ia isa a a ds a iyl pariKi oe i mie alas ae a as 173 paril t see s sri nie a ee Irl PariPerl s sos osa eiaa ape g e 4 36 Pariputs e sacrae nasies moe we te 179 PariPython gt s soe sa 42 be dee si 36 ParisiZe lo dd Gow ee wb ae ae 16 pari Init 149 150 203 parser code oaoa 177 179 Pascal triangle sa 402 sie yos sm pue 126 path oe eka ewe ee ee ee es 16 Pert wee tadve weed tow ee Gi x 129 Perl ic eee bs egg ee Be ee dee ae 36 POFMCONUM s a s sosea e wo ae ee Gt 52 PSIMUTS s ss sar
134. Meta key can give funny re sults output 8 bit accented characters for instance If you don t want to fall back to the Esc combination put the following two lines in your inputrc set convert meta on set output meta off 2 10 2 Command completion and online help As in the Emacs shell lt TAB gt will complete words for you But under readline this mechanism will be context dependent GP will strive to only give you meaningful completions in a given context it will fail sometimes but only under rare and restricted conditions For instance shortly after a we expect a user name then a path to some file Directly after default has been typed we would expect one of the default keywords After whatnow we expect the name of an old function which may well have disappeared from this version After a we expect a member keyword And generally of course we expect any GP symbol which may be found in the hashing lists functions both yours and GP s and variables If at any time only one completion is meaningful GP will provide it together with e an ending comma if we re completing a default e a pair of parentheses if we re completing a function name In that case hitting lt TAB gt again will provide the argument list as given by the online help recall that you can always undo the effect of the preceding keys by hitting C _ 40 Otherwise hitting lt TAB gt once more will give you the list of possible c
135. ONT TACO 2444 4 9 424 eed ox 64 contfracpnqn 64 continued fraction 64 Control statements 141 conversions 2 0000 156 CONVO serra 119 COOrdCh ke we ee ee 74 COPY se oh ad Pe e a a De 155 COLO 64 hbk Awe eee Rea SA wd 64 COED sea kde bee e bawdawe 64 COTE nu Shwe bee Ae Bo oe ee 64 COTEGISG i s soog aowa he eee 64 corediscO as mas oo t 64 coredisc2 o g w gi a 64 COS tara 58 COSA cogido ei as 2 be e 58 COLD wae 4 bon ee ete OE ed we ee ee 58 CPW time s e460 eA oe eee ee aed 18 CrCabl M nk od w ane eee a oe BOs 153 CVG bie ce aa Ere ahd ay tose ee ee 81 CUELLOS ie Sie e ok ae e a 117 208 ABICO Nucia FS 156 190 debug js pe as ee ee aS 14 20 172 debugfiles sses ee eee bees 15 20 debugging 2 172 debuglevel 00 sbi bee tars 66 DEBUGLEVEL o i s e e 1 4 172 debugmem 15 20 DEBUGMEM sasos i aha oe Be we ee i72 debugmem poes era Que d Gd Ge ad a 172 decodemodule 84 decomposition into squares 127 Dedekind 58 92 109 115 default precision 7 default 35 36 143 DEFAULTPREC 3 2 40 Sas ss HAs 152 defaults o cwis 12 20 definite binary quadratic form 166 detTe e na eae kek eed Oe aR a 166 degree gee ea Bae eG ee aes 117 166 delete_ Val o 169 Genom soroan a co ee ww es ol denominator o
136. PROGRAM IS STILL IN DEVELOPMENT STAGE The library syntax is rnfkummer bnr subgroup deg prec where deg is a long 113 3 6 134 rnflllgeram nf pol order given a polynomial pol with coefficients in nf and an order order as output by rnfpseudobasis or similar gives neworder U where neworder is a reduced order and U is the unimodular transformation matrix The library syntax is rnflllgram nf pol order prec 3 6 135 rnfnormgroup bnr pol bnr being a big ray class field as output by bnrinit and pol a relative polynomial defining an Abelian extension computes the norm group alias Artin or Takagi group corresponding to the Abelian extension of bnf bnr 1 defined by pol where the module corresponding to bnr is assumed to be a multiple of the conductor i e polrel defines a subextension of bnr The result is the HNF defining the norm group on the given generators of bnr 5 3 Note that neither the fact that pol defines an Abelian extension nor the fact that the module is a multiple of the conductor is checked The result is undefined if the assumption is not correct The library syntax is rnfnormgroup bnr pol 3 6 136 rnfpolred nf pol relative version of polred Given a monic polynomial pol with co efficients in nf finds a list of relative polynomials defining some subfields hopefully simpler and containing the original field In the present version 2 0 19 this is slower than rnfpolredabs The library syntax is rn
137. SHiftr s corme g aa ee ke bbaw a 186 subell L L L L L ee L 78 shifts o oo 180 subfields 242 a Ghee 105 SIGMA 72 134 SUbgTOUP eoc i aw e Ye a 141 S ZA fete A 46 subgrouplist 115 142 S N O ee ee 46 81 s bgrouplistO ici ar be eea a 115 Signat ee ee Pe subil ne oh a aE ay de 3h ees 183 Signe ee ee 163 166 184 SUD ye Gare Ss Gee oe oe ee a 183 signunits ooo 87 subres 0 00 118 194 simplefactmod 67 SUDTOSCE oe ec ee i a kn a 63 Simplify 17 19 53 subresultant algorithm 67 117 118 Sin naaa a aaar 60 SUBSE eiii 119 Ssindexlexsort 131 S 4 0 ea a a oh axe IR ds a 44 SindeXSort s o co cam 93 36 4 Hb om 131 aaa ra a 131 133 Sinh sy psa pine we are Boe oe ale amp Es 60 sumalt 2 ia a aa 134 SIZODYTE ud ith p eed eh Ge ee 54 A oe co dees gt a rk de 72 134 SIZEGIGIG opis eth GG ow oe a AGE 54 O oe bs we ates a ee es e sh 134 smallfact s socca Ge Fe Ee ee ews 66 sumpos 0 0 eee 134 135 smallinitell ok Hom Chea a Gat a 2 a 76 suppl ee a 127 Smith normal form 81 84 87 98 106 eg ECHAW choice e ks 171 115 126 141 SWIECHOUL ee a ye ha He A eg 171 SMAN ee ae tne wie een a aes 127 sylvestermatrix 1 19 SOS 28 8 RARA ane A 109 symmetric powers 119 SOM je paleta Nu See oe ee a 133 system 17 36 145 146 SOP ii ra Be eee Si oe 170 SOG
138. The function cgetg creates only the root and other calls to cgetg must be made to produce the whole tree For matrices a common mistake is to think that z cgetg 4 t MAT for example will create the root of the matrix one needs also to create the column vectors of the matrix obviously since we specified only one dimension in the first cgetg This is because a matrix is really just a row vector of column vectors hence a priori not a basic type but it has been given a special type number so that operations with matrices become possible 4 3 2 Assignments Firstly if x and y are both declared as GEN i e pointers to something the ordinary C assignment y x makes perfect sense we are just moving a pointer around However physically modifying either x or y for instance x 1 0 will also change the other one which is usually not desirable 154 Very important note Using the functions described in this paragraph is very inefficient and often awkward one of the gerepile functions see Section 4 4 should be preferred See the paragraph end for some exceptions to this rule The general PARI assignment function is the function gaffect with the following syntax void gaffect GEN x GEN y Its effect is to assign the PARI object x into the preexisting object y This copies the whole structure of x into y so many conditions must be met for the assignment to be possible For instance it is allowed to assign an integer into a real
139. User s Guide to PARI GP C Batut K Belabas D Bernardi H Cohen M Olivier Laboratoire A2X U M R 9936 du C N R S Universit Bordeaux I 351 Cours de la Lib ration 33405 TALENCE Cedex FRANCE e mail pari math u bordeaux fr Home Page http www parigp home de Primary ftp site ftp megrez math u bordeaux fr pub pari last updated 20 January 2000 for version 2 0 19 Table of Contents Chapter 1 Overview of the PARI system 1 1 Introduction 1 2 The PARI types 1 3 Operations and functions A Chapter 2 Specific Use of the GP Cab 2 1 Defaults and output formats 2 2 Simple metacommands 2 3 Input formats for the PARI types 2 4 GP operators 2 5 The general GP input line 2 6 The GP PARI programming language 2 7 Interfacing GP with other languages 2 8 The preferences file 2 9 Using GP under GNU Emacs 2 10 Using GP with readline Chapter 3 Functions and Operations Availablet in PARI a GP 3 1 Standard monadic or dyadic operators 3 2 Conversions and similar elementary functions or commands 3 3 Transcendental functions 3 4 Arithmetic functions 3 5 Functions related to elliptic curves 3 6 Functions related to general number fields 3 7 Polynomials and power series 3 8 Vectors matrices linear algebra and sets 3 9 Sums products integrals and similar functions 3 10 Plotting functions 3 11 Programming under GP ra Chapter 4 Programming PARI in are Mode 4 1 Introduction initializations universal obj
140. Y OP Y OP2 Z 0P2 T OPs Y is equivalent to op y opz 2 op x ops y GP knows quite a lot of different operators some of them unary having only one argument some binary Unary operators are defined for either prefix preceding their single argument op x or postfix following the argument x op position never both some are syntactically correct in both positions but with different meanings Binary operators all use the syntax x op y Most of 24 them are well known some are borrowed from C syntax and a few are specific to GP Beware that some GP operators may differ slightly from their C counterparts For instance GP s postfix returns the new value like the prefix of C and the binary shifts lt lt gt gt have a priority which is different from higher than that of their C counterparts When in doubt just surround everything by parentheses besides your code will probably be more legible Here is the complete list in order of decreasing priority binary unless mentioned otherwise e Priority 9 and unary postfix x assigns the value x 1 to x then returns the new value of x This corresponds to the C statement x there is no prefix operator in GP x does the same with x 1 e Priority 8 op where op is any simple binary operator i e a binary operator with no side effects i e one of those defined below which is not a boolean operator comparison or logical x op y assign
141. _VEC and t_COL vector z 1 z 2 z 1g z 11 point to the components of the vector 4 5 15 Type t_MAT matrix z 1 z 21 z 1g z 1 point to the column vectors of z i e they must be of type t_COL and of the same length The last two were introduced for specific GP use and you ll be much better off using the standard malloc ed C constructs when programming in library mode We quote them just for completeness advising you not to use them 4 5 16 Type t_LIST list This one has a second codeword which contains an effective length handled through lgef setlgef z 2 z 1gef z 1 contain the components of the list 4 5 17 Type t_STR character string char GSTR z z 1 points to the first char acter of the NULL terminated string 4 6 PARI variables 4 6 1 Multivariate objects We now consider variables and formal computations As we have seen in Section 4 5 the codewords for types t_POL and t_SER encode a variable number This is an integer ranging from 0 to MAXVARN The lower it is the higher the variable priority PARI does not know anything about intelligent sparse representation of polynomials So a multivariate polynomial in PARI is just a polynomial in one variable whose coefficients are themselves arbitrary polynomials All computations are then just done formally on the coefficients as if the polynomial was univariate In fact the way an object will be considered in formal computati
142. a and sets Note that most linear algebra functions operating on subspaces defined by generating sets such as mathnf qf111 etc take matrices as arguments As usual the generating vectors are taken to be the columns of the given matrix 3 8 1 algdep z k flag 0 x being real or complex finds a polynomial of degree at most k having x as approximate root The algorithm used is a variant of the LLL algorithm due to Hastad Lagarias and Schnorr STACS 1986 Note that the polynomial which is obtained is not necessarily the correct one it s not even guaranteed to be irreducible One can check the closeness either by a polynomial evaluation or substitution or by computing the roots of the polynomial given by algdep If the precision is too low the routine may enter an infinite loop If flag is non zero use a standard LLL flag then indicates a precision which should be between 0 5 and 1 0 times the number of decimal digits to which x was computed The library syntax is algdepO z k flag prec where k and flag are longs Also available is algdep z k prec flag 0 3 8 2 charpoly A v x flag 0 characteristic polynomial of A with respect to the variable v i e determinant of v x J A if A is a square matrix determinant of the map multiplication by A if A is a scalar in particular a polmod e g charpoly 1 x x 2 1 Note that in the latter case the minimal polynomial can be obtained as minpoly A
143. a ee 52 PermuteldV 52 PIL Gh ok Wel eae al Me ats De ea 65 Pi sereta aeoe ac a e wa e 27 56 Plot a phoe aay eee o es 136 PLOTDO fa ate ate oe a a a e 136 PLOTCLTD sss erasten a 136 plotcolor s soera teny be ee es 136 plotcopy oo o ooo o 136 137 PplO0tCUTSOL o 137 plotdra ss poa esans Ga sg oup u 137 Plotiile 26 diia ri de 137 PLOCE sucre ae ee wa a 137 plothraw A 138 plothsizZes 138 PLOTIDIE Luis cc e Bee we che AE 138 plotkill sss esa ap gi e iE 139 plotlines 1 faa ite g y a Gas a ae 139 plotlinetype 139 PLOtMOVe si se co ee 139 plotpoints oi eke sas Ree as 139 plotpointsize 139 plotpointtype 139 PUOULDOR cs Sie a we a ee a 139 plotrecth s s rr ras al a 139 plotrecthraw 140 plotrline 140 plotrmove 40 140 PLlOtrpoint s iong goe eh eee eee os 140 plotscales s uri aaa es aise Goad e ae 140 plotstring sm vas wack ary 36 140 plotterm ici be ee Pe t 36 140 PND say Bb ok Be a ae BE eG 64 pOintch o 245 2568 446988 48445 4 5 74 polintell ss aeg arsada de ree ha 79 POINTED aE wee e 43 POL se ma Gogoa a es BS Gs 47 polcoeff ss ei bia ee ewes 50 116 polcoeffO essa hae a a 116 polcompositum 106 polcompositumO 107 POMCY CUO eaog ns Go a es heey eae eg 117 217 poldegree 0 117 POldiSG oe cad cra 117 POLdISCO dic a e T17 poldiscreduced
144. ad when you don t need to keep gigantic buffers around anymore 2 1 2 colors default this default is only usable if GP is running within certain color capable terminals For instance rxvt color_xterm and modern versions of xterm under X Windows or standard Linux DOS text consoles It causes GP to use a small palette of colors for its output With xterms the colormap used corresponds to the resources Xterm colorn where n ranges from 0 to 15 see the file misc color dft for an example Legal values for this default are strings a Q where k lt 7 and each a is either e the keyword no use the default color usually black e an integer between 0 and 15 corresponding to the aforementioned colormap 13 EMACS e a triple co c1 c2 where co stands for foreground color c for background color and c2 for attributes 0 is default 1 is bold 4 is underline The output objects thus affected are respectively error messages history numbers prompt input line output help messages timer that s seven of them If k lt 7 the remaining a are assumed to be no For instance default colors 9 5 no no 4 typesets error messages in color 9 history numbers in color 5 output in color 4 and does not affect the rest In the present version this default is incompatible with Emacs Changing it will just fail silently the alternative would be to display escape sequences as is since Emacs will refuse to interpret t
145. al longword format 20 internal representation 21 interpolating polynomial 117 intersect o s ponad a aui eee a e 125 intformal go eiea eue Sri e amp 116 ANCNUM isdang ona Se SS a e de ws 132 GntnumO sae See we Aw ws eR ee 132 inverseimage 125 iscomplex 666 844 He ee 191 isdiagonal o sarda etaa 125 igexactze o oea Ge owe paa bee 46 191 isfundamental 67 Ustdead ci oe wick ados 4 ee oe 105 TSMONOMES s Sa e atthe fae te oes Be Be d 191 SpriM ses soa i ni ee a a 67 isprincipalall 86 isprincipalrayall 91 ispseudoprime 67 ISPSP Yew a de eRe ade oa a a 67 USsquare 2 rro 68 issquarefree 62 68 USUNIG s c 2h wwe eR a 86 LOS e y atea Bae ey me ea 156 178 186 J fy ke ARR eek Go Gh ok GE hh a a Ge T3 MP 127 Jbessell gt sso saaana iaae 58 rra triada 76 K kbessel 58 kbhessel2 gt s conog d ee Re eee e 58 Ker poi e a e Geo 125 a s oon e aa opara E ie be aa 125 Kerint nica o Aww e a Ba aa 126 ker mod p cora aoci e e e 125 keyWord s e r s eg eae a e E 34 KILI Sagina t a aeo e aE ek ew as 145 Kodaira s3 aena ie ya a aai p 535 76 Kronecker symbol 68 kronecker o 68 L Laplace dpi ae E Set ee ee Bh a 119 ICLONS seis sema a a 155 DEM crs a e a Bebe ee 68 COP A ate Be os owt Gane as ae ot 155 leadingcoeff 117 lea VeS
146. alf integer lt lt gt gt left and right binary shift x lt lt n x 2 ifn gt 0 and x 2 otherwise and x gt gt n x lt lt n e Priority 2 addition subtraction e Priority 1 lt gt lt gt the usual comparison operators returning 1 for true and O for false For instance x lt 1 returns 1 if x lt 1 and 0 otherwise lt gt test for exact inequality test for exact equality e Priority 0 amp amp logical and logical inclusive or Any sequence of logical or and and operations is evaluated from left to right and aborted as soon as the final truth value is known Thus for instance x amp amp 1 x or type p t_INT amp amp isprime p will never produce an error since the second argument need not and will not be processed when the first is already zero false Remark For the optimal efficiency you should use the and op operators whenever possible a 200000 i 0 while i lt a i i 1 time 4 919 ms i 0 while i lt a i 1 time 4 478 ms i 0 while i lt a i time 3 639 ms For the same reason the shift operators should be preferred to multiplication a 1 lt lt 20000 i 1 while i lt a i i 2 time 5 255 ms i 1 while i lt a i lt lt 1 time 988 ms 26 2 5 The general GP input line 2 5 1 Generalities User interaction with a GP session proceeds as follows a sequence of
147. alled gnil is pushed on the stack this value is not printed if it is returned as the result of a GP expression sequence Upon exit the stack decreases You can kill a variable decreasing the stack yourself This should be used only at the top level of GP to undo the effect of an assignment not from a function However the stack has a bottom the value of a variable is the monomial of degree 1 in this variable as is natural for a mathematician An obvious but important exception are character strings which are evaluated essentially to themselves type t_STR Not exactly so though since we do some work to treat the quoted characters correctly those preceded by a 29 2 6 2 Expressions and expression sequences An expression is formed by combining the GP operators functions including user defined functions see below and control statements It may be preceded by an assignment statement into a variable It always has a value which can be any PARI object Several expressions can be combined on a single line by separating them with semicolons and also with colons for those who are used to BASIC Such an expression sequence will be called simply a seg A seq also has a value which is the value of the last non empty expression in the sequence Under GP the value of the seg and only this last value is always put on the stack i e it will become the next object n The values of the other expression
148. alpow nf x k flag 0 computes the k th power of the ideal x in the number field nf k can be positive negative or zero The result is NOT reduced it is really the k th ideal power and is given in HNF If flag is non zero reduce the result using idealred Note however that this is NOT the same as as idealpow nf x k followed by reduction since the reduction is performed throughout the powering process The library syntax corresponding to flag 0 is idealpow nf x k If k is a long you can use idealpows nf x k Corresponding to flag 1 is idealpowred nf vp k prec where prec is a long 3 6 54 idealprimedec nf p computes the prime ideal decomposition of the prime number p in the number field nf p must be a positive prime number Note that the fact that p is prime is not checked so if a non prime number p is given it may lead to unpredictable results The result is a vector of 5 component vectors each representing one of the prime ideals above p in the number field nf The representation vp p a e f b of a prime ideal means the following The prime ideal is equal to pZ g 0Zk where Zg is the ring of integers of the field and a gt ajw where the w form the integral basis nf zk e is the ramification index f is the residual index and b is an n component column vector representing a 3 Zg such that vp Zg B pZx which will be useful for computing valuations but which the user can ignore The number a is gu
149. ame is omitted uses name This function is useful for adding custom functions to the GP interpreter or picking useful functions from unrelated libraries For instance it makes the function system obsolete install system vs sys libc so sys ls gp gp c gp h gp_rl c But it also gives you access to all non static functions defined in the PARI library For instance the function GEN addii GEN x GEN y adds two PARI integers and is not directly accessible under GP it s eventually called by the operator of course install addii GG addii 1 2 hi 3 Caution This function may not work on all systems especially when GP has been compiled statically In that case the first use of an installed function will provoke a Segmentation Fault i e a major internal blunder this should never happen with a dynamically linked executable Hence if you intend to use this function please check first on some harmless example such as the ones above that it works properly on your machine 3 11 2 14 kill x kills the present value of the variable alias or user defined function x you can only kill your own functions The corresponding identifier can now be used to name any GP object variable or function This is the only way to replace a variable by a function having the same name or the other way round as in the following example f 1 1 1 x 0 KK unused characters f x 0 kill f f x 0 fO
150. and you should never 168 assign values or functions to them as you would do with variables under GP For that you need a user variable All objects created by fetch var are on the heap and not on the stack thus they are not subject to standard garbage collecting they won t be destroyed by a gerepile or avma ltop statement When you don t need a variable number anymore you can delete it using long delete_var which deletes the latest temporary variable created and returns the variable number of the previous one or simply returns 0 if you try in vain to delete MAXVARN Of course you should make sure that the deleted variable does not appear anywhere in the objects you use later on Here is an example long first fetch_var long ni fetch_var long n2 fetch_var prepare three variables for internal use delete all variables before leaving do num delete_var while num amp amp num lt first The dangerous statement while delete_var empty removes all temporary variables that were in use except MAXVARN which cannot be deleted 4 7 Input and output Two important aspects have not yet been explained which are specific to library mode input and output of PARI objects 4 7 1 Input For input PARI provides you with two powerful high level functions which enables you to input your objects as if you were under GP In fact the second one is essentially the GP syntact
151. ang of it Try to guess the results of the following commands without actually typing them assuming that the print command evaluates and prints its string arguments in left to right order ending with a newline and returns 0 as an unprinted result print print 1 3 a 3 4 print a 3 1 a 3 print a a 5 2 To round this up here is a less artificial example used to create generic matrices genmat u v s x matrix u v i j eval Str s i 3 genmat 2 3 genmat 2 3 m hi x11 m11 x12 m12 x13 m13 x21 m21 x22 m22 x23 m23 Note that the argument of Str is evaluated in string context and really consists of 5 pieces ex ercise why are the empty strings necessary This part could also have been written as con cat concat Str s i j but not as concat Str s concat i j More simply we could have written concat Str s 1 31 or even concat s i j silently assuming that s will indeed be a string In practice Str is much more efficient if slightly more cryptic The arguments of the following functions are processed in string context Str addhelp second argument 35 UNIX default second argument error extern plotstring second argument plotterm first argument read system all the printzzx functions all the writezxzx functions The arguments of the following functions are processed as keywords alias default first argument install all arguments
152. aranteed to have a valuation equal to 1 at the prime ideal this is automatic if e gt 1 The library syntax is idealprimedec nf p 3 6 55 idealprincipal nf x creates the principal ideal generated by the algebraic number x which must be of type integer rational or polmod in the number field nf The result is a one column matrix The library syntax is principalideal nf x 97 3 6 56 idealred nf I vdir 0 LLL reduction of the ideal 7 in the number field nf along the direction vdir Tf vdir is present it must be an rl r2 component vector rl and r2 number of real and complex places of nf as usual This function finds a small a in J it is an LLL pseudo minimum along direction vdir The result is the Hermite normal form of the LLL reduced ideal rI a where r is a rational number such that the resulting ideal is integral and primitive This is often but not always a reduced ideal in the sense of Buchmann If J is an idele the logarithmic embeddings of a are subtracted to the Archimedean part More often than not a principal ideal will yield the identity matrix This is a quick and dirty way to check if ideals are principal without computing a full bnf structure but it s not a necessary condition hence a non trivial result doesn t prove the ideal is non trivial in the class group Note that this is not the same as the LLL reduction of the lattice J since ideal operations are involved The library syntax is
153. ariables that occur most frequently have analogues which are macros including the typecast The complete list can be found in the file 150 paricast h which is included by pari h and can be found at the same place For instance you can abbreviate long gzero gt zero long gun gt un long polx v gt lpolx v long gadd x y gt ladd x y In general replacing a leading g by an 1 in the name of a PARI function will typecast the result to long Note that 1div is an ANSI C function which is is hidden in PARI by a macro of the same name representing long gdiv The macro coeff x m n exists with exactly the meaning of x m n under GP when x is a matrix This is a purely syntactical trick to reduce the number of typecasts and thus does not create a copy of the coefficient contrary to all the library functions It can be put on the left side of an assignment statement and its value of type long integer is a pointer to the desired coefficient object The macro gcoeff is a synonym for GEN coeff hence cannot be put on the left side of an assignment To retrieve the values of elements of lists of of lists of vectors without getting infuriated by gigantic lists of typecasts we have the mael macros for multidimensional array element The syntax is maeln z a1 where x is a GEN the a are indexes and n is an integer between 2 and 5 with a standalone mael as a synonym for mae12 This stan
154. ated object q This means 1 we translate copy all the objects in the interval avma 1bot so that its right extremity abuts the address 1top Graphically bot avma l1bot ltop top End of stack s Start free memory garbage becomes bot avma ltop top End of Shack gt H52 255 2 C25t 4 4 Start free memory 157 where denote significant objects the unused part of the stack and the garbage we remove 2 The function then inspects all the PARI objects between avma and 1bot i e the ones that we want to keep and that have been translated and looks at every component of such an object which is not a codeword Each such component is a pointer to an object whose address is either between avma and 1bot in which case it will be suitably updated larger than or equal to 1top in which case it will not change or between 1bot and 1top in which case gerepile will scream an error message at you sig nificant pointers lost in gerepile 3 avma is updated we add 1top 1bot to the old value 4 We return the possibly updated object q if q initially pointed between avma and 1bot we return the translated address as in 2 If not the original address is still valid and we return it As stated above no component of the remaining objects in particular q should belong to the erased segment 1bot 1top and this is checked
155. ation before letting you or a script unset this toggle 2 1 23 seriesprecision default 16 precision of power series see ps 2 1 24 simplify default 1 this is a toggle which can be either 1 on or 0 off When the PARI library computes something the type of the result is not always the simplest possible The only type conversions which the PARI library does automatically are rational numbers to integers when they are of type t_FRAC and equal to integers and similarly rational functions to polynomials when they are of type t_RFRAC and equal to polynomials This feature is useful in many cases and saves time but can be annoying at times Hence you can disable this and whenever you feel like it use the function simplify see Chapter 3 which allows you to simplify objects to the simplest possible types recursively see y 17 UNIX 2 1 25 strictmatch default 1 this is a toggle which can be either 1 on or 0 off If on unused characters after a sequence has been processed will produce an error Otherwise just a warning is printed This can be useful when you re not sure how many parentheses you have to close after complicated nested loops 2 1 26 timer default 0 this is a toggle which can be either 1 on or 0 off If on every instruction sequence anything ended by a newline in your input is timed to some accuracy depending on the hardware and operating system The time measured is the user CPU time not incl
156. ation to the next As it would be too costly to call gerepile once for each iteration we only do it when it seems to have become necessary Of course when the need arises you can use bigger gptr arrays in the PARI library source code we once needed to preserve up to 10 objects at a time in a variant of the LLL algorithm Technical note the statement limit avma bot 2 is dangerous since the addition can over flow which would result in limit being negative This will prevent garbage collection in the loop To avoid this problem we provide a robust macro stack_lim avma n which denotes an address where 2 71 2 71 1 of the total stack space is exhausted 1 2 for n 1 2 3 for n 2 Hence the above snippet should be written as long ltop avma limit stack_lim avma 1 4 4 3 Some hints and tricks In this section we give some indications on how to avoid most problems connected with garbage collecting First although it looks complicated gerepile has turned out to be a very flexible and fast garbage collector which compares very favorably with much more sophisticated methods used in other systems A few tests that we have done indicate that the price paid for using gerepile when properly used is usually around 1 or 2 percents of the total time which is quite acceptable Secondly in many cases in particular when the tree structure and the size of the PARI objects which will appear in a computation are under control one
157. ations are in general quite permissive For instance taking the exponential of a vector should not make sense However it frequently happens that a computation comes out with a result which is a vector with many components and one wants to get the exponential of each one This could easily be done either under GP or in this is actually not quite true internally the format is 2 a where a and b are integers T library mode but in fact PARI assumes that this is exactly what you want to do when you take the exponential of a vector so no work is necessary Most transcendental functions work in the same way see Chapter 3 for details An ambiguity would arise with square matrices PARI always considers that you want to do componentwise function evaluation hence to get for example the exponential of a square matrix you would need to use a function with a different name matexp for instance In the present version 2 0 19 this is not yet implemented See however the program in Appendix C which is a first attempt for this particular function The available operations and functions in PARI are described in detail in Chapter 3 Here is a brief summary 1 3 2 Standard operations Of course the four standard operators exist It should once more be emphasized that division is as far as possible an exact operation 4 divided by 3 gives 4 3 In addition to this operations on integers or polynomials like X Euclidean d
158. atrix top row if the vector is x i e comes first and bottom row otherwise The empty matrix is considered to have a number of rows compatible with any operation in particular concatenation Note that this is definitely not the case for empty vectors or If y is omitted x has to be a row vector or a list in which case its elements are concatenated from left to right using the above rules concat 1 2 3 41 1 1 2 3 4 concat 1 2 3 4 2 1 2 3 ale concat 1 2 3 4 5 6 3 1 2 5 3 4 6 concat 7 8 1 2 3 4 44 1 2 5 7 3 4 6 8 1 2 3 4 The library syntax is concat z y 3 8 4 lindep z flag 0 x being a vector with real or complex coefficients finds a small integral linear combination among these coefficients If flag 0 uses a variant of the LLL algorithm due to Hastad Lagarias and Schnorr STACS 1986 If flag gt 0 uses the LLL algorithm flag is a parameter which should be between one half the number of decimal digits of precision and that number see algdep If flag lt 0 returns as soon as one relation has been found The library syntax is lindepO z flag prec Also available is lindep z prec flag 0 3 8 5 listcreate n creates an empty list of maximal length n This function is useless in library mode 122 3 8 6 listinsert list x n inserts the object x at position n in list which must be of type t_
159. ault compatible to 3 Not exactly since not all their arguments need be evaluated For instance it would be stupid to evaluate both branches of an if statement since only one will apply GP only expands this one 28 Now the main thing to understand is that PARI GP is not a symbolic manipulation package although it shares some of the functionalities One of the main consequences of this fact is that all expressions are evaluated as soon as they are written they never stay in a purely abstract form As an important example consider what happens when you use a variable name before assigning a value into it This is perfectly acceptable to GP which considers this variable in fact as a polynomial of degree 1 with coefficients 1 in degree 1 0 in degree 0 whose variable is the variable name you used If later you assign a value to that variable the objects which you have created before will still be considered as polynomials Tf you want to obtain their value use the function eval see Section 3 7 3 Finally note that if the variable x contains a vector or list you can assign a result to x m i e write something like z k expr If x is a matrix you can assign a result to x m n but not to x m If you want to assign an expression to the m th column of a matrix x use z m expr instead Similarly use z m expr to assign an expression to the m th row of x This process is recursive so if x is a matrix of matrices of
160. ays chosen p adic or power series arguments are also allowed Note that a p adic agm exists only if x y is congruent to 1 modulo p modulo 16 for p 2 x and y cannot both be vectors or matrices The library syntax is agm z y prec 3 3 9 arg x argument of the complex number x such that r lt arg x lt r The library syntax is garg z prec 3 3 10 asin x principal branch of sin x i e such that Re asin w 7 2 7 2 If x R and x gt 1 then asin x is complex The library syntax is gasin z prec 3 3 11 asinh x principal branch of sinh x i e such that Im asinh x 1 2 7 2 The library syntax is gash z prec 3 3 12 atan x principal branch of tan x i e such that Re atan 7 2 7 2 The library syntax is gatan z prec 3 3 13 atanh x principal branch of tanh w i e such that Im atanh x 7 2 7 2 If x Rand z gt 1 then atanh x is complex The library syntax is gath x prec 3 3 14 bernfrac x Bernoulli number Bz where Bo 1 By 1 2 Ba 1 6 expressed as a rational number The argument x should be of type integer The library syntax is bernfrac z 3 3 15 bernreal x Bernoulli number B as bernfrac but B is returned as a real number with the current precision The library syntax is bernreal x prec 57 3 3 16 bernvec x creates a vector containing as rational numbers the Bernoulli numbers Bo Ba Bay T
161. b in nf that is 1 if z ay bz has a non trivial solution x y z in nf and 1 otherwise Otherwise compute the local symbol modulo the prime ideal pr as output by idealprimedec The library syntax is nfhilbert nf a b pr where an omitted pr is coded as NULL 3 6 87 nfhnf nf x given a pseudo matrix A I finds a pseudo basis in Hermite normal form of the module it generates The library syntax is nfhermite nf x 3 6 88 nfhnfmod nf x detz given a pseudo matrix A J and an ideal detx which is contained in read integral multiple of the determinant of 4 1 finds a pseudo basis in Hermite normal form of the module generated by 4 1 This avoids coefficient explosion detz can be computed using the function nfdetint The library syntax is nfhermitemod nf x detz 103 3 6 89 nfinit pol flag 0 pol being a non constant preferably monic irreducible polynomial in Z X initializes a number field structure nf associated to the field K defined by pol As such it s a technical object passed as the first argument to most nfzzxx functions but it contains some information which may be directly useful Access to this information via member functions is prefered since the specific data organization specified below may change in the future Currently nf is arow vector with 9 components nf 1 contains the polynomial pol nf pol nf 2 contains r1 r2 nf sign the number of real and complex places of
162. b if they are prime the seg is evaluated Nothing is done if a gt b Note that a and b must be in R 3 11 1 5 forstep X a b s seq the formal variable X going from a to b in increments of s the seg is evaluated Nothing is done if s gt 0 and a gt b or if s lt 0 and a lt b s must be in R or a vector of steps s Sn In the latter case the successive steps are used in the order they appear in s forstep x 5 20 2 4 print x 5 7 11 13 17 19 141 3 11 1 6 forsubgroup H G B seq executes seg for each subgroup H of the abelian group G given in SNF form or as a vector of elementary divisors whose index is bounded by bound The subgroups are not ordered in any obvious way unless G is a p group in which case Birkhoff s algorithm produces them by decreasing index A subgroup is given as a matrix whose columns give its generators on the implicit generators of G For example the following prints all subgroups of index less than 2 in G Z 2Zg1 x Z 2Zg G 2 2 forsubgroup H G 2 print H 1 1 1 2 2 1 1 O 1 1 The last one for instance is generated by g1 91 g2 This routine is intended to treat huge groups when subgrouplist is not an option due to the sheer size of the output For maximal speed the subgroups have been left as produced by the algorithm To print them in canonical form as left divisors of G in HNF form one can for instance use G matdiagonal 2 2
163. b p1 p2 z 2 lsub p3 p4 z gerepile ltop lbot z Essentially because for instance x 1 is a long and not a GEN so we need to insert many annoying typecasts p1 gmul GEN x 1 GEN y 1 and so on Let us now look at a less trivial example where more than one gerepile is needed in practice at the expense of efficiency one can always use only one using gcopy see below Suppose that we want to write a function which multiplies a line vector by a matrix such a function is of course already part of gmul but let s ignore this for a moment Then the most natural way is to do a cgetg of the result immediately and then a gerepile for each coefficient of the result vector to get rid of the garbage which has accumulated while this particular coefficient was computed We leave the details to the reader who can look at the answer in the file basemath gen1 c in the function gmul case t_VEC times case t_MAT It would theoretically be possible to have a single connected piece of garbage but it would be a much less natural and unnecessarily complicated program Let us now take an example which is probably the least trivial way of using gerepile but is unfortunately sometimes necessary Although it is not an infrequent occurrence we will not give a specific example but a general one suppose that we want to do a computation usually inside a larger function producing more than one PARI object as a result say two for instance Then e
164. be all right Check out existing type names with the metacommand t GP won t let you create meaningless objects in this way where the internal structure doesn t match the type This function can be useful to create reducible rationals type t_FRACN or rational functions type t_RFRACN In fact it s the only way to do so in GP In this case the created object as well as the objects created from it will not be reduced automatically making some operations a bit faster There is no equivalent library syntax since the internal functions typ and settyp are available Note that settyp does not create a copy of x contrary to most PARI functions It also doesn t check for consistency settyp just changes the type in place and returns nothing typ returns a C long integer Note also the different spellings of the internal functions set typ and of the GP function type which is due to the fact that type is a reserved identifier for some C compilers 3 11 2 27 whatnow key if keyword key is the name of a function that was present in GP version 1 39 15 or lower outputs the new function name and syntax if it changed at all 387 out of 560 did 3 11 2 28 write filename strx writes appends to filename the remaining arguments and appends a newline same output as print 3 11 2 29 writel filename str x writes appends to filename the remaining arguments with out a trailing newline same output as print1 3 11 2 30 writetex f
165. bnf regulator roots bnr bnf nf roots of the polnomial generating the field sign bnr bnf nf r1 r2 the signature of the field This means that the field has r real embeddings 2r2 complex ones t2 bnr bnf nf the T2 matrix see nfinit tu bnr bnf a generator for the torsion units tufu bnr bnf as futu but outputs w u zk bnr bnf nf integral basis i e a Z basis of the maximal order zkst bnr structure of Zg m can be extracted also from an idealstar 81 For instance assume that bnf bnfinit pol for some polynomial Then bnf clgp retrieves the class group and bnf clgp no the class number If we had set bnf nfinit pol both would have output an error message All these functions are completely recursive thus for instance bnr bnf nf zk will yield the maximal order of bnr which you could get directly with a simple bnr zk of course The following functions starting with buch in library mode and with bnf under GP are implementations of the sub exponential algorithms for finding class and unit groups under GRH due to Hafner McCurley Buchmann and Cohen Diaz Olivier The general call to the functions concerning class groups of general number fields i e excluding quadclassunit involves a polynomial P and a technical vector tech c c2 nrel borne nrpid minsfb where the parameters are to be understood as follows P is the defining polynomial for the number fie
166. bnfinit ext is a relative extension which has to be a row vector whose components are ext 1 a relative equation of the number field ext over bnf As usual the priority of the variable of the polynomial defining the ground field bnf say y must be lower than the main variable of ext 1 say x ext 2 the generator y of the base field as a polynomial in x as given by rnfequation with flag 1 ext 3 is the bnfinit of the absolute extension ext Q This returns a vector a b where el Norm a x b It looks for a solution which is an S integer with S a list of places of bnf containing the ramified primes the generators of the class group of ext as well as those primes dividing el If ext bnf is known to be Galois set flag 0 here el is a norm iff b 1 If flag is non zero add to S all the places above the primes which divide flag if flag lt 0 or are less than flag if flag gt 0 The answer is guaranteed i e el is a norm iff b 1 under GRH if S contains all primes less than 12 log disc Lxt where Ext is the normal closure of ext bnf The library syntax is rnfisnorm bnf ext x flag prec 3 6 133 rnfkummer bnr subgroup deg 0 bnr being as output by bnrinit finds a relative equation for the class field corresponding to the module in bnr and the given congruence subgroup If deg is positive outputs the list of all relative equations of degree deg contained in the ray class field defined by bnr THIS
167. but the last trap first argument type second argument whatnow 2 7 Interfacing GP with other languages The PARI library was meant to be interfaced with C programs This specific use will be dealt with extensively in Chapter 4 GP itself provides a convenient if simple minded interpreter which enables you to execute rather intricate scripts see Section 3 11 Scripts when properly written tend to be shorter and much clearer than C programs and are certainly easier to write maintain or debug You don t need to deal with memory management garbage collection pointers declarations and so on Because of their intrinsic simplicity they are more robust as well They are unfortunately somewhat slower Thus their use will remain complementary it is suggested that you test and debug your algorithms using scripts before actually coding them in C for the sake of speed Note that the install command enables you to concentrate on critical parts of your programs only which can of course be written with the help of other mathematical libraries than PARI and to easily and efficiently import foreign functions for use under GP see Section 3 11 2 13 We are aware of three PARI related public domain libraries We neither endorse nor support any of them You might want to give them a try if you are familiar with the languages they are based on First there are PariPerl1 written by Ilya Zakharevich ilya math ohio state edu and PariPython
168. cbezoutres 0 4 63 VECEINtL lapa be Gs we BEG Os 58 VECOXETACE comiera 125 130 vecmax onk a a aa E a ee 46 VOCMIA lt 4 4 4 sosa as 46 VOCSOL 2 4 4 4 da 4 0 lo de eo amp x 131 VEOCsSortO mica aaa og 131 VOCE vu rra Sa ee wach e amp G 135 VECIOD xica Sed A aes A eee eS 6 VOCGOr 5 4 4 fo he eke i acest Ae ed 135 VOCIOXV 25 64 4 54 844 48 264 de 135 version number 0 2l Vid td aaa se Ge eG a we ts 40 VOLE ie ve See Hs oes See A es at arn EL 71 VVEC OUO gt is sirc se 135 W A a A A T3 weber 2 2 444 4545444 aa ee e Kig 62 Weber soso 26548445 88 see bes 62 Weierstrass g function 79 Weierstrass equation 2 Weil curve 78 welipell essa eae ie oe e 79 WE osx He eh ce SO EK oe Se ee a 62 Wil asias ed a em hn a 62 WED ste eo Cie a od 62 WhAtDOW bra e o wank od 36 148 WALLS asaltar 143 Wiles 13 WI Ae daa a o a e 21 WHITEY 2 nfs bE ee ale OE ee ee 36 148 WELLO L S504 wa oe ee mah RS SS 148 WEITCUCK aonb eGR eH a ew ea WS 148 X Sem odo da a d e i 51 lM 2 3 a s Seas ra o A 51 Ximi soe eB ra oe a a 51 Alla a ye ae ads Gy pl Z Aassenhaus espada e As 66 116 ZLDEOOD sau do k a EE e 133 Zell ee NI a i a R rae ZETO og ps Ra ee E 6 151 zeta function 4 al ZETA cook hw wR e BOR ee OR Ge ee we ee 62 Zetak 3 sg siii wh A BR Bee 115 zetakinit sc re sco aa toe a Soad 315 zideallog sss s eaa e Prana 96 ZK e why cael O O
169. cial help from the PARI kernel sources 195 2 Compiling the library and the GP calculator 2 1 Basic configuration First have a look at the MACHINES file to see if anything funny applies to your architecture or operating system Then type Configure in the toplevel directory This will attempt to configure GP PARI without outside help Note that if you want to install the end product in some nonstandard place you can use the prefix option as in Configure prefix an exotic directory the default prefix is usr local This phase extracts some files and creates a directory Orxrx where the object files and executables will be built The xxx part depends on your architecture and operating system thus you can build GP for several different machines from the same source tree the builds are completely independent so can be done simultaneously Configure will let the following environment variable override the defaults if set AS Assembler CC C compiler DLLD Dynamic library linker For instance Configure avoids gcc on some architectures due to various problems which may have been fixed in your version of the compiler You can try env CC gcc Configure and compare the benches Also if insist on using a C compiler and run into trouble with a recent g try to use g fpermissive 2 2 Troubleshooting and fine tuning Decide whether you agree with what Configure printed on your screen in particular the architec
170. cmpii GEN x GEN y compares the integer x to the integer y long cmpir GEN x GEN y compares the integer x to the real y long cmprs GEN x long s compares the real x to the long s long cmpri GEN x GEN y compares the real x to the integer y long cmprr GEN x GEN y compares the real x to the real y 5 2 7 Binary operations Let op be some operation of type GEN GEN GEN The names and prototypes of the low level functions corresponding to op will be as follows In this section the z argument in the z functions must be of type t_INT or t_REAL GEN mpop z GEN x GEN y GEN z applies op to the integer or reals x and y GEN opss z long s long t GEN z applies op to the longs s and t GEN opsi z long s GEN x GEN z applies op to the long s and the integer x GEN opsr z long s GEN x GEN z applies op to the long s and the real x GEN opis z GEN x long s GEN z applies op to the integer x and the long s GEN opiilz GEN x GEN y GEN z applies op to the integers x and y GEN opir z GEN x GEN y GEN z applies op to the integer x and the real y 187 GEN oprs z GEN x long s GEN z applies op to the real x and the long s GEN opri z GEN x GEN y GEN z applies op to the real x and the integer y GEN oprr z GEN x GEN y GEN z applies op to the reals x and y Each of the above can be used with the following operators op add addition x y The result is real unless both x and y
171. completions and so on See Section 2 10 1 for a short summary of available commands This might not be available for all architectures Whether extended on line help and line editing are available or not is indicated in the GP banner between the version number and the copyright message If you type you will get a short description of the metacommands keyboard shortcuts Finally typing will return the list of available pre defined member functions These are functions attached to specific kind of objects used to retrieve easily some information from complicated structures you can define your own but they won t be shown here We will soon describe these commands in more detail As a general rule under GP commands starting with or with some other symbols like or are not computing commands but are metacommands which allow the user to exchange information with GP The available metacommands can be divided into default setting commands explained below and simple commands or keyboard shortcuts to be dealt with in Section 2 2 2 1 Defaults and output formats There are many internal variables in GP defining how the system will behave in certain situations unless a specific override has been given Most of them are a matter of basic customization colors prompt and will be set once and for all in your preferences file see Section 2 8 but some of them are useful interactively set timer on increase precision etc
172. computations The library syntax is isprincipalall bnf x flag 3 6 10 bnfisunit bnf x bnf being the number field data output by bnfinit and zx being an algebraic number type integer rational or polmod this outputs the decomposition of x on the fundamental units and the roots of unity if x is a unit the empty vector otherwise More precisely ifuj u are the fundamental units and is the generator of the group of roots of unity found by bnfclassunit or bnfinit the output is a vector 11 r Uy 1 such that z uf ur Pr The z are integers for i lt r and is an integer modulo the order of fori r 1 The library syntax is isunit bnf x 86 3 6 11 bnfmake sbnf sbnf being a small bnf as output by bnfinit x 3 computes the com plete bnfinit information The result is not identical to what bnfinit would yield but is func tionally identical The execution time is very small compared to a complete bnfinit Note that if the default precision in GP or prec in library mode is greater than the precision of the roots sbnf 5 these are recomputed so as to get a result with greater accuracy Note that the member functions are not available for sbnf you have to use bnfmake explicitly first The library syntax is makebigbnf sbnf prec where prec is a C long integer 3 6 12 bnfnarrow bnf bnf being a big number field as output by bnfinit computes the narrow class group of bnf The output is a 3 comp
173. criminant and d is the relative discriminant considered as an element of nf nf 2 The main variable of nf must be of lower priority than that of pol Note As usual nf can be a bnf as output by nfinit The library syntax is rnfdiscf bnf pol 109 3 6 115 rnfeltabstorel rnf x rnf being a relative number field extension L K as output by rnfinit and x being an element of L expressed as a polynomial modulo the absolute equation rnf 11 1 computes x as an element of the relative extension L K as a polmod with polmod coefficients The library syntax is rnfelementabstorel rnf x 3 6 116 rnfeltdown rnf x rnf being a relative number field extension L K as output by rn finit and zx being an element of L expressed as a polynomial or polmod with polmod coefficients computes x as an element of K as a polmod assuming x is in K otherwise an error will occur If x is given on the relative integral basis apply rnfbasistoalg first otherwise PARI will believe you are dealing with a vector The library syntax is rnfelementdown rnf x 3 6 117 rnfeltreltoabs rnf x rnf being a relative number field extension L K as output by rnfinit and zx being an element of L expressed as a polynomial or polmod with polmod coefficients computes x as an element of the absolute extension L Q as a polynomial modulo the absolute equation rnf 11 1 If x is given on the relative integral basis apply rnfbasistoalg first otherwise PARI will believe you ar
174. current stack pointer called avma which stands for available memory address These three variables are global declared for you by pari h For historical reasons they are of type long and not of type GEN as would seem more natural The stack is oriented upside down the more recent an object the closer to bot Accordingly initially avma top and avma gets decremented as new objects are created As its name indicates avma always points just after the first free address on the stack and GEN avma is always a pointer to the latest created object When avma reaches bot the stack overflows aborting all 156 computations and an error message is issued To avoid this you will need to clean up the stack from time to time when some bunch of intermediate objects will not be needed anymore This is called garbage collecting We are now going to describe briefly how this is done We will see many concrete examples in the next subsection e First PARI routines will do their own garbage collecting which means that whenever a doc umented function from the library returns only its result s will have been added to the stack non documented ones may not do this for greater speed In particular a PARI function that does not return a GEN does not clutter the stack Thus if your computation is small enough i e you call few PARI routines or most of them return long integers then you don t need to do any garbage collecting This wil
175. d above you can create readline osname arch using the same naming conventions as for the Oxxx directory e g readline linux i686 2 3 Debugging profiling If you also want to debug the PARI library Configure g will create a directory Oxxx dbg containing a special Makefile ensuring that the GP and PARI library built there will be suitable for debugging if your compiler doesn t use standard flags e g g you may have to tweak that Makefile If you want to profile GP or the library using gprof for instance Configure pg will create an Oxxx pr directory where a suitable version of PARI can be built 2 4 Compilation and tests To compile the GP binary simply type make gp in the distribution directory If your make program supports parallel make you can speed up the process by going to the Dxxx directory that Configure created and doing a parallel make here for instance make j4 with GNU make 2 4 1 Testing To test the binary type make bench This will build a static executable the default built by make gp is probably dynamic and run a series of comparative tests on those two To test only the default binary use make dobench which starts the bench immediately The static binary should be slightly faster In any case this should not take more than one minute user time on modern machines See the file MACHINES to get an idea of how much time comparable systems need we would appreciate a short note in the same forma
176. d at x the formal parameter going from a to b As for prod the initialization parameter x may be given to force the type of the operations being performed As an extreme example compare sum i 1 5000 1 i rational number denominator has 2166 digits time 1 241 ms sum i 1 5000 1 i 0 time 158 ms 72 9 094508852984436967 261245533 The library syntax is somme entree ep GEN a GEN b char expr GEN x This is to be used as follows ep represents the dummy variable used in the expression expr compute a72 b 2 define the dummy variable i entree ep is_entry i sum for a lt i lt b return somme ep a b i72 gzero 3 9 8 sumalt X a expr flag 0 numerical summation of the series expr which should be an alternating series the formal variable X starting at a If flag 0 use an algorithm of F Villegas as modified by D Zagier This is much better than Euler Van Wijngaarden s method which was used formerly Beware that the stopping criterion is that the term gets small enough hence terms which are equal to 0 will create problems and should be removed If flag 1 use a variant with slightly different polynomials Sometimes faster Divergent alternating series can sometimes be summed by this method as well as series which are not exactly alternating see for example Section 2 6 3 Important hint a significant speed gain can be obtained by writing the
177. d rectplot functions sharing the prefix plot work as follows You have at your disposal 16 virtual windows which are filled independently and can then be physically ORed on a single window at user defined positions These windows are numbered from 0 to 15 and must be initialized before being used by the function plotinit which specifies the height and width of the virtual window called a rectwindow in the sequel At all times a virtual cursor initialized at 0 0 is associated to the window and its current value can be obtained using the function plotcursor A number of primitive graphic objects called rect objects can then be drawn in these windows using a default color associated to that window which can be changed under X11 using the plotcolor function black otherwise and only the part of the object which is inside the window will be drawn with the exception of polygons and strings which are drawn entirely but the virtual cursor can move outside of the window The ones sharing the prefix plotr draw relatively to the current position of the virtual cursor the others use absolute coordinates Those having the prefix plotrecth put in the rectwindow a large batch of rect objects corresponding to the output of the related ploth function 135 Finally the actual physical drawing is done using the function plotdraw Note that the windows are preserved so that further drawings using the same windows at different positions or different
178. d types can be mixed however beware when doing operations Note in particular that a polynomial in two variables is simply a polynomial with polynomial coefficients Note that in the present version 2 0 19 of PARI there is a bug in the handling of power series of power series i e power series in several variables However power series of polynomials which are power series in several variables of a special type are OK The reason for this bug is known but it is difficult to correct because the mathematical problem itself contains some amount of imprecision 1 2 5 Strings These contain objects just as they would be printed by the GP calculator 1 2 6 Notes 1 2 6 1 Exact and imprecise objects we have already said that integers and reals are called the leaves because they are ultimately at the end of every branch of a tree representing a PARI object Another important notion is that of an exact object by definition numbers of basic type real p adic or power series are imprecise and we will say that a PARI object having one of these imprecise types anywhere in its tree is not exact All other PARI objects will be called exact This is a very important notion since no numerical analysis is involved when dealing with exact objects 1 2 6 2 Scalar types the first nine basic types from t_INT to t_POLMOD will be called scalar types because they essentially occur as coefficients of other more complicated objects Note that type t_POLMOD is u
179. d when if at all you should use them e the following universal objects by definition objects which do not belong on the stack the integers 0 1 and 2 respectively called gzero gun and gdeux the fraction gt ghalf the complex number gi All of these are of type GEN In addition space is reserved for the polynomials x polx v and the polynomials 1 polun v Here x is the name of variable number v where 0 lt v lt MAXVARN the exact value of which depends on your machine at least 16383 in any case Both polun and polx are arrays of GENs the index being the polynomial variable number However except for the ones corresponding to variables 0 and MAXVARN these polynomials are not created upon initialization It is the programmer s responsibility to fill them before use We ll see how this is done in Section 4 6 never through direct assignment ea heap which is just a linked list of permanent universal objects For now it contains exactly the ones listed above You will probably very rarely use the heap yourself and if so only as a collection of individual copies of objects taken from the stack called clones in the sequel Thus you need not bother with its internal structure which may change as PARI evolves Some complex PARI functions may create clones for special garbage collecting purposes usually destroying them when returning e a table of primes in fact of differences between consecutive primes
180. d with a simple change of variable Furthermore for improper integrals where one or both of the limits of integration are plus or minus infinity the function must decrease sufficiently rapidly at infinity This can often be accomplished through integration by parts Finally the function to be integrated should not be very small compared to the current precision on the entire interval This can of course be accomplished by just multiplying by an appropriate constant Note that infinity can be represented with essentially no loss of accuracy by 1e4000 However beware of real underflow when dealing with rapidly decreasing functions For example if one wants to compute the dae e da to 28 decimal digits then one should set infinity equal to 10 for example and certainly not to 1e4000 The integrand may have values belonging to a vector space over the real numbers in particular it can be complex valued or vector valued See also the discrete summation methods below sharing the prefix sum 3 9 1 intnum X a b expr flag 0 numerical integration of expr smooth in Ja b with respect to X Set flag 0 or omit it altogether when a and b are not too large the function is smooth and can be evaluated exactly everywhere on the interval a b If flag 1 uses a general driver routine for doing numerical integration making no particular assumption slow flag 2 is tailored for being used when a or b are infinite One must hav
181. d y have to be polynomials with integer coefficients If flag 2 use the subresultant algorithm The library syntax is gcdO z y flag Also available are ggcd z y modularged z y and srgcd x y corresponding to flag 0 1 and 2 respectively 3 4 28 hilbert x y p Hilbert symbol of x and y modulo p If x and y are of type integer or fraction an explicit third parameter p must be supplied p 0 meaning the place at infinity Otherwise p needs not be given and x and y can be of compatible types integer fraction real integermod or p adic The library syntax is hil x y p 3 4 29 isfundamental x true 1 if x is equal to 1 or to the discriminant of a quadratic field false 0 otherwise The library syntax is gisfundamental x but the simpler function isfundamental x which returns a long should be used if x is known to be of type integer 3 4 30 isprime x true 1 if x is a strong pseudo prime for 10 randomly chosen bases false 0 otherwise The library syntax is gisprime z but the simpler function isprime z which returns a long should be used if x is known to be of type integer 67 3 4 31 ispseudoprime z true 1 if x is a strong pseudo prime for a randomly chosen base false 0 otherwise The library syntax is gispsp x but the simpler function ispsp x which returns a long should be used if x is known to be of type integer 3 4 32 issquare x amp n true 1 if x is square false 0 if not x
182. deal in the format output by the function idealprimedec this function tests whether the ideal is principal or not The result is more complete than a simple true false answer it gives a row vector v1 va check where v is the vector of components c of the class of the ideal x in the class group expressed on the generators gi given by bnfinit specifically bnf clgp gen which is the same as bnf 8 1 3 The c are chosen so that 0 lt ci lt n i where n is the order of g the vector of n being bnf clgp cyc that is bnf 8 1 2 v2 gives on the integral basis the components of a such that x a 9 In particular x is principal if and only if v is equal to the zero vector and if this the case x Z g where a is given by v2 Note that if a is too large to be given a warning message will be printed and va will be set equal to the empty vector Finally the third component check is analogous to the last component of bnfclassunit it gives a check on the accuracy of the result in bits check should be at least 10 and preferably much more In any case the result is checked for correctness If flag 0 outputs only v which is much easier to compute If flag 2 does as if flag were 0 but doubles the precision until a result is obtained If flag 3 as in the default behaviour flag 1 but doubles the precision until a result is obtained The user is warned that these two last setting may induce very lengthy
183. ded by gzero Also available are polred z prec and factoredpolred z p prec both corresponding to flag 0 3 6 104 polredabs z flag 0 finds one of the polynomial defining the same number field as the one defined by zx and such that the sum of the squares of the modulus of the roots i e the T norm is minimal All x accepted by nfinit are also allowed here e g non monic polynomials nf bnf x Z K basis The binary digits of flag mean 1 outputs a two component row vector P a where P is the default output and a is an element expressed on a root of the polynomial P whose minimal polynomial is equal to z 4 gives all polynomials of minimal T norm of the two polynomials P x and P z only one is given The library syntax is polredabs0 z flag prec 3 6 105 polredord finds polynomials with reasonably small coefficients and of the same degree as that of x defining suborders of the order defined by x One of the polynomials always defines Q hence is equal to x 1 where n is the degree and another always defines the same order as x if x is irreducible The library syntax is ordred z 3 6 106 poltschirnhaus x applies a random Tschirnhausen transformation to the polynomial x which is assumed to be non constant and separable so as to obtain a new equation for the tale algebra defined by x This is for instance useful when computing resolvents hence is used by the polgalois function The l
184. default values the text of seq and a short help text if one was provided using the addhelp function see Section 3 11 2 1 One small difference to predefined functions is that you can never redefine the built in functions while you can redefine a user defined function as many times as you want Typing Mu will output the list of user defined functions An amusing example of a user defined function is the following It is intended to illustrate both the use of user defined functions and the power of the sumalt function Although the Riemann zeta function is included in the standard functions let us assume that this is not the case or that we want another implementation One way to define it which is probably the simplest but certainly not the most efficient is as follows zet s local j not needed and possibly confusing see below sumalt j 1 1 j 1 j s 1 2 1 s This gives reasonably good accuracy and speed as long as you are not too far from the domain of convergence Try it for s integral between 5 and 5 say or for s 0 5 i x t where t 14 134 The iterative constructs which use a variable name forrr2 prodrxrx sumrxx vector ma trix plot etc also consider the given variable to be local to the construct A value is pushed on entry and pulled on exit So it is not necessary for a function using such a construct to declare the variable as a dummy formal parameter In particular
185. device a window of maximal size accessed through coordinates in the 0 1000 x 0 1000 range s plothsizes plotinit 0 s 1 1 s 2 1 plotscale 0 0 1000 0 1000 3 10 13 plotkill w erase rectwindow w and free the corresponding memory Note that if you want to use the rectwindow w again you have to use initrect first to specify the new size So it s better in this case to use initrect directly as this throws away any previous work in the given rectwindow 3 10 14 plotlines w X Y flag 0 draw on the rectwindow w the polygon such that the x y coordinates of the vertices are in the vectors of equal length X and Y For simplicity the whole polygon is drawn not only the part of the polygon which is inside the rectwindow If flag is non zero close the polygon In any case the virtual cursor does not move X and Y are allowed to be scalars in this case both have to There a single segment will be drawn between the virtual cursor current position and the point X Y And only the part thereof which actually lies within the boundary of w Then move the virtual cursor to X Y even if it is outside the window If you want to draw a line from x1 y1 to 2 y2 where 1 yl is not necessarily the position of the virtual cursor use plotmove w x1 y1 before using this function 3 10 15 plotlinetype w type change the type of lines subsequently plotted in rectwindow w type 2 corresponds to frames 1 to axes
186. digits Note that some accuracies attainable on 32 bit machines cannot be attained on 64 bit machines for parity reasons For example the default GP accuracy is 28 decimal digits on 32 bit machines corresponding to prec having the value 5 but this cannot be attained on 64 bit machines After possible conversion the function is computed Note that even if the argument is real the result may be complex e g acos 2 0 or acosh 0 0 Note also that the principal branch is always chosen e If the argument is an integermod or a p adic at present only a few functions like sqrt square root sqr square log exp powering teichmuller Teichmiiller character and agm arithmetic geometric mean are implemented Note that in the case of a 2 adic number sqr x may not be identical to xx x for example if x 1 0 2 and y 1 0 2 then x y 1 O 2 while sqr x 1 O 2 Here 1 x yields the same result as sqr x since the two operands are known to be identical The same statement holds true for p adics raised to the power n where vp n gt 0 55 Remark note that if we wanted to be strictly consistent with the PARI philosophy we should have x x y 4mod8 and sqr xz 4mod 32 when both x and y are congruent to 2 modulo 4 However since integermod is an exact object PARI assumes that the modulus must not change and the result is hence 0 mod 4 in both cases On the other hand p adics are not exact objects hence are treated
187. divround GEN x GEN y if x and y are integers returns the quotient x y of x and y rounded to the nearest integer If x y falls exactly halfway between two consecutive integers then it is rounded towards 00 as for round If x and y are not both integers the result is the same as that of gdivent GEN gmod z GEN x GEN y GEN z yields the true remainder of x modulo the integer or polynomial y GEN gmodsg z long s GEN x GEN z yields the true remainder of the long s modulo the integer x GEN gmodgs z GEN x long s GEN z yields the true remainder of the integer x modulo the long s GEN gres GEN x GEN y creates the Euclidean remainder of the polynomial x divided by the polynomial y GEN ginvmod GEN x GEN y creates the inverse of x modulo y when it exists GEN gpow GEN x GEN y long 1 creates x The precision 1 is taken into account only if y is not an integer and x is an exact object If y is an integer binary powering is done Otherwise the result is exp y log x computed to precision 1 GEN ggcd GEN x GEN y creates the GCD of x and y GEN glem GEN x GEN y creates the LCM of x and y GEN subres GEN x GEN y creates the resultant of the polynomials x and y computed using the subresultant algorithm GEN gpowgs GEN x long n creates x using binary powering GEN gsubst GEN x long v GEN y substitutes the object y into x for the variable number v int gdivise GEN x GEN y returns 1 true if
188. ds for x a a2 an with all the necessary typecasts and returns a long i e they are valid lvalues The gmaeln macros are synonyms for GEN maeln Note that due to the implementation of matrix types in PARI i e as horizontal lists of vertical vectors coeff x y is actually completely equivalent to mael y x It is suggested that you use coeff in matrix context and mael otherwise 4 2 2 Variations on basic functions In the library syntax descriptions in Chapter 3 we have only given the basic names of the functions For example gadd x y assumes that x and y are PARI objects of type GEN and creates the result x y on the PARI stack For most of the basic operators and functions many other variants are available We give some examples for gadd but the same is true for all the basic operators as well as for some simple common functions a more complete list is given in Chapter 5 GEN gaddgs GEN x long y GEN gaddsg long x GEN y In the following three z is a preexisting GEN and the result of the corresponding operation is put into z The size of the PARI stack does not change void gaddz GEN x GEN y GEN z void gaddgsz GEN x long y GEN z void gaddsgz GEN x GEN y GEN z There are also low level functions which are special cases of the above GEN addii GEN x GEN y here x and y are GENs of type t_INT this is not checked GEN addrr GEN x GEN y here x and y are GEN reals type t_REAL There also exist fu
189. due class as x and in the same residue class as y if it is possible This function also allows vector and matrix arguments in which case the operation is recur sively applied to each component of the vector or matrix For polynomial arguments it is applied to each coefficient Finally chinese x 1x x regardless of the type of x this allows vector arguments to contain other data so long as they are identical in both vectors The library syntax is chinois z y 3 4 9 content x computes the gcd of all the coefficients of x when this gcd makes sense If x is a scalar this simply returns x If x is a polynomial and by extension a power series it gives the usual content of x If x is a rational function it gives the ratio of the contents of the numerator and the denominator Finally if x is a vector or a matrix it gives the gcd of all the entries The library syntax is content z 3 4 10 contfrac z b lmazx creates the row vector whose components are the partial quo tients of the continued fraction expansion of x the number of partial quotients being limited to Imax If x is a real number the expansion stops at the last significant partial quotient if Imax is omitted x can also be a rational function or a power series If a vector b is supplied the numerators will be equal to the coefficients of b The length of the result is then equal to the length of b unless a partial remainder is encountered which is equal to zero I
190. e The standard boolean functions inclusive or amp amp and and not are also available and the library syntax is gor z y gand z y and gnot x respectively In library mode it is in fact usually preferable to use the two basic functions which are gcmp z y which gives the sign 1 0 or 1 of x y where x and y must be in R and gegal z y which can be applied to any two PARI objects x and y and gives 1 i e true if they are equal but not necessarily identical 0 i e false otherwise Particular cases of gegal which should be used are gempO0 x x 0 gemp1 x x 1 and gemp_1 z x 1 Note that gemp0 x tests whether x is equal to zero even if x is not an exact object To test whether x is an exact object which is equal to zero one must use isexactzero Also note that the gcmp and gegal functions return a C integer and not a GEN like gle etc GP accepts the following synonyms for some of the above functions since we thought it might easily lead to confusion we don t use the customary C operators for bitwise and or bitwise or use bitand or bitor hence and amp are accepted as synonyms of and amp amp respectively Also lt gt is accepted as a synonym for On the other hand is definitely not a synonym for since it is the assignment statement 3 1 13 lex x y gives the result of a lexicographic comparison between x and y This is to be interpreted in quite a wide sen
191. e ab gt 0 and in fact if for example b 00 then it is preferable to have a as large as possible at least a gt 1 If flag 3 the function is allowed to be undefined but continuous at a or b for example the function sin x x at x 0 The library syntax is intnumO entree e GEN a GEN b char expr long flag long prec 132 3 9 2 matrix m n X Y expr 0 creation of the mxn matrix whose coefficients are given by the expression expr There are two formal parameters in expr the first one X corresponding to the rows the second Y to the columns and X goes from 1 to m Y goes from 1 to n If one of the last 3 parameters is omitted fill the matrix with zeroes The library syntax is matrice GEN nlig GEN ncol entree el entree e2 char expr 3 9 3 prod X a b expr x 1 product of expression expr initialized at x the formal parameter X going from a to b As for sum the main purpose of the initialization parameter x is to force the type of the operations being performed For example if it is set equal to the integer 1 operations will start being done exactly If 1t is set equal to the real 1 they will be done using real numbers having the default precision If it is set equal to the power series 1 O X for a certain k they will be done using power series of precision at most k These are the three most common initializations As an extreme example compare prod i 1 100 1 X7i this has degree 5050
192. e coefficients of the number field occur explicitly as polmods as coefficients of x the variable of these polmods must be the same as the main variable of t see nffactor The library syntax is nfroots nf 1 3 6 98 nfrootsof1 nf computes the number of roots of unity w and a primitive w th root of unity expressed on the integral basis belonging to the number field nf The result is a two component vector w 2 where z is a column vector expressing a primitive w th root of unity on the integral basis nf zk The library syntax is rootsof1 nf 3 6 99 nfsnf nf x given a torsion module x as a 3 component row vector 4 I J where A is a square invertible n x n matrix J and J are two ideal lists outputs an ideal list d d which is the Smith normal form of x In other words x is isomorphic to ZK d 9 ZK dy and d divides d _ for i gt 2 The link between x and A J J is as follows if e is the canonical basis of K I by b and J a1 a then x is isomorphic to biei p aie gt bnen a1 Az p Pa S An An 7 where the A are the columns of the matrix A Note that every finitely generated torsion module can be given in this way and even with b Zg for all i The library syntax is nfsmith nf x 3 6 100 nfsolvemodpr nf a b pr solution of a x b in Zx pr where a is a matrix and ba column vector and where pr is in modpr format see nfmodprinit The library syntax is nfsolvemodpr nf a b
193. e components are technical the numbering being very close to that of nfinit In the following description we let K be the base field defined by nf m the degree of the base field n the relative degree L the large field of relative degree n or absolute degree nm r and r2 the number of real and complex places of K rnf 1 contains the relative polynomial pol rnf 2 is a row vector with r r2 entries entry j being a 2 component row vector r 1 7 2 where rj and rj are the number of real and complex places of L above the j th place of K so that r 1 0 and r 2 n if j is a complex place while if j is a real place we have rj 1 255 2 n rnf 3 is a two component row vector d L K s where 0 L K is the relative ideal discrimi nant of L K and s is the discriminant of L K viewed as an element of K K in other words it is the output of rnfdisc rnf 4 is the ideal index f i e such that d pol Z g f70 L K rnf 5 is a vector vm with 7 entries useful for certain computations in the relative extension L K vm 1 is a vector of r r2 matrices the j th matrix being an 11 j 72 X n matrix M representing the numerical values of the conjugates of the j th embedding of the elements of the integral basis where r is as in rnf 2 vm 2 is a vector of r rg matrices the j th matrix MC being essentially the conjugate of the matrix M except that the last r2 columns are also multiplied by 2 vm 3 is a vector of r
194. e de In any case if you like this software we would appreciate if you could send us an email message giving us some information about yourself and what you use PARI for Put as header of your message new user so we can recognize it easily Good luck and enjoy 200 Appendix B A Sample program and Makefile We assume that you have installed the PARI library and include files as explained in Appendix A or in the installation guide If you chose differently any of the directory names change them accordingly in the Makefiles If the program example that we have given is in the file matexp c say as the first of several matrix transcendental functions then a sample Makefile might look as follows Note that the actual file examples Makefile is much more elaborate and you should have a look at it if you intend to use install on custom made functions see Section 3 11 2 13 CC cc INCDIR home belabas GP include pari LIBDIR home belabas GP lib CFLAGS 0 I INCDIR L LIBDIR all matexp matexp matexp c CC CFLAGS o matexp matexp c lpari lm We then give the listing of the program examples matexp c seen in detail in Section 4 8 with the slight modifications explained at the end of that section Id matexp c v 1 3 1999 12 17 16 14 01 karim Exp include pari h GEN matexp GEN x long prec long lx lg x i k n ltop avma GEN y r s p1 p2 check that x is a square matrix if ty
195. e dealing with a vector The library syntax is rnfelementreltoabs rnf x 3 6 118 rnfeltup rnf x rnf being a relative number field extension L K as output by rnfinit and x being an element of K expressed as a polynomial or polmod computes x as an element of the absolute extension L Q as a polynomial modulo the absolute equation rnf 11 1 Note that it is unnecessary to compute x as an element of the relative extension L K its expression would be identical to itself If x is given on the integral basis of K apply nfbasistoalg first otherwise PARI will believe you are dealing with a vector The library syntax is rnfelementup rnf x 3 6 119 rnfequation nf pol flag 0 given a number field nf as output by nfinit or simply a polynomial and a polynomial pol with coefficients in nf defining a relative extension L of nf computes the absolute equation of L over Q If flag is non zero outputs a 3 component row vector z a k where z is the absolute equation of L over Q as in the default behaviour a expresses as a polmod a root 8 of pol in terms of a root 0 of z and k is a small integer such that 0 6 ka where a is a root of the polynomial defining the base field nf The main variable of nf must be of lower priority than that of pol Note that for efficiency this does not check whether the relative equation is irreducible over nf but only if it is squarefree If it is reducible but squarefree the result will be the absolute
196. e function itself should works as described For any remarks about improving this interface please mail allomberQmath u bordeaux fr The output is an 8 component vector gal gal 1 contains the polynomial pol gal pol 1 gal 2 is a three components vector p e q where p is a prime number gal p such that pol totally split modulo p gal p e is an integer and q p is the modulus of the roots in gal roots gal 3 is a vector L containing the p adic roots of pol as integers implicitly modulo gal mod gal roots gal 4 is the inverse of the Van der Monde matrix of the p adic roots of pol multiplied by gal 5 gal 5 is a multiple of the least common denominator of the automorphisms expressed as polynomial in a root of pol gal 6 is the Galois group G expressed as a vector of permutations of L gal group gal 7 is a generating subset S s1 sg of G expressed as a vector of permutations of L gal gen gal 8 contains the relative orders o1 0 of the generators of S gal orders We have the following properties e G is super solvable if and only if 01 0y is decreasing e if not set H the maximal normal supersolvable subgroup of G if G H As then o1 0g ends by 2 2 3 if G H S4 then 0 0 ends by 2 2 3 2 e for 1 lt i lt g the subgroup of G generated by s1 Sg is normal with the exception of i g 2 in the second case and of i g 3 in the third
197. e g t_INT or integer as well as various miscellaneous keywords such as edit short summary of line editor commands operator member user defined nf ell Last but not least without argument will open a dvi previewer xdvi by default GPXDVI if it is defined in your environment containing the full user s manual tutorial and refcard do the same with the tutorial and reference card respectively Technical note these functionalities are provided by an external perl script that you are free to use outside any GP session and modify to your liking if you are perl knowledgeable It is called gphelp lies in the doc subdirectory of your distribution just make sure you run Configure first see Appendix A and is really two programs in one The one which is used from within GP is gphelp which runs TFX on a selected part of this manual then opens a previewer gphelp detex is a text mode equivalent which looks often nicer especially on a colour capable terminal see misc gprc dft for examples The default help selects which help program will be used from within GP You are welcome to improve this help script or write new ones and we really would like to know about it so that we may include them in future distributions By the way outside of GP you can give more than one keyword as argument to gphelp 2 2 2 comment Everything between the stars is ignored by GP These comments can span any number of lines 2 2 3 one
198. e initial help of Annette Hoffman from the University of Saarbriicken and David Carlisle from the University of Manchester it is possible to use GP as a subprocess of GNU Emacs Of course you need GNU Emacs to be installed on your machine To use this you should include in your emacs file the following lines autoload gp mode home belabas GP 1lib pari pari nil t gp P P autoload gp script mode home belabas GP lib pari pari nil t gp P P P autoload home belabas GP lib pari pari nil t gp P P autoload gpman home belabas GP lib pari pari nil t setq auto mode alist cons gp script mode auto mode alist gp gp P where pari el is the name of the file that will have to be loaded by GNU Emacs if you have changed the name or if you have the file in a different directory you must of course supply the correct name This file is included in the PARI distribution and probably has been installed at the same time as GP Once this is done under GNU Emacs if you type M x gp where as usual M is the Meta key i e Escape or on SUN keyboards the Left key a special shell will be started which in particular launches GP with the default stack size prime limit and input buffer size If you type instead C u M x gp you will be asked for the name of the GP executable the stack size the prime limit and the input buffer size before the execution of GP begins If for any of these you simply type return the defa
199. e log of x in the multiplicative group Z pZ This function using a simple minded baby step giant step approach and requires O p storage hence it cannot be used for p greater than about 10 The library syntax is znlog z g 3 4 63 znorder x x must be an integer mod n and the result is the order of x in the multiplicative group Z nZ Returns an error if x is not invertible The library syntax is order z 3 4 64 znprimroot zx returns a primitive root of z where x is a prime power The library syntax is gener z 3 4 65 znstar n gives the structure of the multiplicative group Z nZ as a 3 component row vector v where v 1 n is the order of that group v 2 is a k component row vector d of integers d i such that d i gt 1 and dli d i 1 for i gt 2 and Z nZ I Z d i Z and v 3 is a k component row vector giving generators of the image of the cyclic groups Z d i Z The library syntax is znstar n 72 3 5 Functions related to elliptic curves We have implemented a number of functions which are useful for number theorists working on elliptic curves We always use Tate s notations The functions assume that the curve is given by a general Weierstrass model y 017Yy azy xr aox 047 a6 where a priori the a can be of any scalar type This curve can be considered as a five component vector E a1 a2 a3 a4 a6 Points on E are represented as two component vectors x y except for
200. e output is a PostScript program appended to the psfile 3 10 30 psploth X a b expr same as ploth except that the output is a PostScript program appended to the psfile 3 10 31 psplothraw listz listy same as plothraw except that the output is a PostScript pro gram appended to the psfile 3 11 Programming under GP 3 11 1 Control statements A number of control statements are available under GP They are simpler and have a syntax slightly different from their C counterparts but are quite powerful enough to write any kind of program Some of them are specific to GP since they are made for number theorists As usual X will denote any simple variable name and seq will always denote a sequence of expressions including the empty sequence 3 11 1 1 break n 1 interrupts execution of current seq and immediately exits from the n innermost enclosing loops within the current function call or the top level loop n must be bigger than 1 If n is greater than the number of enclosing loops all enclosing loops are exited 3 11 1 2 for X a b seq the formal variable X going from a to b the seq is evaluated Nothing is done if a gt b a and b must be in R 3 11 1 3 fordiv n X seq the formal variable X ranging through the positive divisors of n the sequence seq is evaluated n must be of type integer 3 11 1 4 forprime X a b seq the formal variable X ranging over the prime numbers between a to b including a and
201. e problems only with w when you insist on having a filename whose first character is a digit and with r or w if the filename itself contains a space In such cases just use the underlying read or write function see Section 3 11 2 28 2 2 1 command GP on line help interface As already mentioned if you type n where n is a number from 1 to 11 you will get the list of functions in Section 3 n of the manual the list of sections being obtained by simply typing 7 These names are in general not informative enough More details can be obtained by typing function which gives a short explanation of the function s calling convention and effects Of course to have complete information read Chapter 3 of this manual the source code is at your disposal as well though a trifle less readable Much better help can be obtained through the extended help system see below If the line before the copyright message indicates that extended help is available this means perl is installed on your system GP was told about it at compile time and the whole PARI distribution was correctly installed you can add more signs for extended functionalities keyword yields the functions description as it stands in this manual usually in Chapter 2 or 3 If you re not satisfied with the default chapter chosen you can impose a given chapter by 18 ending the keyword with followed by the chapter number e g Hello 2 will look in Chapter 2
202. ealreltoabs rnf x rnf being a relative number field extension L K as output by rnfinit and z being a relative ideal which can be as in the absolute case of many different types including of course elements computes the HNF matrix of the ideal considered as an ideal of the absolute extension L Q The library syntax is rnfidealreltoabs rnf x 3 6 128 rnfidealtwoelt rnf x rnf being a relative number field extension L K as output by rnfinit and z being an ideal of the relative extension L K given by a pseudo matrix gives a vector of two generators of x over Zr expressed as polmods with polmod coefficients The library syntax is rnfidealtwoelement rnf x 111 3 6 129 rnfidealup rnf x rnf being a relative number field extension L K as output by rnfinit and x being an ideal of K gives the ideal zZz as an absolute ideal of L Q the relative ideal representation is trivial the matrix is the identity matrix and the ideal list starts with x all the other ideals being Zg The library syntax is rnfidealup rnf x 3 6 130 rnfinit nf pol nf being a number field in nfinit format considered as base field and pol a polynomial defining a relative extension over nf this computes all the necessary data to work in the relative extension The main variable of pol must be of higher priority i e lower number than that of nf and the coefficients of pol must be in nf The result is an 11 component row vector as follows most of th
203. eals in S v 5 gives the S class group structure in the usual format a row vector whose three components give in order the S class number the cyclic components and the generators v 6 is a copy of S The library syntax is bnfsunit bnf S prec 87 3 6 16 bnfunit bnf bnf being a big number field as output by bnfinit outputs a two component row vector giving in the first component the vector of fundamental units of the number field and in the second component the number of bit of accuracy which remained in the computation which is always correct otherwise an error message is printed This function is mainly for people who used the wrong flag in bnfinit and would like to skip part of a lengthy bnfinit computation The library syntax is buchfu bnf 3 6 17 bnrL1 bnr subgroup flag 0 bnr being the number field data which is output by bnrinit 1 and subgroup being a square matrix defining a congruence subgroup of the ray class group corresponding to bnr or 0 for the trivial congruence subgroup returns for each character x of the ray class group which is trivial on this subgroup the value at s 1 or s 0 of the abelian L function associated to x For the value at s 0 the function returns in fact for each character x a vector r cx where ry is the order of L s x at s 0 and cy the first non zero term in the expansion of L s x at s 0 in other words L s X t s O s x near 0 flag is opt
204. eaning of this is clear when zx is a rational number or function When z is an integer or a polynomial the result is equal to 1 When x is a vector or a matrix the lowest common denominator of the components of x is computed All other types are forbidden The library syntax is denom z 3 2 24 floor x floor of x When z is in R the result is the largest integer smaller than or equal to x Applied to a rational function floor x returns the euclidian quotient of the numerator by the denominator The library syntax is gfloor z 3 2 25 frac x fractional part of x Identical to x floor x If x is real the result is in 0 1 The library syntax is gfrac z 3 2 26 imag 1 imaginary part of x When x is a quadratic number this is the coefficient of w in the canonical integral basis 1 w The library syntax is gimag z 5l 3 2 27 length x number of non code words in x really used i e the effective length minus 2 for integers and polynomials In particular the degree of a polynomial is equal to its length minus 1 If x has type t_STR output number of letters The library syntax is glength x and the result is a C long 3 2 28 lift x v lifts an element x a mod n of Z nZ to a in Z and similarly lifts a polmod to a polynomial if v is omitted Otherwise lifts only polmods with main variable v if v does not occur in 2 lifts only intmods If x is of type fraction complex quadratic polynomial power
205. ec in anal c identifier This limitation should disappear in future versions When the function is called under GP the prototype is scanned and each time an atom corresponding to a mandatory argument is met a user given argument is read GP outputs an error message it the argument was missing Each time an optional atom is met a default value is inserted if the user omits the argument The automatic atoms fill in the argument list transparently supplying the current value of the corresponding variable or a dummy pointer For instance here is how you would code the following prototypes which don t involve default values GEN name GEN x GEN y long prec gt GGp void name GEN x GEN y long prec gt vGGp void name GEN x long y long prec gt vGLp long name GEN x gt ql If you want more examples GP gives you easy access to the parser codes associated to all GP functions just type h function You can then compare with the C prototypes as they stand in the code Remark If you need to implement complicated control statements probably for some improved summation functions you ll need to know about the entree type which is not documented Check the comment before the function list at the end of language init c and the source code in language sumiter c You should be able to make something of it 4 9 3 Coding guidelines Code your function in a file of its own using as a guide other functions i
206. ector The main variable of nf must be of lower priority than that of x in other words the variable number of nf must be greater than that of x However if the polynomial defining the number field occurs explicitly in the coefficients of x as modulus of a t_POLMOD its main variable must be the same as the main variable of x For example nf nfinit y 2 1 nffactor nf x 2 y OK nffactor nf x72 Mod y y 2 1 MM OK nffactor nf x 2 Mod z z72 1 WRONG NN NN The library syntax is nffactor nf x 3 6 83 nffactormod nf x pr factorization of the univariate polynomial z modulo the prime ideal pr in the number field nf x can have coefficients in the number field scalar polmod polynomial column vector or modulo the prime ideal integermod modulo the rational prime under pr polmod or polynomial with integermod coefficients column vector of integermod The prime ideal pr must be in the format output by idealprimedec The main variable of nf must be of lower priority than that of x in other words the variable number of nf must be greater than that of x However if the coefficients of the number field occur explicitly as polmods as coefficients of x the variable of these polmods must be the same as the main variable of t see nffactor The library syntax is nffactormod nf x pr 3 6 84 nfgaloisapply nf aut x nf being a number field as output by nfinit and aut being a Galois automorphism of nf expre
207. ects 4 2 Important technical notes 4 3 Creation of PARI objects assignments conversions 4 4 Garbage collection 4 5 Implementation of the PARI types 4 6 PARI variables 4 7 Input and output 4 8 A complete program 4 9 Adding functions to PARI Chapter 5 Technical Reference Gide fon Tove Bevel PO 5 1 Level 0 kernel operations on unsigned longs 5 2 Level 1 kernel operations on longs integers and reals 5 3 Level 2 kernel operations on general PARI objects i Appendix A Installation Guide for the UNIX Versions Appendix B A Sample program and Makefile Appendix C Summary of Available Constants Index Pn Bw W 18 21 24 26 28 36 36 38 39 43 44 46 55 62 72 79 115 120 131 135 141 149 149 150 153 156 163 167 169 173 177 183 183 184 189 195 201 203 205 Chapter 1 Overview of the PARI system 1 1 Introduction The PARI system is a package which is capable of doing formal computations on recursive types at high speed it is primarily aimed at number theorists but can be used by anybody whose primary need is speed Although quite an amount of symbolic manipulation is possible in PARI this system does very badly compared to much more sophisticated systems like Axiom Macsyma Maple Mathematica or Reduce on such manipulations e g multivariate polynomials formal integration etc On the other hand the three main advantages of the sy
208. ed at infinity The extension W i is represented by a 4 component row vector m d r D with the following meaning m is the prime ideal factorization of the modulus d L Q is the absolute degree of L r is the number of real places of L and D is the factorization of the absolute discriminant Each prime ideal pr p a e f 6 in the prime factorization m is coded as p n2 f 1 n j 1 where n is the degree of the base field and j is such that pr idealprimedec nf p j m can be decoded using bnfdecodemodule The library syntax is bnrdisclistO al a2 a3 bound arch flag 3 6 25 bnrinit bnf ideal flag 0 bnf is as output by bnfinit ideal is a valid ideal or a module initializes data linked to the ray class group structure corresponding to this module This is the same as bnrclass bnf ideal flag 1 The library syntax is bnrinitO0 bnf ideal flag prec 90 3 6 26 bnrisconductor al a2 a3 al a2 a3 represent an extension of the base field given by class field theory for some modulus encoded in the parameters Outputs 1 if this modulus is the conductor and 0 otherwise This is slightly faster than bnrconductor The library syntax is bnrisconductor al a2 a3 and the result is a long 3 6 27 bnrisprincipal bnr x flag 1 bnr being the number field data which is output by bnrinit and z being an ideal in any form outputs the components of x on the ray class group generators in a way similar to
209. elian extension The result is a 3 component vector conductor rayclgp subgroup where conductor is the conductor of the extension given as a 2 component row vector fo fo rayclgp is the full ray class group corresponding to the conductor given as a 3 component vector h cyc gen as usual for a group and subgroup is a matrix in HNF defining the subgroup of the ray class group on the given generators gen The library syntax is rnfconductor rnf pol prec 3 6 112 rnfdedekind nf pol pr given a number field nf as output by nfinit and a polynomial pol with coefficients in nf defining a relative extension L of nf evaluates the relative Dedekind criterion over the order defined by a root of pol for the prime ideal pr and outputs a 3 component vector as the result The first component is a flag equal to 1 if the enlarged order is pr maximal and to O otherwise the second component is a pseudo basis of the enlarged order and the third component is the valuation at pr of the order discriminant The library syntax is rnfdedekind nf pol pr 3 6 113 rnfdet nf M given a pseudomatrix M over the maximal order of nf computes its pseudodeterminant The library syntax is rnfdet nf M 3 6 114 rnfdisc nf pol given a number field nf as output by nfinit and a polynomial pol with coefficients in nf defining a relative extension L of nf computes the relative discriminant of L This is a two element row vector D d where D is the relative ideal dis
210. en n is negative gshift acts like a right 175 shift of n hence does not noramlly perform an exact division on integers The function gshift is the PARI analogue of the C or GP operators lt lt and gt gt We now come to the heart of the function We have a GEN p1 which points to a certain matrix of which we want to take the exponential We will want to transform this matrix into a matrix with real or complex of real entries before starting the computation To do this we simply multiply by the real number 1 in precision prec 1 to be on the side of safety To sum the series we will use three variables a variable p2 which at stage k will contain p1 k a variable y which will contain Se p1 i and a variable r which will contain the size estimate s k Note that we do not use Horner s rule This is simply because we are lazy and do not want to compute in advance the number of terms that we need We leave this modification and many other improvements to the reader The program continues as follows initializations before the loop r cgetr prec 1 gaffsg 1 r pl gmul r p1 y gscalmat r 1x 1 creates scalar matrix with r on diagonal p2 pls r s k 1 y gadd y p2 now the main loop while expo r gt BITS_IN_LONG prec 1 k p2 gdivgs gmul p2 p1 k r gdivgs gmul s r k y gadd y p2 now square back n times if necessary if n lbot avma y gcopy y
211. en to making it user friendly The situation has now changed somewhat and GP is very useful as a stand alone tool The operations and functions available in PARI and GP will be described in the next chapter In the present one we describe the specific use of the GP programmable calculator For starting the calculator the general commandline syntax is gp s stacksize p primelimit where items within brackets are optional These correspond to some internal parameters of GP or defaults See Section 2 1 below for a list and explanation of all defaults there are many more than just those two These defaults can be changed by adding parameters to the input line as above or interactively during a GP session or in a preferences file also known as gprc Some new features were developed on UNIX platforms and depend heavily on the operating system in use It is possible that some of these will be ported to other operating systems BeOS MacOS DOS OS 2 Windows etc in future versions most of them should be easy tasks for anybody acquainted with those As for now most of them were not So whenever a specific feature of the UNIX version is discussed in a paragraph a UNIX sign sticks out in the left margin like here Just skip these if you re stranded on a different operating system the core GP functions i e at least everything which is even faintly mathematical in nature will still be available to you It may also be possible and then
212. entries are expressed as algebraic numbers in the number field nf transforms it so that the entries are expressed as a column vector on the integral basis nf zk The library syntax is algtobasis nf x 99 3 6 66 nfbasis z flag 0 p integral basis of the number field defined by the irreducible preferably monic polynomial x using a modified version of the round 4 algorithm by default The binary digits of flag have the following meaning 1 assume that no square of a prime greater than the default primelimit divides the discrim inant of x i e that the index of x has only small prime divisors 2 use round 2 algorithm For small degrees and coefficient size this is sometimes a little faster This program is the translation into C of a program written by David Ford in Algeb Thus for instance if flag 3 this uses the round 2 algorithm and outputs an order which will be maximal at all the small primes If p is present we assume without checking that it is the two column matrix of the fac torization of the discriminant of the polynomial x Note that it does not have to be a complete factorization This is especially useful if only a local integral basis for some small set of places is desired only factors with exponents greater or equal to 2 will be considered The library syntax is nfbasisO z flag p An extended version is nfbasis x amp d flag p where d will receive the discriminant of the number field not o
213. equation of the tale algebra defined by pol If pol is not squarefree an error message will be issued The library syntax is rnfequation0 nf pol flag 3 6 120 rnfhnfbasis bnf x given a big number field bnf as output by bnfinit and either a polynomial x with coefficients in bnf defining a relative extension L of bnf or a pseudo basis x of such an extension gives either a true bnf basis of L in upper triangular Hermite normal form if it exists zero otherwise The library syntax is rnfhermitebasis nf x 110 3 6 121 rnfidealabstorel rnf x rnf being a relative number field extension L K as output by rnfinit and x being an ideal of the absolute extension L Q given in HNF if it is not apply idealhnf first computes the relative pseudomatrix in HNF giving the ideal x considered as an ideal of the relative extension L K The library syntax is rnfidealabstorel rnf x 3 6 122 rnfidealdown rnf x rnf being a relative number field extension L K as output by rnfinit and x being an ideal of the absolute extension L Q given in HNF if it is not apply idealhnf first gives the ideal of K below zx i e the intersection of x with K Note that if x is given as a relative ideal i e a pseudomatrix in HNF then it is not necessary to use this function since the result is simply the first ideal of the ideal list of the pseudomatrix The library syntax is rnfidealdown rnf x 3 6 123 rnfidealhnf rnf x rnf being a relative numb
214. er Gives an error if x has no variable associated to it Note that this function is useful only in GP since in library mode the function gvar is more appropriate The library syntax is gpolvar x However in library mode this function should not be used Instead test whether x is a p adic type t_PADIC in which case p is in 2 2 or call the function gvar x which returns the variable number of x if it exists BIGINT otherwise 3 3 Transcendental functions As a general rule which of course in some cases may have exceptions transcendental functions operate in the following way e If the argument is either an integer a real a rational a complex or a quadratic number it is if necessary first converted to a real or complex number using the current precision held in the default realprecision Note that only exact arguments are converted while inexact arguments such as reals are not Under GP this is transparent to the user but when programming in library mode care must be taken to supply a meaningful parameter prec as the last argument of the function if the first argument is an exact object This parameter is ignored if the argument is inexact Note that in library mode the precision argument prec is a word count including codewords i e represents the length in words of a real number while under GP the precision which is changed by the metacommand Xp or using default realprecision is the number of significant decimal
215. er field extension L K as output by rn finit and z being a relative ideal which can be as in the absolute case of many different types including of course elements computes as a 2 component row vector the relative Hermite normal form of zx the first component being the HNF matrix with entries on the integral basis and the second component the ideals The library syntax is rnfidealhermite rnf x 3 6 124 rnfidealmul rnf x y rnf being a relative number field extension L K as output by rnfinit and z and y being ideals of the relative extension L K given by pseudo matrices outputs the ideal product again as a relative ideal The library syntax is rnfidealmul rnf x y 3 6 125 rnfidealnormabs rnf x rnf being a relative number field extension L K as output by rnfinit and being a relative ideal which can be as in the absolute case of many different types including of course elements computes the norm of the ideal x considered as an ideal of the absolute extension L Q This is identical to idealnorm rnfidealnormrel rnf x only faster The library syntax is rnfidealnormabs rnf x 3 6 126 rnfidealnormrel rnf x rnf being a relative number field extension L K as output by rnfinit and z being a relative ideal which can be as in the absolute case of many different types including of course elements computes the relative norm of x as a ideal of K in HNF The library syntax is rnfidealnormrel rnf x 3 6 127 rnfid
216. er is normalized meaning that the first mantissa longword ie z 2 is non zero However the integer may have been created with a longer length Hence the length which is in z 0 can be larger than the effective length which is in z 1 Accessing zi for i larger than or equal to the effective length will yield random results This information is handled using the following macros long signe GEN z returns the sign of z void setsigne GEN z long s sets the sign of z to s long lgefint GEN z returns the effective length of z void setlgefint GEN z long 1 sets the effective length of z to 1 The integer 0 can be recognized either by its sign being 0 or by its effective length being equal to 2 When z 0 the word z 2 exists and is non zero and the absolute value of z is z 2 z 3 z lgefint z 1 in base 2 BITS_IN_LONG where as usual in this notation z 2 is the highest order longword The following further macros are available long mpodd GEN x which is 1 if x is odd and 0 otherwise long mod2 GEN x mod4 x and so on up to mod64 x which give the residue class of x modulo the corresponding power of 2 for positive x you will obtain weird results if you use these on the integer 0 or on negative numbers These macros directly access the binary data and are thus much faster than the generic modulo functions Besides they return long integers instead of GENs so they don t clutter up the stack
217. ersion 2 0 19 a primitive but useful version of Lenstra s Elliptic Curve Method ECM has been implemented There is now a very large package which enables the number theorist to work with ease in alge braic number fields All the usual operations on elements ideals prime ideals etc are available More sophisticated functions are also implemented like solving Thue equations finding integral bases and discriminants of number fields computing class groups and fundamental units computing in relative number field extensions including explicit class field theory and also many functions dealing with elliptic curves over Q or over local fields 1 3 6 Other functions Quite a number of other functions dealing with polynomials e g finding complex or p adic roots factoring etc power series e g substitution reversion linear algebra e g determinant charac teristic polynomial linear systems and different kinds of recursions are also included In addition standard numerical analysis routines like Romberg integration open or closed on a finite or infinite interval real root finding when the root is bracketed polynomial interpolation infinite series evaluation and plotting are included See the last sections of Chapter 3 for details 10 UNIX EMACS Chapter 2 Specific Use of the GP Calculator Originally GP was designed as a debugging tool for the PARI system library and hence not much thought had been giv
218. es or 263 1 for 64 bit machines if x is an exact object The library syntax is padicprec z p and the result is a long integer 3 2 34 permtonum z given a permutation x on n elements gives the number k such that x numtoperm n k i e inverse function of numtoperm The library syntax is permutelnv z 52 3 2 35 precision z n gives the precision in decimal digits of the PARI object x If x is an exact object the largest single precision integer is returned If n is not omitted creates a new object equal to x with a new precision n This is to be understood as follows For exact types no change For x a vector or a matrix the operation is done componentwise For real x n is the number of desired significant decimal digits If n is smaller than the precision of x x is truncated otherwise x is extended with zeros For x a p adic or a power series n is the desired number of significant p adic or X adic digits where X is the main variable of x Note that the function precision never changes the type of the result In particular it is not possible to use it to obtain a polynomial from a power series For that see truncate The library syntax is precision0 x n where n is a long Also available are ggprecision x result is a GEN and gprec x n where n is a long 3 2 36 random N 2 gives a random integer between 0 and N 1 N can be arbitrary large This is an internal PARI function and does not depend o
219. escribes the format to use to write the remaining operands as in the printf function however see the next section The simple syntax above is just a special case with a constant format and no remaining arguments The general syntax is void err numerr 171 where numerr is a codeword which indicates what to do with the remaining arguments and what message to print The list of valid keywords is in language errmessages c together with the basic corresponding message For instance err typeer matexp will print the message xxx incorrect type in matexp Among the codewords are warning keywords all those which start with the prefix warn In that case err does not abort the computation just print the requested message and go on The basic example is err warner Strategy 1 failed Trying strategy 2 which is the exact equivalent of err talker except that you certainly don t want to stop the program at this point just inform the user that something important has occured in particular this output would be suitably highlighted under GP whereas a simple printf would not 4 7 4 Debugging output The global variables DEBUGLEVEL and DEBUGMEM corresponding to the default debug and debugmem see Section 2 1 are used throughout the PARI code to govern the amount of diagnostic and debugging output depending on their values You can use them to debug your own functions especially after having made them accessible under GP t
220. esent matrices with zero columns and a nonzero number of rows 2 3 15 Lists type t_LIST lists cannot be input directly you have to use the function listcreate first then listput each time you want to append a new element but you can access the elements directly as with the vector types described above The function List can be used to transform row or column vectors into lists see Chapter 3 2 3 16 Strings type t_STR to enter a string just enclose it between double quotes like this this is a string The function Str can be used to transform any object into a string see Chapter 3 2 4 GP operators Loosely speaking an operator is a function usually associated to basic arithmetic operations whose name contains only non alphanumeric characters In practice most of these are simple functions which take arguments and return a value assignment operators also have side effects Each of these has some fixed and unchangeable priority which means that in a given expression the operations with the highest priority will be performed first Operations at the same priority level will always be performed in the order they were written i e from left to right Anything enclosed between parenthesis is considered a complete subexpression and will be resolved independently of the surrounding context For instance assuming that o0p op2 op3 are standard binary operators with increasing priorities think of for instance
221. ete functions but otherwise accept them The output uses the new conventions though and there may be subtle incompatibilities between the behaviour of former and current functions even when they share the same name the current function is used in such cases of course We thought of this one as a transitory help for GP old timers Thus to encourage switching to compatible 0 it is not possible to disable the warning compatible 2 use only the old function naming scheme as used up to version 1 39 15 but taking case into account Thus I y 1 is not the same as i user variable unbound by default and you won t get an error message using i as a loop index as used to be the case compatible 3 try to mimic exactly the former behaviour This is not always possible when functions have changed in a fundamental way But these differences are usually for the better they were meant to anyway and will probably not be discovered by the casual user One adverse side effect is that any user functions and aliases that have been defined before changing compatible will get erased if this change modifies the function list i e if you move between groups 0 1 and 2 3 variables are unaffected We of course strongly encourage you to try and get used to the setting compatible 0 14 UNIX 2 1 4 debug default 0 debugging level Tf it is non zero some extra messages may be printed some of it in French according to what is going
222. f the functions described here can be applied to other types 3 7 1 O a b p adic if a is an integer greater or equal to 2 or power series zero in all other cases with precision given by b The library syntax is ggrandocp a b where bis a long 3 7 2 deriv x v derivative of x with respect to the main variable if v is omitted and with respect to v otherwise x can be any type except polmod The derivative of a scalar type is zero and the derivative of a vector or matrix is done componentwise One can use z as a shortcut if the derivative is with respect to the main variable of zx The library syntax is deriv z v where v is a long and an omitted v is coded as 1 3 7 3 eval x replaces in x the formal variables by the values that have been assigned to them after the creation of x This is mainly useful in GP and not in library mode Do not confuse this with substitution see subst Applying this function to a character string yields the output from the corresponding GP command as if directly input from the keyboard see Section 2 6 5 The library syntax is geval z The more basic functions poleval q x qfeval q x and hqfeval q x evaluate q at x where q is respectively assumed to be a polynomial a quadratic form a symmetric matrix or an Hermitian form an Hermitian complex matrix 3 7 4 factorpadic pol p r flag 0 p adic factorization of the polynomial pol to precision r the result being a two colu
223. f any type If flag 0 use standard Gauss pivot If flag 1 use matsupplement The library syntax is matimage0 x flag Also available is image x flag 0 3 8 23 matimagecompl z gives the vector of the column indices which are not extracted by the function matimage Hence the number of components of matimagecompl x plus the number of columns of matimage x is equal to the number of columns of the matrix zx The library syntax is imagecompl z 3 8 24 matindexrank 1 x being a matrix of rank r gives two vectors y and z of length r giving a list of rows and columns respectively starting from 1 such that the extracted matrix obtained from these two vectors using vecextract z y 2 is invertible The library syntax is indexrank z 3 8 25 matintersect z y x and y being two matrices with the same number of rows each of whose columns are independent finds a basis of the Q vector space equal to the intersection of the spaces spanned by the columns of x and y respectively See also the function idealintersect which does the same for free Z modules The library syntax is intersect z y 3 8 26 matinverseimage z y gives a column vector belonging to the inverse image of the column vector y by the matrix x if one exists the empty vector otherwise To get the complete inverse image it suffices to add to the result any element of the kernel of x obtained for example by matker The library syntax is inverseimage z y 3 8
224. f the polynomial x and an omitted p should be input as gzero Also available are base x amp d flag 0 base2 x amp d flag 2 and factoredbase z p amp d 3 6 67 nfbasistoalg nf this is the inverse function of nfalgtobasis Given an object x whose entries are expressed on the integral basis nf zk transforms it into an object whose entries are algebraic numbers i e polmods The library syntax is basistoalg nf x 3 6 68 nfdetint nf x given a pseudo matrix x computes a non zero ideal contained in i e mul tiple of the determinant of x This is particularly useful in conjunction with nfhnfmod The library syntax is nfdetint nf x 3 6 69 nfdisc x flag 0 p field discriminant of the number field defined by the integral preferably monic irreducible polynomial x flag and p are exactly as in nfbasis That is p provides the matrix of a partial factorization of the discriminant of x and binary digits of flag are as follows 1 assume that no square of a prime greater than primelimit divides the discriminant 2 use the round 2 algorithm instead of the default round 4 This should be slower except maybe for polynomials of small degree and coefficients The library syntax is nfdiscfO z flag p where to omit p you should input gzero You can also use discf x flag 0 3 6 70 nfeltdiv nf x y given two elements x and y in nf computes their quotient x y in the number field nf The library synta
225. for section heading Hello which doesn t exist by the way All operators e g amp amp etc are accepted by this extended help as well as a few other keywords describing key GP concepts e g readline the line editor integer nf number field as used in most algebraic number theory computations e11 elliptic curves etc In case of conflicts between function and default names e g log simplify the function has higher priority Use 7 default defaultname to get the default help 27 pattern produces a list of sections in Chapter 3 of the manual related to your query As before if pattern ends by followed by a chapter number that chapter is searched instead you also have the option to append a simple without a chapter number to browse through the whole manual If your query contains dangerous characters e g or blanks it is advisable to enclose it within double quotes as for GP strings e g elliptic curve Note that extended help is much more powerful than the short help since it knows about operators as well you can type or amp amp whereas a single would just yield a not too helpful xxx unknown identifier message Also you can ask for extended help on section number n in Chapter 3 just by typing 7 n where n would yield merely a list of functions Finally a few key concepts in GP are documented in this way metacommands e g defaults e g psfile and type names
226. fpolred nf pol prec 3 6 137 rnfpolredabs nf pol flag 0 relative version of polredabs Given a monic poly nomial pol with coefficients in nf finds a simpler relative polynomial defining the same field If flag 1 returns P a where P is the default output and a is an element expressed on a root of P whose characteristic polynomial is pol if flag 2 returns an absolute polynomial same as rnfequation nf rnfpolredabs nf pol but faster Remark In the present implementation this is both faster and much more efficient than rnf polred the difference being more dramatic than in the absolute case This is because the imple mentation of rnfpolred is based on a partial implementation of an incomplete reduction theory of lattices over number fields i e the function rnflllgram which deserves to be improved The library syntax is rnfpolredabs nf pol flag prec 3 6 138 rnfpseudobasis nf pol given a number field nf as output by nfinit and a polynomial pol with coefficients in nf defining a relative extension L of nf computes a pseudo basis A T and the relative discriminant of L This is output as a four element row vector 4 I D d where D is the relative ideal discriminant and d is the relative discriminant considered as an element of nf mp Note As usual nf can be a bnf as output by bnfinit The library syntax is rnfpseudobasis nf pol 114 3 6 139 rnfsteinitz nf x given a number field nf as ou
227. fying x y det x x Id 2 must be a non necessarily invertible square matrix The library syntax is adj x 3 8 11 matcompanion z the left companion matrix to the polynomial z The library syntax is assmat z 3 8 12 matdet zx flag 0 determinant of x x must be a square matrix If flag 0 uses Gauss Bareiss If flag 1 uses classical Gaussian elimination which is better when the entries of the ma trix are reals or integers for example but usually much worse for more complicated entries like multivariate polynomials The library syntax is det x flag 0 and det2 x flag 1 3 8 13 matdetint x x being an m x n matrix with integer coefficients this function computes a multiple of the determinant of the lattice generated by the columns of x if it is of rank m and returns zero otherwise This function can be useful in conjunction with the function mathnfmod which needs to know such a multiple Other ways to obtain this determinant assuming the rank is maximal is matdet qf111 x 4 2 x or more simply matdet mathnf x Experiment to see which is faster for your applications The library syntax is detint 123 3 8 14 matdiagonal z x being a vector creates the diagonal matrix whose diagonal entries are those of x The library syntax is diagonal z 3 8 15 mateigen x gives the eigenvectors of x as columns of a matrix The library syntax is eigen 3 8 16 mathess x Hessenberg form of the
228. g For instance using dbx or gdb if obj is a GEN typing print output obj will enable you to see the content of obj provided the optimizer has not put it into a register but it s rarely a good idea to debug optimized code e prettymatrix format this format is identical to the preceding one except for matrices The relevant functions are void matbrute GEN obj char x long n void outmat GEN obj which is followed by a newline and a buffer flush e prettyprint format the basic function has an additional parameter m corresponding to the minimum field width used for printing integers void sor GEN obj char x long n long m The simplified version is 170 void outbeaut GEN obj which is equivalent to sor obj g 1 0 followed by a newline and a buffer flush e The first extra format corresponds to the texprint function of GP and gives a TFX output of the result It is obtained by using void exe GEN obj char x long n e The second one is the function GENtostr which converts a PARI GEN to an ASCII string The syntax is chart GENtostr GEN obj wich returns a malloc ed character string which you should free after use e The third and final one outputs the hexadecimal tree corresponding to the GP command x using the function void voir GEN obj long nb which will only output the first nb words corresponding to leaves very handy when you have a look at big recursive structures If you set thi
229. ger coefficients The result of this function is a vector v with 10 components it is not a bnf you need bnfinit for that which for ease of presentation is in fact output as a one column matrix First we describe the default behaviour flag 0 v 1 is equal to the polynomial P Note that for optimum performance P should have gone through polred or nfinit z 2 v 2 is the 2 component vector r1 r2 where rl and r2 are as usual the number of real and half the number of complex embeddings of the number field K v 3 is the 2 component vector containing the field discriminant and the index v 4 is an integral basis in Hermite normal form v 5 v clgp is a 3 component vector containing the class number v clgp no the structure of the class group as a product of cyclic groups of order n v clgp cyc and the corresponding generators of the class group of respective orders n v clgp gen v 6 v reg is the regulator computed to an accuracy which is the maximum of an internally determined accuracy and of the default v 7 is a measure of the correctness of the result If it is close to 1 the results are correct under GRH If it is close to a larger integer this shows that the product of the class number by the regulator is off by a factor equal to this integer and you must start again with a larger value for c or a different random seed i e use the function setrand Since the computation involves a random process s
230. ges made to the current line C t and M t will transpose the character word preceding the cursor and the one under the cursor Keeping the M key down while you enter an integer a minus sign meaning reverse behaviour gives an argument to your next readline command for instance M C k will kill text back to the start of line If you prefer Vi style editing M C j will toggle you to Vi mode Of course you can change all these default bindings For that you need to create a file named inputrc in your home directory For instance notice the embedding conditional in case you would want specific bindings for GP if Pari GP set show all if ambiguous C h backward delete char e C h backward kill word C xd dump functions Co C v C b can be annoying when copy pasting Es C v C b endif C x C r will re read this init file incorporating any changes made to it during the current session Note By default and are bound to the function pari matched insert which if electric parentheses are enabled default off will automatically insert the matching closure respectively and This behaviour can be toggled on and off by giving the numeric argument 2 to M 2 which is useful if you want e g to copy paste some text into the calculator If you don t want a toggle you can use M 0 M 1 to specifically switch it on or off Note In recent versions of readline 2 1 for instance the Alt or
231. h is a technical vector empty by default containing c c2 nrel borne nbpid minsfb in this order see the beginning of the section or the keyword bnf You can supply any number of these provided you give an actual value to each of them the empty arg trick won t work here Careful use of these parameters may speed up your computations considerably The library syntax is bnfclassunit0 P flag tech prec 3 6 3 bnfclgp P tech as bnfclassunit but only outputs v 5 i e the class group The library syntax is bnfclassgrouponly P tech prec where tech is as described under bnfclassunit 3 6 4 bnfdecodemodule nf m if m is a module as output in the first component of an extension given by bnrdisclist outputs the true module The library syntax is decodemodule nf m 3 6 5 bnfinit P flag 0 tech essentially identical to bnfclassunit except that the output contains a lot of technical data and should not be printed out explicitly in general The result of bnfinit is used in programs such as bnfisprincipal bnfisunit or bnfnarrow The result is a 10 component vector bnf e The first 6 and last 2 components are technical and in principle are not used by the casual user However for the sake of completeness their description is as follows We use the notations explained in the book by H Cohen A Course in Computational Algebraic Number Theory Graduate Texts in Maths 138 Springer Verlag 1993 Section 6 5
232. hat the curve is a modular elliptic curve The optional parameter A is a cutoff point for the integral which must be chosen close to 1 for best speed The result must be independent of A so this allows some internal checking of the function Note that if the conductor of the curve is large say greater than 10 this function will take an unreasonable amount of time since it uses an O N algorithm The library syntax is lseriesell E s A prec where prec is a long and an omitted A is coded as NULL 3 5 18 ellorder F z gives the order of the point z on the elliptic curve E if it is a torsion point zero otherwise In the present version 2 0 19 this is implemented only for elliptic curves defined over Q The library syntax is orderell F z 3 5 19 ellordinate F x gives a 0 1 or 2 component vector containing the y coordinates of the points of the curve E having x as x coordinate The library syntax is ordell E x 3 5 20 ellpointtoz F z if E is an elliptic curve with coefficients in R this computes a complex number t modulo the lattice defining E corresponding to the point z i e such that in the standard Weierstrass model g t z 1 o t z 2 In other words this is the inverse function of ellztopoint If E has coefficients in Qp then either Tate s u is in Qp in which case the output is a p adic number t corresponding to the point z under the Tate parametrization or only its square is in which case the o
233. he automorphims defined by the permutations perm of the roots gal roots If no flags or flag 0 output format is the same that nfsubfield return P x such that P is a polynomial defining the fixed field of gal pol by the subgroup generated by perm and x is a root of P in gal expressed as a polmod in gal pol If flag 1 return only the polynomial P If flag 2 return P x F where P and x are as above and F is the factorization of gal pol over the field defined by P where variable v y by default stands for a root of P The priority of v must be less than the priority of the variable of gal pol P is garanteed to be squarefree modulo gal p Example 92 G galoisinit x 4 1 galoisfixedfield G G group 2 2 x72 2 Mod x 3 x x74 1 x 2 y x 1 x72 y x 1 compute the factorization z4 1 1 2z 1 1 y 2x 1 The library syntax is galoisfixedfield gal perm p 3 6 34 galoisinit pol den Computes the Galois group and all neccessary informations for computing the fixed fields of the Galois extension K Q where K is the number field defined by pol which can be a monic irreducible polynomial in Z X or a number field as output by nfinit The extension K Q must be Galois with Galois group weakly super solvable see nf galois conj Warning The interface of this function is experimental so the described output can be subject to important changes in the near future However th
234. he change of variables This is implicit when pol is not monic first a linear change of variables is performed to get a monic polynomial then a polred reduction If flag 4 as 2 but uses a partial polred If flag 5 as 3 using a partial polred The library syntax is nfinitO z flag prec 3 6 90 nfisideal nf x returns 1 if x is an ideal in the number field nf 0 otherwise The library syntax is isideal x 3 6 91 nfisincl x y tests whether the number field K defined by the polynomial x is conjugate to a subfield of the field L defined by y where x and y must be in Q X If they are not the output is the number 0 If they are the output is a vector of polynomials each polynomial a representing an embedding of K into L i e being such that y xo a Tf y is a number field nf a much faster algorithm is used factoring x over y using nffactor Before version 2 0 14 this wasn t guaranteed to return all the embeddings hence was triggered by a special flag This is no more the case The library syntax is nfisincl z y flag 3 6 92 nfisisom x y as nfisincl but tests for isomorphism If either x or y is a number field a much faster algorithm will be used The library syntax is nfisisom z y flag 3 6 93 nfnewprec nf transforms the number field nf into the corresponding data using current usually larger precision This function works as expected if nf is in fact a bnf update bnf to current precision but may be
235. he internals at 66 work by using GP s debuglevel default parameter level 3 shows just the outline 4 turns on time keeping 5 and above show an increasing amount of internal details Tf you see anything funny happening please let us know The library syntax is factorint n flag 3 4 25 factormod z p flag 0 factors the polynomial x modulo the prime integer p using Berlekamp The coefficients of x must be operation compatible with Z pZ The result is a two column matrix the first column being the irreducible polynomials dividing x and the second the exponents If flag is non zero outputs only the degrees of the irreducible polynomials for example for computing an L function A different algorithm for computing the mod p factorization is factorcantor which is sometimes faster The library syntax is factormod z p flag Also available are factmod z p which is equiv alent to factormod z p 0 and simplefactmod z p factormod z p 1 3 4 26 fibonacci x xt Fibonacci number The library syntax is fibo x x must be a long 3 4 27 gcd z y flag 0 creates the greatest common divisor of x and y x and y can be of quite general types for instance both rational numbers Vector matrix types are also accepted in which case the GCD is taken recursively on each component Note that for these types gcd is not commutative If flag 0 use Euclid s algorithm If flag 1 use the modular gcd algorithm x an
236. he library syntax is nextprime z 3 4 38 numdiv x number of divisors of x z must be of type integer and the result is a long The library syntax is numbdiv z 3 4 39 omega x number of distinct prime divisors of x x must be of type integer The library syntax is omega z the result is a long 3 4 40 precprime z finds the largest prime less than or equal to x x can be of any real type Returns 0 if x lt 1 Note that if x is a prime this function returns x and not the largest prime strictly smaller than x The library syntax is precprime z 68 3 4 41 prime z the x prime number which must be among the precalculated primes The library syntax is prime x x must be a long 3 4 42 primes 1 creates a row vector whose components are the first x prime numbers which must be among the precalculated primes The library syntax is primes x x must be a long 3 4 43 qfbclassno z flag 0 class number of the quadratic field of discriminant x In the present version 2 0 19 a simple algorithm is used for x gt 0 so x should not be too large say x lt 10 for the time to be reasonable On the other hand for x lt 0 one can reasonably compute classno x for x lt 102 since the method used is Shanks method which is in O a 4 For larger values of D see quadclassunit If flag 1 compute the class number using Euler products and the functional equation However it is in O a Important wa
237. he nt Legendre polynomial in variable v The library syntax is legendre n where x is a long 3 7 16 polrecip pol reciprocal polynomial of pol i e the coefficients are in reverse order pol must be a polynomial The library syntax is polrecip z 3 7 17 polresultant z y uy flag 0 resultant of the two polynomials x and y with exact entries with respect to the main variables of x and y if v is omitted with respect to the variable v otherwise The algorithm used is the subresultant algorithm by default If flag 1 uses the determinant of Sylvester s matrix instead here x and y may have non exact coefficients If flag 2 uses Ducos s modified subresultant algorithm It should be much faster than the default if the coefficient ring is complicated e g multivariate polynomials or huge coefficients and slightly slower otherwise The library syntax is polresultant0 x y v flag where v is a long and an omitted v is coded as 1 Also available are subres z y flag 0 and resultant2 x y flag 1 3 7 18 polroots pol flag 0 complex roots of the polynomial pol given as a column vector where each root is repeated according to its multiplicity The precision is given as for transcendental functions under GP it is kept in the variable realprecision and is transparent to the user but it must be explicitly given as a second argument in library mode The algorithm used is a modification of A Sch
238. hem On the other hand you can customize highlighting in your emacs so as to mimic exactly this behaviour See emacs pariemacs txt If you use an old readline library version number less than 2 0 you should do as in the example above and leave a3 and a4 prompt and input line strictly alone Since old versions of readline did not handle escape characters correctly or more accurately treated them in the only sensible way since they did not care to check all your terminal capabilities it just ignored them changing them would result in many annoying display bugs The hacker s way to check if this is the case would be to look in the readline h include file wherever your readline include files are for the string RL_PROMPT_START_IGNORE If it s there you are safe A more sensible way is to make some experiments and get a more recent readline if yours doesn t work the way you d like it to See the file misc gprc dft for some examples 2 1 3 compatible default 0 The GP function names and syntax have changed tremendously between versions 1 xx and 2 00 To help you cope with this we provide some kind of backward compatibility depending on the value of this default compatible 0 no backward compatibility In this mode a very handy function to be described in Section 3 11 2 27 is whatnow which tells you what has become of your favourite functions which GP suddenly can t seem to remember compatible 1 warn when using obsol
239. hen calling the function has to be less than the number of formal variables Uninitialized formal variables will be given a default value An equal sign following a variable name in the function definition followed by any expression gives the variable a default value The expression gets evaluated the moment the function is defined and is fixed afterward A variable for which you supply no default value will be initialized to zero list of local variables is the list of the additional local variables which are used in the function body Note that if you omit some or all of these local variable declarations the non declared variables will become global hence known outside of the function and this may have undesirable side effects On the other hand in some cases it may also be what you want Local variables can be given a default value as the formal variables 30 Example For instance foo x 1 y 2 z 3 print x y z defines a function which prints its arguments at most three of them separated by colons This then follows the rules of default arguments generation as explained at the beginning of Section 3 0 2 foo 6 7 6283 foo 5 1 5 3 foo 13213 Once the function is defined using the above syntax you can use it like any other function In addition you can also recall its definition exactly as you do for predefined functions that is by writing name This will print the list of arguments as well as their
240. her variables used so that a 1ift of the result will be legible The library syntax is factmod9 z p a 3 4 23 factorial x or x factorial of x The expression x gives a result which is an integer while factorial x gives a real number The library syntax is mpfact x for z and mpfactr x prec for factorial x x must be a long integer and not a PARI integer 3 4 24 factorint n flag 0 factors the integer n using a combination of the Pollard Rho method with modifications due to Brent Lenstra s ECM with modifications by Montgomery and MPQS the latter adapted from the LiDIA code with the kind permission of the LiDIA main tainers as well as a search for pure powers with exponents lt 10 The output is a two column matrix as for factor This gives direct access to the integer factoring engine called by most arithmetical functions flag is optional its binary digits mean 1 avoid MPQS 2 skip first stage ECM we may still fall back to it later 4 avoid Rho 8 don t run final ECM as a result a huge composite may be declared to be prime Note that a strong probabilistic primality test is used thus composites might very rarely not be detected The machinery underlying this function is still in a somewhat experimental state but should be much faster on average than pure ECM as used by all PARI versions up to 2 0 8 at the expense of heavier memory use You are invited to play with the flag settings and watch t
241. hese Bernoulli numbers can then be used as follows Assume that this vector has been put into a variable say bernint Then you can define under GP bern x if x 1 return 1 2 if x lt 0 x 2 return 0 bernint x 2 1 and then bern k gives the Bernoulli number of index k as a rational number exactly as bern real k gives it as a real number If you need only a few values calling bernfrac k each time will be much more efficient than computing the huge vector above The library syntax is bernvec z 3 3 17 besseljh n x J Bessel function of half integral index More precisely besseljh n x computes Jn 1 2 x where n must be of type integer and x is any element of C In the present version 2 0 19 this function is not very accurate when zx is small The library syntax is jbesselh n x prec 3 3 18 besselk nu x flag 0 K Bessel function of index nu which can be complex and argument x Only real and positive arguments x are allowed in the present version 2 0 19 If flag is equal to 1 uses another implementation of this function which is often faster The library syntax is kbessel nu x prec and kbessel2 nu x prec respectively 3 3 19 cos x cosine of x The library syntax is gcos z prec 3 3 20 cosh 1 hyperbolic cosine of x The library syntax is gch x prec 3 3 21 cotan x cotangent of x The library syntax is gcotan z prec 3 3 22 dilog x principal branch of the dilogar
242. hrough the command install see Section 3 11 2 13 For debugging output you can use printf and the standard output functions brute or output mainly but also some special purpose functions which embody both concepts the main one being void fprintferr char pariformat Now let s define what a PARI format is It is a character string similar to the one printf uses where characters have a special meaning It describes the format to use when printing the remaining operands But in addition to the standard format types you can use 4Z to denote a GEN object we would have liked to pick G but it was already in use For instance you could write err talker x d Z is not invertible i x i since the err function accepts PARI formats Here i is an int x a GEN which is not a leaf and this would insert in raw format the value of the GEN x i 4 7 5 Timers and timing output To profile your functions you can use the PARI timer The functions long timer and long timer2 return the elapsed time since the last call of the same function in milliseconds Two different functions identical except for their independent time of last call memories are provided so you can have both global timing and fine tuned profiling You can also use void msgtimer char format which prints prints Time then the remaining arguments as specified by format which is a PARI format then the output of timer2 This mechanism is simple
243. ibrary syntax is tschirnhaus z 3 6 107 rnfalgtobasis rnf x rnf being a relative number field extension L K as output by rnfinit and zx being an element of L expressed as a polynomial or polmod with polmod coefficients expresses x on the relative integral basis The library syntax is rnfalgtobasis rnf x 108 3 6 108 rnfbasis bnf x given a big number field bnf as output by bnfinit and either a poly nomial x with coefficients in bnf defining a relative extension L of bnf or a pseudo basis x of such an extension gives either a true bnf basis of L if it exists or an n l element generating set of L if not where n is the rank of L over bnf The library syntax is rnfbasis bnf x 3 6 109 rnfbasistoalg rnf x rnf being a relative number field extension L K as output by rnfinit and x being an element of L expressed on the relative integral basis computes the repre sentation of x as a polmod with polmods coefficients The library syntax is rnfbasistoalg rnf x 3 6 110 rnfcharpoly nf 7T a v x characteristic polynomial of a over nf where a belongs to the algebra defined by T over nf i e nf X T Returns a polynomial in variable v x by default The library syntax is rnfcharpoly nf T a v where v is a variable number 3 6 111 rnfconductor bnf pol bnf being a big number field as output by bnfinit and pol a relative polynomial defining an Abelian extension computes the class field theory conductor of this Ab
244. ical parser hence you can use it not only for input but for most computations that you can do under GP These functions are called flisexpr and flisseq The first one has the following syntax GEN flisexpr char s Its effect is to analyze the input string s and to compute the result as in GP However it is limited to one expression If you want to read and evaluate a sequence of expressions use GEN flisseq char s In fact these two functions start by filtering out all spaces and comments in the input string that s what the initial f stands for They then call the underlying basic functions the GP parser proper GEN lisexpr char s and GEN lisseq char s which are slightly faster but which you probably don t need To read a GEN from a file you can use the simpler interface 169 GEN lisGEN FILE file which reads a character string of arbitrary length from the stream file up to the first new line character applies flisexpr to it and returns the resulting GEN This way you won t have to worry about allocating buffers to hold the string To interactively input an expression use lisGEN stdin Once in a while it may be necessary to evaluate a GP expression sequence involving a call to a function you have defined in C This is easy using install which allows you to manipulate quite an arbitrary function GP knows about pointers The syntax is void install void f char name char code where f is the addres
245. id affrr GEN x GEN z assigns the real x into the real z GEN stoi long s creates the PARI integer corresponding to the long s long itos GEN x converts the PARI integer x to a C long if possible otherwise an error message is issued GEN mptrunc z GEN x GEN z truncates the integer or real x not the same as the integer part if x is non integer and negative GEN mpent z GEN x GEN z true integer part of the integer or real x i e the floor function 5 2 4 Valuation and shift long vals long s 2 adic valuation of the long s Returns 1 if s is equal to 0 with no error long vali GEN x 2 adic valuation of the integer x Returns 1 if s is equal to 0 with no error GEN mpshift z GEN x long n GEN z shifts the real or integer x by n If n is positive this is a left shift i e multiplication by 2 If n is negative it is a right shift by n which amounts to the truncation of the quotient of x by 27 GEN shifts long s long n converts the long s into a PARI integer and shifts the value by n GEN shifti GEN x long n shifts the integer x by n GEN shiftr GEN x long n shifts the real x by n 5 2 5 Unary operations Let op be some unary operation of type GEN GEN The names and prototypes of the low level functions corresponding to op will be as follows GEN mpop GEN x creates the result of op applied to the integer or real x GEN ops long s creates the result of op applied to the long s
246. ilename str x as write in TEX format 148 Chapter 4 Programming PARI in Library Mode 4 1 Introduction initializations universal objects To be able to use PARI in library mode you must write a C program and link it to the PARI library See the installation guide in Appendix A on how to create and install the library and include files A sample Makefile is presented in Appendix B Probably the best way to understand how programming is done is to work through a complete example We will write such a program in Section 4 8 Before doing this a few explanations are in order First one must explain to the outside world what kind of objects and routines we are going to use This is done simply with the statement include lt pari h gt This file pari h imports all the necessary constants variables and functions defines some important macros and also defines the fundamental type for all PARI objects the type GEN which is simply a pointer to long Technical note we would have liked to define a type GEN to be a pointer to itself This unfortu nately is not possible in C except by using structures but then the names become unwieldy The result of this is that when we use a component of a PARI object it will be a long hence will need to be typecast to a GEN again if we want to avoid warnings from the compiler This will sometimes be quite tedious but of course is trivially done See the discussion on typecasts in the next
247. ill need to type explicitly a command of the above form 11 UNIX After the copyright the computer works for a few seconds it is in fact computing and storing a table of primes writes the top level help information some initial defaults and then waits after printing its prompt initially 7 Note that at any point the user can type Ctrl C that is press simultaneously the Control and C keys the current computation will be interrupted and control given back to the user at the GP prompt The top level help information tells you that as in many systems to get help you should type a When you do this and hit return a menu appears describing the eleven main categories of available functions and what to do to get more detailed help If you now type n with 1 lt n lt 11 you will get the list of commands corresponding to category n and simultaneously to Section 3 n of this manual If you type functionname where functionname is the name of a PARI function you will get a short explanation of this function If extended help see Section 2 2 1 is available on your system you can double or triple the sign to get much more respectively the complete description of the function e g sqrt or a list of GP functions relevant to your query e g 7 elliptic curve or quadratic field If GP was compiled with the right options see Appendix A a line editor will be available to correct the command line get automatic
248. implemented though yet e Finally note that in the same way that printtex allows you to have a TFX output corre sponding to printed results the functions starting with ps allow you to have PostScript output of the plots This will not be absolutely identical with the screen output but will be sufficiently close Note that you can use PostScript output even if you do not have the plotting routines enabled The PostScript output is written in a file whose name is derived from the psfile default pari ps if you did not tamper with it Each time a new PostScript output is asked for the PostScript output is appended to that file Hence the user must remove this file or change the value of psfile first if he does not want unnecessary drawings from preceding sessions to appear On the other hand in this manner as many plots as desired can be kept in a single file None of the graphic functions are available within the PARI library you must be under GP to use them The reason for that is that you really should not use PARI for heavy duty graphical work there are much better specialized alternatives around This whole set of routines was only meant as a convenient but simple minded visual aid If you really insist on using these in your program we warned you the source plot c should be readable enough for you to achieve something 3 10 1 plot X a b expr Ymin Ymax crude ASCII plot of the function represented by expression exp
249. integer x truncated to n bits that is the integer y not a 2 i 0 The special case n 1 means no truncation an infinite sequence of leading 1 is then represented as a negative number Negative numbers behave as if modulo a huge power of 2 The library syntax is gbitneg z 3 2 13 bitnegimply x y bitwise negated imply of two integers x and y or not x gt y that is the integer So 2 andnot y 2 Negative numbers behave as if modulo a huge power of 2 The library syntax is gbitnegimply z y 3 2 14 bitor z y bitwise inclusive or of two integers x and y that is the integer Se or y 2 Negative numbers behave as if modulo a huge power of 2 The library syntax is gbitor z y 3 2 15 bittest x n outputs the nt bit of x starting from the right i e the coefficient of 2 in the binary expansion of x The result is 0 or 1 To extract several bits at once as a vector pass a vector for n The library syntax is bittest x n where n and the result are longs 49 3 2 16 bitxor z y bitwise exclusive or of two integers x and y that is the integer Y a xor yj 2 Negative numbers behave as if modulo a huge power of 2 The library syntax is gbitxor z y 3 2 17 ceil x ceiling of z When z is in R the result is the smallest integer greater than or equal to x Applied to a rational function ceil x returns the euclidian quotient of the numerator by the denominator The library syntax is
250. inter avma in ltop Note that we are going to assume throughout that the garbage does not overflow the currently available stack If it ever did we would have several options allocate a larger stack in the main program for instance change 1000000 into 2000000 do some gerepileing along the way or if you know what you are doing use allocatemoremem Secondly the err function is the general error handler for the PARI library This will abort the program after printing the required message Thirdly notice how we handle the special case 1x 1 empty matrix before accessing 1x x 1 Doing it the other way round could produce a fatal error a segmentation fault or 174 a bus error most probably Indeed if x is of length 1 then x 1 is not a component of x It is just the contents of the memory cell which happens to follow the one pointed to by x and thus has no reason to be a valid GEN Now recall that none of the codeword handling macros do any kind of type checking see Section 4 5 thus lg would consider x 1 as a valid address and try to access GEN x 1 the first codeword which is unlikely to be a legal memory address In the fourth place to compute the square of the L norm of x we just add the squares of the L norms of the column vectors which we obtain using the library function gnorml2 Had this function not existed the norm computation would of course have been just as easy to write but we would have needed a double
251. into a list The only other way to create a t_LIST is to use the function listcreate This is useless in library mode 3 2 2 Mat x transforms the object x into a matrix If x is not a vector or a matrix this creates a 1 x 1 matrix If x is a row resp column vector this creates a 1 row resp 1 column matrix If x is already a matrix a copy of x is created This function can be useful in connection with the function concat see there The library syntax is gtomat z 3 2 3 Mod z y flag 0 creates the PARI object x mod y i e an integermod or a polmod y must be an integer or a polynomial If y is an integer x must be an integer a rational number or a p adic number compatible with the modulus y If y is a polynomial x must be a scalar which is not a polmod a polynomial a rational function or a power series This function is not the same as x y the result of which is an integer or a polynomial If flag is equal to 1 the modulus of the created result is put on the heap and not on the stack and hence becomes a permanent copy which cannot be erased later by garbage collecting see Section 4 4 Functions will operate faster on such objects and memory consumption will be lower On the other hand care should be taken to avoid creating too many such objects Under GP the same effect can be obtained by assigning the object to a GP variable the value of which is a permanent object for the duration of the relevan
252. into a set use the function Set The library syntax is setisset x and this returns a long 3 8 50 setminus z y difference of the two sets x and y i e set of elements of x which do not belong to y The library syntax is setminus z y 3 8 51 setsearch z y flag 0 searches if y belongs to the set x If it does and flag is zero or omitted returns the index j such that x j y otherwise returns 0 If flag is non zero returns the index j where y should be inserted and 0 if it already belongs to x this is meant to be used in conjunction with listinsert This function works also if x is a sorted list see listsort The library syntax is setsearch z y flag which returns a long integer 3 8 52 setunion z y union of the two sets x and y The library syntax is setunion z y 3 8 53 trace x this applies to quite general x If x is not a matrix it is equal to the sum of x and its conjugate except for polmods where it is the trace as an algebraic number For x a square matrix it is the ordinary trace If x is a non square matrix but not a vector an error occurs The library syntax is gtrace z 3 8 54 vecextract z y z extraction of components of the vector or matrix x according to y In case x is a matrix its components are as usual the columns of x The parameter y is a component specifier which is either an integer a string describing a range or a vector If y is an integer it is considered as a mask
253. ion formula except when s is of type integer in which case it is computed using Bernoulli numbers for s lt 0 or s gt 0 and even and using modular forms for s gt 0 and odd The library syntax is gzeta s prec 3 4 Arithmetic functions These functions are by definition functions whose natural domain of definition is either Z or Zs or sometimes polynomials over a base ring Functions which concern polynomials exclusively will be explained in the next section The way these functions are used is completely different from transcendental functions in general only the types integer and polynomial are accepted as arguments If a vector or matrix type is given the function will be applied on each coefficient independently In the present version 2 0 19 all arithmetic functions in the narrow sense of the word Euler s totient function the Moebius function the sums over divisors or powers of divisors etc call after trial division by small primes the same versatile factoring machinery described under factorint It includes Pollard Rho ECM and MPQS stages and has an early exit option for the functions moebius and the integer function underlying issquarefree Note that it relies on a fairly strong probabilistic primality test numbers found to be strong pseudo primes after 10 successful trials of the Rabin Miller test are declared primes 3 4 1 Qfb a b c D 0 creates the binary quadratic form ax bry cy If b
254. ion process to have dynamic file names if you wish 3 11 2 20 quit exits GP 3 11 2 21 read str reads in the file whose name results from the expansion of the string str If str is omitted re reads the last file that was fed into GP The return value is the result of the last expression evaluated 3 11 2 22 reorder x x must be a vector If x is the empty vector this gives the vector whose components are the existing variables in increasing order i e in decreasing importance Killed variables see kill will be shown as 0 If x is non empty it must be a permutation of variable names and this permutation gives a new order of importance of the variables for output only For example if the existing order is x y z then after reorder z x the order of importance of the variables with respect to output will be z y x The internal representation is unaffected 3 11 2 23 setrand n reseeds the random number generator to the value n The initial seed is n l The library syntax is setrand n where n is a long Returns n 3 11 2 24 system str str is a string representing a system command This command is executed its output written to the standard output this won t get into your logfile and control returns to the PARI system This simply calls the C system command 146 3 11 2 25 trap e rec seq tries to execute seg trapping error e that is effectively pre venting it from aborting computations in
255. ional default value is 0 its binary digits mean 1 compute at s 1 if set to 1 or s 0 if set to 0 2 compute the primitive L functions associated to x if set to 0 or the L function with Euler factors at prime ideals dividing the modulus of bnr removed if set to 1 this is the so called Lg s x function where S is the set of infinite places of the number field together with the finite prime ideals dividing the modulus of bnr see the example below 3 returns also the character Example bnf bnfinit x 2 229 bnr bnrinit bnf 1 1 bnrLi bnr 0 returns the order and the first non zero term of the abelian L functions L s x at s 0 where x runs through the characters of the class group of Q v229 Then bnr2 bnrinit bnf 2 1 bnrL1 bnr2 0 2 returns the order and the first non zero terms of the abelian L functions Ls s x at s 0 where x runs through the characters of the class group of Q v229 and S is the set of infinite places of Q v229 together with the finite prime 2 note that the ray class group modulo 2 is in fact the class group so bnrL1 bnr2 0 returns exactly the same answer as bnrL1 bnr 0 The library syntax is bnrL1 bnr subgroup flag prec 88 3 6 18 bnrclass bnf ideal flag 0 bnf being a big number field as output by bnfinit the units are mandatory unless the ideal is trivial and deal being either an ideal in any form or a two component row vector containing an ideal and an r compone
256. ional one flag whose default value is 0 the should never be typed it is just a convenient notation we will use throughout to denote optional arguments That is you can type foo x 2 or foo x which is then understood to mean foo x 0 As well a comma or closing parenthesis where an optional argument should have been signals to GP it should use the default Thus the syntax foo x is also accepted as a synonym for our last expression When a function has more than one optional argument the argument list is filled with user supplied values in order And when none are left the defaults are used instead Thus assuming that foo s prototype had been foo x 1 y 2 z 3 typing in foo 6 4 would give you foo 6 4 3 In the rare case when you want to set some far away flag and leave the defaults in between as they stand you can use the empty arg trick alluded to above foo 6 1 would yield foo 6 2 1 By the way foo by itself yields foo 1 2 3 as was to be expected In this rather special case of a function having no mandatory argument you can even omit the a standalone foo would be enough though we don t really recommend it for your scripts for the sake of clarity In defining GP syntax we strove to put optional arguments at the end of the argument list of course since they would not make sense otherwise and in order of decreasing usefulness so that most of the time you will be able to ignore them F
257. ions in particular those relative to height computations see ellheight require also that the curve be in minimal Weierstrass form This is achieved by the function ellglobalred All functions related to elliptic curves share the prefix ell and the precise curve we are interested in is always the first argument in either one of the three formats discussed above unless otherwise specified For instance in functions which do not use the extra information given by long vectors the curve can be given either as a five component vector or by one of the longer vectors computed by ellinit 3 5 1 elladd 21 22 sum of the points z1 and z2 on the elliptic curve corresponding to the vector E The library syntax is addell E z1 22 73 3 5 2 ellak E n computes the coefficient a of the L function of the elliptic curve E i e in principle coefficients of a newform of weight 2 assuming Taniyama Weil conjecture which is now known to hold in full generality thanks to the work of Breuil Conrad Diamond Taylor and Wiles E must be a medium or long vector of the type given by ellinit For this function to work for every n and not just those prime to the conductor must be a minimal Weierstrass equation If this is not the case use the function ellglobalred first before using ellak The library syntax is akell E n 3 5 3 ellan E n computes the vector of the first n az corresponding to the elliptic curve E All comments in ellak descrip
258. ironment expansion 48 environment expansion 13 environment variable 48 OTC a e de Ed A 58 CFE soea ete ee de 171 172 174 STEILE ai ok Skee Gk be so 171 CITOR pia te Aisa ee I GG Lid CLLOL ad A ay Gee a i e 35 144 ETA wee wae ras 58 59 73 Euclid Basa a a bee 67 Euclidean quotient 44 Euclidean remainder 45 Euler product 65 69 133 Euler totient function 62 65 Buler gorras a PG ee a He a 134 BUI fue de oe BE oai 27 28 56 Euler Maclaurin 62 eUlerphi awe gM we ee eG 63 65 eval ok gies yak He ee Se eS 48 116 EXACT Objet 4 x eae ara a oS 6 CXC Deu ess ee oe He Oe eg irl ORD sopp koa ate a a oe ake Sete E ee ak 59 OXPl 2a ba a a A Hs 184 CXPO o saca ee oe 164 166 184 expression sequence 29 EXPTESSION ss a cla Ha Be ee bw Ss 29 ORLON sped osa ee ee aa 17 30 144 CXLACL rs a a ee Goes 131 F factcantor es soe e nacca we e moewa 66 FACtMOd oss sodok a en Soe UR a 67 factmnod9 a gos go be Bo we eee E 66 factor murgas aa a 65 66 factor0 serca era 65 66 Lactorback scroll ea e 66 factorcantor 2 284 eee EEE 66 factoredbase 100 factoredpolred 108 PACTOLE LT sos ok hn Ew Ak aoe ck Eo 66 factorial sars wih ey Ge a le GG Ss 66 factorint Vocero a 65 66 Factor Mod ecran e a a A eS 67 Tacto D eu e E a ai ih ep 65 92 Factor padic s s wees kee se ss 116 factorpadic4 asese sairas 1
259. is matches the C prototype from paridecl h GEN bnfinitO GEN P long flag GEN data long prec This function is in fact coded in basemath buch2 c and will in this case be completely identical to the GP function bnfinit but GP does not need to know about this only that it can be found somewhere in the shared library libpari so Important note You see in this example that it is the function s responsibility to correctly interpret its operands data NULL is interpreted by the function as an empty vector Note that since NULL is never a valid GEN pointer this trick always enables you to distinguish between a default value and actual input the user could explicitly supply an empty vector Note If install were not available we would have to modify language helpmessages c and language init c and recompile GP The entry in functions_basic corresponding to the function above is actually bnfinit 91 void bnfinitO 6 GDO L DGp 181 182 Chapter 5 Technical Reference Guide for Low Level Functions In this chapter we give a description all public low level functions of the PARI system These essentially include functions for handling all the PARI types Higher level functions such as arithmetic or transcendental functions are described fully in Chapter 3 of this manual Many other undocumented functions can be found throughout the source code These private functions are more efficient than the library functions that cal
260. ith in previous GP commands But if y has been modified e g y 1 then the value of gy is not what you expected it to be and corresponds instead to the current value of the GP variable e g gun 4 6 2 2 Temporary variables MAXVARN is available but is better left to pari internal functions some of which don t check that MAXVARN is free for them to use which can be considered a bug You can create more temporary variables using long fetch_var This returns a variable number which is guaranteed to be unused by the library at the time you get it and as long as you do not delete it we ll see how to do that shortly This has lower number i e higher priority than any temporary variable produced so far MAXVARN is assumed to be the first such This call updates all the aforementioned internal arrays In particular after the statement v fetch_var you can use polun v and polx v The variables created in this way have no identifier assigned to them though and they will be printed as lt number gt except for MAXVARN which will be printed as You can assign a name to a temporary variable after creating it by calling the function void name_var long n char s after which the output machinery will use the name s to represent the variable number n The GP parser will not recognize it by that name however and calling this on a variable known to GP will raise an error Temporary variables are meant to be used as free variables
261. ithm of x i e analytic continuation of the power series log2 1 inst x m The library syntax is dilog x prec 3 3 23 eint1 x n exponential integral 2 e dt x R If n is present outputs the n dimensional vector eint1 x eint1 nx x gt 0 This is faster than repeatedly calling eint1 i x The library syntax is veceint1 x n prec Also available is eint1 x prec 58 3 3 24 erfc x complementary error function 2 7 f e dt The library syntax is erfc x prec 3 3 25 eta x flag 0 Dedekind s 7 function without the q 4 This means the following if x is a complex number with positive imaginary part the result is 1 q where q e If x is a power series or can be converted to a power series with positive valuation the result is If 2 If flag 1 and x can be converted to a complex number i e is not a power series computes the true 7 function including the leading q 21 The library syntax is eta x prec 3 3 26 exp 1 exponential of x p adic arguments with positive valuation are accepted The library syntax is gexp z prec 3 3 27 gammah x gamma function evaluated at the argument x 1 2 When z is an integer this is much faster than using gamma x 1 2 The library syntax is ggamd z prec 3 3 28 gamma z gamma function of x In the present version 2 0 19 the p adic gamma function is not implemented The library syntax is ggamma z prec
262. itten as long as one pays proper attention to variable scope Here s a last example used to retrieve the coefficient array of a multivariate polynomial a non trivial task due to PARI s unsophisticated representation for those objects coeffs P nbvar local v if type P t_POL for i 0 nbvar 1 P P return P v vector poldegree P 1 i polcoeff P i 1 vector length v i coeffs v i nbvar 1 If P is a polynomial in k variables show that after the assignment v coeffs P k the coeffi cient of x7 x in P is given by v m 1 1 n 11 What would happen if the declaration local v had been omitted The operating system will automatically limit the recursion depth dive n if n dive n 1 dive 5000 deep recursion if n dive n 1 There s no way to increase the recursion limit which may be different on your machine since it would simply crash the GP process Function which take functions as parameters This is easy in GP using the following trick neat example due to Bill Daly calc f x eval Str f x If you call this with calc sin 1 it will return sin 1 evaluated 32 Restrictions on variable use it is not allowed to use the same variable name for different parameters of your function Or to use a given variable both as a formal parameter and a local variable in a given function Hence f x x 1 KK user function f variable x dec
263. iv nf x y flag 0 and idealdivexact nf x y flag 1 3 6 43 idealfactor nf x factors into prime ideal powers the ideal x in the number field nf The output format is similar to the factor function and the prime ideals are represented in the form output by the idealprimedec function i e as 5 element vectors The library syntax is idealfactor nf x 95 3 6 44 idealhnf nf a b gives the Hermite normal form matrix of the ideal a The ideal can be given in any form whatsoever typically by an algebraic number if it is principal by a Z system of generators as a prime ideal as given by idealprimedec or by a Z basis If b is not omitted assume the ideal given was aZk bZ kx where a and b are elements of K given either as vectors on the integral basis nf 7 or as algebraic numbers The library syntax is idealhnf0 nf a b where an omitted b is coded as NULL Also available is idealhermite nf a b omitted 3 6 45 idealintersect nf x y intersection of the two ideals x and y in the number field nf When zx and y are given by Z bases this does not depend on nf and can be used to compute the intersection of any two Z modules The result is given in HNF The library syntax is idealintersect nf x y 3 6 46 idealinv nf x inverse of the ideal x in the number field nf The result is the Hermite normal form of the inverse of the ideal together with the opposite of the Archimedean information if it is given The library
264. ivision Euclidean remainder exist and for integers computes the quotient such that the remainder has smallest possible absolute value There is also the exponentiation operator when the exponent is of type integer Otherwise it is considered as a transcendental function Finally the logical operators not prefix operator amp amp and operator or operator exist giving as results 1 true or 0 false Note that amp and are also accepted as synonyms respectively for amp amp and However there is no bitwise and or or 1 3 3 Conversions and similar functions Many conversion functions are available to convert between different types For example floor ceiling rounding truncation etc Other simple functions are included like real and imaginary part conjugation norm absolute value changing precision or creating an integermod or a polmod 1 3 4 Transcendental functions They usually operate on any object in C and some also on p adics The list is everexpanding and of course contains all the elementary functions plus already a number of others Recall that by extension PARI usually allows a transcendental function to operate componentwise on vectors or matrices 1 3 5 Arithmetic functions Apart from a few like the factorial function or the Fibonacci numbers these are functions which explicitly use the prime factor decomposition of integers The standard functions are included In the present v
265. ject to a given precision For instance gaffect x tmp cgetr 3 x tmp at the beginning of a routine where precision can be kept to a minimum otherwise the precision of x will be used in all subsequent computations which will be a disaster if x is known to thousands of digits 4 3 3 Copy It is also very useful to copy a PARI object not just by moving around a pointer as in the y x example but by creating a copy of the whole tree structure without pre allocating a possibly complicated y to use with gaffect The function which does this is called gcopy with the predefined macro lcopy as a synonym for long gcopy Its syntax is GEN gcopy GEN x and the effect is to create a new copy of x on the PARI stack Beware that universal objects which occur in specific components of certain types mainly moduli for types t_INTMOD and t_PADIC are not copied as they are assumed to be permanent In this case gcopy only copies the pointer Use GEN forcecopy GEN x if you want a complete copy Please be sure at this point that you really understand the difference between y x y gcopy x and gaffect x y this will save you from many obvious mistakes later on 155 4 3 4 Clones Sometimes it may be more efficient to create a permanent copy of a PARI object This will not be created on the stack but on the heap The function which does this is called gclone with the predefined macro Iclone as a synonym for 1long gclone Its syn
266. k eS winch AG Mode bes 203 MPCMP 2 2 4 4 e inay Apa Ey ee gee 187 MPO VG ee ee rte veces Src ee ee 189 MpdvmMdZ o e coea wa vee gee whee es 188 MPentll 2d eo eS Gos y amp Gens 186 Mpeulers ons Ge aw ae kw ee ee 56 203 MP Act cares ito sra 66 MpLACt rb Yee at o a do cl ed 66 A ee kes ee ance Rt ae 187 MPANVEL os ais owe a ee 187 MPINVSE ror aiw ee ee a a 187 MPINVZ porse da a a 187 MPoOdd ri a e aa 164 MPPl 0 it meros e e Se Ge 56 203 MEOS ap des Ds a eS 62 66 mpshift z 186 mptruncl2 llar sra e 186 MSSLIMOT e ca sa Hoe a ow 172 TOU dea oh hes eta coe oly Whack ok 68 mulll 2 ches be eee YR we ES 183 MULSTT ne wea ww eee we we Rw 189 multivariate polynomial 32 N name var bs ges age Be a ee we BS A 168 newtonpoly o 99 NeXt 2b eed hae a na a e aoa 142 147 mextprime 68 Af ee 79 D sew bee we oo Ba wel as 33 81 nfalgtobasi8 99 nfbasis 99 100 104 nfbasisO alesana te ee aed ee a 100 nfbasistoalg 100 nidetint so ass sr edk eee He eH 100 D ATSE vo Bia s moas a ee ew a a 100 MEALSCLO 2 4 oe Chew hh dw hee ew 100 nidivetic lt 4 s sor ew a Re ew Eek 100 MEGIVIOS a s sirds BR we a a da 101 MEeEUCALY s sa aa la He e 100 nfeltdiveuc 100 nfeltdivmodpr 100 Nieltaivrem ou s ace ee poa ed wh 101 nfeltmod s meee Skee Bd we eK 101 NECTEMUL sis ens ee Soe Re A we 101 nfeltmulmodpr
267. ke as first argument a number field of that precise type respectively output by rnfinit nfinit bnfinit and bnrinit However and even though it may not be specified in the descriptions of the functions below it is permissible if the function expects a nf to use a bnf instead which contains much more information The program will make the effort of converting to what it needs On the other hand if the program requires a big number field the program will not launch bnfinit for you which can be a costly operation Instead it will give you a specific error message The data types corresponding to the structures described above are rather complicated Thus as we already have seen it with elliptic curves GP provides you with some member functions to retrieve the data you need from these structures once they have been initialized of course The relevant types of number fields are indicated between parentheses bnf bnr bnf big number field clgp bnr bnf classgroup This one admits the following three subclasses cyc cyclic decomposition SNF gen generators no number of elements diff bnr bnf nf the different ideal codiff bnr bnf nf the codifferent inverse of the different in the ideal group disc bnr bnf nf discriminant fu bnr bnf nf fundamental units futu bnr bnf u w u is a vector of fundamental units w generates the torsion nf bnr bnf nf number field reg bnr
268. ke this into account i e an imprecise equality is checked not a precise one The library syntax is oncurve F z and the result is a long 3 5 15 ellj x elliptic j invariant x must be a complex number with positive imaginary part or convertible into a power series or a p adic number with positive valuation The library syntax is jell x prec 76 3 5 16 elllocalred E p calculates the Kodaira type of the local fiber of the elliptic curve E at the prime p E must be given by a medium or long vector of the type given by ellinit and is assumed to have all its coefficients a in Z The result is a 4 component vector f kod v c Here f is the exponent of p in the arithmetic conductor of E and kod is the Kodaira type which is coded as follows 1 means good reduction type Ig 2 3 and 4 mean types II III and IV respectively 4 v with y gt 0 means type I finally the opposite values 1 2 etc refer to the starred types Ig II etc The third component v is itself a vector u r s t giving the coordinate changes done during the local reduction Normally this has no use if u is 1 that is if the given equation was already minimal Finally the last component c is the local Tamagawa number cp The library syntax is localreduction p 3 5 17 elllseries E s A 1 E being a medium or long vector given by ellinit this computes the value of the L series of E at s It is assumed that E is a minimal model over Z and t
269. l probably be the case in many of your subroutines Of course the objects that were on the stack before the function call are left alone Except for the ones listed below PARI functions only collect their own garbage e It may happen that you need to preserve some but not all objects that were created after a certain point for instance if the final result you need is not a GEN or if some search proved futile Then it is enough to record the value of avma just before the first garbage is created and restore it upon exit long ltop avma record initial avma garbage avma ltop restore it All objects created in the garbage zone will eventually be overwritten they should not be accessed anymore once avma has been restored e If you want to destroy i e give back the memory occupied by the latest PARI object on the stack e g the latest one obtained from a function call and the above method is not available because the initial value of avma has been lost just use the function void cgiv GEN z where z is the object you want to give back e Unfortunately life is not so simple and sometimes you will want to give back accumulated garbage during a computation without losing recent data For this you need the gerepile function or one of its variants described hereafter GEN gerepile long ltop long lbot GEN q This function cleans up the stack between ltop and 1bot where lbot lt ltop and returns the upd
270. l them but much sloppier on argument checking and damage control Use them at your own risk 5 1 Level 0 kernel operations on unsigned longs For the non 68k versions we need level O operations simulating basic operations of the 68020 processor on which PARI was originally implemented The type ulong is defined in the file parigen h as unsigned long Note that in the prototypes below a ulong is sometimes implicitly typecast to int or long The global ulong variables overflow which will contain only 0 or 1 and hiremainder used to be declared in the file pariinl h However for certain architectures they are no longer needed and or have been replaced with local variables for efficiency and the functions mentioned below are really chunks of assembler code which will be inlined at each invocation by the compiler If you really need to use these lowest level operations directly make sure you know your way through the PARI kernel sources and understand the architecture dependencies To make the following descriptions valid both for 32 bit and 64 bit machines we will set BIL to be equal to 32 resp 64 an abbreviation of BITS_IN_LONG which is what is actually used in the source code int addll int x int y adds the ulongs x and y returns the lower BIL bits and puts the carry bit into overflow int addllx int x int y adds overflow to the sum of the ulongs x and y returns the lower BIL bits and puts the carry bit into overflow
271. lared twice Also the statement global x y z t see Section 3 11 2 11 declares the corresponding variables to be global It is then forbidden to use them as formal parameters or loop indexes as described above since the parameter would shadow the variable Implementation note For the curious reader here is how these stacks are handled a hashing function is computed from the identifier and used as an index in hashtable a table of pointers Each of these pointers begins a linked list of structures type entree The linked list is searched linearly for the identifier each list will typically have less than 7 components or so When the correct entree is found it points to the top of the stack of values for that identifier if it is a variable to the function itself if it is a predefined function and to a copy of the text of the function if it is a user defined function When an error occurs all of this maze rather a tree in fact is searched and hopefully restored to the state preceding the last call of the main evaluator Note The above syntax using the local keyword was introduced in version 2 0 13 The old syntax name list of true formal variables list of local variables seq is still recognized but is deprecated since genuine arguments and local variables become undistin guishable 2 6 4 Member functions Member functions use the dot notation to retrieve information from complicated structures by defa
272. larger values may correspond to something else w 1 changes highlevel plotting This is only taken into account by the gnuplot interface 3 10 16 plotmove w x y move the virtual cursor of the rectwindow w to position x y 3 10 17 plotpoints w X Y draw on the rectwindow w the points whose x y coordinates are in the vectors of equal length X and Y and which are inside w The virtual cursor does not move This is basically the same function as plothraw but either with no scaling factor or with a scale chosen using the function plotscale As was the case with the plotlines function X and Y are allowed to be simultaneously scalar In this case draw the single point X Y on the rectwindow w if it is actually inside w and in any case move the virtual cursor to position x y 3 10 18 plotpointsize w size changes the size of following points in rectwindow w If w 1 change it in all rectwindows This only works in the gnuplot interface 3 10 19 plotpointtype w type change the type of points subsequently plotted in rectwindow w type 1 corresponds to a dot larger values may correspond to something else w 1 changes highlevel plotting This is only taken into account by the gnuplot interface 139 3 10 20 plotrbox w dx dy draw in the rectwindow w the outline of the rectangle which is such that the points x1 y1 and x1 dx yl dy are opposite corners where x1 yl is the current position of
273. ld which must be in Z X irreducible and preferably monic In fact if you supply a non monic polynomial at this point GP will issue a warning then transform your polynomial so that it becomes monic Instead of the normal result say res you then get a vector res Mod a Q where Mod a Q Mod X P gives the change of variables The numbers c and c2 are positive real numbers which control the execution time and the stack size To get maximum speed set c2 c To get a rigorous result under GRH you must take c2 12 or c2 6 in the quadratic case but then you should use the much faster function quadclassunit Reasonable values for c are between 0 1 and 2 The defaults are c c2 0 3 nrel is the number of initial extra relations requested in computing the relation matrix Rea sonable values are between 5 and 20 The default is 5 borne is a multiplicative coefficient of the Minkowski bound which controls the search for small norm relations If this parameter is set equal to 0 the program does not search for small norm relations Otherwise reasonable values are between 0 5 and 2 0 The default is 1 0 nrpid is the maximal number of small norm relations associated to each ideal in the factor base Irrelevant when borne 0 Otherwise reasonable values are between 4 and 20 The default is 4 minsfb is the minimal number of elements in the sub factorbase If the program does not seem to succeed in finding a full rank mat
274. lication note that if the divisor is a matrix it must be an invertible square matrix and in that case the result is zx y Furthermore note that the result is as exact as possible in particular division of two integers always gives a rational number which may be an integer if the quotient is exact and not the Euclidean quotient see x y for that and similarly the quotient of two polynomials is a rational function in general To obtain the approximate real value of the quotient of two integers add 0 to the result to obtain the approximate p adic value of the quotient of two integers add O p k to the result finally to obtain the Taylor series expansion of the quotient of two polynomials add 0 X k to the result or use the taylor function see Section 3 7 31 The library syntax is gdiv x y for x y 3 1 5 The expression x y is the Euclidean quotient of x and y The types must be either both integer or both polynomials The result is the Euclidean quotient In the case of integer division the quotient is such that the corresponding remainder is non negative The library syntax is gdivent x y for x y 44 3 1 6 The expression x y is the Euclidean quotient of x and y The types must be either both integer or both polynomials The result is the rounded Euclidean quotient In the case of integer division the quotient is such that the corresponding remainder is smallest in absolute value and in case of a tie the q
275. line comment The rest of the line is ignored by GP 2 2 4 Na n prints the object number n n in raw format If the number n is omitted print the latest computed object 19 UNIX 2 2 5 b n Same as Na in prettyprint i e beautified format 2 2 6 c prints the list of all available hardcoded functions under GP not including operators written as special symbols see Section 2 4 More information can be obtained using the meta command see above For user defined functions member functions see Nu and um 2 2 7 Md prints the defaults as described in the previous section shortcut for default see Section 3 11 2 4 2 2 8 Ne n switches the echo mode on 1 or off 0 If n is explicitly given set echo to n 2 2 9 g n sets the debugging level debug to the non negative integer n 2 2 10 gf n sets the file usage debugging level debugfiles to the non negative integer n 2 2 11 gm n sets the memory debugging level debugmem to the non negative integer n 2 2 12 h m n outputs some debugging info about the hashtable If the argument is a number n outputs the contents of cell n Ranges can be given in the form m n from cell m to cell n last cell If a function name is given instead of a number or range outputs info on the internal structure of the hash cell this function occupies a struct entree in C If the range is reduced to a dash outputs statistics about hash cell usage 2 2
276. llowing macros long typ GEN z returns the type number of z void settyp GEN z long n sets the type number of z to n you should not have to use this function if you use cgetg long lg GEN z returns the length in longwords of the root of z long setlg GEN z long 1 sets the length of z to 1 you should not have to use this function if you use cgetg however see an advanced example in Section 4 8 If you know enough about PARI to need to access the clone bit then you ll be able to find usage hints in the code esp killbloc and matrix_block It is technical after all These macros are written in such a way that you don t need to worry about type casts when using them i e if z is a GEN typ z 2 will be accepted by your compiler without your having to explicitly type typ GEN z 2 Note that for the sake of efficiency none of the codeword handling macros check the types of their arguments even when there are stringent restrictions on their use The possible second codeword is used differently by the different types and we will describe it as we now consider each of them in turn 163 4 5 1 Type t_INT integer this type has a second codeword z 1 which contains the following information the sign of z coded as 1 0 or 1 if z gt 0 z 0 z lt 0 respectively the effective length of z i e the total number of significant longwords This means the following apart from the integer 0 every integ
277. lred 97 idealmorm 97 idealpow sasine e408 oe e 97 idealpowred 97 idealpowWs ciesa wat eee aa ee ws 97 idealprimedec 97 idealprincipal g7 idealred 97 idealstar sadesa cdi d etaar nag 98 idealstarO 98 idealtwoelt co ee es 98 idealval cock ee eR we ee ek ee 98 213 ideal tWO elt us ees 98 idele ea 79 ideleprincipal 98 dmat el a ade ae e 124 Trois ds 142 IMAG 2 ovio we aros ol MAS atte se a o o EP ae S 125 IMABECOMPL se sse we a a we 125 imprecise object como bu ae es 6 INCL fee kc on aed een eae arses ee 59 INCLAM s scs che tees ea odes E e Rg he 4 59 INCPAM2 seri ee a we Bee dee ee Ge 59 INCCAM e ba aay ete dre os Grae ae ee te 59 INCGaM4 Sedas Oe a Ba eee a 59 AINC AMC 2 bee e e Re ee 59 inclusive or o 45 indefinite binary quadratic form 166 indexrank os gn msn 125 INOCXSOPG sa s te owes oh a ol ew 131 infile ssec seriadas awe ee wa 171 infinite products lt 6 s 6 4 0 4645 133 infinitesum 134 ANITY e ae a es Me A ew 132 initell pe beh og Awe aoe Bee 76 INIEZOLA cei rd e oo Go Soke wes G 115 IDU coh a ee sa Ow we a 169 IM PUG ss Bac Ae th a A he ee 144 install 8s 4 a ms 36 145 170 172 180 INTER es c sam na wn ada Ree we eae A 116 A a a 5 21 103 integermod 5 21 165 integral basis o 99 intern
278. lt 0 this is a toggle which can be either 1 on or 0 off When logging mode is turned on GP opens a log file whose exact name is determined by the logfile default Subsequently all the commands and results will be written to that file see 1 In case a file with this precise name already existed it will not be erased your data will be appended at the end 15 UNIX 2 1 13 logfile default pari log name of the log file to be used when the log toggle is on Tilde and time expansion are performed 2 1 14 output default 1 this can take three values 0 raw 1 prettymatrix or 2 prettyprint This means that independently of the default format for reals which we explained above you can print results in three ways either in raw format i e a format which is equivalent to what you input including explicit multiplication signs and everything typed on a line instead of two dimensional boxes This can have several advantages for instance it allows you to pick the result with a mouse or an editor and to put it somewhere else The second format is the prettymatriz format The only difference to raw format is that matrices are printed as boxes instead of horizontally This is prettier but takes more space and cannot be used for input Column vectors are still printed horizontally The third format is the prettyprint format or beautified format In the present version 2 0 19 this is not beautiful at all Independently
279. m are in the heap and not on the PARI stack We start by recalling the universal objects introduced in Section 4 1 t_INT gzero zero gun un gdeux deux t_FRAC ghalf lhalf t_COMPLEX gi t_POL polun lpolun polx lpolx Only polynomials in the variables O and MAXVARN are defined initially Use fetch var see Section 4 6 2 2 to create new ones The other objects are not initialized by default bern i This is the 2i th Bernoulli number Bp 1 By 1 6 B4 1 30 etc To initialize them use the function void mpbern long n long prec This creates the even numbered Bernoulli numbers up to B n 2 as real numbers of precision prec They can then be used with the macro bern i Note that this is not a function but simply an abbreviation hence care must be taken that i is inside the right bounds i e 0 lt i lt n 1 before using it since no checking is done by PARI itself geuler This is Euler s constant It is initialized by the first call to mpeuler see Section 3 3 2 gpi This is the number 7 It is initialized by the first call to mppi see Section 3 3 4 The use of both geuler and gpi is deprecated since it s always possible that some library function increases the precision of the constant after you ve computed it hence modifying the computation accuracy without your asking for it and increasing your running times for no good reason You should always use mpeuler and mppi
280. mat so aa mo san Ao oS 125 176 gscalsmat 125 176 OS ae ee he ee eee ee E 60 ESTE varias pues we Bas 45 175 eshittlzl ema e es 193 Gaigne Lira Bes 46 164 184 190 GSM occiso sa Be 60 GSiZe a pp bo ee ee Rl ae ga 54 190 OS aie de ee es eee 44 61 192 212 BEGI gece eek eae we Pe 61 GSTR nk ee dosh eS a ea he G 167 SUD s be a Be a ee 44 estibeslZl msira e tae 193 gs bsg z Lesiones 193 SSUDSE gk eos i a AE 120 194 estiblzl sr srad tenak aa a 193 gsumdivk o ea rae e sacca eee 72 Stan nce ek bee ee eed a doe BEE 61 Sth aaea dae e See Pe 2 bee wg 61 gtodouble sa ee ee cms 156 190 Btolong scc ee ee EG 156 190 gtomat fans baw Oa aa 47 Stopoly ie e eee O a S 47 190 gLOpolyIeV o ooo ooo 47 190 SLOSE L sa ta a aieo E eo a ae a 48 190 Stoset gals ewe SG HR G AE rs 48 BLOVEC 2444 p oe a we So 48 190 o E 130 GCEANS aoe bbe a eds de 127 GUPUNG La ea Gade a Gea Gk e 54 192 SUD il ae es ca ae ee a 149 gunciode 244 6 retar taketa es 156 Eval s pe Oa ae Sw we a Toe A a 191 a 2 vik See tk Reo 166 167 185 191 BZOLO o oci wos yoa e eS 149 175 ZO me She n a E ts 62 Bzetak corps msi 115 BZD ae hee ee ee RE EE eG 20 H Hadamard product 119 hashing function 33 hashtable 33 HCLASSDO we io e A 69 heap o o ooo oo 20 150 203 Wells 24 04 2 awe aa 75 DOlp evs oe tee Gs AOS es ee ae el we A S 15 66 79 80 95 97 103 105 110 115 124
281. me and perform environment expansion on the string This feature can be used to read environment variable values i 1 Str x i 91 xi eval 7 72 x1 Str HOME 1 13 home pari The library syntax is strtoGENstr z flag This function is mostly useless in library mode Use the pair strtoGEN GENtostr to convert between char and GEN 3 2 9 Vec x transforms the object x into a row vector The vector will be with one com ponent only except when x is a vector matrix or a quadratic form in which case the resulting vector is simply the initial object considered as a row vector but more importantly when x is a polynomial or a power series In the case of a polynomial the coefficients of the vector start with the leading coefficient of the polynomial while for power series only the significant coefficients are taken into account but this time by increasing order of degree The library syntax is gtovec z 48 3 2 10 binary x outputs the vector of the binary digits of x Here x can be an integer a real number in which case the result has two components one for the integer part one for the fractional part or a vector matrix The library syntax is binaire z 3 2 11 bitand z y bitwise and of two integers x and y that is the integer Pe and y 2 Negative numbers behave as if modulo a huge power of 2 The library syntax is gbitand z y 3 2 12 bitneg x n 1 bitwise negation of an
282. ments In that case the square root if it exists which is returned is the one whose first p adic digit or its unique p adic digit in the case of integermods is in the interval 0 p 2 When the argument is an integermod a non prime or a non prime adic the result is undefined and the function may not even return The library syntax is gsqrt x prec 3 3 40 tan x tangent of x The library syntax is gtan z prec 3 3 41 tanh x hyperbolic tangent of z The library syntax is gth z prec 3 3 42 teichmuller x Teichm ller character of the p adic number zx The library syntax is teich x 61 3 3 43 theta q z Jacobi sine theta function The library syntax is theta q z prec 3 3 44 thetanullk q k k th derivative at z 0 of theta q z The library syntax is thetanullk q k prec where k is a long 3 3 45 weber z flag 0 one of Weber s three f functions If flag 0 returns f x exp im 24 n 2 1 2 n x such that j f 16 f where j is the elliptic j invariant see the function e11j If flag 1 returns f x 2 2 m x such that j f7 16 fi Finally if flag 2 returns falx V2n 2x n x such that j 16 f3 Note the identities f8 f f and f fifo V2 The library syntax is weber0 z flag prec or wf x prec wf1 x prec or wf2 z prec 3 3 46 zeta s Riemann s zeta function s gt n f computed using the Euler Maclaurin summat
283. mn matrix as in factor r must be strictly larger than the p adic valuation of the discriminant of pol for the result to make any sense The method used is a modified version of the round 4 algorithm of Zassenhaus If flag 1 use an algorithm due to Buchmann and Lenstra which is usually less efficient The library syntax is factorpadic4 pol p r where r is a long integer 3 7 5 intformal x v formal integration of x with respect to the main variable if v is omitted with respect to the variable v otherwise Since PARI does not know about abstract logarithms they are immediately evaluated if only to a power series logarithmic terms in the result will yield an error x can be of any type When z is a rational function it is assumed that the base ring is an integral domain of characteristic zero The library syntax is integ z v where v is a long and an omitted v is coded as 1 3 7 6 padicappr pol a vector of p adic roots of the polynomial pol congruent to the p adic number a modulo p or modulo 4 if p 2 and with the same p adic precision as a The number a can be an ordinary p adic number type t_PADIC i e an element of Qp or can be an element of a finite extension of Qp in which case it is of type t_POLMOD where at least one of the coefficients of the polmod is a p adic number In this case the result is the vector of roots belonging to the same extension of Q as a The library syntax is apprgen9 pol a but if
284. move primes from the list use removeprimes The library syntax is addprimes z 3 4 3 bestappr x k if x R finds the best rational approximation to x with denominator at most equal to k using continued fractions The library syntax is bestappr z k 3 4 4 bezout x y finds u and v minimal in a natural sense such that x x u y v gced z y The arguments must be both integers or both polynomials and the result is a row vector with three components u v and gcd z y The library syntax is vecbezout z y to get the vector or gbezout z y amp u amp v which gives as result the address of the created gcd and puts the addresses of the corresponding created objects into u and v 3 4 5 bezoutres z y as bezout with the resultant of x and y replacing the gcd The library syntax is vecbezoutres x y to get the vector or subresext z y amp u amp v which gives as result the address of the created gcd and puts the addresses of the corresponding created objects into u and v 3 4 6 bigomega x number of prime divisors of x counted with multiplicity x must be an integer The library syntax is bigomega z the result is a long 3 4 7 binomial z y binomial coefficient Ge Here y must be an integer but x can be any PARI object The library syntax is binome z y where y must be a long 63 3 4 8 chinese x y if z and y are both integermods or both polmods creates with the same type a z in the same resi
285. mpt After a user interrupt C entering an empty input line i e hitting the return key has the same effect as next Break loops are useful as a debugging tool to inspect the values of GP variables to understand why a problem occurred or to change GP behaviour increase debugging level start storing results in a logfile modify parameters in the middle of a long computation hit C type in your modifications then type next If rec is the empty string the last default handler is popped out and replaced by the previous one for that error Note The interface is currently not adequate for trapping individual exceptions In the current version 2 0 19 the following keywords are recognized but the name list will be expanded and changed in the future all library mode errors can be trapped it s a matter of defining the keywords to GP and there are currently far too many useless ones accurer accuracy problem gdiver2 division by 0 archer not available on this architecture or operating system typeer wrong type errpile the PARI stack overflows 147 3 11 2 26 type z t this is useful only under GP If t is not present returns the internal type number of the PARI object x Otherwise makes a copy of x and sets its type equal to type t which can be either a number or preferably since internal codes may eventually change a symbolic name such as t_FRACN you can skip the t_ part here so that FRACN by itself would also
286. n PARI must be aware that the names of almost all functions that he uses might be subject to change If the need arises i e if there really are people out there who delve into the innards of PARI updated versions with no name changes will be released 4 2 3 Portability 32 bit 64 bit architectures PARI supports both 32 bit and 64 bit based machines but not simultaneously The library will have been compiled assuming a given architecture a priori following a guess by the Configure program see Appendix A and some of the header files you include through pari h will have been modified to match the library Portable macros are defined to bypass most machine dependencies If you want your programs to run identically on 32 bit and 64 bit machines you will have to use these and not the corre sponding numeric values whenever the precise size of your long integers might matter Here are the most important ones 64 bit 32 bit BITS_IN_LONG 64 32 LONG_IS_64BIT defined undefined DEFAULTPREC 3 4 19 decimal digits see formula below MEDDEFAULTPREC 4 6 38 decimal digits BIGDEFAULTPREC 5 8 57 decimal digits For instance suppose you call a transcendental function such as GEN gexp GEN x long prec The last argument prec is only used if x is an exact object otherwise the relative precision is determined by the precision of x But since prec sets the size of the inexact result counted in long words including codewords
287. n external prettyprinter to use instead of the default ugly one when output is 2 prettyprint This is experimental for the time being coloring directives are not honoured when this default is used 2 1 18 primelimit default 200k on the Mac and 500k otherwise GP precomputes a list of all primes less than primelimit at initialization time These are used by many arithmetical functions If you don t plan to invoke any of them you can just set this to 1 16 EMACS 2 1 19 prompt default a string that will be printed as prompt Note that most usual escape sequences are available there Ne for Esc An for Newline for Time expansion is performed This string is sent through the library function strftime on a Unix system you can try man strftime at your shell prompt This means that constructs have a special meaning usually related to the time and date For instance H hour 24 hour clock and M minute 00 59 use hh to get a real If you use readline escape sequences in your prompt will result in display bugs If you have a relatively recent readline see the comment at the end of Section 2 1 2 you can brace them with special sequences and and you will be safe If these just result in extra spaces in your prompt then you ll have to get a more recent readline See the file misc gprc dft for an example Caution Emacs needs to know about the prompt pattern to separate your input from previo
288. n the PARI sources One important thing to remember is to clean the stack before exiting your main function usually using gerepile since otherwise successive calls to the function will clutter the stack with unnecessary garbage and stack overflow will occur sooner Also if it returns a GEN and you want it to be accessible to GP you have to make sure this GEN is suitable for gerepileupto see Section 4 4 If error messages are to be generated in your function use the general error handling routine err see Section 4 7 3 Recall that apart from the warn variants this function does not return but ends with a longjmp statement As well instead of explicit printf fprintf statements use the following encapsulated variants void pariputs char s write s to the GP output stream void fprintferr char s write s to the GP error stream this function is in fact much more versatile see Section 4 7 4 Declare all public functions in paridecl h you want the outside world to know about them The other ones should be declared static in your file Your function is now ready to be used in library mode after compilation and creation of the library If possible compile it as a shared library see the Makefile coming with the matexp example in the distribution It is however still inaccessible from GP 179 4 9 4 Integration with GP as a shared module To tell GP about your function you must do the following First find a name for it It
289. n the system s random number generator Note that the resulting integer is obtained by means of linear congruences and will not be well distributed in arithmetic progressions The library syntax is genrand N 3 2 37 real x real part of x In the case where x is a quadratic number this is the coefficient of 1 in the canonical integral basis 1 w The library syntax is greal x 3 2 38 round z amp e If x is in R rounds x to the nearest integer and sets e to the number of error bits that is the binary exponent of the difference between the original and the rounded value the fractional part If the exponent of x is too large compared to its precision i e e gt 0 the result is undefined and an error occurs if e was not given Important remark note that contrary to the other truncation functions this function operates on every coefficient at every level of a PARI object For example 24x X 1 7 truncate ES 249x whereas d 24x X 1 7 2x X 29 T n 2 ou X X An important use of round is to get exact results after a long approximate computation when theory tells you that the coefficients must be integers The library syntax is grndtoi z e where e is a long integer Also available is ground z 53 3 2 39 simplify x this function tries to simplify the object x as much as it can The simplifi cations do not concern rational functions which PARI automatically tries to simplify but t
290. n to Unix workstations and Macs PARI has been ported to a considerable number of smaller and larger machines for example the VAX 68000 based machines like the Atari Mac Classic or Amiga 500 68020 machines such as the Amiga 2500 or 3000 and even to MS DOS 386 or better machines using the EMX port of the GNU C compiler and DOS extender 1 2 The PARI types The crucial word in PARI is recursiveness most of the types it knows about are recursive For example the basic type Complex exists actually called t_COMPLEX However the components i e the real and imaginary part of such a complex number can be of any type The only sensible ones are integers we are then in Z rational numbers Q 1 real numbers R i C or even elements of Z nZ Z nZ i when this makes sense or p adic numbers when p 3 mod 4 Q This feature must of course not be used too rashly for example you are in principle allowed to create objects which are complex numbers of complex numbers but don t expect PARI to make sensible use of such objects you will mainly get nonsense On the other hand one thing which is allowed is to have components of different but com patible types For example taking again complex numbers the real part could be of type integer and the imaginary part of type rational By compatible we mean types which can be freely mixed in operations like or x For example if the real part is of type real the imagi
291. n which case the expansion stops In the case of real numbers the stopping criterion is thus different from the one mentioned above since if b is too long some partial quotients may not be significant The library syntax is contfracO x b lmax Also available are gboundcf x Imax gcf x or gcf2 b x where lmaz is a C integer 3 4 11 contfracpnqn z when x is a vector or a one row matrix x is considered as the list of partial quotients ao a1 n of a rational number and the result is the 2 by 2 matrix Pn Pn 1 qn dn 1 in the standard notation of continued fractions so pn qn ao 1 a1 1 a If x is a matrix with two rows bo b1 6n and ao a1 n this is then considered as a generalized continued fraction and we have similarly pn qn 1 bo0 a9 b1 a1 bp an Note that in this case one usually has bp 1 The library syntax is pnqn z 3 4 12 core n flag 0 if n is a non zero integer written as n df with d squarefree returns d If flag is non zero returns the two element row vector d f The library syntax is core0 n flag Also available are core n core n 0 and core2 n core n 1 3 4 13 coredisc n flag if n is a non zero integer written as n df with d fundamental discriminant including 1 returns d If flag is non zero returns the two element row vector d f Note that if n is not congruent to 0 or 1 modulo 4 f will be a half integer and not an integer
292. nary part cannot be of type integermod integers modulo a given number n Let us now describe the types As explained above they are built recursively from basic types which are as follows We use the letter T to designate any type the symbolic names correspond to the internal representations of the types type t_INT Z Integers with arbitrary precision type t_REAL R Real numbers with arbitrary precision type t_INTMOD Z nZ Integermods integers modulo n type t_FRAC Q Rational numbers in irreducible form type t_FRACN Q Rational numbers not necessarily in irreducible form type t_COMPLEX T i Complex numbers type t_PADIC Qp p adic numbers type t_QUAD Qlu Quadratic Numbers where Z w Z 2 type t_POLMOD X P X T X Polmods polynomials modulo P type t_POL X Polynomials type t_SER X Power series finite Laurent series T T T type t_RFRAC T T T T X Rational functions in irreducible form type t_RFRACN X Rational functions not necessarily in irreducible form type t_VEC g Row i e horizontal vectors type t_COL is Column i e vertical vectors type t_MAT Mm n T Matrices type t_LIST TE Lists type t_STR Character strings and where the types T in recursive types can be different in each component In addition there exist types t_QFR and t_QFI for binary quadratic forms of respectively positive and negative discriminants which can be used in specific operations but which may disappear in future
293. nctions addir addri mpadd whose two arguments can be of type integer or real addis to add a t_INT and a long and so on 151 All these functions can of course be called by the user but we feel that the few microseconds lost in calling more general functions in this case gadd are compensated by the fact that one needs to remember a much smaller number of functions and also because there is a hidden danger here the types of the objects that you use if they are themselves results of a previous computation are not completely predetermined For instance the multiplication of a type real t_REAL by a type integer t_INT usually gives a result of type real except when the integer is 0 in which case according to the PARI philosophy the result is the exact integer 0 Hence if afterwards you call a function which specifically needs a real type argument you are going to be in trouble If you really want to use these functions their names are self explanatory once you know that i stands for a PARI integer r for a PARI real mp for i or r s for an ordinary signed long whereas z as a suffix means that the result is not created on the PARI stack but assigned to a preexisting GEN object passed as an extra argument For completeness Chapter 5 gives a description of all these low level functions Please note that in the present version 2 0 19 the names of the functions are not always consis tent This will be changed Hence anyone programming i
294. nd 1 if not see however the important remark below a variable number e g 0 for x 1 for y etc and an effective length These data can be handled with the following macros signe and setsigne as for reals and integers long lgef GEN z returns the effective length of z void setlgef GEN z long 1 sets the effective length of z to 1 long varn GEN z returns the variable number of the object z void setvarn GEN z long v sets the variable number of z to v Note also the function long gvar GEN z which tries to return a variable number for z even if z is not a polynomial or power series The variable number of a scalar type is set by definition equal to BIGINT The components z 2 z 31 z 1gef z 1 point to the coefficients of the polynomial in as cending order with z 2 being the constant term and so on Note that the degree of the polynomial is equal to its effective length minus three The function long degree GEN x returns the degree of x with respect to its main variable even when x is not a polynomial a rational function for instance By convention the degree of 0 is 1 Important remark A zero polynomial can be characterized by the fact that its sign is O However its effective length may be equal to 2 or greater than 2 If it is greater than 2 this means that all the coefficients of the polynomial are equal to zero as they should for a zero polynomial but not all of these zeros are exact zeros and more p
295. ng flag long prec 3 9 12 vector n X expr 0 creates a row vector type t_VEC with n components whose components are the expression expr evaluated at the integer points between 1 and n If one of the last two arguments is omitted fill the vector with zeroes The library syntax is vecteur GEN nmax entree ep char expr 3 9 13 vectorv n X expr as vector but returns a column vector type t_COL The library syntax is vvecteur GEN nmax entree ep char expr 3 10 Plotting functions Although plotting is not even a side purpose of PARI a number of plotting functions are provided Moreover a lot of people felt like suggesting ideas or submitting huge patches for this section of the code Among these special thanks go to Klaus Peter Nischke who suggested the recursive plotting and the forking resizing stuff under X11 and Ilya Zakharevich who undertook a complete rewrite of the graphic code so that most of it is now platform independent and should be relatively easy to port or expand These graphic functions are either e high level plotting functions all the functions starting with ploth in which the user has little to do but explain what type of plot he wants and whose syntax is similar to the one used in the preceding section with somewhat more complicated flags e low level plotting functions where every drawing primitive point line box etc must be specified by the user These low level functions calle
296. ng like w quadgen d where d is the discriminant of the quadratic order in which you want to work hence d is congruent to 0 or 1 modulo 4 The name w is of course just a suggestion but corresponds to traditional usage You can of course use any variable name that you like However quadratic numbers are always printed with a w regardless of the discriminant So beware two numbers can be printed in the same way and not be equal However GP will refuse to add or multiply them for example Now 1 w will be the canonical integral basis of the quadratic order i e w Vd 2 if d 0mod4 and w 1 Vd 2 if d 1mod 4 where d is the discriminant and to enter x yw you just type x y w 2 3 8 Polmods type t_POLMOD exactly as for integermods to enter x mody where x and y are polynomials type Mod x y not x y see Section 3 2 3 Note that when y is an irreducible polynomial in one variable polmods whose modulus is y are simply algebraic numbers in the finite extension defined by the polynomial y This allows us to work easily in number fields finite extensions of the p adic field Qp or finite fields 22 Important remark Since the variables occurring in a polmod are not free variables it is es sential in order to avoid inconsistencies that polmods use the same variable in internal operations ie between polmods and variables of lower priority which have been introduced later in the GP session for external operations
297. nix system HOME _gpre on a DOS OS 2 or Windows system e If HOME also leaves us clueless we try gprc on a Unix system where as usual stands for your home directory or _ gpre on a DOS OS 2 or Windows system e Finally if no gprc was found among the user files mentioned above we look for etc gpre etc gprc for a system wide gprc file you ll need root privileges to set up such a file yourself Note that on Unix systems the gprc s default name starts with a and thus is hidden to regular 1s commands you need to type 1s a to see whether it s already there without your knowing about it In any case GP will open the corresponding file and process the commands in there before doing anything else e g creating the PARI stack If the file doesn t exist or cannot be read GP will proceed to the initialization phase at once eventually emitting a prompt If any explicit commandline switches are given they will override the values read from the gprc file The syntax in this file and valid in this file only at this very precise moment is simple minded but should be sufficient for most purposes It is read line by line white space being optional as usual unless surrounded by quotes Two types of lines are first dealt with by a preprocessor e comments are removed This applies to all text surrounded by as well as everything following on a given line e lines starting with if keyword are treated as
298. not necessarily of type t_REAL or raises an error if x is not embeddable into the complex numbers long ismonome GEN x returns 1 true if x is a non zero monomial in its main variable 0 oth erwise long ggval GEN x GEN p returns the greatest exponent e such that p divides x when this makes sense long gval GEN x long v returns the highest power of the variable number v dividing the poly nomial x int pvaluation GEN x GEN p GEN r applied to non zero integers x and p returns the highest exponent e such that p divides x creates the quotient x p and returns its address in r In particular if p is a prime this returns the valuation at p of x and r will obtain the prime to p part of x 191 5 3 3 Assignment statements void gaffsg long s GEN x assigns the long s into the object x void gaffect GEN x GEN y assigns the object x into the object y 5 3 4 Unary operators GEN gneg z GEN x GEN z yields x GEN gabs z GEN x GEN z yields x GEN gsqr GEN x creates the square of x GEN ginv GEN x creates the inverse of x GEN gfloor GEN x creates the floor of x i e the true integral part GEN gfrac GEN x creates the fractional part of x i e x minus the floor of x GEN gceil GEN x creates the ceiling of x GEN ground GEN x rounds the components of x to the nearest integers Exact half integers are rounded towards 00 GEN grndtoi GEN x long e same as round but in addition puts mi
299. ns long precp GEN z returns the p adic precision of z void setprecp GEN z long 1 sets the p adic precision of z to 1 long valp GEN z returns the p adic valuation of z i e the unbiased exponent This is defined even if z is equal to 0 see Section 1 2 6 3 void setvalp GEN z long e sets the p adic valuation of z to e In addition to this codeword z 2 points to the prime p z 3 points to pP P 2 and z 4 points to an integer representing the p adic unit associated to z modulo z 3 and points to zero if z is zero To summarize if z 4 0 we have the equality z per z 4 OLB pr x z2 a OPO 4 5 7 Type t_QUAD quadratic number z 1 points to the polynomial defining the quadratic field z 2 to the real part and z 3 to the imaginary part which are to be taken as the coefficients of z with respect to the canonical basis 1 w see Section 1 2 3 Complex numbers are a particular case of quadratics but deserve a separate type 4 5 8 Type t_POLMOD polmod exactly as for integermods z 1 points to the modulus and z 2 to a polynomial representing the class of z Both must be of type polynomial However one must obey the rules explained in Chapter 2 concerning the hierarchical structure of the variables of a polymod 165 4 5 9 Type t_POL polynomial this type has a second codeword which is analogous to the one for integers It contains a sign 0 if the polynomial is equal to 0 a
300. nt row vector of flags indicating which real Archimedean embeddings to take in the module computes the ray class group of the number field for the module ideal as a 3 component vector as all other finite Abelian groups cardinality vector of cyclic components corresponding generators If flag 2 the output is different It is a 6 component vector w w 1 is bnf w 2 is the result of applying idealstar bnf 1 2 w 3 w 4 and w 6 are technical components used only by the function bnrisprincipal wl5 is the structure of the ray class group as would have been output with flag 0 If flag 1 as above except that the generators of the ray class group are not computed which saves time The library syntax is bnrclass0 bnf ideal flag prec 3 6 19 bnrclassno bnf 1 bnf being a big number field as output by bnfinit units are manda tory unless the ideal is trivial and J being either an ideal in any form or a two component row vec tor containing an ideal and an r component row vector of flags indicating which real Archimedean embeddings to take in the modulus computes the ray class number of the number field for the modulus This is faster than bnrclass and should be used if only the ray class number is desired The library syntax is rayclassno bnf 1 3 6 20 bnrclassnolist bnf list bnf being a big number field as output by bnfinit units are mandatory unless the ideal is trivial and list being a list of modules as outpu
301. nts of gptr without doing any copying This is subject to the same restrictions as gerepile the only difference being that more than one address gets updated 4 4 2 Examples Let x and y be two preexisting PARI objects and suppose that we want to compute x y This can trivially be done using the following program we skip the necessary declarations everything in sight is a GEN p1 gsqr x p2 gsqr y z gadd p1 p2 The GEN z indeed points at the desired quantity However consider the stack it contains as unnecessary garbage p1 and p2 More precisely it contains in this order z p2 p1 recall that since the stack grows downward from the top the most recent object comes first We need a way to get rid of this garbage in this case it causes no harm except that it occupies memory space but in other cases it could disconnect other PARI objects and this is dangerous It would not have been possible to get rid of p1 p2 before z is computed since they are used in the final operation We cannot record avma before p1 is computed and restore it later since this would destroy z as well It is not possible either to use the function cgiv since p1 and p2 are not at the bottom of the stack and we don t want to give back z But using gerepile we can give back the memory locations corresponding to p1 p2 and move the object z upwards so that no space is lost Specifically ltop avma remember the current address of the top
302. nus the number of signif icant binary bits left after rounding into e If e is positive all significant bits have been lost This kind of situation raises an error message in ground but not in grndtoi GEN gtrunc GEN x truncates x This is the false integer part if x is an integer i e the unique integer closest to x among those between 0 and x If x is a series it will be truncated to a polynomial if x is a rational function this takes the polynomial part GEN gcvtoi GEN x long e same as grndtoi except that rounding is replaced by truncation GEN gred z GEN x GEN z reduces x to lowest terms if x is a fraction or rational function types t_FRAC t_FRACN t_RFRAC and t_RFRACN otherwise creates a copy of x GEN content GEN x creates the GCD of all the components of x GEN normalize GEN x applied to an unnormalized power series x i e type t_SER with all coef ficients correctly set except that x 2 might be zero normalizes x correctly in place Returns x For internal use GEN normalizepol GEN x applied to an unnormalized polynomial x i e type t_POL with all coefficients correctly set except that x 2 might be zero normalizes x correctly in place and returns x For internal use 192 5 3 5 Binary operators GEN gmaxj z GEN x GEN y GEN z yields the maximum of the objects x and y if they can be compared GEN gmaxsglz long s GEN x GEN z yields the maximum of the long s and the object x GEN gmaxgs
303. o Z intersected with the lattice generated by the columns of zx If p 2 returns a matrix whose columns form a basis of the lattice equal to Z intersected with the Q vector space generated by the columns of x The library syntax is matrixqz0 z p 3 8 35 matsize x x being a vector or matrix returns a row vector with two components the first being the number of rows 1 for a row vector the second the number of columns 1 for a column vector The library syntax is matsize x 126 3 8 36 matsnf X flag 0 if X is a singular or non singular square matrix outputs the vector of elementary divisors of X i e the diagonal of the Smith normal form of X The binary digits of flag mean 1 complete output if set outputs U V D where U and V are two unimodular matrices such that U x X x V is the diagonal matrix D Otherwise output only the diagonal of D 2 generic input if set allows polynomial entries Otherwise assume that X has integer coefficients 4 cleanup if set cleans up the output This means that elementary divisors equal to 1 will be deleted i e outputs a shortened vector D instead of D If complete output was required returns U V D so that U XV D holds If this flag is set X is allowed to be of the form D or U V D as would normally be output with the cleanup flag unset The library syntax is matsnf0 X flag Also available is smith X flag 0 3 8 37 mats
304. odpr nf x y pr 3 6 77 nfeltpow nf x k given an element x in nf and a positive or negative integer k computes x in the number field nf The library syntax is element_pow nf x k 3 6 78 nfeltpowmodpr nf x k pr given an element x in nf an integer k and a prime ideal pr in modpr format see nfmodprinit computes 2 modulo the prime ideal pr The library syntax is element_powmodpr nf x k pr 3 6 79 nfeltreduce nf x ideal given an ideal in Hermite normal form and an element x of the number field nf finds an element r in nf such that x r belongs to the ideal and r is small The library syntax is element_reduce nf x ideal 3 6 80 nfeltreducemodpr nf x pr given an element x of the number field nf and a prime ideal pr in modpr format compute a canonical representative for the class of x modulo pr The library syntax is nfreducemodpr2 nf x pr 101 3 6 81 nfeltval nf x pr given an element x in nf and a prime ideal pr in the format output by idealprimedec computes their the valuation at pr of the element x The same result could be obtained using idealval nf x pr since x would then be converted to a principal ideal but it would be less efficient The library syntax is element_val nf x pr and the result is a long 3 6 82 nffactor nf x factorization of the univariate polynomial x over the number field nf given by nfinit x has coefficients in nf i e either scalar polmod polynomial or column v
305. olve x y x being an invertible matrix and y a column vector finds the solution u of xxu y using Gaussian elimination This has the same effect as but is a bit faster than 27 x y The library syntax is gauss z y 3 8 38 matsolvemod m d y flag 0 mm being any integral matrix d a vector of positive integer moduli and y an integral column vector gives a small integer solution to the system of congruences Mi 1 y mod d if one exists otherwise returns zero Shorthand notation y resp d can be given as a single integer in which case all the y resp d above are taken to be equal to y resp d If flag 1 all solutions are returned in the form of a two component row vector x u where x is a small integer solution to the system of congruences and u is a matrix whose columns give a basis of the homogeneous system so that all solutions can be obtained by adding x to any linear combination of columns of u If no solution exists returns zero The library syntax is matsolvemod0 m d y flag Also available are gaussmodulo m d y flag 0 and gaussmodulo2 m d y flag 1 3 8 39 matsupplement x assuming that the columns of the matrix x are linearly independent if they are not an error message is issued finds a square invertible matrix whose first columns are the columns of x i e supplement the columns of x to a basis of the whole space The library syntax is suppl z 3 8 40 mattranspose x o
306. ompletions Just experi ment with this mechanism as often as possible you ll probably find it very convenient For instance you can obtain default seriesprecision 10 just by hitting def lt TAB gt se lt TAB gt 10 which saves 18 keystrokes out of 27 Hitting M h will give you the usual short online help concerning the word directly beneath the cursor M H will yield the extended help corresponding to the help default program usually opens a dvi previewer or runs a primitive tex to ASCIT program None of these disturb the line you were editing 41 42 Chapter 3 Functions and Operations Available in PARI and GP The functions and operators available in PARI and in the GP PARI calculator are numerous and everexpanding Here is a description of the ones available in version 2 0 19 It should be noted that many of these functions accept quite different types as arguments but others are more restricted The list of acceptable types will be given for each function or class of functions Except when stated otherwise it is understood that a function or operation which should make natural sense is legal In this chapter we will describe the functions according to a rough classification For the functions in alphabetical order see the general index The general entry looks something like foo x flag 0 short description The library syntax is foo z flag This means that the GP function foo has one mandatory argument x and an opt
307. omputing E F for small primes of good reduction then look for torsion points using Weierstrass parametrization and Mazur s classification If flag 1 use Lutz Nagell much slower E is allowed to be a medium vector The library syntax is elltors0 E flag 78 3 5 27 ellwp E z x flag 0 Computes the value at z of the Weierstrass p function attached to the elliptic curve E as given by ellinit alternatively E can be given as a lattice w1 w2 If z is omitted or is a simple variable computes the power series expansion in z starting 27 O 2 The number of terms to an even power in the expansion is the default serieslength in GP and the second argument C long integer in library mode Optional flag is for now only taken into account when z is numeric and means 0 compute only 2 1 compute p 2 9 2 The library syntax is ellwp0 z flag prec precdl Also available is weipell E precdl for the power series in x po1x 0 3 5 28 ellzeta E z value of the Weierstrass function of the lattice associated to E as given by ellinit alternatively E can be given as a lattice w1 w2 The library syntax is ellzeta E z 3 5 29 ellztopoint E z E being a long vector computes the coordinates x y on the curve E corresponding to the complex number z Hence this is the inverse function of ellpointtoz In other words if the curve is put in Weierstrass form x y represents the Weierstrass
308. on see Ag 2 1 5 debugfiles default 0 file usage debugging level Tf it is non zero GP will print information on file descriptors in use from PARI s point of view see gf 2 1 6 debugmem default 0 memory debugging level If it is non zero GP will regularly print information on memory usage If it s greater than 2 it will indicate any important garbage collecting and the function it is taking place in see gm Important Note As it noticeably slows down the performance and triggers bugs in some versions of a popular compiler the first functionality memory usage is disabled if you re not running a version compiled for debugging see Appendix A 2 1 7 echo default 0 this is a toggle which can be either 1 on or 0 off When echo mode is on each command is reprinted before being executed This can be useful when reading a file with the Nr or read commands For example it is turned on at the beginning of the test files used to check whether GP has been built correctly see Ne 2 1 8 format default g0 28 and g0 38 on 32 bit and 64 bit machines respectively of the form xm n where x is a letter in e f g and n m are integers If x is f real numbers will be printed in fixed floating point format with no explicit exponent e g 0 000033 if the letter is e they will be printed in scientific format always with an explicit exponent e g 3 3e 5 If the letter is g real numbers will be printed in f format e
309. onent row vector v analogous to the corresponding class group component bnf clgp bnf 8 1 the first component is the narrow class number v no the second component is a vector containing the SNF cyclic components v cyc of the narrow class group and the third is a vector giving the generators of the corresponding v gen cyclic groups Note that this function is a special case of bnrclass The library syntax is buchnarrow bnf 3 6 13 bnfsignunit bnf bnf being a big number field output by bnfinit this computes an r X r r2 1 matrix having 1 components giving the signs of the real embeddings of the fundamental units The library syntax is signunits bnf 3 6 14 bnfreg bnf bnf being a big number field output by bnfinit computes its regulator The library syntax is regulator bnf tech prec where tech is as in bnfclassunit 3 6 15 bnfsunit bnf S computes the fundamental S units of the number field bnf output by bnfinit where S is a list of prime ideals output by idealprimedec The output is a vector v with 6 components v 1 gives a minimal system of integral generators of the S unit group modulo the unit group v 2 contains technical data needed by bnfissunit v 3 is an empty vector used to give the logarithmic embeddings of the generators in v 1 in version 2 0 16 v 4 is the S regulator this is the product of the regulator the determinant of v 2 and the natural logarithms of the norms of the id
310. onfiguring or compiling GP In fact with readline even line editing becomes more powerful outside an Emacs buffer 2 10 1 A too short introduction to readline The basics are as follows read the readline user manual assume that C stands for the Control key combined with another and the same for M with the Meta key generally C combinations act on characters while the M ones operate on words The Meta key might be called Alt on some keyboards will display a black diamond on most others and can safely be replaced by Esc in any case Typing any ordinary key inserts text where the cursor stands the arrow keys enabling you to move in the line There are many more movement commands which will be familiar to the Emacs user for instance C a C e will take you to the start end of the line M b M f move the cursor backward forward by a word etc Just press the Return key at any point to send your command to GP All the commands you type in are stored in a history with multiline commands being saved as single concatenated lines The Up and Down arrows or C p C n will move you through it M lt M gt sending you to the start end of the history C r C s will start an incremental backward forward search You can kill text C k kills till the end of line M d to the end of current word which you 39 can then yank back using the C y key M y will rotate the kill ring C _ will undo your last changes incrementally M r undoes all chan
311. onhage s remarkable root finding algorithm due to and implemented by X Gourdon Barring bugs it is guaranteed to converge and to give the roots to the required accuracy If flag 1 use a variant of the Newton Raphson method which is not guaranteed to converge but is rather fast If you get the messages too many iterations in roots or INTERNAL ERROR incorrect result in roots use the default function i e no flag or flag 0 This used to be the default root finding function in PARI until version 1 39 06 The library syntax is roots pol prec or rootsold pol prec 3 7 19 polrootsmod pol p flag 0 row vector of roots modulo p of the polynomial pol The particular non prime value p 4 is accepted mainly for 2 adic computations Multiple roots are not repeated If p lt 100 you may try setting flag 1 which uses a naive search In this case multiple roots are repeated with their order of multiplicity The library syntax is rootmod pol p flag 0 or rootmod2 pol p flag 1 3 7 20 polrootspadic pol p r row vector of p adic roots of the polynomial pol with p adic precision equal to r Multiple roots are not repeated p is assumed to be a prime The library syntax is rootpadic pol p r where r is a long 118 3 7 21 polsturm pol a b number of real roots of the real polynomial pol in the interval Ja b using Sturm s algorithm a resp b is taken to be oo resp 00 if omitted
312. ons which you ought to know about use u if you are subject to memory lapses The total number of different variable names is limited to 16384 and 65536 on 32 bit and 64 bit machines respectively which should be enough If you ever need hundreds of variables you should probably be using vectors instead 2 3 10 Power series type t_SER type a rational function or polynomial expression and add to it OCexpr k where expr is an expression which has non zero valuation it can be a polynomial power series or a rational function the most common case being simply a variable name This indicates to GP that it is dealing with a power series and the desired precision is k times the valuation of expr with respect to the main variable of expr to check the ordering of the variables or to modify it use the function reorder see Section 3 11 2 22 2 3 11 Rational functions types t_RFRAC and t_RFRACN as for fractions all rational func tions are automatically reduced to lowest terms under GP All that was said about fractions in Section 2 3 4 remains valid here 2 3 12 Binary quadratic forms of positive or negative discriminant type t_QFR and t_QFI these are input using the function Qfb see Chapter 3 For example Qfb 1 2 3 will create the binary form x 2xy 3y It will be imaginary of internal type t_QFI since 2 4 x 3 8 is negative In the case of forms with positive discriminant type t_QFR you may add an optional four
313. ons depends entirely on its principal variable number which is given by the function long gvar GEN z which returns a variable number for z even if z is not a polynomial or power series The variable number of a scalar type is set by definition equal to BIGINT which is bigger than any legal variable number The variable number of a recursive type which is not a polynomial or power series is the minimal variable number of its components But for polynomials and power series only the outermost number counts the representation is not symmetrical at all Under GP one need not worry too much since the interpreter will define the variables as it sees them and do the right thing with the polynomials produced however have a look at the remark in Section 2 3 8 But in library mode they are tricky objects if you intend to build polynomials yourself and not just let PARI functions produce them which is usually less efficient For instance it does not make sense to have a variable number occur in the components of a polynomial whose main variable has a higher number lower priority even though there s nothing PARI can do to prevent you from doing it 167 4 6 2 Creating variables A basic difficulty is to create a variable As we have seen in Sec tion 4 1 a plethora of objects is associated to variable number v Here is the complete list polun v and polx v which you can use in library mode and which represent respectively
314. or some of these optional flags we adopted the customary binary notation as a compact way to represent many toggles with just one number Letting po Pn be a list of switches i e of properties which can be assumed to take either the value 0 or 1 the number 2 2 40 means that p3 and ps have been set that is set to 1 and none of the others were that is they were set to 0 This will usually be announced as The binary digits of flag mean 1 po 2 pi 4 p2 and so on using the available consecutive powers of 2 To finish with our generic simple minded example the library function foo as defined above is seen to have two mandatory arguments x and flag no PARI mathematical function has been implemented so as to accept a variable number of arguments When not mentioned otherwise the result and arguments of a function are assumed implicitly to be of type GEN Most other functions return an object of type long integer in C see Chapter 4 The variable or parameter names prec and flag always denote long integers 43 Pointers If a parameter in the function prototype is prefixed with a amp sign as in foo z amp e it means that besides the normal return value the variable named e may be set as a side effect When passing the argument the amp sign has to be typed in explicitly As of version 2 0 19 this pointer argument is optional for all documented functions hence the amp will always appear between brackets as
315. p polynomial For rational numbers or rational functions there are also only two components the numerator and the denominator which must both be of type integer resp polynomial Finally p adic numbers have three components the prime p the modulus p and an approx imation to the p adic number Here Z is considered as limZ p Z and Q as its field of fractions Like real numbers the codewords contain an exponent giving essentially the p adic valuation of the number and also the information on the precision of the number which is in fact redundant with p but is included for the sake of efficiency 1 2 3 Complex numbers and quadratic numbers quadratic numbers are numbers of the form a bw where w is such that Z w Z 2 and more precisely w Vd 2 when d 0mod4 and w 1 Vd 2 when d 1 mod 4 where d is the discriminant of a quadratic order Complex numbers correspond to the very important special case w y 1 Complex and quadratic numbers are partially recursive the two components a and b can be of type integer real rational integermod or p adic and can be mixed subject to the limitations mentioned above For example a bi with a and b p adic is in Q i but this is equal to Qp when p 1mod4 hence we must exclude these p when one explicitly uses a complex p adic type 1 2 4 Polynomials power series vectors matrices and lists they are completely recur sive their components can be of any type an
316. p x t_MAT err typeer matexp if lx 1 return cgetg 1 t_MAT if 1x lg x 1 err talker not a square matrix convert x to real or complex of real and compute its L norm s gzero r cgetr prect1 affsr 1 r x gmul r x for i 1 i lt lx i s gadd s gnorml2 GEN x i if typ s t_REAL setlg s 3 s gsqrt s 3 we do not need much precision on s ifs lt 1 we are happy k expo s if k lt 0 n 0 pl x else n k 1 pl gmul2n x n setexpo s 1 201 initializations before the loop y gscalmat r 1x 1 creates scalar matrix with r on diagonal p2 pi r 8 k 1 y gadd y p2 the main loop while expo r gt BITS_IN_LONG prec 1 k p2 gdivgs gmul p2 p1 k r gdivgs gmul s r k y gadd y p2 square back n times if necessary for i 0 i lt n i y gsqr y return gerepileupto ltop y int main long d prec 3 GEN x take a stack of 10 bytes no prime table pari_init 1000000 2 printf precision of the computation in decimal digits n d itos lisGEN stdin if d gt 0 prec long d parik1 3 printf input your matrix in GP format n x matexp lisGEN stdin prec sor x g d 0 exit 0 202 Appendix C Summary of Available Constants In this appendix we give the list of predefined constants available in the PARI library All of the
317. pansion has been performed e time expansion the string is sent through the library function strftime This means that Achar combinations have a special meaning usually related to the time and date For instance H hour 24 hour clock and 4M minute 00 59 on a Unix system you can try man strftime at your shell prompt to get a complete list This is applied to prompt psfile and logfile For instance default prompt R will prepend the time of day in the form hh mm to GP s usual prompt e environment expansion When the string contains a sequence of the form SOMEVAR e g HOME the environment is searched and if SOMEVAR is defined the sequence is replaced by the corresponding value Also the symbol has the same meaning as in the C and bash shells by itself stands for your home directory and user is expanded to user s home directory This is applied to all filenames 2 1 1 buffersize default 30k GP input is buffered which means only so many bytes of data can be read at a time before a command is executed This used to be a very important variable to allow for very large input files to be read into GP for example large matrices without it complaining about unused characters Currently buffersize is automatically adjusted to the size of the data that are to be read It will never go down by itself though Thus this option may come in handy to decrease the buffer size after some unusually large re
318. patching together various scripts possibly written with different naming conventions For instance the following situation is dangerous p 3 fix characteristic forprime p 2 N p S 24 since within the loop or within the function s body even worse in the subroutines called in that scope the true global value of p will be hidden If the statement global p 3 appears at the beginning of the script then both expressions will trigger syntax errors Calling global without arguments prints the list of global variables in use In particular eval global will output the values of all local variables 144 UNIX 3 11 2 12 input reads a string interpreted as a GP expression from the input file usually standard input i e the keyboard If a sequence of expressions is given the result is the result of the last expression of the sequence When using this instruction it is useful to prompt for the string by using the print1 function Note that in the present version 2 19 of pari el when using GP under GNU Emacs see Section 2 9 one must prompt for the string with a string which ends with the same prompt as any of the previous ones a will do for instance 3 11 2 13 install name code gpname lib loads from dynamic library lib the function name Assigns to it the name gpname in this GP session with argument code code see Section 4 9 2 for an explanation of those If lib is omitted uses libpari so If gpn
319. pe is set otherwise and the components and further codeword fields which are left unchanged may not match the PARI conventions for the new type void setlg GEN x long s sets the length of x to s Again this should be used with extreme care since usually the length is set otherwise and increasing the length joins previously unrelated memory words to the root node of x This is however an extremely efficient way of truncating vectors or polynomials void setlgef GEN x long s sets the effective length of x to s where x is a polynomial The number s must be less than or equal to the length of x void setlgefint GEN x long s sets the effective length of the integer x to s The number s must be less than or equal to the length of x void setsigne GEN x long s sets the sign of x to s If x is an integer or real s must be equal to 1 0 or 1 and if x is a polynomial or a power series s must be equal to 0 or 1 void setexpo GEN x long s sets the binary exponent of the real number x to s after adding the appropriate bias The unbiased value s must be a 24 bit signed number void setvalp GEN x long s sets the p adic or X adic valuation of x to s if x is a p adic or a power series respectively void setprecp GEN x long s sets the p adic precision of the p adic number x to s void setvarn GEN x long s sets the variable number of the polynomial or power series x to s where 0 lt s lt MAXVARN 5 2 2 Memory allocation on
320. pe is to add new functions to PARI We explain here how to do this so that in particular the new function can be called from GP 177 4 9 2 The calling interface from GP parser codes A parser code is a character string describing all the GP parser needs to know about the function prototype It contains a sequence of the following atoms e Syntax requirements used by functions like for sum etc separator required at this point between two arguments e Mandatory arguments appearing in the same order as the input arguments they describe G GEN amp GEN L long we implicitly identify int with long S symbol i e GP identifier name Function expects a entree V variable as S but rejects symbols associated to functions n variable expects a variable number a long not an entree I string containing a sequence of GP statements a seq to be processed by lisseq useful for control statements string containing a single GP statement an expr to be processed by lisexpr r raw input treated as a string without quotes Quoted args are copied as strings Stops at first unquoted or Special chars can be quoted using Example aa b n c yields the string aab n c E s expanded string Example Pi x 2 yields 3 142x2 Unquoted components can be of any PARI type converted following current output format e Optional arguments s any number of strings possibly 0 see s s p idem setting prettyp
321. pt that if the modulus is not the exact conductor corre sponding to the L no data is computed and the result is 0 gzero If flag 3 as case 2 outputting relative data The library syntax is bnrdiscO al a2 a3 flag prec 3 6 24 bnrdisclist bnf bound arch flag 0 bnf being a big number field as output by bnfinit the units are mandatory computes a list of discriminants of Abelian extensions of the number field by increasing modulus norm up to bound bound where the ramified Archimedean places are given by arch unramified at infinity if arch is void or omitted If flag is non zero give arch all the possible values See bnr at the beginning of this section for the meaning of al a2 a3 The alternative syntax bnrdisclist bnf list is supported where list is as output by ideal list or ideallistarch with units The output format is as follows The output v is a row vector of row vectors allowing the bound to be greater than 21 for 32 bit machines and v j is understood to be in fact V 2 i 1 j of a unique big vector V note that 215 is hardwired and can be increased in the source code only on 64 bit machines and higher Such a component Vk is itself a vector W maybe of length 0 whose components correspond to each possible ideal of norm k Each component Wi corresponds to an Abelian extension L of bnf whose modulus is an ideal of norm k and no Archimedean components hence the extension is unramifi
322. quite slow many generators of principal ideals have to be computed The library syntax is nfnewprec nf prec 3 6 94 nfkermodpr nf a pr kernel of the matrix a in Zx pr where pr is in modpr format see nfmodprinit The library syntax is nfkermodpr nf a pr 3 6 95 nfmodprinit nf pr transforms the prime ideal pr into modpr format necessary for all operations modulo pr in the number field nf Returns a two component vector P a where P is the Hermite normal form of pr and a is an integral element congruent to 1 modulo pr and congruent to 0 modulo p pr Here p ZN pr and e is the absolute ramification index The library syntax is nfmodprinit nf pr 105 3 6 96 nfsubfields nf d 0 finds all subfields of degree d of the number field nf all subfields if d is null or omitted The result is a vector of subfields each being given by g h where g is an absolute equation and h expresses one of the roots of g in terms of the root x of the polynomial defining nf This is a crude implementation by M Olivier of an algorithm due to J Kliiners The library syntax is subfields nf d 3 6 97 nfroots nf x roots of the polynomial x in the number field nf given by nfinit without multiplicity x has coefficients in the number field scalar polmod polynomial column vector The main variable of nf must be of lower priority than that of x in other words the variable number of nf must be greater than that of x However if th
323. r favourite Web search engine for the site nearest to you But if you want the very latest version including development versions you should use the anonymous ftp address ftp megrez math u bordeaux fr pub pari where you will find all the different ports and possibly some binaries A lot of version information mailing list archives and various tips can be found on PARI s fledgling home page http www parigp home de Implementation notes You can skip this section and switch to Section 1 2 if you re not inter ested in hardware technicalities You won t miss anything that would be mentioned here The PARI package contains essentially three versions The first one is a specific implementation for 680x0 based computers which contains a kernel for the elementary arithmetic operations on multiprecise integers and real numbers and binary decimal conversion routines entirely written in MC68020 assembly language around 6000 lines the rest being at present entirely written in ANSI C with a C compatible syntax The system runs on SUN 3 xx Sony News NeXT cubes and on 680x0 based Macs with x gt 2 It should be very easy to port on any other 680x0 based machine like for instance the Apollo Domain workstations Note that the assembly language source code uses the SUN syntax which for some strange reason differs from the Motorola standard used by most other 680x0 machines in the world In the Mac distribution we have included a prog
324. r from a to b with Y ranging from Ymin to Ymaz If Ymin resp Ymar is not given the minima resp the maxima of the computed values of the expression is used instead 3 10 2 plotbox w 12 y2 let x1 y1 be the current position of the virtual cursor Draw in the rectwindow w the outline of the rectangle which is such that the points xl yl and 12 y2 are opposite corners Only the part of the rectangle which is in w is drawn The virtual cursor does not move 136 3 10 3 plotclip w clips the content of rectwindow w i e remove all parts of the drawing that would not be visible on the screen Together with plotcopy this function enables you to draw on a scratchpad before commiting the part you re interested in to the final picture 3 10 4 plotcolor w c set default color to c in rectwindow w In present version 2 0 19 this is only implemented for X11 window system and you only have the following palette to choose from 1 black 2 blue 3 sienna 4 red 5 cornsilk 6 grey 7 gainsborough Note that it should be fairly easy for you to hardwire some more colors by tweaking the files rect h and plotX c User defined colormaps would be nice and may be available in future versions 3 10 5 plotcopy wl w2 dx dy copy the contents of rectwindow wl to rectwindow w2 with offset dx dy 3 10 6 plotcursor w give as a 2 component vector the current scaled position of the virtual cursor corresponding to the rectwindow w 3
325. r x transpose of x This has an effect only on vectors and matrices The library syntax is gtrans z 3 8 41 qfgaussred q decomposition into squares of the quadratic form represented by the sym metric matrix q The result is a matrix whose diagonal entries are the coefficients of the squares and the non diagonal entries represent the bilinear forms More precisely if a denotes the output one has g x Y ayu 01323 j gt i The library syntax is sqred z 127 3 8 42 qfjacobi x x being a real symmetric matrix this gives a vector having two components the first one is the vector of eigenvalues of x the second is the corresponding orthogonal matrix of eigenvectors of x The method used is Jacobi s method for symmetric matrices The library syntax is jacobi z 3 8 43 qflll x flag 0 LLL algorithm applied to the columns of the not necessarily square matrix x The columns of x must however be of maximal rank unless specified otherwise below The result is a square transformation matrix T such that x T is an LLL reduced basis of the lattice generated by the column vectors of x If flag O default the computations are done with real numbers i e not with rational numbers hence are fast but as presently programmed version 2 0 19 are numerically unstable If flag 1 it is assumed that the corresponding Gram matrix is integral The computation is done entirely with integers and the algorithm is both accu
326. ram which automatically converts from the SUN syntax into the standard one at least for the needed PARI assembly file On the Unix distribution we have included other versions of the assembly file using different syntaxes This version is not really maintained anymore since we lack the hardware to update test it The second version is a version where most of the kernel routines are written in C but the time critical parts are written in a few hundred lines of assembler at most At present there exist three versions for the Sparc architecture one for Sparc version 7 e g Sparcstation 1 1 IPC IPX or 2 one for Sparc version 8 with supersparc processors e g Sparcstation 10 and 20 and one for Sparc version 8 with microsparc I or II processors e g Sparcclassic or Sparcstation 4 and 5 No specific version is written for the Ultrasparc since it can use the microsparc II version In addition versions exist for the HP PA architecture for the PowerPC architecture only for the 601 for the Intel family starting at the 386 under Linux OS 2 MSDOS or Windows and finally for the DEC Alpha 64 bit processors Finally a third version is written entirely in C and should be portable without much trouble to any 32 or 64 bit computer having no real memory constraints It is about 2 times slower than versions with a small assembly kernel This version has been tested for example on MIPS based DECstations 3100 and 5000 and SGI computers In additio
327. rate and quite fast In this case x needs not be of maximal rank If flag 2 similar to case 1 except x should be an integer matrix whose columns are linearly independent The lattice generated by the columns of x is first partially reduced before applying the LLL algorithm A basis is said to be partially reduced if v v gt vi for any two distinct basis vectors v i Uj This can be significantly faster than flag 1 when one row is huge compared to the other rows If flag 3 all computations are done in rational numbers This does not incur numerical instability but is extremely slow This function is essentially superseded by case 1 so will soon disappear If flag 4 x is assumed to have integral entries but needs not be of maximal rank The result is a two component vector of matrices the columns of the first matrix representing a basis of the integer kernel of x not necessarily LLL reduced and the columns of the second matrix being an LLL reduced Z basis of the image of the matrix x If flag 5 case as case 4 but x may have polynomial coefficients If flag 7 uses an older version of case 0 above If flag 8 same as case 0 where x may have polynomial coefficients If flag 9 variation on case 1 using content The library syntax is qflll0 z flag prec Also available are Ml x prec flag 0 Ulint x flag 1 and Ulkerim z flag 4 128 3 8 44 qflllgram z flag 0 same as qf111 e
328. reate space to hold them 2 For the creation of leaves i e integers or reals which is very common GEN cgeti long length GEN cgetr long length should be used instead of cgetg length t_INT and cgetg length t_REAL respectively 3 The macros lgetg lgeti lgetr are predefined as long cgetg long cgeti long cgetr respectively Examples 1 z cgeti DEFAULTPREC and cgetg DEFAULTPREC t_INT create an integer ob ject whose precision is bit_accuracy DEFAULTPREC 64 This means z can hold rational integers of absolute value less than 2 Note that in both cases the second codeword will not be filled Of course we could use numerical values e g cgeti 4 but this would have different mean ings on different machines as bit_accuracy 4 equals 64 on 32 bit machines but 128 on 64 bit machines 2 The following creates a type complex object whose real and imaginary parts can hold real numbers of precision bit_accuracy MEDDEFAULTPREC 96 bits z cgetg 3 t_COMPLEX z 1 1getr MEDDEFAULTPREC z 2 lgetr MEDDEFAULTPREC 3 To create a matrix object for 4 x 3 matrices z cgetg 4 t_MAT for i 1 i lt 4 i z i lgetg 5 t_COL If one wishes to create space for the matrix elements themselves one has to follow this with a double loop to fill each column vector These last two examples illustrate the fact that since PARI types are recursive all the branches of the tree must be created
329. recisely the leading term z 1gef z 1 is not an exact zero 4 5 10 Type t_SER power series This type also has a second codeword which encodes a sign i e O if the power series is 0 and 1 if not a variable number as for polynomials and a biased exponent with a bias of HIGHVALPBIT This information can be handled with the following functions signe setsigne varn setvarn as for polynomials and valp setvalp for the exponent as for p adic numbers Beware do not use expo and setexpo on power series If the power series is non zero z 2 z 3 z 1g z 1 point to the coefficients of z in ascending order z 2 being the first non zero coefficient Note that the exponent of a power series can be negative i e we are then dealing with a Laurent series with a finite number of negative terms 4 5 11 Type t_RFRAC and t_RFRACN rational function z 1 points to the numerator and z 2 on the denominator The denominator must be of type polynomial Note that a type t_RFRACN rational function can be converted to irreducible form using the function gred 4 5 12 Type t_QFR indefinite binary quadratic form z 1 z 2 z 3 point to the three coefficients of the form and should be of type integer z 4 is Shanks s distance function and should be of type real 4 5 13 Type t_QFI definite binary quadratic form z 1 z 2 z 3 point to the three coefficients of the form All three should be of type integer 166 4 5 14 Type t
330. reduced f reduced discriminant vector of the integral monic polynomial f This is the vector of elementary divisors of Zla f a Z a where a is a root of the polynomial f The components of the result are all positive and their product is equal to the absolute value of the discriminant of f The library syntax is reduceddiscsmith z 3 7 12 polinterpolate za ya v x amp e given the data vectors xa and ya of the same length n xa containing the x coordinates and ya the corresponding y coordinates this function finds the interpolating polynomial passing through these points and evaluates it at v If present e will contain an error estimate on the returned value The library syntax is polint a ya v amp e where e will contain an error estimate on the returned value 3 7 13 polisirreducible pol pol being a polynomial univariate in the present version 2 0 19 returns 1 if pol is non constant and irreducible 0 otherwise Irreducibility is checked over the smallest base field over which pol seems to be defined The library syntax is gisirreducible pol 3 7 14 pollead z v leading coefficient of the polynomial or power series x This is computed with respect to the main variable of x if v is omitted with respect to the variable v otherwise The library syntax is pollead zx v where v is a long and an omitted v is coded as 1 Also available is leadingcoeff x 117 3 7 15 pollegendre n v x creates t
331. remainder into r unless r is equal to NULL or ONLY_REM as above void dvmdsiz long s GEN x GEN z GEN r assigns the Euclidean quotient of the long s and the integer x into the integer or real z putting the remainder into r unless r is equal to NULL or ONLY_REM as above void dvmdisz GEN x long s GEN z GEN r assigns the Euclidean quotient of the integer x and the long s into the integer or real z putting the remainder into r unless r is equal to NULL or ONLY_REM as above void dvmdiiz GEN x GEN y GEN z GEN r assigns the Euclidean quotient of the integers x and y into the integer or real z putting the address of the remainder into r unless r is equal to NULL or ONLY_REM as above 5 2 9 Miscellaneous functions void addsii long s GEN x GEN z assigns the sum of the long s and the integer x into the integer z essentially identical to addsiz except that z is specifically an integer long divise GEN x GEN y if the integer y divides the integer x returns 1 true otherwise returns 0 false long divisii GEN x long s GEN z assigns the Euclidean quotient of the integer x and the long s into the integer z and returns the remainder as a long long mpdivis GEN x GEN y GEN z if the integer y divides the integer x assigns the quotient to the integer z and returns 1 true otherwise returns 0 false void mulsii long s GEN x GEN z assigns the product of the long s and the integer x into the integer z e
332. rent nature to compute the exponential of a matrix 4 9 Adding functions to PARI 4 9 1 Nota Bene As already mentioned modified versions of the PARI package should NOT be spread without our prior approval If you do modify PARI however it is certainly for a good reason hence we would like to know about it so that everyone can benefit from it There is then a good chance that the modifications that you have made will be incorporated into the next release Recall the e mail address pari math u bordeaux fr or use the mailing lists Roughly four types of modifications can be made The first type includes all improvements to the documentation in a broad sense This includes correcting typos or inacurracies of course but also items which are not really covered in this document e g if you happen to write a tutorial or pieces of code exemplifying some fine points that you think were unduly omitted The second type is to expand or modify the configuration routines and skeleton files the Con figure script and anything in the config subdirectory so that compilation is possible or easier or more efficient on an operating system previously not catered for This includes discovering and removing idiosyncrasies in the code that would hinder its portability The third type is to modify existing mathematical code either to correct bugs to add new functionalities to existing functions or to improve their efficiency Finally the last ty
333. result is not guaranteed to be complete some conjugates may be missing no warning issued especially so if the corresponding polynomial has a huge index In that case increasing the default precision may help If flag 4 use Allombert s algorithm and permutation testing If the field is Galois with weakly super solvable Galois group return the complete list of automorphisms else only the identity element If present d is assumed to be a multiple of the least common denominator of the conjugates expressed as polynomial in a root of pol A group G is weakly super solvable if it contains a super solvable normal subgroup H such that G H or G H A4 or G H S4 Abelian and nilpotent groups are weakly super solvable In practice almost all groups of small order are weakly super solvable the exceptions having order 36 1 exception 48 2 56 1 60 1 72 5 75 1 80 1 96 10 and gt 108 Hence flag 4 permits to quickly check whether a polynomial of order strictly less than 36 is Galois or not This method is much faster than nfroots and be applied to polynomial of degree more than 50 The library syntax is galoisconj0 nf flag d prec Also available are galoisconj nf for flag 0 galoisconj2 nf n prec for flag 2 where n is a bound on the number of conjugates and galoisconj4 nf d corresponding to flag 4 3 6 86 nfhilbert nf a b pr if pr is omitted compute the global Hilbert symbol a
334. rix which you can see in GP by typing g 2 increase this number Reasonable values are between 2 and 5 The default is 3 Remarks Apart from the polynomial P you don t need to supply any of the technical parameters under the library you still need to send at least an empty vector cgetg 1 t_VEC However should you choose to set some of them they must be given in the requested order For example if you want to specify a given value of nrel you must give some values as well for c and c2 and provide a vector c c2 nrel Note also that you can use an nf instead of P which avoids recomputing the integral basis and analogous quantities 82 3 6 1 bnfcertify bnf bnf being a big number field as output by bnfinit or bnfclassunit checks whether the result is correct i e whether it is possible to remove the assumption of the Generalized Riemann Hypothesis If it is correct the answer is 1 If not the program may output some error message but more probably will loop indefinitely In no occasion can the program give a wrong answer barring bugs of course if the program answers 1 the answer is certified The library syntax is certifybuchall bnf and the result is a C long 3 6 2 bnfclassunit P flag 0 tech Buchmann s sub exponential algorithm for com puting the class group the regulator and a system of fundamental units of the general algebraic number field K defined by the irreducible polynomial P with inte
335. rk bnr subgroup flag 3 6 30 dirzetak nf b gives as a vector the first b coefficients of the Dedekind zeta function of the number field nf considered as a Dirichlet series The library syntax is dirzetak nf b 3 6 31 factornf x t factorization of the univariate polynomial x over the number field defined by the univariate polynomial t x may have coefficients in Q or in the number field The main variable of t must be of lower priority than that of x in other words the variable number of t must be greater than that of x However if the coefficients of the number field occur explicitly as polmods as coefficients of x the variable of these polmods must be the same as the main variable of t For example factornf x 2 Mod y y 2 1 y 2 1 factornf x 2 1 y 2 1 these two are OK factornf x 2 Mod z z72 1 y 2 1 EK incorrect type in gmulsg The library syntax is polfnf z t 3 6 32 ffinit p n v x computes a monic polynomial of degree n which is irreducible over F For instance if P ffinit 3 2 y you can represent elements in F32 as polmods modulo P This function is rather crude and expects p to be relatively small p lt 23 The library syntax is ffinit p n v where v is a variable number 3 6 33 galoisfixedfield gal perm fl 0 uv y gal being be a Galois field as output by galoisinit and perm an element of gal group or a vector of such elements computes the fixed field of gal by t
336. rning For D lt 0 this function often gives incorrect results when the class group is non cyclic because the authors were too lazy to implement Shanks method completely It is there fore strongly recommended to use either the version with flag 1 the function qfhclassno x if x is known to be a fundamental discriminant or the function quadclassunit The library syntax is qfbclassno0 x flag Also available are classno x qfbclassno z classno2 1 qfbclassno z 1 and finally there exists the function hclassno x which com putes the class number of an imaginary quadratic field by counting reduced forms an O x algorithm See also qfbhclassno 3 4 44 gfbcompraw z y composition of the binary quadratic forms x and y without reduction of the result This is useful e g to compute a generating element of an ideal The library syntax is compraw z y 3 4 45 qfbhclassno x Hurwitz class number of x where x is non negative and congruent to 0 or 3 modulo 4 See also qfbclassno The library syntax is hclassno z 3 4 46 qfbnucomp z y composition of the primitive positive definite binary quadratic forms x and y using the NUCOMP and NUDUPL algorithms of Shanks la Atkin is any positive constant but for optimal speed one should take 1 D 4 where D is the common discriminant of x and y The library syntax is nucomp z y The auxiliary function nudupl z should be used instead for speed when x y 3 4
337. rom the gprc file this provides some common shortcuts to lengthy names Finally if you have superuser privileges and want to provide system wide defaults you can copy your customized gprc file to etc gprc In older versions gphelp was hidden in pari lib directory and wasn t meant to be used from the shell prompt but not anymore If gp complains it can t find gphelp check whether your gpre or the system wide gprc does contain explicit paths If so correct them according to the current misc gprc dft 4 Getting Started 4 1 Printable Documentation To print the user s guide for which you ll need a working plain T X installation type make doc This will create in two passes a file doc users dvi containing the manual with a table of contents and an index You must then send the users dvi file to your favourite printer in the usual way probably via dvips Also included are a short tutorial doc tutorial dvi and a reference card doc refcard dvi and doc refcard ps for GP 4 2 C programming Once all libraries and include files are installed you can link your C programs to the PARI library A sample makefile examples Makefile is provided to illustrate the use of the various libraries Type make all in the examples directory to see how they perform on the mattrans c program which is commented in the manual 4 3 GP scripts Several complete sample GP programs are also given in the examples directory for example Shanks s
338. s x op y to x and returns the new value of x not a reference to the variable x Thus an assignment cannot occur on the lefthand side of another assignment e Priority 7 is the assignment operator The result of x y is the value of the expression y which is also assigned to the variable x This is not the equality test operator Beware that a statement like x 1 is always true i e non zero and sets x to 1 e Priority 6 unary prefix logical not x return 1 if x is equal to 0 specifically if gemp0 x 1 and 0 otherwise unary prefix quote its argument without evaluating it a x 1 x 1 subst a x 1 k variable name expected subst a x 1 a subst a x 1 1 2 e Priority 5 powering unary postfix derivative with respect to the main variable unary postfix vector matrix transpose unary postfix factorial x x a 1 1 x b extracts member b from structure z e Priority 4 unary prefix toggles the sign of its argument has no effect whatsoever e Priority 3 multiplication exact division 3 2 3 2 not 1 5 25 euclidean quotient and remainder i e if x qy r with 0 lt r lt y if x and y are polynomials assume instead that degr lt deg y and that the leading terms of r and x have the same sign then x y q x y r rounded euclidean quotient for integers rounded towards 00 when the exact quotient would be a h
339. s a basis of the Mordell Weil group of E its determinant is equal to the regulator of E Note that this matrix should be divided by 2 to be in accordance with certain normalizations E is assumed to be integral given by a minimal model The library syntax is mathell E x prec 75 3 5 13 ellinit E flag 0 computes some fixed data concerning the elliptic curve given by the five component vector E which will be essential for most further computations on the curve The result is a 19 component vector E called a long vector in this section shortened to 13 components medium vector if flag 1 Both contain the following information in the first 13 components Q1 42 43 44 06 ba ba be bg C4 C6 J In particular the discriminant is E 12 or E disc and the j invariant is E 13 or E j The other six components are only present if flag is O or omitted Their content depends on whether the curve is defined over R or not e When E is defined over R E 14 E roots is a vector whose three components contain the roots of the associated Weierstrass equation If the roots are all real then they are ordered by decreasing value If only one is real it is the first component of E 14 E 15 E omega 1 is the real period of E integral of dx 2y a x a3 over the connected component of the identity element of the real points of the curve and E 16 E omega 2 is a complex period In other words w E 15 and wa
340. s componentwise on rational functions and vector matrices e is then the maximal number of error bits Note a very special use of truncate when applied to a power series it transforms it into a polynomial or a rational function with denominator a power of X by chopping away the O X Similarly when applied to a p adic number it transforms it into an integer or a rational number by chopping away the O p The library syntax is gevtoi x amp e where e is a long integer Also available is gtrunc z 3 2 43 valuation x p computes the highest exponent of p dividing x If p is of type integer x must be an integer an integermod whose modulus is divisible by p a fraction a q adic number with q p or a polynomial or power series in which case the valuation is the minimum of the valuation of the coefficients If p is of type polynomial x must be of type polynomial or rational function and also a power series if x is a monomial Finally the valuation of a vector complex or quadratic number is the minimum of the component valuations If x 0 the result is VERYBIGINT 2 1 for 32 bit machines or 2 1 for 64 bit machines if x is an exact object If x is a p adic numbers or power series the result is the exponent of the zero Any other type combinations gives an error The library syntax is ggval x p and the result is a long 54 3 2 44 variable x gives the main variable of the object x and p if x is a p adic numb
341. s creates y on the PARI stack but a copy is also created on the heap for quicker computations next time the function is called 3 3 3 I the complex number y 1 The library syntax is the global variable gi of type GEN 3 3 4 Pi the constant m 3 14159 The library syntax is mppi prec where prec must be given Note that this creates 7 on the PARI stack but a copy is also created on the heap for quicker computations next time the function is called 3 3 5 abs x absolute value of x modulus if x is complex Power series and rational functions are not allowed Contrary to most transcendental functions an exact argument is not converted to a real number before applying abs and an exact result is returned if possible abs 1 wi 1 abs 3 7 4 7x1 12 5 7 abs 1 1 3 1 414213562373095048801688724 If x is a polynomial returns x if the leading coefficient is real and negative else returns zx The library syntax is gabs z prec 56 3 3 6 acos x principal branch of cos7 x ie such that Re acos x 0 7 If x R and x gt 1 then acos x is complex The library syntax is gacos z prec 3 3 7 acosh x principal branch of cosh x i e such that Im acosh x 0 7 If x R and x lt 1 then acosh x is complex The library syntax is gach z prec 3 3 8 agm z y arithmetic geometric mean of x and y In the case of complex or negative numbers the principal square root is alw
342. s in the seq are discarded after the execution of the seq is complete except of course if they were assigned into variables In addition the value of the seg or of course of an expression if there is only one is printed if the line does not end with a semicolon 2 6 3 User defined functions It is very easy to define a new function under GP which can then be used like any other function The syntax is as follows name list of formal variables local list of local variables seq which looks better written on consecutive lines name zo 41 local to ti 3 local note that the first newline is disregarded due to the preceding sign and the others because of the enclosing braces Both lists of variables are comma separated and allowed to be empty The local statements can be omitted as usual seq is any expression sequence name is the name given to the function and is subject to the same restrictions as variable names In addition variable names are not valid function names you have to ki11 the variable first the converse is true function names can t be used as variables see Section 3 11 2 14 Previously used function names can be recycled you are just redefining the function the previous definition is lost of course list of formal variables is the list of variables corresponding to those which you will actually use when calling your function The number of actual parameters supplied w
343. s of the function cast to the C type void name is the name by which you want to access your function from within your GP expressions and code is a character string describing the function call prototype see Section 4 9 2 for the precise description of prototype strings In case the function returns a GEN it should satisfy gerepileupto assumptions see Section 4 4 4 7 2 Output For output there exist essentially three different functions with variants corresponding to the three main GP output formats as described in Section 2 1 14 plus three extra ones respectively devoted to T X output string output and advanced debugging e raw format obtained by using the function brute with the following syntax void brute GEN obj char x long n This prints the PARI object obj in format x0 n using the notations from Section 2 1 8 Recall that here x is either e or g corresponding to the three numerical output formats and n is the number of printed significant digits and should be set to 1 if all of them are wanted these arguments only affect the printing of real numbers Usually you won t need that much flexibility so most of the time you will get by with the function void outbrute GEN obj which is equivalent to brute x g 1 or even better with void output GEN obj which is equivalent to outbrute obj followed by a newline and a buffer flush This is especially nice during debuggin
344. s parameter to 1 all significant words will be printed Usually this last type of output would only be used for debugging purposes Remark Apart from GENtostr all PARI output is done on the stream outfile which by default is initialized to stdout If you want that your output be directed to another file you should use the function void switchout char name where name is a character string giving the name of the file you are going to use The output will be appended at the end of the file In order to close the file simply call switchout NULL Similarly errors are sent to the stream errfile stderr by default and input is done on the stream infile which you can change using the function switchin which is analogous to switchout Advanced Remark All output is done according to the values of the pariOut pariErr global variables which are pointers to structs of pointer to functions If you really intend to use these this probably means you are rewriting GP In that case have a look at the code in language es c init80 or GENtostr for instance 4 7 3 Errors If you want your functions to issue error messages you can use the general error handling routine err The basic syntax is err talker error message This will print the corresponding error message and exit the program in library mode go back to the GP prompt otherwise You can also use it in the more versatile guise err talker format where format d
345. s the section number of Chapter 3 in which this function would belong type in GP to see the list V is a number between 0 and 99 Right now there are only two significant values zero means that it s possible to call the function without argument and non zero means it needs at least one argument code is the parser code Once this has been done in the file language helpmessages c add in exact alphabetical order a short message describing the effect of your function name x y short descriptive message The message must be a single line of arbitrary length Do not use n the necessary newlines will be inserted by GP s online help functions Optional arguments should be shown between braces see the other messages for comparison Now you can recompile GP 180 4 9 6 Example A complete description could look like this E install bnfinitO GDO L DGp ClassGroupInit libpari so addhelp ClassGroupInit ClassGroupInit P flag 0 data compute the necessary data for which means we have a function ClassGroupInit under GP which calls the library function bnfinitO The function has one mandatory argument and possibly two more two D in the code plus the current real precision More precisely the first argument is a GEN the second one is converted to a long using itos 0 is passed if it is omitted and the third one is also a GEN but we pass NULL if no argument was supplied by the user Th
346. se For example the vector 1 3 will be considered smaller than the longer vector 1 3 1 but of course larger than 1 2 5 i e 1lex 1 3 1 3 1 will return 1 The library syntax is lexcmp z y 3 1 14 sign x sign 0 1 or 1 of x which must be of type integer real or fraction The library syntax is gsigne x The result is a long 3 1 15 max z y and min z y creates the maximum and minimum of x and y when they can be compared The library syntax is gmax z y and gmin z y 3 1 16 vecmax x if x is a vector or a matrix returns the maximum of the elements of zx otherwise returns a copy of x Returns oo in the form of 2 1 or 2 1 for 64 bit machines if x is empty The library syntax is vecmax z 3 1 17 vecmin x if x is a vector or a matrix returns the minimum of the elements of x otherwise returns a copy of x Returns 00 in the form of 23t 1 or 263 1 for 64 bit machines if x is empty The library syntax is vecmin z 46 3 2 Conversions and similar elementary functions or commands Many of the conversion functions are rounding or truncating operations In this case if the argu ment is a rational function the result is the Euclidean quotient of the numerator by the denomi nator and if the argument is a vector or a matrix the operation is done componentwise This will not be restated for every function 3 2 1 List x transforms a row or column vector x
347. section After declaring the use of the file pari h the first executable statement of a main program should be to initialize the PARI system and in particular the PARI stack which will be both a scratchboard and a repository for computed objects This is done with a call to the function void pari_init long size long maxprime The first argument is the number of bytes given to PARI to work with it should not reasonably be taken below 500000 and the second is the upper limit on a precomputed prime number table If you don t want prime numbers just put maxprime 2 Be careful because lots a PARI functions need this table certainly all the ones of interest to number theorists If you wind up with the error message not enough precomputed primes try to increase this value We have now at our disposal e a large PARI stack containing nothing It s a big connected chunk of memory whose size you chose when invoking pari_init All your computations are going to take place here When doing large computations unwanted intermediate results clutter up memory very fast so some kind of garbage collecting is needed Most large systems do garbage collecting when the memory is getting scarce and this slows down the performance In PARI we have taken a different approach you must do your own cleaning up when the intermediate results are not needed anymore Special 149 purpose routines have been written to do this we will see later how an
348. sed to define algebraic extensions of a base ring and as such is a scalar type 1 2 6 3 What is zero This is a crucial question in all computer systems The answer we give in PARI is the following For exact types all zeros are equivalent and are exact and thus are usually represented as an integer zero The problem becomes non trivial for imprecise types For p adics the answer is as follows every p adic number including 0 has an exponent e and a mantissa a purist would say a significand u which is a p adic unit except when the number is zero in which case u is zero the significand having a certain precision k i e being defined modulo p Then this p adic zero is understood to be equal to O p i e there are infinitely many distinct p adic zeros The number k is thus irrelevant For power series the situation is similar with p replaced by X i e a power series zero will be O X9 the number k here the length of the power series being also irrelevant For real numbers the precision k is also irrelevant and a real zero will in fact be O 2 where e is now usually a negative binary exponent This of course will be printed as usual for a real number 0 0000 in f format or 0 Ezxx in e format and not with a O symbol as with p adics or power series 1 3 Operations and functions 1 3 1 The PARI philosophy The basic philosophy which governs PARI is that operations and functions should firstly give as exac
349. sos wos seras wae 51 deriv s stin k e a i i a 115 116 destruction 000004 Lor deb diga pre nA aa a A E E 123 det anpe s eb ea g a eee aP eS 123 detint 24 66 pinea ea e a es 123 diagonal geg grit do is eke Ges 123 Diamond iia eds a od 73 OIL sn ee ean ra A 81 Gilherence 6 poe ed we hos Oe OP A ee wes 44 o s 6 ed a eh 6 ee 150 203 ALO iy G a ola ede Re a a a a 58 Girdiv exa ssl a b ake S 64 direuler 1 eee ee Hs 65 Dirichlet series 64 65 92 Ciel eee ws eA Sd e 65 Girzetake veo ia Ge GG we a i Da 92 ISC merra E a ey Se en ee 73 81 discl besa wee Yee wwe we wwe a 100 GUSCSE aereas e 117 GUVISS is as a a 189 dIVIS TL en acs a et A A 189 Givisors o e oa cop ee ee 24 65 Givll seca aa sea ee 184 divre pe ee be ee bee Bw Ee gs 45 GivsSuM 20364 wk a ee Be wd A RR eG dow 134 GIVE Se a aie a a BAe ae wey ee 41 AUMALI rana o a ee at Eos 188 AUMALIZ ei a we aa 189 GQVMGUS m s osados a Es 188 AUMALSZ bs as E e ee wk EE hs 189 GvVMGSi oy Bs bt awe BS ta ee Ke 188 AVMASIZ i 4 wa ow a EES a OA 189 AUMASS ess Pe a EE ew we 188 AVMASSZ eos uoi cae eee o Bo 188 E ECHO rop gi et he os Be bo oie i 15 20 ECM 244 a06 44 hes os 62 66 editing characters 27 effective length 164 166 GIGN cg dh oui art sn a ch ee ee 124 COEL Gre ake a eee doe ao Ee ee 58 element div posee paa Geek we SEOs 100 element_divmodpr 101 element m l 5 3 24 6 ste amp
350. square matrix x The library syntax is hess z 3 8 17 mathilbert x x being a long creates the Hilbert matrix of order x i e the matrix whose coefficient i j is 1 i j 1 The library syntax is mathilbert z 3 8 18 mathnf z flag 0 if x is a not necessarily square matrix of maximal rank finds the upper triangular Hermite normal form of x If the rank of x is equal to its number of rows the result is a square matrix In general the columns of the result form a basis of the lattice spanned by the columns of x If flag 0 uses the naive algorithm If the Z module generated by the columns is a lattice it is recommanded to use mathnfmod x matdetint x instead much faster If flag 1 uses Batut s algorithm Outputs a two component row vector H U where H is the upper triangular Hermite normal form of x i e the default result and U is the unimodular transformation matrix such that xU 0 H If the rank of x is equal to its number of rows H is a square matrix In general the columns of H form a basis of the lattice spanned by the columns of x If flag 2 uses Havas s algorithm Outputs H U P such that H and U are as before and P is a permutation of the rows such that P applied to xU gives H This does not work very well in present version 2 0 19 If flag 3 uses Batut s algorithm and outputs H U P as in the previous case If flag 4 as in case 1 above but uses LLL reduction along the
351. ss than d if d is set subcyclo n d 1 local Z G S if d lt 0 d n Z znstar n G matdiagonal Z 2 s forsubgroup H G d S concat S galoissubcyclo n mathnf concat G H Z S The library syntax is galoissubcyclo n H Z v where n is a C long integer 3 6 37 idealadd nf x y sum of the two ideals x and y in the number field nf When x and y are given by Z bases this does not depend on nf and can be used to compute the sum of any two Z modules The result is given in HNF The library syntax is idealadd nf x y 94 3 6 38 idealaddtoone nf x y x and y being two co prime integral ideals given in any form this gives a two component row vector a b such that a x b y and a b 1 The alternative syntax idealaddtoone nf v is supported where v is a k component vector of ideals given in any form which sum to Zg This outputs a k component vector e such that eli xi for 1 lt i lt k and gt lt lt p eli 1 The library syntax is idealaddtoone0 nf x y where an omitted y is coded as NULL 3 6 39 idealappr nf x flag 0 if x is a fractional ideal given in any form gives an element a in nf such that for all prime ideals p such that the valuation of x at p is non zero we have Up up x and up a gt 0 for all other p If flag is non zero x must be given as a prime ideal factorization as output by idealfactor but possibly with zero
352. ssed either as a polynomial or a polmod such automorphisms being found using for example one of the variants of nfgaloisconj computes the action of the automorphism aut on the object x in the number field x can be an element scalar polmod polynomial or column vector of the number field an ideal either given by Zkx generators or by a Z basis a prime ideal given as a 5 element row vector or an idele given as a 2 element row vector Because of possible confusion with elements and ideals other vector or matrix arguments are forbidden The library syntax is galoisapply nf aut x 102 3 6 85 nfgaloisconj nf flag 0 d nf being a number field as output by nfinit computes the conjugates of a root r of the non constant polynomial x nf 1 expressed as polynomials in r This can be used even if the number field nf is not Galois since some conjugates may lie in the field As a note to old timers of PARI starting with version 2 0 17 this function works much better than in earlier versions nf can simply be a polynomial if flag 4 1 If no flags or flag 0 if nf is a number field use a combination of flag 4 and 1 and the result is always complete else use a combination of flag 4 and 2 and the result is subject to the restriction of flag 2 but a warning is issued when it is not proven complete If flag 1 use nfroots require a number field If flag 2 use complex approximations to the roots and an integral LLL The
353. ssentially dentical to mulsiz except that z is specifically an integer 5 3 Level 2 kernel operations on general PARI objects The functions available to handle subunits are the following GEN compo GEN x long n creates a copy of the n th true component i e not counting the codewords of the object x GEN truecoeff GEN x long n creates a copy of the coefficient of degree n of x if x is a scalar polynomial or power series and otherwise of the n th component of x The remaining two are macros NOT functions see Section 4 2 1 for a detailed explanation long coeff GEN x long i long j applied to a matrix x type t_MAT this gives the address of the coefficient at row i and column j of x long mael n GEN x long a1 long an stands for x a az an where 2 lt n lt 5 with all the necessary typecasts 189 5 3 1 Copying and conversion GEN cgetp GEN x creates space sufficient to hold the p adic x and sets the prime p and the p adic precision to those of x but does not copy the p adic unit or zero representative and the modulus of x GEN gcopy GEN x creates a new copy of the object x on the PARI stack For permanent subob jects only the pointer is copied GEN forcecopy GEN x same as copy except that even permanent subobjects are copied onto the stack long taille GEN x returns the total number of BIL bit words occupied by the tree representing x GEN gclone GEN x creates a new permanent copy
354. ssign the value of c to both bb and a if this really is what you intended you re a hopeless case 2 6 The GP PARI programming language The GP calculator uses a purely interpreted language The structure of this language is reminiscent of LISP with a functional notation f x y rather than f x y all programming constructs such as if while etc are functions see Section 3 11 for a complete list and the main loop does not really execute but rather evaluates sequences of expressions Of course it is by no means a true LISP 2 6 1 Variables and symbolic expressions In GP you can use up to 16383 variable names up to 65535 on 64 bit machines These names can be any standard identifier names i e they must start with a letter and contain only valid keyword characters _ or alphanumeric characters A Za z0 9 To avoid confusion with other symbols you must not use other non alphanumeric symbols like or In addition to the function names which you must not use see the list with c there are exactly three special variable names which you are not allowed to use Pi and Euler which represent well known constants and I y 1 Note that GP names are case sensitive since version 1 900 This means for instance that the symbol i is perfectly safe to use and will not be mistaken for 1 and that o is not synonymous anymore to 0 If you grew addicted to the previous behaviour you can have it back by setting the def
355. st compat If you want to test the graphic routines use make test graphic You will have to click on the mouse button after seeing each image under X11 under suntools you must kill the images There will be eight of them probably shown twice under X11 try to resize at least one of them as a further test The make bench and make test compat runs produce a Postscript file pari ps in Oxxx which you can send to a Postscript printer The output should bear some similarity to the screen images 3 Installation When everything looks fine type make install You may have to do this with superuser privileges depending on the target directories Beware that if you chose the same installation directory as before in the Configure process this will wipe out any files from version 1 39 15 and below that might already be there Libraries and executable files from newer versions starting with version 1 900 are not removed since they are only links to files bearing the version number beware of that as well if you re an avid GP fan don t forget to delete the old pari libraries once in a while This installs in the directories chosen at Configure time the default GP executable probably gp dyn under the name gp the default PARI library probably libpari so the necessary include files the manual pages the documentation and help scripts and emacs macros By default if a dynamic library libpari so could be built the static library libpari a
356. stem are its speed which can be between 5 and 100 times better on many computations the possibility of using directly data types which are familiar to mathematicians and its extensive algebraic number theory module which has no equivalent in the above mentioned systems It is possible to use PARI in two different ways 1 as a library which can be called from an upper level language application for instance written in C C Pascal or Fortran 2 as a sophisticated programmable calculator named GP which contains most of the control instructions of a standard language like C The use of GP is explained in chapters 2 and 3 and the programming in library mode is explained in chapters 3 4 and 5 In the present Chapter 1 we give an overview of the system Important note A tutorial for GP is provided in the standard distribution tutorial dvi and you should read this first at least the beginning of it you can skip the specialized topics you re not interested in You can then start over and read the more boring stuff which lies ahead But you should do that eventually at the very least the various Chapter headings You can have a quick idea of what is available by looking at the GP reference card refcard dvi or refcard ps In case of need you can then refer to the complete function description in Chapter 3 How to get the latest version This package can be obtained by anonymous ftp from quite a number of sites ask archie or you
357. stood as follows every PARI type has one or two initial code words The components are counted starting at 1 after these code words In particular if x is a vector this is indeed the n component of x if x is a matrix the n column if x is a polynomial the nt coefficient i e of degree n 1 and for power series the nt significant coefficient The use of the function component implies the knowledge of the structure of the different PARI types which can be recalled by typing t under GP The library syntax is compo z n where n is a long The two other methods are more natural but more restricted The function polcoeff zx 7 gives the coefficient of degree n of the polynomial or power series x with respect to the main variable of x to check variable ordering or to change it use the function reorder see Section 3 11 2 22 In particular if n is less than the valuation of x or in the case of a polynomial greater than the degree the result is zero contrary to compo which would send an error message If x is a power series and n is greater than the largest significant degree then an error message is issued 50 For greater flexibility vector or matrix types are also accepted for x and the meaning is then identical with that of compo Finally note that a scalar type is considered by polcoeff as a polynomial of degree zero The library syntax is truecoeff x n The third method is specific to vectors or matrices under GP
358. syntax is idealinv nf x 3 6 47 ideallist nf bound flag 4 computes the list of all ideals of norm less or equal to bound in the number field nf The result is a row vector with exactly bound components Each component is itself a row vector containing the information about ideals of a given norm in no specific order This information can be either the HNF of the ideal or the idealstar with possibly some additional information If flag is present its binary digits are toggles meaning 1 give also the generators in the idealstar 2 output L U where L is as before and U is a vector of zinternallogs of the units 4 give only the ideals and not the idealstar or the ideallog of the units The library syntax is ideallistO nf bound flag where bound must be a C long integer Also available is ideallist nf bound corresponding to the case flag 0 3 6 48 ideallistarch nf list arch flag 0 vector of vectors of all idealstarinit see idealstar of all modules in list with Archimedean part arch added void if omitted list is a vector of big ideals as output by ideallist flag for instance flag is optional its binary digits are toggles meaning 1 give generators as well 2 list format is L U see ideallist The library syntax is ideallistarch0 nf list arch flag where an omitted arch is coded as NULL 3 6 49 ideallog nf x bid nf being a number field bid being a big ideal as output by ideal
359. t use gerepilemany of which the above is just a special case If you followed us this far congratulations and rejoice the rest is much easier 4 5 Implementation of the PARI types Although it is a little tedious we now go through each type and explain its implementation Let z be a GEN pointing at a PARI object In the following paragraphs we will constantly mix two points of view on the one hand z will be treated as the C pointer it is in the context of program fragments like z 1 on the other as PARI s handle on the internal representation of some mathematical entity so we will shamelessly write z 4 0 to indicate that the value thus represented is nonzero in which case the pointer z certainly will be non NULL We offer no apologies for this style In fact you had better feel comfortable juggling both views simultaneously in your mind if you want to write correct PARI programs Common to all the types is the first codeword z 0 which we don t have to worry about since this is taken care of by cgetg Its precise structure will depend on the machine you are using but it always contain the following data the internal type number associated to the symbolic type name the length of the root in longwords and a technical bit which indicates whether the object is a clone see below or not This last one is used by GP for internal garbage collecting you won t have to worry about it These data can be handled through the fo
360. t a result as possible and secondly be permitted if they make any kind of sense More specifically if you do an operation not a transcendental one between exact objects you will get an exact object For example dividing 1 by 3 does not give 0 33333 as you might expect but simply the rational number 1 3 If you really want the result in type real evaluate 1 3 or add 0 to 1 3 The result of operations between imprecise objects will be as precise as possible Consider for example one of the most difficult cases that is the addition of two real numbers and y The accuracy of the result is a priori unpredictable it depends on the precisions of x and y on their sizes i e their exponents and also on the size of x y PARI works out automatically the right precision for the result even when it is working in calculator mode GP where there is a default precision In particular this means that if an operation involves objects of different accuracies some digits will be disregarded by PARI It is a common source of errors to forget for instance that a real number is given as r 2 where r is a rational approximation e a binary exponent and e is a nondescript real number less than 1 in absolute value Hence any number less than 2 may be treated as an exact zero 7 0 E 28 1 E 100 1 0 E 28 As an exercise if a 27 100 why do a O anda 1 differ The second part of the PARI philosophy is that PARI oper
361. t by ideallist of ideallistarch outputs the list of the class numbers of the corresponding ray class groups The library syntax is rayclassnolist bnf list 3 6 21 bnrconductor a1 a2 a3 flag 04 conductor of the subfield of a ray class field as defined by a1 az az see bnr at the beginning of this section The library syntax is bnrconductor a az az flag prec where an omitted argument among the a is input as gzero and flag is a C long 3 6 22 bnrconductorofchar bnr chi bnr being a big ray number field as output by bnrclass and chi being a row vector representing a character as expressed on the generators of the ray class group gives the conductor of this character as a modulus The library syntax is bnrconductorofchar bnr chi prec where prec is a long 89 3 6 23 bnrdisc al a2 a3 flag 0 al a2 a3 defining a big ray number field L over a groud field K see bnr at the beginning of this section for the meaning of al a2 a3 outputs a 3 component row vector N Ri D where N is the absolute degree of L Ri the number of real places of L and D the discriminant of L Q including sign if flag 0 If flag 1 as above but outputs relative data N is now the degree of L K R is the number of real places of K unramified in L so that the number of real places of L is equal to Ri times the relative degree N and D is the relative discriminant ideal of L K If flag 2 does as in case 0 exce
362. t in case your system is not listed and you nevertheless have a working GP executable If a BUG message shows up it probably means that something is wrong Most probably with the installation procedure but it may be a bug in the Pari system in which case we would appreciate a report including the relevant dif file in the Oxxz directory and the file dft Config in Error messages of the form not yet available for this architecture are an obvious special case which should not trigger a bug report unless you implement the functionality yourself that is Note If when running gp dyn you get a message of the form ld so warning libpari so xrx has older revision than expected trr possibly followed by more errors you already have a dynamic PARI library installed and a broken local configuration Either remove the old library or unset the LD_LIBRARY_PATH environment variable Try to disable this variable in any case if anything very wrong occurs with the gp dyn binary e g Illegal Instruction on startup It doesn t affect gp sta 197 Note2 there s a known minor problem on Pentium processors unrelated to the infamous fdiv bug which results in a discrepancy in bench elliptic the last few decimals of the components of an ell structure may be slightly off with respect to the bench both results are correct given the requested precision 2 4 2 Some more testing Optional You can test GP in compatibility mode with make te
363. t library function call and is treated as such This value is subject to garbage collection since it will be deleted when the value changes This is preferable and the above flag is only retained for compatibility reasons it can still be useful in library mode The library syntax is Mod0 z y flag Also available are e for flag 1 gmodulo z y e for flag 0 gmodulcp z y 3 2 4 Pol x v x transforms the object x into a polynomial with main variable v If x is a scalar this gives a constant polynomial If x is a power series the effect is identical to truncate see there i e it chops off the O X If x is a vector this function creates the polynomial whose coefficients are given in x with x 1 being the leading coefficient which can be zero Warning this is not a substitution function It is intended to be quick and dirty So if you try Pol a y on the polynomial a x y you will get y y which is not a valid PARI object The library syntax is gtopoly x v where v is a variable number 47 3 2 5 Polrev z v x transform the object x into a polynomial with main variable v If x is a scalar this gives a constant polynomial If x is a power series the effect is identical to truncate see there i e it chops off the O X If x is a vector this function creates the polynomial whose coefficients are given in x with z 1 being the constant term Note that this is the reverse of Pol if x is a vector otherwise
364. t of x and 2 This is different from gshift when n is negative and x is of type t_INT gshift truncates while gmul2n creates a fraction if necessary GEN gdiv z GEN x GEN y GEN z yields the quotient of the objects x and y GEN gdivgs z GEN x long s GEN z yields the quotient of the object x and the long s GEN gdivsg z long s GEN x GEN z yields the quotient of the long s and the object x GEN gdivent z GEN x GEN y GEN z yields the true Euclidean quotient of x and the integer or polynomial y GEN gdiventsg z long s GEN x GEN z yields the true Euclidean quotient of the long s by the integer x GEN gdiventgs z GEN x long s GEN z yields the true Euclidean quotient of the integer x by the long s GEN gdiventres GEN x GEN y creates a 2 component vertical vector whose components are the true Euclidean quotient and remainder of x and y GEN gdivmod GEN x GEN y GEN r If r is not equal to NULL or ONLY_REM creates the false Euclidean quotient of x and y and puts the address of the remainder into r If r is equal 193 to NULL do not create the remainder and if r is equal to ONLY_REM create and output only the remainder The remainder is created after the quotient and can be disposed of individually with a cgiv r GEN poldivres GEN x GEN y GEN r same as gdivmod but specifically for polynomials x and y GEN gdeuc GEN x GEN y creates the Euclidean quotient of the polynomials x and y GEN g
365. take rather long about twice as long as with real numbers of the same length It would be better to initialize s to a real zero using for instance the instructions s cgetr prec 1 gaffsg 0 s This raises the question which real zero does this produce have a look at Section 1 2 6 3 In fact the following choice has been made it will give you the zero with exponent equal to BITS_IN_LONG times the number of longwords in the mantissa i e bit_accuracy lg s Instead of the above idiom you can also use the function GEN realzero long prec which simply returns a real zero to accuracy bit_accuracy prec The sixth remark here is about how to determine the approximate size of a real number The fastest way to do this is to look at its binary exponent Hence we need to have s actually represented as areal number and not as an integer or arational number The result of transcendental functions is guaranteed to be of type t_REAL or complex with t_REAL components thus this is indeed the case after the call to gsqrt since its argument is a nonnegative real number Finally note the use of the function gmul2n It has the following syntax GEN gmul2n GEN x long n and the effect is simply to multiply x by 2 where n can be positive or negative This is much faster than gmul or gmulgs There is another function gshift with exactly the same syntax When n is non negative the effects of these two functions are the same However wh
366. tarting again with exactly the same parameters may give the correct result In this case a warning message is printed v 8 v tu a vector with 2 components the first being the number w of roots of unity in K and the second a primitive w th root of unity expressed as a polynomial v 9 v fu is a system of fundamental units also expressed as polynomials v 10 gives a measure of the correctness of the computations of the fundamental units not of the regulator expressed as a number of bits Tf this number is greater than 20 say everything is OK If v 10 lt 0 then we have lost all accuracy in computing the units usually an error message will be printed and the units not given In the intermediate cases one must proceed with caution for example by increasing the current precision If flag 1 and the precision happens to be insufficient for obtaining the fundamental units exactly the internal precision is doubled and the computation redone until the exact results are obtained The user should be warned that this can take a very long time when the coefficients of the fundamental units on the integral basis are very large for example in the case of large real 83 quadratic fields In that case there are alternate methods for representing algebraic numbers which are not implemented in PARI If flag 2 the fundamental units and roots of unity are not computed Hence the result has only 7 components the first seven ones tec
367. tax is GEN gclone GEN x A clone can be removed from the heap thus destroyed using void gunclone GEN x No PARI object should keep references to a clone which has been destroyed If you want to copy a clone back to the stack then delete it use forcecopy and not gcopy otherwise some components might not be copied moduli of t_INTMODs and t_POLMODs for instance 4 3 5 Conversions The following functions convert C objects to PARI objects creating them on the stack as usual GEN stoi long s C long integer small to PARI integer t_INT GEN dbltor double s C double to PARI real t_REAL The accuracy of the result is 19 decimal digits i e a type t_REAL of length DEFAULTPREC although on 32 bit machines only 16 of them will be significant We also have the converse functions long itos GEN x x must be of type t_INT double rtodbl GEN x x must be of type t_REAL as well as the more general ones long gtolong GEN x double gtodouble GEN x 4 4 Garbage collection 4 4 1 Why and how As we have seen the pari_init routine allocates a big range of addresses the stack that are going to be used throughout Recall that all PARI objects are pointers But for universal objects they will all point at some part of the stack The stack starts at the address bot and ends just before top This means that the quantity top bot sizeof long is equal to the size argument of pari_init The PARI stack also has a
368. th component related to the regulator more precisely to Shanks and Lenstra s distance which must be a real number See also the function qfbprimeform which directly creates a prime form of given discriminant see Chapter 3 23 2 3 13 Row and column vectors types t_VEC and t_COL to enter a row vector type the components separated by commas and enclosed between brackets and e g 1 2 3 To enter a column vector type the vector horizontally and add a tilde to transpose yields the empty row vector The function Vec can be used to transform any object into a vector see Chapter 3 2 3 14 Matrices type t_MAT to enter a matrix type the components line by line the components being separated by commas the lines by semicolons and everything enclosed in brackets and eg x y z t u v yields the empty 0x0 matrix The function Mat can be used to transform any object into a matrix see Chapter 3 Note that although the internal representation is essentially the same only the type number is different a row vector of column vectors is not a matrix for example multiplication will not work in the same way Note also that it is possible to create matrices by conversion of empty column vectors and concatenation or using the matrix function with a given positive number of columns each of which has zero rows It is not possible to create or repr
369. the functionalities they provide All of them are free though you ought to make a small donation to the FSF if you use and like GNU wares e GNU readline library This provides line editing under GP an automatic context dependent completion and an editable history of commands Note that it is incompatible with SUN command tools yet another reason to dump Suntools for X Windows A recent readline version number at least 2 2 is preferred but older versions should be usable e GNU gzip gunzip gzcat package enables GP to read compressed data e GNU emacs GP can be run in an Emacs buffer with all the obvious advantages if you are familiar with this editor Note that readline is still useful in this case since it provides a much better automatic completion than is provided by Emacs GP mode e perl provides extended online help full text from Chapter 3 about functions and concepts which can be used under GP or independently http www perl com will direct you to the nearest CPAN archive site e A colour capable xterm which enables GP to use different user configurable colours for its output All xterm programs which come with current X11R6 3 distributions will satisfy this requirement Under X11R6 you can for instance use color_xterm get the latest version at http www clark net pub dickey xterm One notable exception is the native AIX C compiler on IBM RS 6000 workstations which generates fast code even without any spe
370. the point at infinity i e the identity element of the group law represented by the one component vector 0 It is useful to have at one s disposal more information This is given by the function ellinit see there which usually gives a 19 component vector which we will call a long vector in this section If a specific flag is added a vector with only 13 component will be output which we will call a medium vector A medium vector just gives the first 13 components of the long vector corresponding to the same curve but is of course faster to compute The following member functions are available to deal with the output of ellinit al a6 b2 b8 c4 c6 coefficients of the elliptic curve area volume of the complex lattice defining E disc discriminant of the curve j j invariant of the curve omega w1 w2 periods forming a basis of the complex lattice defining E w1 is the real period and wa3 w1 belongs to Poincar s half plane eta quasi periods 71 72 such that nyw2 now in roots roots of the associated Weierstrass equation tate u u v in the notation of Tate wW Mestre s w this is technical Their use is best described by an example assume that E was output by ellinit then typing E disc will retrieve the curve s discriminant The member functions area eta and omega are only available for curves over Q Conversely tate and w are only available for curves defined over Qp Some funct
371. the same value of prec will yield different results on 32 bit and 64 bit machines Real numbers have two codewords see Section 4 5 so the formula for computing the bit accuracy is bit_accuracy prec prec 2 x BITS_IN_LONG this is actually the definition of a macro The corresponding accuracy expressed in decimal digits would be bit_accuracy prec x log 2 log 10 152 For example if the value of prec is 5 the corresponding accuracy for 32 bit machines is 5 2 x log 232 log 10 28 decimal digits while for 64 bit machines it is 5 2 log 2 log 10 57 decimal digits Thus you must take care to change the prec parameter you are supplying according to the bit size either using the default precisions given by the various DEFAULTPRECs or by using conditional constructs of the form ifndef LONG_IS_64BIT prec 4 else prec 6 endif which is in this case equivalent to the statement prec MEDDEFAULTPREC Note that for parity reasons half the accuracies available on 32 bit architectures the odd ones have no precise equivalents on 64 bit machines 4 3 Creation of PARI objects assignments conversions 4 3 1 Creation of PARI objects The basic function which creates a PARI object is the function cgetg whose prototype is GEN cgetg long length long type Here length specifies the number of longwords to be allocated to the object and type is the type number of the object preferably in
372. the vector containing the rl r2 roots nf roots of nf 1 corresponding to the r1 r2 embeddings of the number field into C the first r1 components are real the next r2 have positive imaginary part nf T is an integral basis in Hermite normal form for Zg nf zk expressed on the powers of 0 nf 8 is the n x n integral matrix expressing the power basis in terms of the integral basis and finally nf 9 is the n x n matrix giving the multiplication table of the integral basis If a non monic polynomial is input nfinit will transform it into a monic one then reduce it see flag 3 It is allowed though not very useful given the existence of nfnewprec to input a nf or a bnf instead of a polynomial The special input format x B is also accepted where x is a polynomial as above and B is the integer basis as computed by nfbasis This can be useful since nfinit uses the round 4 104 algorithm by default which can be very slow in pathological cases where round 2 nfbasis x 2 would succeed very quickly If flag 2 pol is changed into another polynomial P defining the same number field which is as simple as can easily be found using the polred algorithm and all the subsequent computations are done using this new polynomial In particular the first component of the result is the modified polynomial If flag 3 does a polred as in case 2 but outputs nf Mod a P where nf is as before and Mod a P Mod z pol gives t
373. their local variables from a member function For instance one could implement a dreadful idea as far as efficiency goes correct_ell_if_needed x local tmp if type x t_VEC tmp ellinit x some further checks tmp x j correct_ell_if_needed x 13 2 6 5 Strings and Keywords GP variables can now hold values of type character string internal type t_STR This section describes how they are actually used as well as some convenient tricks automatic concatenation and expansion keywords valid in string context As explained above the general way to input a string is to enclose characters between quotes This is the only input construct where whitespace characters are significant the string will contain the exact number of spaces you typed in Besides you can escape characters by putting a just before them the translation is as follows e lt Escape gt n lt Newline gt t lt Tab gt For any other character x x is expanded to x In particular the only way to put a into a string is to escape it Thus for instance a would produce the string whose content is a This is definitely not the same thing as typing a whose content is merely the one letter string a You can concatenate two strings using the concat function If either argument is a string the other is automatically converted to a string if necessary it will be evaluated first concat ex 1 1 1 e
374. tic curve E where E is given in the long or medium format output by ellinit in the form of a two component vector u v of power series given to the current default series precision This vector is characterized by the following two properties First the point x y u v satisfies the equation of the elliptic curve Second the differential du 2v a1u a3 is equal to f z dz a differential form on H To N where N is the conductor of the curve The variable used in the power series for u and v is 2 which is implicitly understood to be equal to exp 2i7z It is assumed that the curve is a strong Weil curve and the Manin constant is equal to 1 The equation of the curve E must be minimal use ellglobalred to get a minimal equation The library syntax is taniyama and the precision of the result is determined by the global variable precdl 3 5 26 elltors E flag 0 if E is an elliptic curve defined over Q outputs the torsion subgroup of E as a 3 component vector t v1 v2 where t is the order of the torsion group v1 gives the structure of the torsion group as a product of cyclic groups sorted by decreasing order and v2 gives generators for these cyclic groups must be a long vector as output by ellinit E ellinit 0 0 0 1 0 elltors E 1 4 2 2 LO 0 1 0 Here the torsion subgroup is isomorphic to Z 2Z x Z 2Z with generators 0 0 and 1 0 If flag 0 use Doud s algorithm bound torsion by c
375. tic curve E by changing the coordinates using the vector v u r s t ie if x and y are the new coordinates then x u x r y u y su x t The vector E must be a medium or long vector of the type given by ellinit The library syntax is coordch E v 3 5 7 ellchangepoint x v changes the coordinates of the point or vector of points x using the vector v u r s tJ ie if 2 and y are the new coordinates then x u 2 r y uy su22 t see also ellchangecurve The library syntax is pointch z v 74 3 5 8 elleisnum E k flag 0 E being an elliptic curve as output by ellinit or alterna tively given by a 2 component vector w1 w2 and k being an even positive integer computes the numerical value of the Eisenstein series of weight k at E When flag is non zero and k 4 or 6 returns g2 or g3 with the correct normalization The library syntax is elleisnum 5E k flag 3 5 9 elleta om returns the two component row vector 71 72 of quasi periods associated to om w1 wa The library syntax is elleta om prec 3 5 10 ellglobalred calculates the arithmetic conductor the global minimal model of E and the global Tamagawa number c Here EF is an elliptic curve given by a medium or long vector of the type given by ellinit and is supposed to have all its coefficients a in Q The result is a 3 component vector N v c N is the arithmetic conductor of the curve v is itself a vector u r s
376. tion can be found in a forthcoming paper One must have m lt n The library syntax is polzagreel n m prec if the result is only wanted as a polynomial with real coefficients to the precision prec or polzag n m if the result is wanted exactly where n and m are longs 3 7 27 serconvol x y convolution or Hadamard product of the two power series x and y in other words if x Y ag X and y bx X then serconvol x y ax by X The library syntax is convol z y 3 7 28 serlaplace x x must be a power series with only non negative exponents If z Y ap k XF then the result is Daz X The library syntax is laplace z 3 7 29 serreverse x reverse power series i e x71 not 1 x of x x must be a power series whose valuation is exactly equal to one The library syntax is recip z 119 3 7 30 subst x y z replace the simple variable y by the argument z in the polynomial ex pression x Every type is allowed for x but if it is not a genuine polynomial or power series or rational function the substitution will be done as if the scalar components were polynomials of degree one In particular beware that subst 1 x 1 2 3 4 1 1 0 o 1 smallskip subst 1 x Mat 0 1 OK forbidden substitution by a non square matrix If x is a power series z must be either a polynomial a power series or a rational function y must be a simple variable name The library syntax is gsubst x v
377. tion remain valid The library syntax is anell E n where n is a C integer 3 5 4 ellap E p flag 0 computes the a corresponding to the elliptic curve E and the prime number p These are defined by the equation E F p 1 ap where E F stands for the number of points of the curve E over the finite field Fp When flag is O this uses the baby step giant step method and a trick due to Mestre This runs in time O p and requires O p storage hence becomes unreasonable when p has about 30 digits If flag is 1 computes the a as a sum of Legendre symbols This is slower than the previous method as soon as p is greater than 100 say No checking is done that p is indeed prime E must be a medium or long vector of the type given by ellinit defined over Q F or Q The library syntax is ellap0 E p flag Also available are apell E p corresponding to flag 0 and apell2 E p flag 1 3 5 5 ellbil 21 22 if z1 and 22 are points on the elliptic curve E this function computes the value of the canonical bilinear form on z1 z2 ellheight E 21 22 ellheight E 21 ellheight F 22 where denotes of course addition on E In addition z1 or 22 but not both can be vectors or matrices Note that this is equal to twice some normalizations E is assumed to be integral given by a minimal model The library syntax is bilhell F z1 22 prec 3 5 6 ellchangecurve v changes the data for the ellip
378. to r and returns the quotient If r is equal to NULL only the quotient is returned If r is equal to ONLY_REM the remainder is returned instead of the quotient In the generic case the remainder is created after the quotient and can be disposed of individually with a cgiv r The remainder is always of the sign of the dividend s GEN dvmdsi long s GEN x GEN x r creates the Euclidean quotient and remainder of the long s by the integer x Obeys the same conventions with respect to r GEN dvmdis GEN x long s GEN x r create the Euclidean quotient and remainder of the integer x by the long s GEN dvmdii GEN x GEN y GEN r returns the Euclidean quotient of the integer x by the inte ger y and puts the remainder into r If r is equal to NULL the remainder is not created and if r is equal to ONLY_REM only the remainder is created and returned In the generic case the remainder is created after the quotient and can be disposed of individually with a cgiv r The remainder is always of the sign of the dividend x GEN truedvmdii GEN x GEN y GEN r as dvmdii but with a non negative remainder void mpdvmdz GEN x GEN y GEN z GEN r assigns the Euclidean quotient of the integers x and y into the integer or real z putting the remainder into r unless r is equal to NULL or ONLY_REM as above 188 void dvmdssz long s long t GEN z GEN r assigns the Euclidean quotient of the longs s and t into the integer or real z putting the
379. to use but not foolproof If some other function uses these timers and many PARI functions do when DEBUGLEVEL is high enough the timings will be meaningless The functions long gentimer long id or long genmsgtimer long id char format are equivalent to timer and msgtimer respectively except they will use a unique timer denoted by id To get a valid identifier use id get_timer 0 172 This timer has to be deleted when it s not needed anymore i e when the main function returns with a call to get_timer id After such a call the reserved identifier becomes available again 4 8 A complete program Now that the preliminaries are out of the way the best way to learn how to use the library mode is to work through a detailed non trivial example of a main program We will write a program which computes the exponential of a square matrix x The complete listing is given in Appendix B but each part of the program will be produced and explained here We will use an algorithm which is not optimal but is not far from the one used for the PARI function gexp in fact embodied in the function mpexp1 This consists in calculating the sum of the series e2 2 y a k 0 for a suitable positive integer n and then computing e by repeated squarings First we will need to compute the L norm of the matrix z i e the quantity z lell2 yd 22 We will then choose the integer n such that the L norm of x 2 is less than or equal
380. tput by nfinit and either a polynomial x with coefficients in nf defining a relative extension L of nf or a pseudo basis x of such an extension as output for example by rnfpseudobasis computes another pseudo basis A T not in HNF in general such that all the ideals of 7 except perhaps the last one are equal to the ring of integers of nf and outputs the four component row vector A I D d as in rnfpseudobasis The name of this function comes from the fact that the ideal class of the last ideal of I which is well defined is called the Steinitz class of the module Zr Note nf can be a bnf as output by bnfinit The library syntax is rnfsteinitz nf x 3 6 140 subgrouplist bnr bound flag 0 bnr being as output by bnrinit or a list of cyclic components of a finite Abelian group G outputs the list of subgroups of G of index bounded by bound if not omitted Subgroups are given as HNF left divisors of the SNF matrix corresponding to G If flag 0 default and bnr is as output by bnrinit gives only the subgroups whose modulus is the conductor The library syntax is subgrouplist0 bnr bound flag prec where bound flag and prec are long integers 3 6 141 zetak znf 2x flag 0 znf being a number field initialized by zetakinit not by nfinit computes the value of the Dedekind zeta function of the number field at the complex number x If flag 1 computes Dedekind A function instead i e the product of the Dedekind zeta f
381. ts integrals and similar functions Although the GP calculator is programmable it is useful to have preprogrammed a number of loops including sums products and a certain number of recursions Also a number of functions from numerical analysis like numerical integration and summation of series will be described here One of the parameters in these loops must be the control variable hence a simple variable name The last parameter can be any legal PARI expression including of course expressions using loops Since it is much easier to program directly the loops in library mode these functions are mainly useful for GP programming The use of these functions in library mode is a little tricky and its explanation will be mostly omitted although the reader can try and figure it out by himself by checking the example given for the sum function In this section we only give the library syntax with no semantic explanation The letter X will always denote any simple variable name and represents the formal parameter used in the function numerical integration A number of Romberg like integration methods are implemented see intnum as opposed to intformal which we already described The user should not require too much accuracy 18 or 28 decimal digits is OK but not much more In addition analytical cleanup of the integral must have been done there must be no singularities in the interval or at the boundaries In practice this can be accomplishe
382. ture compiler and optimization flags If anything should have been found and was not consider that Configure failed and follow the instructions below Look especially for the readline and X11 libraries and the perl and gunzip or zcat binaries In case the default Configure run fails miserably try Configure a interactive mode and answer all the questions there aren t that many Of course Configure will still provide defaults for each answer but if you accept them all it will fail just the same so be wary In any case we would appreciate a bug report including the complete output from Configure and the file Oxxx dft Config in that was produced in the process Note that even in interactive mode you can t directly tell Configure where the readline library and include files are If they are not in a standard place it won t find them Nonetheless it first searches the distribution toplevel for a readline directory Thus if you just want to give readline a try as you probably should you can get the source and compile it there you don t need to install it You can also use this feature together with a symbolic link named readline in the PARI toplevel directory if you have compiled the readline library somewhere else without installing it to one of its standard locations 196 Technical note Configure can build GP on different architectures simultaneously from the same toplevel sources Instead of the readline link allude
383. ty i e a higher number than the variable defining the extension For example under GP you can use the variable name y or t to define the base field and the variable name x to define the relative extension Now a last set of definitions concerning the way big ray number fields or bnr are input using class field theory These are defined by a triple al a2 a3 where the defining set a1 a2 a3 80 can have any of the following forms bnr bnr subgroup bnf module bnf module subgroup where e bnf is as output by bnfclassunit or bnfinit where units are mandatory unless the ideal is trivial bnr by bnrclass with flag gt 0 or bnrinit This is the ground field e module is either an ideal in any form see above or a two component row vector containing an ideal and an r component row vector of flags indicating which real Archimedean embeddings to take in the module e subgroup is the HNF matrix of a subgroup of the ray class group of the ground field for the modulus module This is input as a square matrix expressing generators of a subgroup of the ray class group bnr clgp on the given generators The corresponding bnr is then the subfield of the ray class field of the ground field for the given modulus associated to the given subgroup All the functions which are specific to relative extensions number fields big number fields big number rays share the prefix rnf nf bnf bnr respectively They are meant to ta
384. typically between a polynomial and a polmod For example PARI will not recognize that Mod y y72 1 is the same as Mod x x72 1 Hopefully this problem will pass away when type element of a number field is eventually introduced On the other hand Mod x x72 1 Mod x x72 1 which gives Mod 2 x x72 1 and x Mod y y 2 1 which gives a result mathematically equivalent to x i with i 1 are completely correct while y Mod x x72 1 gives Mod x y x72 1 which may not be what you want y is treated here as a numerical parameter not as a polynomial variable Note added in version 2 0 16 As long as the main variables are the same it is allowed to mix t_POL and t_POLMODs The result will be the expected t_POLMOD For instance x Mod x x72 1 is equal to Mod 2 x x72 1 This wasn t the case prior to version 2 0 16 it returned a polynomial in x equivalent to x 7 which was in fact an invalid object you couldn t lift it 2 3 9 Polynomials type t_POL type the polynomial in a natural way not forgetting to put a between a coefficient and a formal variable this x does not appear in beautified output Any variable name can be used except for the reserved names I used exclusively for the square root of 1 Pi 3 14 Euler Euler s constant and all the function names predefined functions as described in Chapter 3 use c to get the complete list of them and user defined functi
385. uding the time for printing the results see and 2 1 27 Note on output formats A zero real number is printed in e format as 0 Exzx where xx is the usually negative decimal exponent of the number cf Section 1 2 6 3 This allows the user to check the accuracy of the zero in question this could also be done using x but that would be more technical When the integer part of a real number x is not known exactly because the exponent of x is greater than the internal precision the real number is printed in e format note that in versions before 1 38 93 this was instead printed with a at the end Note also that in beautified format a number of type integer or real is written without enclosing parentheses while most other types have them Hence if you see the expression 3 14 it is not of type real but probably of type complex with zero imaginary part if you want to be sure type x or use the function type 2 2 Simple metacommands Simple metacommands are meant as shortcuts and should not be used in GP scripts see Sec tion 3 11 Beware that these as all of GP input are now case sensitive For example Q is no longer identical to q In the following list braces are used to denote optional arguments with their default values when applicable e g n 0 means that if n is not there it is assumed to be 0 Whitespace or spaces between the metacommand and its arguments and within arguments is optional This can caus
386. ult types ell nf bnf bnr and prime ideals The syntax structure member is taken to mean retrieve member from structure e g ell j returns the j invariant of the elliptic curve e11 or outputs an error message if e11 doesn t have the correct type To define your own member functions use the syntax structure member function text where function text is written as the seg in a standard user function without local variables whose only argument would be structure For instance the current implementation of the e11 type is simply an horizontal vector the j invariant being the thirteenth component This could be implemented as x j if type x t_VEC length x lt 14 error this is not a proper elliptic curve x x 13 You can redefine one of your own member functions simply by typing a new definition for it On the other hand as a safety measure you can t redefine the built in member functions so typing the above text would in fact produce an error you d have to call it e g x j2 in order for GP to accept it Typing um will output the list of user defined member functions 33 Note Member functions were not meant to be too complicated or to depend on any data that wouldn t be global Hence they do no have parameters besides the implicit structure or local variables Of course if you need some preprocessing work in there there s nothing to prevent you from calling your own functions using freely
387. ult value will be used On UNIX machines it will be the place you told Configure usually usr local bin gp for the executable 4000000 for the stack 500000 for the prime limit and 30000 for the buffer size You can then work as usual under GP but with two notable advantages which don t really matter if readline is available to you see below First and foremost you have at your disposal all the facilities of a text editor like Emacs in particular for correcting or copying blocks Second you can have an on line help which is much more complete than what you obtain by typing name 38 This is done by typing M In the minibuffer Emacs asks what function you want to describe and after your reply you obtain the description which is in the users manual including the description of functions such as A which use special symbols This help system can also be menu driven by using the command M Xc which opens a help menu window which enables you to choose the category of commands for which you want an explanation Nevertheless if extended help is available on your system see Section 2 2 1 you should use it instead of the above since it s nicer it ran through T X and understands many more keywords Finally you can use command completion in the following way After the prompt type the first few letters of the command then lt TAB gt where lt TAB gt is the TAB key If there exists a unique command starting with the letters
388. unction by its gamma and exponential factors The accuracy of the result depends in an essential way on the accuracy of both the zetakinit program and the current accuracy but even so the result may be off by up to 5 or 10 decimal digits The library syntax is glambdak znf x prec or gzetak znf x prec 3 6 142 zetakinit x computes a number of initialization data concerning the number field de fined by the polynomial x so as to be able to compute the Dedekind zeta and lambda functions respectively zetak x and zetak x 1 This function calls in particular the bnfinit program The result is a 9 component vector v whose components are very technical and cannot really be used by the user except through the zetak function The only component which can be used if it has not been computed already is v 1 4 which is the result of the bnfinit call This function is very inefficient and should be rewritten It needs to computes millions of coefficients of the corresponding Dirichlet series if the precision is big Unless the discriminant is small it will not be able to handle more than 9 digits of relative precision e g zetakinit x78 2 needs 440MB of memory at default precision The library syntax is initzeta 115 3 7 Polynomials and power series We group here all functions which are specific to polynomials or power series Many other functions which can be applied on these objects are described in the other sections Also some o
389. uotient closest to 00 is chosen The library syntax is gdivround z y for x y 3 1 7 The expression x y is the Euclidean remainder of x and y The modulus y must be of type integer or polynomial The result is the remainder always non negative in the case of integers Allowed dividend types are scalar exact types when the modulus is an integer and polynomials polmods and rational functions when the modulus is a polynomial The library syntax is gmod z y for x y 3 1 8 divrem z y creates a column vector with two components the first being the Euclidean quotient the second the Euclidean remainder of the division of x by y This avoids the need to do two divisions if one needs both the quotient and the remainder The arguments must be both integers or both polynomials in the case of integers the remainder is non negative The library syntax is gdiventres z y 3 1 9 The expression xn is powering If the exponent is an integer then exact operations are performed using binary left shift powering techniques In particular in this case x cannot be a vector or matrix unless it is a square matrix and moreover invertible if the exponent is negative If x is a p adic number its precision will increase if v n gt 0 PARI is able to rewrite the multiplication xx of two identical objects as x or sqr x here identical means the operands are two different labels referencing the same chunk of memory no equality test is
390. urves y f X will be drawn in the same window The binary digits of flag mean e 1 parametric plot Here expr must be a vector with an even number of components Successive pairs are then understood as the parametric coordinates of a plane curve Each of these are then drawn For instance ploth X 0 2 Pi sin X cos X 1 will draw a circle 137 ploth X 0 2 Pi sin X cos X will draw two entwined sinusoidal curves ploth X 0 2 Pi X X sin X cos X 1 will draw a circle and the line y z e 2 recursive plot If this flag is set only one curve can be drawn at time i e expr must be either a two component vector for a single parametric curve and the parametric flag has to be set or a scalar function The idea is to choose pairs of successive reference points and if their middle point is not too far away from the segment joining them draw this as a local approximation to the curve Otherwise add the middle point to the reference points This is very fast and usually more precise than usual plot Compare the results of ploth X 1 1 sin 1 X 2 and ploth X 1 1 sin 1 X for instance But beware that if you are extremely unlucky or choose too few reference points you may draw some nice polygon bearing little resemblance to the original curve For instance you should never plot recursively an odd function in a symmetric interval around 0 Try ploth x 20 20 sin x 2 to see why Hence it s usually
391. us GP results without ambiguity It s not a trivial problem to adapt automatically this regular expression to an arbitrary prompt which can be self modifying Thus in this version 2 0 19 Emacs relies on the prompt being the default one So do not tamper with the prompt variable unless you modify it simultaneously in your emacs file see emacs pariemacs txt and misc gprc dft for examples 2 1 20 psfile default pari ps name of the default file where GP is to dump its PostScript drawings these will always be appended so that no previous data are lost Tilde and time expansion are performed 2 1 21 realprecision default 28 and 38 on 32 bit and 64 bit machines respectively the number of significant digits and at the same time the number of printed digits of real numbers see p Note that PARI internal precision works on a word basis 32 or 64 bits hence may not coincide with the number of decimal digits you input For instance to get 2 decimal digits you need one word of precision which on a 32 bit machine actually gives you 9 digits 9 lt log 2 7 lt 10 default realprecision 2 realprecision 9 significant digits 2 digits displayed 2 1 22 secure default 0 this is a toggle which can be either 1 on or 0 off If on the system and extern command are disabled These two commands are potentially dangerous when you execute foreign scripts since they let GP execute arbitrary UNIX commands GP will ask for confirm
392. utput is t 1 t E must be a long vector output by ellinit The library syntax is zell E z prec 3 5 21 ellpow z n computes n times the point z for the group law on the elliptic curve E Here n can be in Z or n can be a complex quadratic integer if the curve E has complex multiplication by n if not an error message is issued The library syntax is powell F z n TT 3 5 22 ellrootno E p 1 E being a medium or long vector given by ellinit this computes the local if p 4 1 or global if p 1 root number of the L series of the elliptic curve E Note that the global root number is the sign of the functional equation and conjecturally is the parity of the rank of the Mordell Weil group The equation for E must have coefficients in Q but need not be minimal The library syntax is ellrootno E p and the result equal to 1 is a long 3 5 23 ellsigma E z flag 0 value of the Weierstrass function of the lattice associated to E as given by ellinit alternatively E can be given as a lattice w1 w2 If flag 1 computes an arbitrary determination of log o z If flag 2 3 same using the product expansion instead of theta series The library syntax is ellsigma E z flag 3 5 24 ellsub z1 22 difference of the points z1 and 22 on the elliptic curve corresponding to the vector E The library syntax is subell E z1 22 3 5 25 elltaniyama E computes the modular parametrization of the ellip
393. utside quotes gets immediately expanded We need an additional notation for this chapter An argument between braces followed by a star like str x means that any number of such arguments possibly none can be given 3 11 2 1 addhelp S str changes the help message for the symbol S The string str is expanded on the spot and stored as the online help for S If S is a function you have defined its definition will still be printed before the message str It is recommended that you document global variables and user functions in this way Of course GP won t protest if you don t do it There s nothing to prevent you from modifying the help of built in PARI functions but if you do we d like to hear why you needed to do it 3 11 2 2 alias newkey key defines the keyword newkey as an alias for keyword key key must correspond to an existing function name This is different from the general user macros in that alias expansion takes place immediately upon execution without having to look up any function code and is thus much faster A sample alias file misc gpalias is provided with the standard distribution Alias commands are meant to be read upon startup from the gprc file to cope with function names you are dissatisfied with and should be useless in interactive usage 3 11 2 3 allocatemem x 0 this is a very special operation which allows the user to change the stack size after initialization x must be a non negative integer If x
394. ven if we set up the work properly before cleaning up we will have a stack which has the desired results z1 z2 say and then connected garbage from lbot to ltop If we write zi gerepile ltop lbot z1 then the stack will be cleaned the pointers fixed up but we will have lost the address of z2 This is where we need one of the gerepilemany functions we declare GEN gptr 2 Array of pointers to GENs gptr 0 amp z1 gptr 1 amp z2 and now the call gerepilemany ltop gptr 2 copies z1 and z2 to new locations cleans the stack from ltop to the old avma and updates the pointers z1 and z2 Here we don t assume anything about the stack the garbage can be disconnected and z1 z2 need not be at the bottom of the stack If all of these assumptions are in fact satisfied then we can call gerepilemanysp instead which will usually be faster since we don t need the initial copy on the other hand it is less cache friendly Another important usage is random garbage collection during loops whose size requirements we cannot or don t bother to control in advance long ltop avma limit avmatbot 2 GEN x y while garbage x garbage y garbage if avma lt limit memory is running low half spent since entry anything anything 161 GEN gptr 2 gptr 0 amp x gptr 1 y gerepilemany ltop gptr 2 Here we assume that only x and y are needed from one iter
395. versions Every PARI object called GEN in the sequel belongs to one of these basic types Let us have a closer look 1 2 1 Integers and reals they are of arbitrary and varying length each number carrying in its internal representation its own length or precision with the following mild restrictions given for 32 bit machines the restrictions for 64 bit machines being so weak as to be considered inexistent integers must be in absolute value less than 2268435454 i e roughly 80807123 digits The precision of real numbers is also at most 80807123 significant decimal digits and the binary exponent must be in absolute value less than 22 8388608 Note that PARI has been optimized so that it works as fast as possible on numbers with at most a few thousand decimal digits In particular not too much effort has been put into fancy multiplication techniques only the Karatsuba algorithm is implemented Hence although it is possible to use PARI to do computations with 107 decimal digits much better programs can be written for such huge numbers Integers and real numbers are completely non recursive types and are sometimes called the leaves 1 2 2 Integermods rational numbers irreducible or not p adic numbers polmods and rational functions these are recursive but in a restricted way For integermods or polmods there are two components the modulus which must be of type integer resp polynomial and the representative number res
396. will not be created If you want it as well you can use the target make install lib sta You can install a statically linked gp with the target make install bin sta As a rule programs linked statically with libpari a may be slightly faster about 5 gain but use much more disk space and take more time to compile They are also harder to upgrade you will have to recompile them all instead of just installing the new dynamic library On the other hand there s no risk of breaking them by installing a new pari library 3 1 The Galois package The default polgalois function can only compute Galois groups of polynomials of degree less or equal to 7 If you want to handle polynomials of degree bigger than 7 and less than 11 you need to fetch a separate archive galdata tgz which can probably be found at the same place where you got the main PARI archive and on the megrez ftp server in any case Untar the archive in the datadir directory which was chosen at Configure time it s one of the last messages on the screen if you did not run Configure a You can then test the polgalois function with your favourite polynomials 198 3 2 The GPRC file Copy the file misc gprc dft or gprc dos if you re using GP EXE to HOME gprc Modify it to your liking For instance if you re not using an ANSI terminal remove control characters from the prompt variable You can also enable colors If desired also copy modify misc gpalias somewhere and call it f
397. windows can be done without extra work If you want to erase a window and free the corresponding memory use the function plotkill It is not possible to partially erase a window Erase it completely initialize it again and then fill it with the graphic objects that you want to keep In addition to initializing the window you may want to have a scaled window to avoid un necessary conversions For this use the function plotscale below As long as this function is not called the scaling is simply the number of pixels the origin being at the upper left and the y coordinates going downwards Note that in the present version 2 0 19 all these plotting functions both low and high level have been written for the X11 window system hence also for GUI s based on X11 such as Open windows and Motif only though very little code remains which is actually platform dependent A Suntools Sunview Macintosh and an Atari Gem port were provided for previous versions These may be adapted in future releases Under X11 Suntools the physical window opened by plotdraw or any of the ploth func tions is completely separated from GP technically a fork is done and the non graphical memory is immediately freed in the child process which means you can go on working in the current GP session without having to kill the window first Under X11 this window can be closed enlarged or reduced using the standard window manager functions No zooming procedure is
398. within gerepile But beware as well that the addresses of all the objects in the translated zone will have changed after a call to gerepile every pointer you may have kept around elsewhere outside the stack objects which previously pointed into the zone below 1top must be discarded If you need to recover more than one object use one of the gerepilemany functions below As a consequence of the preceding explanation we must now state the most important law about programming in PARI If a given PARI object is to be relocated by gerepile then apart from universal ob jects the chunks of memory used by its components should be in consecutive memory locations All GENs created by documented PARI function are guaranteed to satisfy this This is because the gerepile function knows only about two connected zones the garbage that will be erased between lbot and 1top and the significant pointers that will be copied and updated If there is garbage interspersed with your objects disasters will occur when we try to update them and consider the corresponding pointers So be very wary when you allow objects to become disconnected Have a look at the examples it s not as complicated as it seems In practice this is achieved by the following programming idiom ltop avma garbage lbot avma q anything return gerepile ltop lbot q returns the updated q Beware that ltop avma garbage return gerepile ltop avma anything
399. x is element_div nf x y 100 3 6 71 nfeltdiveuc nf x y given two elements x and y in nf computes an algebraic integer q in the number field nf such that the components of x qy are reasonably small In fact this is functionally identical to round nfeltdiv nf x y The library syntax is nfdiveuc nf x y 3 6 72 nfeltdivmodpr nf zx y pr given two elements x and y in nf and pr a prime ideal in modpr format see nfmodprinit computes their quotient 2 y modulo the prime ideal pr The library syntax is element_divmodpr nf x y pr 3 6 73 nfeltdivrem nf x y given two elements x and y in nf gives a two element row vector q r such that x qy r q is an algebraic integer in nf and the components of r are reasonably small The library syntax is nfdivres nf x y 3 6 74 nfeltmod nf x y given two elements x and y in nf computes an element r of nf of the form r x qy with q and algebraic integer and such that r is small This is functionally identical to x nfeltmul nf round nfeltdiv nf x y y The library syntax is nfmod nf x y 3 6 75 nfeltmul nf x y given two elements x and y in nf computes their product x x y in the number field nf The library syntax is element_mul nf x y 3 6 76 nfeltmulmodpr nf x y pr given two elements x and y in nf and pr a prime ideal in modpr format see nfmodprinit computes their product x y modulo the prime ideal pr The library syntax is element_mulm
400. x1 x2 yl y2 scale the local coordinates of the rectwindow w so that x goes from z1 to x2 and y goes from yl to y2 12 lt x1 and y2 lt yl being allowed Initially after the initialization of the rectwindow w using the function plotinit the default scaling is the graphic pixel count and in particular the y axis is oriented downwards since the origin is at the upper left The function plotscale allows to change all these defaults and should be used whenever functions are graphed 3 10 27 plotstring w x flag 0 draw on the rectwindow w the String x see Section 2 6 5 at the current position of the cursor flag is used for justification bits 1 and 2 regulate horizontal alignment left if 0 right if 2 center if 1 Bits 4 and 8 regulate vertical alignment bottom if 0 top if 8 v center if 4 Can insert additional small gap between point and string horizontal if bit 16 is set vertical if bit 32 is set see the tutorial for an example 3 10 28 plotterm term sets terminal where high resolution plots go this is currently only taken into account by the gnuplot graphical driver Using the gnuplot driver possible terminals are the same as in gnuplot If term is lists possible values Terminal options can be appended to the terminal name and space terminal size can be put immediately after the name as in gif 300 200 Positive return value means success 140 3 10 29 psdraw list same as plotdraw except that th
401. x2 a 2 b ex concat b a 2 ex2 concat a b 13 2ex Some functions expect strings for some of their arguments print would be an obvious example Str is a less obvious but very useful one see the end of this section for a complete list While typing in such an argument you will be said to be in string context The rest of this section is devoted to special syntactical tricks which can be used with such arguments and only here you will get an error message if you try these outside of string context e Writing two strings alongside one another will just concatenate them producing a longer string Thus it is equivalent to type in a b or a b A little tricky point in the first expression the first whitespace is enclosed between quotes and so is part of a string while the 34 second before the b is completely optional and GP actually suppresses it as it would with any number of whitespace characters at this point i e outside of any string e If you insert an expression without quotes when GP expects a string it gets expanded it is evaluated as a standard GP expression and the final result as would have been printed if you had typed it by itself is then converted to a string as if you had typed it directly For instance a 1 1 b is equivalent to a2b three strings get created the middle one being the expansion of 1 1 and these are then concatenated according to the rule described above
402. xcept that the matrix x which must now be a square symmetric real matrix is the Gram matrix of the lattice vectors and not the coordinates of the vectors themselves The result is again the transformation matrix T which gives as columns the coefficients with respect to the initial basis vectors The flags have more or less the same meaning but some are missing In brief flag 0 numerically unstable in the present version 2 0 19 flag 1 x has integer entries the computations are all done in integers flag 4 x has integer entries gives the kernel and reduced image flag 5 same as 4 for generic x flag 7 an older version of case 0 The library syntax is qflllgramO z flag prec Also available are lUgram x prec flag 0 lllgramint x flag 1 and Ilgramkerim z flag 4 3 8 45 qfminim x b m flag 0 x being a square and symmetric matrix representing a posi tive definite quadratic form this function deals with the minimal vectors of x depending on flag If flag 0 default seeks vectors of square norm less than or equal to b for the norm defined by x and at most 2m of these vectors The result is a three component vector the first component being the number of vectors the second being the maximum norm found and the last vector is a matrix whose columns are the vectors found only one being given for each pair v at most m such pairs If flag 1 ignores m and returns the first vector whose norm
403. xcept when their absolute value is less than 2732 in which case they are printed in e format The number n is the number of significant digits printed for real numbers except if n lt 0 where all the significant digits will be printed initial default 28 or 38 for 64 bit machines and the number m is the number of characters to be used for printing integers but is ignored if equal to 0 which is the default This is a feeble attempt at formatting 2 1 9 help default the location of the gphelp script the name of the external help program which will be used from within GP when extended help is invoked usually through a or request see Section 2 2 1 or M H under readline see Section 2 10 1 2 1 10 histsize default 5000 GP keeps a history of the last histsize results computed so far which you can recover using the notation see Section 2 2 4 When this number is exceeded the oldest values are erased Tampering with this default is the only way to get rid of the ones you don t need anymore 2 1 11 lines default 0 if set to a positive value GP prints at most that many lines from each result terminating the last line shown with if further material has been suppressed The various print commands see Section 3 11 2 are unaffected so you can always type print a or b to view the full result If the actual screen width cannot be determined a line is assumed to be 80 characters long 2 1 12 log defau
404. y divides x 0 otherwise GEN gbezout GEN x GEN y GEN u GEN v creates the GCD of x and y and puts the adresses of objects u and v such that ux vy gcd x y into u and v 194 Appendix A Installation Guide for the UNIX Versions 1 Required tools We assume that you have either an ANSI C or a C compiler available If your machine does not have one for example if you still use bin cc in SunOS 4 1 x we strongly suggest that you obtain the gcc g compiler from the Free Software Foundation or by anonymous ftp As for all GNU software mentioned afterwards you can find the most convenient site to fetch gcc at the address http www gnu ai mit edu order ftp html You can certainly compile PARI with a different compiler but the PARI kernel takes advantage of some optimizations provided by gcc if it is available This results in about 20 speedup on most architectures Important Note The graphic routines in the present version have only been tested under X11 and gnuplot and may not work at all if you try to compile GP with an old Suntools library even though this is supposedly supported nobody has tested it yet 1 1 Optional packages The following programs and libraries are useful in conjunction with GP but not mandatory They re probably already installed somewhere on your system with the possible exception of readline which we think is really worth a try In any case get them before proceeding if you want
405. y quadratic form 5 02 binary quadratic forms 23 Binary aia e An e 48 DIDOMO mass dia Bie ea 63 binomial coefficient 63 binomial 6 244 404 44 kee ak 63 Birch and Swinnerton Dyer conjecture 75 bitand 2282s ee eee eee 46 48 DICHES dera ee ee 49 bitnegimply s i e poe ee wu a ee a 49 DI OT 2 otk a a we ie 46 49 BITS_IN_LONG 152 pittestie wan e betes a ee 49 bitwise amd 46 48 bitwise exclusive or 49 bitwise inclusive or 49 bitwise negation 49 bitwise OT seras a da a es 46 DICO a boos eke daa dao Be Ss 49 bit_accuracy 152 175 Of ecs e baw ee eA EE eee a 79 DEE osa de wR ee E 33 81 biicertily o oos s dip ae ao Gar aa 82 bnfclassgrouponly 84 bnfclassunit sa b eee 5 ae fs 83 bnfclassunitO 84 a 10 cae ee ee eda ee 84 bnfdecodemodule 84 DNPANI Cs og oh he eH e a he 79 84 bnfinitO awe Bw lat a 85 bnfisintnorm corria 85 bHPISHOTM rn Ke de we ek Gs 85 86 bnfisprincipal 86 bnfissunit 6 266845 ew DE e ia 86 DOFLSUIDAE ld ate ed woo oe Ew 86 bnifmake se ss sopa addons Ga e aoi 86 bninarrow searag ada 70 87 DO TOBE dao oe Ba we ee eS 87 bnfsignunit 87 Paf s nit morsa ew oe ww a 87 DAFUN LE g od at a wk SoS wok he ae a 87 DIVE techs E See we ae Bk FR es 79 DOC O ia rana al a a DO PBRECLASS s ua lata Be ho 88 bnrelassO
406. you use this while defining a function and if you ask for the definition of the function using name you will see that your backslash has disappeared and that everything is on the same line You can type a anywhere It will be interpreted as above only if apart from ignored whitespace characters it is immediately followed by a newline For example you can type 73 4 27 instead of typing 3 4 The second one is a slight variation on the first and is mostly useful when defining a user function see Section 2 6 3 since an equal sign can never end a valid expression GP will disregard a newline immediately following an a 123 1 123 The third one cannot be used everywhere but is in general much more useful It is the use of braces and When GP sees an opening brace at the beginning of a line modulo spaces as usual it understands that you are typing a multi line command and newlines will be ignored until you type a closing brace However there is an important but easily obeyed restriction inside an open brace close brace pair all your input lines will be concatenated suppressing any newlines Thus all newlines should occur after a semicolon a comma or an operator for clarity s sake we don t recommend splitting an identifier over two lines in this way For instance the following program a b b c F would silently produce garbage since what GP will really see is a bb c which will a
407. ype changes Specifically a complex or quadratic number whose imaginary part is exactly equal to 0 i e not a real zero is converted to its real part and a polynomial of degree zero is converted to its constant term For all types this of course occurs recursively This function is useful in any case but in particular before the use of arithmetic functions which expect integer arguments and not for example a complex number of 0 imaginary part and integer real part which is however printed as an integer The library syntax is simplify lt 3 2 40 sizebyte x outputs the total number of bytes occupied by the tree representing the PARI object x The library syntax is taille2 x which returns a long The function taille returns the number of words instead 3 2 41 sizedigit x outputs a quick bound for the number of decimal digits of the components of x off by at most 1 If you want the exact value you can use length Str x which is much slower The library syntax is gsize x which returns a long 3 2 42 truncate z amp e truncates x and sets e to the number of error bits When z is in R this means that the part after the decimal point is chopped away e is the binary exponent of the difference between the original and the truncated value the fractional part If the exponent of x is too large compared to its precision i e e gt 0 the result is undefined and an error occurs if e was not given The function applie
408. z 2 0xe0000000 z 3 0x0 4 5 3 Type t_INTMOD integermod z 1 points to the modulus and z 2 at the number representing the class z Both are separate GEN objects and both must be of type integer satisfying the inequality 0 lt z 2 lt z 1 It is good practice to keep the modulus object on the heap so that new integermods resulting from operations can point at this common object instead of carrying along their own copies of it on the stack The library functions implement this practice almost by default 4 5 4 Type t_FRAC and t_FRACN rational number z 1 points to the numerator and z 2 to the denominator Both must be of type integer In principle z 2 gt 0 but this rule does not have to be strictly obeyed Note that a type t_FRACN rational number can be converted to irreducible form using the function GEN gred GEN x 4 5 5 Type t_COMPLEX complex number z 1 points to the real part and z 2 to the imaginary part A priori z 1 and z 2 can be of any type but only certain types are useful and make sense 4 5 6 Type t_PADIC p adic numbers this type has a second codeword 1 which contains the following information the p adic precision the exponent of p modulo which the p adic unit corresponding to z is defined if z is not 0 i e one less than the number of significant p adic digits and the biased exponent of z the bias being equal to HIGHVALPBIT here This information can be handled using the following functio
Download Pdf Manuals
Related Search
Related Contents
little disk Piano di Sicurezza AVF ES150B mounting kit ControlWave® Micro - Welcome to Emerson Process Management description of program eligibility and service RAM N°1 - Noname présentation AREVA des travaux et bilan de la Type 5420 Copyright © All rights reserved.
Failed to retrieve file