Home
User`s Guide to Pari/GP - PARI/GP Development Headquarters
Contents
1. 163 Gntersect gia 6 e HE ss 173 Gntformal ete ee tow le a 162 IOT OUF ERCOS ma ehh e i 185 232 intfourierexp 22 6k o css 185 intfouriersin 185 intfuncinit secs raor a oe 185 intlaplaceinv 185 186 intmellininv 186 187 intmellininvshort 187 MIMO bee eR Gk aS SSA EES Hee f intMOod e s a e a e Ge Me ee e 8 18 GntnuMm skedare ed 184 187 192 196 intnuminit soria owe es 188 192 intnuminitgen 192 intnuminitgen0 192 intnumromb 24 4 4 e 4 eGo A 192 193 intnumstep 188 193 INVETSE ria a a a ee ee eS 66 inverseimage 174 isdiagonal a su cee gt ee rei 174 isfundamental OT isidro id on ae feds 148 ISPOWEY marica be a es A 97 98 iSpring se gs dor is ae aes hat st cb sh 98 isprincipalall 124 ispseudoprime 98 100 101 TSSQUATC ea doo ve eke ee 99g issquarefree 89 99 ISUDIL ab sos sia do Ker e 125 J Sl see he sorte esate ok capt an acne e eat oes a eh ee 108 PACODL masta ia a ee A e e ae Ae 177 JDESSEL oo eb ke Spee 2 dee ee SE 83 JPesselh n ky tae ll ara ad o 84 Jelly eb wad ra A 112 K KDESSOL 2s ree ca ek es E ee ee 84 KOE garb Ee bok he mete gh gold acca ah Bed 174 Kori o Sh do ge eS a ae E 174 kerint 24 54 anes be ee ba de ws 174 keyword o oe D4 e ORE OA oe we Gg 40 Kill e rada e Ee we 211 KILLO ua h e gan a a E 211 KOdairai
2. 51 200 graphcolors ssas ee wb ee ees 51l greal pb oa Be ke ie ce hk 78 prop la 2s he ee ta ee a 105 GRH 104 120 121 123 124 157 167 PINGtOL ue Sk has Oe GS 78 BVOUNd o a ed a ek Gs we a Sees 78 SSW peek be wR eae Beare oO 86 PENITE escri a ee es 68 BS IBEDO scr soreer 9 0 ws 68 ESTO pk ea hee ra 86 EST 6 ieee be pe ee ee tale 65 87 ESITE is ge ah a es amp ene ee ae 87 E8SQUEO ess en ee ee 88 GSU Go ea ea 65 GSUBSE basa e bees Be baw 166 gsubstpol soso hs Ge ee ds 167 Substvec amo eee 167 gsumdivk 2 eee ee eee 105 OLA ich oe ge ee o ee 88 Sth ereda ne be Soe a BG be 88 BtOCOl corps cia de be ewe eo 69 gtolist e cua a Bw Gok we ae ae hos 69 Stomat edo ve eae he EK ee eG ws 70 StOpoly na cw a eee ae ee a ee 71 gtopolyrev 71 toser usina hb eae Gand bog es 71 ptoset 244 ce oe hea a eee wk FE BLOVEC oe eee Se a E Re ae fee gtovecrev sa so sonaa o e E 73 gtovecsmall 13 Ane feb bk ee eed eee ew 180 PECANS ads a Ge de ete Geen Gea at teat 176 StTUNG fee wa eee ee es 80 EUA e bk ee Re a ee 80 BZO A mossos be ewe eo 89 Szetak oca Ye ok ee Bak a 160 gzetakall 2 eee sra 160 a ee gb ee gk ES ee Eee 57 215 231 Hadamard product 166 hbessell 83 hbessel2 2 cas sa Pe kw a Se eee 83 HCLlASSNO horario ke aA e 102 MEAD i ase du E dee ks eee wd A ke 57 Holp te Sash Bins esti E E baie ase Ghee A 5l Hermite normal form 1
3. 149 207 DO ke aot es ha a See Bh eek eae ik Gwe A 119 MOMMY amp case ss ae Ge oe ee SI ee eG 76 HOTM Z gt unir ee ee ee a 76 NOU sfc aa eee Gee Bee ee Ere amp 69 MUCOMP Gi bee era de Boe o ase at ee 102 DUQUPL A bade Gina eG ee os ee G howe G 102 number field 20 numbpart musicas 100 DUMAITV 75 bo ci 100 NMUMGEY lt a d A ie ec rs ome O e ne mumerator 28 11 numerical derivation 25 numerical integration 184 mumtoperm o 77 MUPOW eses be BG ae ark wg 102 N ron Tate height 111 O Deo atinada a Be ee a 161 OMERA iiem Ee e a 104 ODORA cre eee eee e 100 108 QUCUTNMO 4d ghd Gos a wh a ES G 112 Operator ese so a a es 24 OF 6b eG eS ae y a da 69 OF fa eee A OR Rw A eee we 73 74 ordell ae ee bbe wees fe ee ee 113 Oder mida a Be a ee 2k So a 107 OTOTEO ox Lo Be a deo cee Be 152 OUTPUT ecos bc bee cea a aS 52 56 P p adic number 7 8 19 padicappr o o reos ppa ao 162 padicprec i sos aon ooo ooo coo Ta parametric plot o ooo 201 PariEmacs o 217 PariPython 2 ao seu Ba a ae a ee 47 ParistZOs ei lic tl ke amp are ene ee a 52 Pascal triangle 175 Path oc ese eae ee ee Gab eee es 52 Pauli nia ee eR ee wR Oe a 141 Perf Pe eo ke we ee Be ws 179 Perla et ee es ok ee 47 A A Be hs 30 permtonum ss s esaa g aei 77 Pio ee Baw ee paman w wi we ae 82 Plot pee tate eee eka ee ee oe Re x 2
4. 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 computing 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 an sell The library syntax is GEN elltorsO GEN E long flag 3 5 32 ellwp E z 2 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 wa If z is omitted or is a simple variable computes the power series expansion in z starting z7 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 p z 1 compute p z p 2 The library syntax is GEN ellwpO GEN E GEN z NULL long flag long prec long precdl J Also available is GEN weipell GEN E long precdl for the power series 115 3 5 33 ellzeta E z E being given by ellinit returns the value at z of the Weierstrass function of the period lattice L of E al 2 gt a E 286 9 Alternatively one can input a lattice basis w1
5. The library syntax is GEN gsqrtn GEN x GEN n GEN z NULL long prec 3 3 46 tan x tangent of x The library syntax is GEN gtan GEN x long prec 3 3 47 tanh x hyperbolic tangent of z The library syntax is GEN gth GEN x long prec 3 3 48 teichmuller x Teichm ller character of the p adic number x i e the unique p 1 th root of unity congruent to x pe modulo p The library syntax is GEN teich GEN x 3 3 49 theta q z Jacobi sine theta function 01 z q 2 4 AGO sin 2n 1 2 n gt 0 The library syntax is GEN theta GEN q GEN z long prec 3 3 50 thetanullk q k k th derivative at z 0 of theta q z The library syntax is GEN thetanullk GEN q long k long prec GEN vecthetanullk GEN q long k long prec returns the vector of all 40 q 0 for i 1 3 2 1 3 3 51 weber x flag 0 one of Weber s three f functions If flag 0 returns f x exp im 24 n 2 1 2 m x such that j f7 16 f where j is the elliptic j invariant see the function e11j If flag 1 returns fila 2 2 m x such that j f7 16 fi Finally if flag 2 returns folz V2n 2x n x such that j f2 16 f3 Note the identities f8 f f and f fifo V2 The library syntax is GEN weber0 GEN x long flag long prec Also available are GEN weberf GEN x long prec GEN weberf1 GEN x long prec and GEN weberf2 GEN x long prec 88 3 3 52 zeta s For s a complex num
6. 00 103 quadregulator 105 quadunit e sd te utad 105 QU b be ew naw ee Bead e e 57 211 QUOTE op moi eg ee a Ge i p a ali Quotient 4 4 paset o A 65 R Pl aes oe os Ae Sr ee 119 T2 cee ea wee eee Sw ee 119 TACOS ose dra Be Es 106 Fandom egs saa a a ed 78 210 Tank a nin KG os amp ate dw bk Ge BG gos 175 rational function T 22 rational number T 8 18 TOW fOTINGG s sast 2a we we ads a es 52 read s and eee eck Sek Oe at a dn ee ae of Tead jh nox Shh ok de woe Bk 42 94 212 214 readline sb oros A 2 6 eee 53 FOAdVeS s s ssa Gwe Re arawa AD 212 real number e 1 A ae Be eee ee ee ae eR 78 realprecision LT 53 97 TOC P ess aca r wok we a a moi a 166 recursion depth or recursion aos s or aw aaa a es OL recursive DIOL sc a a we woe be be we wok 201 redimag lt lt sos o son doma mo oa h Eo a 103 redreal s 2 6 aeon a e ocx 103 r drealnod o otes aa a 4444 24 103 reduceddiscsmith 163 reduction s sos sa aou aiia a iot 102 103 reference Card 56 TODS sans Ba Ge e amp a EO regulator s so sese e ee es 125 removeprimes 105 ESTU Lasse a i 44 207 ThORCAL SY re fink a AE Ets 103 rhorealnod s sos a aon Re a aon ee dk 103 Riemann zeta function 30 88 oe ea tea due dee he eae ba Ke 117 rnfalgtobasis rse sare tras men 152 THEDASIS 44 65 se 244 85 a SS 152 rnfbasistoalg wi ss sas id ad do
7. Avoid modifying X within expr if you do the formal variable still runs from 1 to n In particular vector n i expr is not equivalent to v vector n for i 1 n vlil expr as the following example shows n 3 v vector n vector n i i gt 2 3 4 v vector n for i 1 n vli i gt 2 0 4 The library syntax is GEN vecteur GEN n char X NULL 3 8 62 vectorsmall n X expr 0 creates a row vector of small integers type t_VECSMALL 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 GEN vecteursmall GEN n char X NULL 3 8 63 vectorv n X expr 0 as vector but returns a column vector type t_COL The library syntax is GEN vvecteur GEN n char X NULL 3 9 Sums products 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 In the descriptions the letter X will always denote any simple variable name and represents the formal parameter used in the function
8. This bid is used in ideallog to compute discrete logarithms It also contains useful information which can be conveniently retrieved as bid mod the modulus bid clgp G as a finite abelian group bid no the cardinality of G bid cyc elementary divisors and bid gen generators If flag 1 default the result is a bid structure without generators If flag 2 as flag 1 but including generators which wastes some time If flag 0 deprecated Only outputs Zx I as an abelian group i e as a 3 component vector h d g h is the order d is the vector of SNF cyclic components and g the corresponding generators This flag is deprecated it is in fact slightly faster to compute a true bid structure which contains much more information The library syntax is GEN idealstar0 GEN nf GEN I long flag 3 6 69 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 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 GEN ideal_two_eltO
9. right in 3 3s algdep 2 1 6 37 1 5 30 200 wrong in 2 9s p250 algdep 2 1 6 37 1 5 30 right in 2 8s algdep 2 1 6 37 1 5 30 200 right in 3 4s ANNAN PSLQ p200 algdep 2 1 6 37 1 5 30 3 AN failure in 14s p250 7 algdep 2 1 6 3 1 5 30 3 AN right in 18s Proceeding by increments of 5 digits of accuracy algdep with default flag produces its first correct result at 205 digits and from then on a steady stream of correct results Interestingly enough our PSLQ also reliably succeeds from 205 digits on and is 5 times slower at that accuracy 168 The above example is the testcase studied in a 2000 paper by Borwein and Lisonek Appli cations of integer relation algorithms Discrete Math 217 p 65 82 The paper concludes in the superiority of the PSLQ algorithm which either shows that PARI s implementation of PSLQ is lacking or that its LLL is extremely good The version of PARI tested there was 1 39 which succeeded reliably from precision 265 on in about 60 as much time as the current version The library syntax is GEN algdepO GEN x long k long flag long prec Also available is GEN algdep GEN x long k long prec flag 0 3 8 2 charpoly A v x flag 3 characteristic polynomial of A with respect to the variable v i e determinant of v x I A if A is a square matrix If A is not a square matrix it returns the characteristic polynomi
10. a is a fifth root of 5 43 0 z polredabs pol 1 look for a simpler polynomial pol z 1 5 x 20 25 x710 5 a subst a pol x z 21 a in the new coordinates 6 Mod 5 22 x 19 1 22 x714 123 22xx 9 9 11 x 4 x 20 25 x710 5 The library syntax is GEN polcompositum0 GEN P GEN Q long flag 3 6 113 polgalois x Galois group of the non constant polynomial Q X In the present version 2 4 2 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 4 component vector n s k name with the following meaning n is the cardi nality of the group s is its signature s 1 if the group is a subgroup of the alternating group An s 1 otherwise and name is a character string containing name of the transitive group according to the GAP 4 transitive groups library by Alexander Hulpke k is more arbitrary and the choice made up to version 2 2 3 of PARI is rather unfortunate for n gt 7 k is the numbering of the group among all transitive subgroups of Sn as given in The transitive groups of degree up to eleven G Butler and J McKay Communications in Algebra vol 11 1983 pp 863 911 group k is denoted Ty there And for n lt 7 it was ad hoc so as to ensure that a giv
11. autoload pari nil t gp P autoload gpman pari nil t 8P P setq auto mode alist cons gp gp script mode auto mode alist which autoloads functions from the PariEmacs package and ensures that file with the gp suffix are edited in gp script mode Once this is done under GNU Emacs if you type M x gp where as usual M is the Meta key a special shell will be started launching gp with the default stack size and prime limit You can then work as usual under gp but with all the facilities of an advanced text editor See the PariEmacs documentation for customizations menus etc 62 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 4 2 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 The general entry looks something like foo x flag 0 short description The library syntax is GEN foo GEN x long fl 0 This means that the GP function foo has one mandatory argument x and a
12. 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 11 ex2 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 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 second
13. 2 13 17 ps n sets seriesprecision to n significant terms Prints its current value if n is omitted 2 13 18 q quits the gp session and returns to the system Shortcut for the function quit see Section 3 12 21 2 13 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 12 22 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 If a gp binary file see Section 3 12 32 is read using this command it is silently loaded without cluttering the history Assuming gp figures how to decompress files on your machine this command accepts com pressed 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 13 20 s prints the state of the PARI stack and heap This is used primarily as a debugging device for PARI 2 13 21 t 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 neces
14. 7 1 2 x 3 x72 1 3 x72 2 x 1 Pol 1 2 3 x 12 x 2 2xx 3 Polrev 1 2 3 x 3 3 x 2 Qex 1 The latter two are much more efficient constructors than an explicit summation the latter is quadratic in the degree the former linear for i 1 1074 Polrev vector 100 i i time 124ms for i 1 1074 sum i 1 100 i 1 x7i time 3 985ms Polynomials are always printed as univariate polynomials with monomials sorted by degreasing degree x y 1 72 hi x72 2xy 2 x y72 2xy 1 Univariate polynomial in x whose coefficients are polynomials in y See Section 2 5 for valid variable names and a discussion of multivariate polynomial rings 2 3 11 Power series t_SER Typing 0 X k where amp is an integer yields an X adic 0 of accu racy k representing any power series in X whose valuation is gt k Of course X can be replaced by any other variable name To input a general non 0 power series type in a polynomial or rational function in X say and add 0 X7k to it 21 Caveat Power series with inexact coefficients sometimes have a non intuitive behaviour if k significant terms are requested an inexact zero is counted as significant even if it is the coefficient of lowest degree This means that useful higher order terms may be disregarded If the series precision is insufficient errors may occur mostly division by 0 which could have been avoided by a better g
15. 83 88 bernreal vs sordas hha we ad ss 83 bernvec sena moa eee we ee we a 83 besselhit 83 besselh2 ic eid ghe how oh eS doh eee o G 83 besseli o 83 besselj i isese ee we sa 83 DesseL iba ts A 83 besselk 24 64 eee ee A Ee Re a 84 besseln ssi soomes Bee ndopa ee 84 bostappr ora ei ear Ge Gr a a 89 bestappr ces rerea toane DE SaS 89 DOZOUt gt 2 5 eee AA a 90 DezZoutI eS boda ca e oo ek 90 DIE na ee Ba Ee 39 118 bid 244 0 base we ba Be oe bee ed 119 DIGOMO GE wes td GOR SR we ae ee G 90 bilhell se e s wee boi Gaa ew 109 Linares aa a a 73 binary fille ain ante ag ee 215 binary file 57 212 binary flag s soms are o 63 binary quadratic form ead Binary Ses ao be eh wee Be are x T3 binomial coefficient 90 binomial s soegan a amp ee aaa Had 90 Birch and Swinnerton Dyer conjecture 110 bitand oaaao 69 73 DICHO rado a 73 bitnegimply e resas eresia 13 DICO aho a a 69 73 Dittest ot a a al d as 74 bitwise and 69 73 bitwise exclusive or 74 bitwise inclusive or T3 bitwise negation 73 DILWISCHOL ave ias a we 69 DICXOL ie o e cee be ae 74 ONI ee ea ea a g i 39 116 DOE 2a soe Goa maa ba ee ag eh ee 119 bnl certif y aca ed eee SY 121 bnfclassunit 121 b fcelass nitO sosa acedos po ees 122 BPC Lop ee ked aa eh eek ae A ed 122 bnfdecodemodule
16. The coefficients of x must be operation compatible with Z pZ The result is a two column matrix the first column contains the irreducible factors of x and the second their exponents If all the coefficients of x are in Fp a much faster algorithm is applied using the computation of isomorphisms between finite fields The library syntax is GEN factorff GEN x GEN p GEN a 3 4 22 factorial x factorial of x The expression q gives a result which is an integer while factorial 1 gives a real number The library syntax is GEN mpfactr long x long prec GEN mpfact long x returns zq as a t_INT 3 4 23 factorint z flag 0 factors the integer n into a product of pseudoprimes see ispseu doprime using a combination of the Shanks SQUFOF and 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 maintainers as well as a search for pure powers The output is a two column matrix as for factor Use isprime on the result if you want to guarantee primality 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 and SQUFOF 8 don t run final ECM as a result a huge composite may be declared to be prime Note that a strong probab
17. This is a two element row vector D d where D is the relative ideal discriminant 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 see Section 2 5 3 The library syntax is GEN rnfdiscf GEN nf GEN pol 3 6 126 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 pol computes x as an element of the relative extension L K as a polmod with polmod coefficients The library syntax is GEN rnfelementabstorel GEN rnf GEN x 153 3 6 127 rnfeltdown rnf x rnf being a relative number field extension L K as output by rn finit and z being an element of L expressed as a polynomial or polmod with polmod coefficients computes xz as an element of K as a polmod assuming z 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 GEN rnfelementdown GEN rnf GEN x 3 6 128 rnfeltreltoabs rnf x rnf being a relative number field extension L K as output by rnfinit and z 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 pol If x is given on the relative integral basi
18. mathnf A vecextract Ker Str HA The library syntax is GEN idealintersect GEN nf GEN A GEN B 3 6 57 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 syntax is GEN idealinv GEN nf GEN x 136 3 6 58 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 depending on the value of flag The possible values of flag are 0 give the bid associated to the ideals without generators 1 as 0 but include the generators in the bid 2 in this case nf must be a bnf with units Each component is of the form bid U where bid is as case 0 and U is a vector of discrete logarithms of the units More precisely it gives the ideallogs with respect to bid of bnf tufu This structure is technical and only meant to be used in conjunction with bnrclassnolist or bnrdisclist 3 as 2 but include the generators in the bid 4 give only the HNF of the ideal nf nfinit x 2 1 L ideallist nf 100 2 L 1 13 1 0 0 11 A single ideal of norm 1 L 65 74 4 There are 4 ideals of norm 4 in Zli
19. matinverseimage M 1 2 3 4 45 3 no solution K matker M 76 2 1 The library syntax is GEN inverseimage GEN x GEN y 3 8 29 matisdiagonal z returns true 1 if x is a diagonal matrix false 0 if not The library syntax is long isdiagonal GEN x 3 8 30 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 FpM_ker z p where x has integer entries reduced mod p and pis prime is equivalent to but orders of magnitude faster than matker x Mod 1 p and needs much less stack space To use it under gp type install FpM_ker GG first The library syntax is GEN matker0 GEN x long flag Also available are GEN ker GEN x flag 0 GEN keri GEN x flag 1 3 8 31 matkerint z 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 The library syntax is GEN matkerintO GEN x long flag Also available is GEN kerint GENJ x flag 0 3 8 32 matmuldiagonal z d product of the matrix x by the diagonal matrix whose diagonal
20. 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 ploth may evaluate expr thousands of times given the relatively low resolution of plotting devices few significant digits of the result will be meaningful Hence you should keep the current precision to a minimum e g 9 before calling this function n specifies the number of reference point on the graph where a value of 0 means we use the hardwired default values 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 fk X and then all the curves y f X will be drawn in the same window The binary digits of flag mean e Parametric 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 Parametric ploth X 0 2 Pi sin X cos X ploth X 0 2 Pi X X sin X cos X Parametric draw successively a circle two entwined sinusoidal curves and a circle cut by the line y a e 2 Recursive recursive plot If this flag
21. 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 are completing a default e a pair of parentheses if we are completing a function name In that case hitting lt TAB gt again will provide the argument list as given by the online help Otherwise hitting lt TAB gt once more will give you the list of possible completions Just ex periment with this mechanism as often as possible you will 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 ASCII program None of these disturb the line you were editing recall that you can always undo the effect of the preceding keys by hitting C _ 61 2 16 GNU Emacs and PariEmacs If you install the PariEmacs package see Appendix A you may use gp as a subprocess in Emacs You then need to include in your emacs file the following lines autoload gp mode pari nil t autoload gp script mode pari nil t
22. y evaluates to the modular Euclidean remainder of x and y which we now define If y is an integer this is the smallest non negative integer congruent to x modulo y If y is a polynomial this is the polynomial of smallest degree congruent to modulo y When y is a non integral real number x y is defined as x a y y This coincides with the definition for y integer if and only if x is an integer but still belongs to 0 y For instance 1 2 3 11 2 70 5 3 kkk forbidden division t_REAL t_INT 1 2 3 0 12 1 2 Note that when y is an integer and x a polynomial y is first promoted to a polynomial of degree 0 When z is a vector or matrix the operator is applied componentwise The library syntax is GEN gmod GEN x GEN y for x y 3 1 8 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 invertible if the exponent is negative If x is a p adic number its precision will increase if v n gt 0 Powering a binary quadratic form types t_QFI and t_QFR returns a reduced representative of the class provided the input is reduced In particular x is identical to x PARI is able to rewrite the multiplication x x of two identical objects as x or sqr x Here identical means the operands are two different labels referencing the sa
23. 0 LLL reduction of the ideal 7 in the number field nf along the direction vdir If vdir is present it must be an rl r2 component vector r1 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 but it is not a necessary condition a non trivial result does not prove that the ideal is non trivial in the class group For guaranteed results see bnfisprincipal which requires the computation of a full bnf structure Note that this is not the same as the LLL reduction of the lattice J since ideal operations are involved The library syntax is GEN ideallllred GEN nf GEN I GEN vdir NULL long prec 3 6 68 idealstar nf flag 1 outputs a bid structure necessary for computing in the finite abelian group G Zx I Here nf is a number field and J is a modulus either an 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
24. 1 X7i MN this has degree 5050 time 128 ms prod i 1 100 1 X i 1 0G 1019 time 8 ms 12 1 X X72 X75 X77 X 12 X715 X 22 X 26 X 35 X 40 X 51 X 57 X 70 X 77 X 92 X7100 0 X 101 Of course in this specific case it is faster to use eta which is computed using Euler s formula prod i 1 1000 1 X i 1 0 X 1001 time 589 ms ps1000 seriesprecision 1000 significant terms eta X time 8ms 4 0 X71001 The library syntax is produit GEN a GEN b char expr GEN x 193 3 9 16 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 void E GEN eval GEN void GEN a GEN b long prec 3 9 17 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 In particular non convergent products result in infinite loops 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 void E GEN eval GEN void GEN a long prec flag 0 or prodinf1 with the same arguments flag 1 3 9 18 solve X a b expr find a real ro
25. 2 14 The preferences file This file called gprc in the sequel is used to modify or extend gp default behaviour in all gp sessions e g customize default values or load common user functions and aliases gp opens the gprc file and processes the commands in there before doing anything else e g creating the PARI stack If the file does not exist or cannot be read gp will proceed to the initialization phase at once eventually emitting a prompt If any explicit command line switches are given they override the values read from the preferences file 2 14 1 Syntax The syntax in the gprc file and valid in this file only is simple minded but should be sufficient for most purposes The file is read line by line as usual white space is ignored unless surrounded by quotes and the standard multiline constructions using braces or are available multiline comments between are also recognized 2 14 1 1 Preprocessor 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 to everything following on a given line e lines starting with if boolean are treated as comments if boolean evaluates to false and read normally otherwise The condition can be negated using either if not or if If the rest of the current line is empty the test applies to the next line same behaviour as under gp Only three tests can be performed EMACS true
26. 2111 Of course the results above are obvious adding t places at infinity will add t copies of Z 2Z to the ray class group The following application is more typical L ideallist bnf 100 2 units are required now La ideallistarch bnf L 1 1 H bnrclassnolist bnf La H 98 6 2 12 2 The library syntax is GEN ideallistarch GEN nf GEN list GEN arch NNN 3 6 60 ideallog nf x bid nf is a number field bid is as output by idealstar nf D and x a non necessarily integral element of nf which must have valuation equal to 0 at all prime ideals in the support of D This function computes the discrete logarithm of x on the generators given in bid gen In other words if g are these generators of orders d respectively the result is a column vector of integers x such that 0 lt x lt d and x of mod D Note that when D is an idele this implies also sign conditions on the embeddings The library syntax is GEN zideallog GEN nf GEN x GEN bid 3 6 61 idealmin nf iz vdir computes a minimum of the ideal x in the direction vdir in the number field nf The library syntax is GEN minideal GEN nf GEN ix GEN vdir NULL long prec 3 6 62 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
27. 3 1 12 12 factorback 5 2 3 13 30 factorback 2 2 3 1 nfinit x 3 2 4 16 O 0 o 16 0 o O 16 nf nfinit x 2 1 fa idealfactor nf 10 25 EEZ 1 1 2 1 1 1 2 5 2 1 1 1 2 1 1 5 2 1 T 1 2 1 1 factorback fa forbidden multiplication t_VEC t_VEC factorback fa nf 46 10 0 o 10 In the fourth example 2 and 3 are interpreted as principal ideals in a cubic field In the fifth one factorback fa is meaningless since we forgot to indicate the number field and the entries in the first column of fa can t be multiplied The library syntax is GEN factorbackO GEN f GEN e NULL GEN nf NULL Also avail able is GEN factorback GEN f GEN nf NULL case e NULL 3 4 20 factorcantor z p factors the polynomial x 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 GEN factcantor GEN x GEN p 94 3 4 21 factorff x p a factors the polynomial x in the field F defined by the irreducible poly nomial a over F
28. 8 1 3 Ag 12 1 4 S4 24 1 5 In degree 5 Cs 5 1 1 Ds 10 1 2 Mao 20 1 3 As 60 1 4 S5 120 1 5 In degree 6 Cg 6 1 1 S3 6 1 2 De 12 1 3 A4 12 1 4 Gig 18 1 5 A4 x Co 24 1 6 S 24 1 7 Sy 24 1 8 Gy 36 1 9 Gi 36 1 10 S4 x Cy 48 1 11 As PSL2 5 60 1 12 Gro 72 1 13 Ss PGLa 5 120 1 14 Ag 360 1 15 Sg 720 1 16 In degree 7 C7 7 1 1 D7 14 1 2 Moi 21 1 3 Ma2 42 1 4 PSL2 7 PSL3 2 168 1 5 A7 2520 1 6 S7 5040 1 7 Warning The method used is that of resolvent polynomials and is sensitive to the current preci sion 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 GEN polgalois GEN x long prec To enable the new format in library mode set the global variable new_galois_format to 1 3 6 114 polred z flag 0 fa 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 poss
29. Buchmann McCurley 103 buchnarrow 020084 125 C Cantor Zassenhaus 94 CaTaCt e ana ce aa o ee a 169 CATA soaa wk De ee E a 169 carberkowitz 4 169 CAThesS uc a oe Rew hee ae es 169 227 RO 74 CEnterlift os cies rar 74 COnterldttO sirio ble ge a e 74 certifyb chall ss sea sises a 121 character string 23 Character oon we ee ee Ee ee es 117 character 126 128 129 characteristic polynomial 169 Charpoly 602 45 eee ee saa eee 169 CHarpolyO emi rpk eno tt ae wae et 169 Chebyshev 162 165 CHINESE ara Spee ey doe e 90 chinese g sa s oaceae Bo are ae os 90 classgrouponly 122 CIASSNO i Ao eo ee OE Re Re ee 102 ClaSSno ca uo fo Se ae GA Bk e A 102 CUB a in ie at ee EE Gece te RAS ja hatin Ae 2 119 CLES sa sese hon ee Ge a ee ee we 47 cmdto laicas a 53 code words s s se a la a 74 COGITE ubica ee Re we 119 Cole ii es gist ait GR he het we aah He 69 COLOS g dom ao di o o 48 column vector 004 T Aa comparison operators 68 compatible 0 49 completion s reos sas aca e 60 complex number 7 8 19 COMPO o v esmo a ee a Ae ee a a 75 Component so boso moe ee paag ee as 74 COMPOSICI N s a gi Bok ow Ho a e 102 COMPOSITUM s s s sadra erran a 149 COPEN 2 e soca ee EE ee 102 COMPTOSS ce ia aa e ee Me ao ee ck He 57 ConGat 444 22 2445 24 41 169 170 CONJ e smet ara
30. F truncate f t O t77 expansion around t 0 g x if x gt le 18 f x subst F t x note that6 18 gt 105 intnum x 0 00 1 g x Euler 2 0 E 106 perfect It is up to the user to determine constants such as the 10718 and 7 used above True singularities With true singularities the result is worse For instance intnum x 0 1 1 sqrt x 2 1 1 92 E 59 only 59 correct decimals intnum x 0 1 2 1 1 sqrt x 2 2 0 E 105 better Oscillating functions intnum x 0 oo sin x x Pi 2 1 20 78 nonsense intnum x 0 00 1 sin x x Pi 2 2 0 004 bad intnum x O oo0 I sin x x Pi 2 3 0 E 105 perfect intnum x 0 oo I sin 2 x x Pi 2 oops wrong k 4 0 07 intnum x 0 o00 2 I sin 2 x x Pi 2 75 0 E 105 perfect intnum x 0 loo 1 sin x 3 x Pi 4 6 0 0092 bad sin x 3 3 sin x sin 3 x 4 47 0 x 17 We may use the above linearization and compute two oscillating integrals with infinite endpoints loo I and oo 3 I respectively or notice the obvious change of variable and reduce to the single integral 3 Jee sin x x dx We finish with some more complicated examples intnum x 0 oo0 I 1 cos x x 2 Pi 2 1 0 0004 bad intnum x 0 1 1 cos x x 2 intnum x 1 oo 1 x 2 intnum x 1 oo 1 cos x x 2 Pi
31. M b M f move the cursor backward forward by a word etc Just press the lt Return gt key at any point to send your command to gp All the commands you type at the gp prompt are stored in a history a multiline command being saved as a single concatenated line The Up and Down arrows or C p C n will move you through the history 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 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 changes 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 60 e C h backward kill word C xd dump functions Co C v C b can be annoyi
32. The expression to be summed integrated etc is any legal PARI expression including of course expressions using loops 183 Library mode Since it is easier to program directly the loops in library mode these functions are mainly useful for GP programming Using them in library mode is tricky and we will not give any details although the reader can try and figure it out by himself by checking the example given for sum On the other hand numerical routines code a function to be integrated summed etc with two parameters named GEN eval GEN void void E The second is meant to contain all auxiliary data needed by your function The first is such that eval x E returns your function evaluated at x For instance one may code the family of functions f x gt x t via GEN f GEN x void t return gsqr gadd x GEN t One can then integrate f between a and b with the call intnum void stoi 1 amp fun a b NULL prec Since you can set E to a pointer to any struct typecast to void the above mechanism handles arbitrary functions For simple functions without extra parameters you may set E NULL and ignore that argument in your function definition Numerical integration Starting with version 2 2 9 the powerful double exponential univariate integration method is implemented in intnum and its variants Romberg integration is still available under the name intnumromb but superseded It is possible to
33. corresponding to centerlift0 x 1 74 3 2 26 component x n extracts the n component of x This is to be understood 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 e column if x is a polynomial the nt coefficient i e of degree n 1 and for power series the n significant coefficient For polynomials and power series one should rather use polcoeff and for vectors and matri ces the operator Namely if x is a vector then x n represents the nt component of x If x is a matrix x m n represents the coefficient of row m and column n of the matrix x m represents the mt row of x and x n represents the nt column of x Using of this function requires detailed knowledge of the structure of the different PARI types and thus it should almost never be used directly Some useful exceptions x 3 0 3 5 component x 2 2 81 p p adic acurracy component x 1 13 3 p q Q b 1 2 3 component q 1 5 1 The library syntax is GEN compo GEN x long n 3 2 27 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 intmods fractions or p adics The only forbidden type is polmod
34. creates an empty list This routine used to have a mandatory argument which is now ignored for backward compatibility In fact this function has become redundant and obsolete it will disappear in future versions of PARI just use List 170 3 8 6 listinsert L x n inserts the object x at position n in L which must be of type t_LIST This has complexity O L n 1 all the remaining elements of list from position n 1 onwards are shifted to the right The library syntax is GEN listinsert GEN L GEN x long n 3 8 7 listkill L obsolete retained for backward compatibility Just use L List instead of listkill L In most cases you won t even need that e g local variables are automatically cleared when a user function returns The library syntax is void listkill GEN L 3 8 8 listpop list n removes the n th element of the list list which must be of type t_LIST If n is omitted or greater than the list current effective length removes the last element This runs in time O L n 1 The library syntax is void listpop GEN list long n 3 8 9 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 appends x You may put an element into an occupied cell not changing the effective length but it is easier to use the standard list n x construct This runs in time O Z in the worst case when the lis
35. entries are those of the vector d Equivalent to but much faster than x matdiagonal d The library syntax is GEN matmuldiagonal GEN x GEN d 174 3 8 33 matmultodiagonal x y product of the matrices x and y assuming that the result is a diagonal matrix Much faster than zxy in that case The result is undefined if x y is not diagonal The library syntax is GEN matmultodiagonal GEN x GEN y 3 8 34 matpascal n q creates as a matrix the lower triangular Pascal triangle of order x 1 i e 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 GEN matqpascal long n GEN q NULL Also available is GEN mat pascal GEN x 3 8 35 matrank zx rank of the matrix z The library syntax is long rank GEN x 3 8 36 matrix m n X Y expr 0 creation of the m x n 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 GEN matrice GEN m GEN n char X NULL 3 8 37 matrixqz z p 0 x being an m xn 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 n The function
36. long prec 3 3 34 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 GEN hyperu GEN a GEN b GEN x long prec 3 3 35 incgam s x y incomplete gamma function The argument x and s are complex num bers x must be a positive real number if s 0 The result returned is je e t8 dt When y is given assume of course without checking that y I s For small x this will speed up the computation The library syntax is GEN incgamO GEN s GEN x GEN y NULL long prec Also avail able is GEN incgam GEN s GEN x long prec 3 3 36 incgamc s x complementary incomplete gamma function The arguments x and s are complex numbers such that s is not a pole of T and z s 1 is not much larger than 1 otherwise the convergence is very slow The result returned is J ett dt The library syntax is GEN incgamc GEN s GEN x long prec 3 3 37 Ingamma z principal branch of the logarithm of the gamma function of x This function is analytic on the complex plane with non positive integers removed Can have much larger arguments than gamma itself The p adic lngamma function is not implemented The library syntax is GEN glngamma GEN x long prec 3 3 38 log x principal branch of the natural logarithm of x i e such that Im log x 7 7 The result is complex with imaginar
37. long prec 3 6 97 nfhilbert nf a b pr if pr is omitted compute the global Hilbert symbol a b in nf that is 1 if 2 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 long nfhilbertO GEN nf GEN a GEN b GEN pr NULL 3 6 98 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 GEN nfhermite GEN nf GEN x 145 3 6 99 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 GEN nfhermitemod GEN nf GEN x GEN detx 3 6 100 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 nfzzrzx functions but it contains some information which may be directly useful Access to this information via member functions is preferred since the specific data organization specified below may change in the future Currently nf is a row vector with 9 component
38. matsolve 044442446 46 a e 176 matsolvemod s iw risa 176 matsolvemodO 176 matsupplement 176 Mattranspose 176 MAX dra uch ta nw e e Use de HR 68 member functions 39 108 119 MID uma ela o ds AAA E 68 minideal uta a a 138 MIDI spe ak 2 al ee ee 179 MiniM2 2 be eee yee we ban me wo 179 minimal model 110 113 minimal polynomial 176 minimal vector sso sss ase seiss 179 Minpoly 264 se eee a e G 176 177 MOG mireia ai hk Soe 70 MOdpH aos Bw a a BO ke a Gk e 148 modreverse 004 141 modulus 245 24 ou bak a YS 118 Moebius 2 204 89 100 MOCDAUS 2 6 cad ag be we on BoP ge 89 100 Mordell Weil group 110 111 114 MPeuleD ss fed ss Base ated e Gt 82 MPfaCt oc sp eee eed ww Ee See 95 UPLATE s eta Pewee ade eee wa wt 95 MPD te ci ath el a a a it eee wh 82 MPOS S24 dodo a vow Ae ao e 89 95 multivariate polynomial ob MY cece e Bae Gok we ge Se SI we ae 30 33 N nbesseldor lees HR ew dl ne ews 84 M 6WLONPOLY s s ais Se ES ee ee ws 141 new_galois_format 50 52 150 151 MENA 5 445 o A 44 207 mextprime 100 Nf we Re bach Be ee ea ee ee 39 116 B ee ha te ed ee gw a e 119 nialgtobasis 40 oA ob ten ae dees 141 nibasis isso ws 141 142 147 nfibasisO ss 24 4 Bas eGo ack He Soe 142 nfbasistoalg 142 nidetintia casco Boe ay ias ds es 142 NM OISC ee a Be ae
39. now perfect but slow The library syntax is sumnum void E GEN eval GEN void GEN a GEN sig GEN tab long flag long prec 3 9 24 sumnumalt X a sig expr tab flag 0 numerical summation of 1 expr X the variable X taking integer values from ceiling of a to 00 where expr is assumed to be a holomorphic function for R X gt sig or sig 1 Warning This function uses the intnum routines and is orders of magnitude slower than sumalt It is only given for completeness and should not be used in practice 197 Warning2 The expression expr must not include the 1 coefficient Thus sumalt n a 1 f n is approximately equal to sumnumalt n a sig f n sig is coded as in sumnum However for slowly decreasing functions where sig is coded as o a with a lt 1 it is not really important to indicate a In fact as for sumalt the program will often give meaningful results usually analytic continuations even for divergent series On the other hand the exponential decrease must be indicated tab is as in intnum but if used must be initialized with sumnuminit If flag is nonzero assumes that the function f to be summed is of real type i e satisfies f z f Z and then twice faster when tab is precomputed Xp 308 tab sumnuminit 2 omitted 1 abscissa o 2 alternating sums time 1 620 ms slow but done once and for all a sumnumalt n 1 2 1 n 3 n 1 ta
40. o o ee ee ee eee ee 13 2 Introduchiones ss ser foe a ee ag bet an tee o Se Ad ee et 13 2 2 The general gp input line 2 2 ee 15 2 3 The PARL types 2 5 a she dite Rae Mk oe EEE Rae ee a ee 17 2A GP OPePators e s ae oe cn how a ek Tp ar oe Wok age aisle ob eh de eee das de 24 2 5 Variables and symbolic expressions ooo a a 27 2 6 Variables and Scope 1 2 ee aa AA ae a a a A a a E a a a ai 30 24 User defined functions ceci atr grn a wy A A A A oe ee ee 32 2 8 Member FUNCHODS s s rasowa uoaa a a e a o a 39 2 9 Strings and Keywords 2 Al 2 10 Errors and error recovery o oo e 43 2 11 Interfacing GP with other languages a 47 DARDOS e a Paine eh Belo 48 2 13 Simple metacommands oaoa a 55 2 14 The preferences fil eroa moce d s bea ee RD a ee A 58 2 15 Using readline sita ea ae ds le ee dh A WD 60 2 16 GNU Emacs and PariEmacs apitos esp ae a E ia a E E E AAB Ea a a 62 Chapter 3 Functions and Operations Available in PARI and GP 63 3 1 Standard monadic or dyadic operators e 65 3 2 Conversions and similar elementary functions or commands 69 3 3 Transcendental functions 2 e 81 34 Arithmetic functions oe gn elt e eae ee eo a ap ae des de 89 3 5 Functions related to elliptic curves oaoa ee 108 3 6 Functions related to general number fields 0 0 020200000048 116 3 7 Polynomials and power series a 161 3 8 Vectors matrices linear a
41. psfile 2 2824 8688446 reti 53 199 PEI ss rc a E da A 86 PSPLlOBA eo eek cc ey do Ba eo 204 psplothraw se piao md ee eee 204 Python a od de Soe amp done dae wed a 47 Q QED ada do td Gt ae de ee A 71 QDO 2g eee ha ewe eae GS ee ee 71 QP DCIASSNO iii Bee we ie a 101 103 QPbclassnoo0 out wate od wb Gee a 102 QfbcOMprawW gt s 6 se bee ee eS 102 qfbhclassno oo 102 qfbnucomp lt sso ee eee bt ee ws 102 QEDNUPOW a eos be he e 102 qfbpowraw o 102 qfbprimeform eres ss restos 103 Q DISA sa sg s sooto ae E ee we pi 103 GibredO sa s iio o e e a 103 Q DSOLVE soss kasya da asa ere eg 103 dleval cuarta da 161 qfigalissred sporos aonig a a A Ge es 177 qfgaussred_positive 177 Ei wee Oa a ee wa eee 71 Gfijacobi a eee ee ss Lir GELLI e miai A ae og 168 177 E O IN 177 qflllgram e 4460844 sas as 4 177 qflllgramO 178 QM MM op wg ee a oe ee 178 179 GFMINIMO os das dee ee Ge Gea a 179 Qiperfechion ele e Kas 179 QE x ice ote e ee Ges val A TO i dua ste Ger Saw Pe 179 Q IEPO sena a E A ee 179 J S eiii A Oe Bens 179 180 QE aen dae ae Hi eect ont ede Be a ae EE 198 quadclassunit 103 quadclassunitO 104 quaddisc oo 104 UAB so s eo ee a Bd 104 quadhWlbert si s ca e 104 quadpoly s ss sa erea tsa paw we 105 quadpolyO scs sest anene eG ai 105 quadratic number 7 8 20 quadray e 22 66 is eee de bee ee es 105 quadregula
42. see conjvec for this The library syntax is GEN gconj GEN x 3 2 28 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 intmod 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 GEN conjvec GEN x long prec 3 2 29 denominator x denominator of x The meaning of this is clear when z is a rational number or function If x is an integer or a polynomial it is treated as a rational number of function respectively and the result is equal to 1 For polynomials you probably want to use denominator content x instead As for modular objects t_INTMOD and t_PADIC have denominator 1 and the denominator of a t_POLMOD is the denominator of its minimal degree polynomial representative If x is a recursive structure for instance a vector or matrix the lcm of the denominators of its components a common denominator is computed This also applies for t_COMPLEXs and t_QUADs 75 Warning multivariate objects are created according to variable priorities with possibly surprising side effects x y is a p
43. the all important concept of variable priority In the next Section 2 6 we shall no longer consider only free variables but adopt the viewpoint of computer programming and assign values to these symbols bound variables are names associated to values in a given scope 2 5 1 Variable names A valid name starts with a letter followed by any number of keyword characters _ or alphanumeric characters A Za z0 9 The built in function names are reserved and cannot be used see the list with Ac including the constants Pi Euler and I y 1 GP names are case sensitive For instance the symbol i is perfectly safe to use and will not be mistaken for I y 1 analogously o is not synonymous to 0 In GP you can use up to 16383 variable names up to 65535 on 64 bit machines If you ever need thousands of variables and this becomes a serious limitation you should probably be using vectors instead e g instead of variables X1 X2 X3 you might equally well store their values in X 1 X 2 X 3 2 5 2 Variables and polynomials What happens when you use a valid variable name t say for the first time before assigning a value into it This registers a new free variable with the interpreter which will be written as t and evaluates to a monomial of degree 1 in the said variable t It is important to understand that PARI GP is not a symbolic manipulation package even free variables already have default values there is no such thing as
44. variable M t to For instance substpol x 4 x72 1 x72 y 166 11 y72 y gt 1 substpol x 4 x72 1 x73 y 12 x 2 y x 1 substpol x 4 x72 1 x 1 72 y 13 4 y 6 x y 2 3xy 3 The library syntax is GEN gsubstpol GEN x GEN y GEN z 3 7 35 substvec x v w v being a vector of monomials of degree 1 variables w a vector of expressions of the same length replace in the expression x all occurrences of v by w The substitutions are done simultaneously more precisely the v are first replaced by new variables in x then these are replaced by the w substvec x y x y Ly x 11 ly x substvec x y x y y x y 12 ly x yl not y 2 y The library syntax is GEN gsubstvec GEN x GEN v GEN w 3 7 36 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 in GP but must be given as a second argument in library mode The library syntax is GEN tayl GEN x long y long precdl 3 7 37 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 the result is conditional on the GRH or some heuristic stre
45. w2 directly instead of E e ellinit 0 0 0 1 0 ellzeta e e omega 1 2 42 0 8472130847939790866064991234 4 417621070 E 29x I 2 ellzeta 1 11 1 2 43 3 141592653589793238462643384 0 E 37 I The quasi periods of such that Ez aw bwe z am bno for integers a and b are obtained directly as n 2 w 2 or using elleta The library syntax is GEN ellzeta GEN E GEN z long prec 3 5 34 ellztopoint F z E being an ell as output by ellinit computes the coordinates x y on the curve E corresponding to the complex number z Hence this is the inverse function of el1 pointtoz In other words if the curve is put in Weierstrass form x y represents the Weierstrass 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 GEN pointell GEN E GEN z long 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 are found in section Section 3 4 Arithmetic functions 3 6 1 Number field structures Let K Q X T a number field Zx its ring of integers T Z X is monic Three basic number field structures can be associated to K in GP e nf denotes a number field i e a data str
46. x mody i e an intmod 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 The library syntax is GEN gmodulo GEN x GEN y 3 2 5 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 with non negative valuation or a rational function the effect is similar to truncate i e we chop off the O X or compute the Euclidean quotient of the numerator by the denominator then change the main variable of the result to v The main use of this function is when z is a vector it creates the polynomial whose coefficients are given by x with x 1 being the leading coefficient which can be zero It is much faster to evaluate Pol on a vector of coefficients in this way than the corresponding formal expression an X ag which is evaluated naively exactly as written linear versus quadratic time in n Polrev can be used if one wants 2 1 to be the constant coefficient Pol 1 2 3 41 x72 2xx 3 Polrev 1 2 3 2 3 x 2 24x 1 The reciprocal function of Pol resp Polrev is Vec resp Vecrev 70 Vec Po
47. 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 For example to build a package for a Linux distribution you may want to use Configure prefix usr This phase extracts some files and creates a directory Oxxx where the object files and executa bles 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 independent and can be done simultaneously Configure tune fine tunes the library for the host used for compilation This adjusts thresholds by running a large number of comparative tests It will take a while about 30 minutes on a 2GHz machine Expect a small performance boost perhaps a 10 speed increase compared to default settings If you are using GMP tune it first then PARI Do not use a heavily loaded machine for tunings Technical note Configure accepts many other flags besides prefix See Configure help for a complete list In particular there are sets of flags related to GNU MP with gmp and GNU readline library with readline Note that autodetection of GMP is disabled by default you probably want to enable it Decide whether you agree with what Configure printed on your screen in particular the architecture compiler and optimization flags Look for me
48. 1 1 1 bnrrootnumber bnr 2 1 returns the root number of the character x of Clz7w 00 Q v229 defined by x 9193 Here 91 92 are the generators of the ray class group given by bnr gen and e 7 N1 Gy e2i7 N2 where Nj Na are the orders of g and ga respectively N 6 and N 3 as bnr cyc readily tells us The library syntax is GEN bnrrootnumber GEN bnr GEN chi long flag long prec 3 6 36 bnrstark bnr subgroup bnr being as output by bnrinit 1 finds a relative equation for the class field corresponding to the modulus in bnr and the given congruence subgroup as usual omit subgroup 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 When the base field is Q the vastly simpler galoissubcyclo is used instead Here is an example bnf bnfinit y 2 3 bnr bnrinit bnf 5 1 bnrstark bnr returns the ray class field of Q vV3 modulo 5 Usually one wants to apply to the result one of rnfpolredabs bnf pol 16 compute a reduced relative polynomial rnfpolredabs bnf pol 16 2 compute a reduced absolute polynomial The routine uses Stark units and needs to find a suitable auxiliary conductor which may not exist when the class field is not cyclic over the base In this case bnrstark is allowed to return a vector of polynomials defining independent relative extensions whose compositum is the requested cla
49. 1 1 2 1 2 1 1 1 4 18 2 2 2 2 4 2 2 2 2 2 2 2 2 0 1 1 1 1 2 1 1 0 4 18 2 2 2 2 2 4 2 2 2 2 2 1 2 1 0 1 2 1 1 1 2 0 4 18 2 2 2 2 2 2 4 2 2 2 2 1 1 1 1 0 2 2 1 0 2 1 4 18 2 2 2 2 2 2 2 4 2 2 2 2 2 0 1 1 2 1 1 0 2 1 4 18 2 2 2 2 2 2 2 2 4 2 2 2 1 1 0 1 1 1 2 0 2 1 4 18 2 2 2 2 2 2 2 2 2 4 2 2 1 0 1 0 1 2 2 1 2 1 4 18 2 2 2 2 2 2 2 2 2 2 4 2 1 0 0 1 2 2 1 1 1 1 4 32 1 2 1 1 2 1 1 2 2 2 2 4 2 1 2 2 2 2 2 2 2 2 2 32 2 2 2 1 2 2 1 2 1 1 1 2 4 2 2 2 2 2 2 2 2 1 2 32 1 1 1 1 0 1 1 0 1 0 0 1 2 4 2 2 2 2 2 2 2 2 0 32 0 1 1 1 1 0 1 1 0 1 0 2 2 2 4 2 2 2 2 2 2 2 0 32 0 0 1 1 1 1 0 1 1 0 1 2 2 2 2 4 2 1 2 2 2 2 0 32 1 2 1 2 1 2 2 2 1 1 2 2 2 2 2 2 4 2 1 2 2 2 2 32 2 2 2 1 1 1 2 1 1 2 2 2 2 2 2 1 2 4 2 2 2 2 2 32 2 1 2 2 2 1 1 1 2 2 1 2 2 2 2 2 1 2 4 2 2 2 2 32 1 1 0 1 1 1 0 0 0 1 1 2 2 2 2 2 2 2 2 4 1 2 0 32 1 1 2 1 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 4 2 2 32 1 0 0 1 0 0 1 1 1 1 1 2 1 2 2 2 2 2 2 2 2 4 0 18 4 4 4 4 4 4 4 4 4 4 4 2 2 0 0 0 2 2 2 0 2 0 8 bie bs qfminim x 0 the Leec attice has 98256 minimal vectors of norm 4 4 98256 4 In the last example we store O vectors to limit memory use All minimal vectors are nevertheless enumerated The library syntax is GEN qfminimO GEN x GEN b NULL GEN m NULL long flag longi prec Also available are GEN minim GEN x GEN b NULL GEN m NULL flag 0 GEN minim2 GEN x GEN b NULL GEN m NULL flag 1 3 8 50 qfperfection a x being a square and symme
50. 2 42 2 18 E 106 OK 190 intnum x 0 oo 1 sin x 3 exp x 0 3 43 5 45 E 107 MM OK intnum x 0 oo 11 sin x 3 exp x 0 3 4 1 33 E 89 lost 16 decimals Try higher m m intnumstep 5 7 the value of m actually used above tab intnuminit 0 oo 1 m 1 try m one higher intnum x 0 oo sin x 3 exp x tab 0 3 6 5 45 E 107 OK this time Warning Like sumalt intnum often assigns a reasonable value to diverging integrals Use these values at your own risk For example intnum x 0 loo I x 2 sin x 71 2 0000000000 Note the formula e sin 1 x dx cos rs 21 1 s a priori valid only for 0 lt R s lt 2 but the right hand side provides an analytic continuation which may be evaluated at s 2 Multivariate integration Using successive univariate integration with respect to different formal parameters it is immediate to do naive multivariate integration But it is important to use a suitable intnuminit to precompute data for the internal integrations at least For example to compute the double integral on the unit disc x y lt 1 of the function x y we can write tab intnuminit 1 1 intnum x 1 1 intnum y sqrt 1 x 2 sqrt 1 x 2 x 2 y72 tab tab The first tab is essential the second optional Compare tab intnuminit 1 1 time 30 ms intnum x 1 1 intnum y sqrt 1 x72 sq
51. 2 isqrtD GEN rhorealnod GEN x GEN issqrtD qfbred x 3 isqrtD 3 4 58 qfbsolve Q p Solve the equation Q z y p over the integers where Q is a binary quadratic form and p a prime number Return x y as a two components vector or zero if there is no solution Note that this function returns only one solution and not all the solutions Let D discQ The algorithm used runs in probabilistic polynomial time in p through the computation of a square root of D modulo p it is polynomial time in D if Q is imaginary but exponential time if Q is real through the computation of a full cycle of reduced forms In the latter case note that bnfisprincipal provides a solution in heuristic subexponential time in D assuming the GRH The library syntax is GEN qfbsolve GEN Q GEN p 103 3 4 59 quadclassunit D flag 0 tech Buchmann McCurley s sub exponential algo rithm for computing the class group of a quadratic order of discriminant D This function should be used instead of qfbclassno or quadregula when D lt 10 D gt 101 or when the structure is wanted It is a special case of bnfinit which is slower but more robust 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 4 2 this does not work at all use the general function bnfnarrow Optional parameter tech is a row vector of the form c1 c2 where c lt c
52. 3 2 KK forbidden division t_INTMOD t_INT Mod 2 9 6 3 Mod 2 3 67 The library syntax is GEN divrem GEN x GEN y long v 1 where v is a variable num ber Also available is GEN gdiventres GEN x GEN y when v is not needed 3 1 10 lex z y gives the result of a lexicographic comparison between x and y as 1 0 or 1 This is to be interpreted in quite a wide sense It is admissible to compare objects of different types scalars vectors matrices provided the scalars can be compared as well as vectors matrices of different lengths The comparison is recursive In case all components are equal up to the smallest length of the operands the more complex is considered to be larger More precisely the longest is the largest when lengths are equal we have matrix gt vector gt scalar For example lex 1 3 1 2 5 1 1 lex 1 3 1 3 1 12 1 lex 1 1 3 1 lex 1 11 74 0 The library syntax is GEN lexcmp GEN x GEN y 3 1 11 max x y creates the maximum of x and y when they can be compared The library syntax is GEN gmax GEN x GEN y 3 1 12 min x y creates the minimum of x and y when they can be compared The library syntax is GEN gmin GEN x GEN y 3 1 13 shift x n shifts componentwise left by n bits if n gt 0 and right by n bits if n lt 0 May be abreviated as x lt lt n or x gt gt n A left shift by n corresponds to multiplication by
53. 3 4 71 zncoppersmith P N X B N finds all integers zo with zo lt X such that gcd N P xo gt B If N is prime or a prime power polrootsmod or polrootspadic will be much faster X must be smaller than exp log B deg P log N The library syntax is GEN zncoppersmith GEN P GEN N GEN X GEN B NULL 106 3 4 72 znlog z g let N such that Z NZ is cyclic and g a primitive root mod N as would be output by znprimroot N The result is the discrete log of x in the multiplicative group Z NZ This function uses a simple minded combination of Pohlig Hellman algorithm and Shanks baby step giant step which requires O q storage where q is the largest prime factor of p 1 p odd prime divisor of N Hence it cannot be used when the q is greater than about 10 g znprimroot 101 1 Mod 2 101 znlog 5 g 2 24 g24 13 Mod 5 101 G znprimroot 2 101710 4 Mod 110462212541120451003 220924425082240902002 znlog 5 G 15 76210072736547066624 G 6 1 The result is undefined when g is not a primitive root or when x is not invertible mod N znlog Mod 2 4 Mod 1 3 43 1 Junk in junk out znlog 6 Mod 2 3 znlog impossible inverse modulo Mod 0 3 For convenience g is also allowed to be a p adic number g 3 0 5 10 znlog 2 g 1 1015243 EE 2 2 0 5710 The library syntax is GEN znlog GEN x GEN g 3 4 73 znorder z o x
54. 4 factorpadic pol p r flag 0 p adic factorization of the polynomial pol to precision r the result being a two column matrix as in factor The factors are normalized so that their leading coefficient is a power of p 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 GEN factorpadicO GEN pol GEN p long r long flag 3 7 5 intformal z 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 GEN integ GEN x long v 1 where v is a variable number 3 7 6 padicappr pol a vector of p adic roots of the polynomial pol congruent to the p adic number a modulo p 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 Zp or can be an integral element of a finite extension of Qp given as a t_POLMOD at least one of whose coefficients is a t_PAD
55. 4 forell E a b seq evaluates seq where the formal variable E ranges through all elliptic curves of conductors from a to b Th elldata database must be installed and contain data for the specified conductors 3 11 5 forprime X a b seq evaluates seq where the formal variable X ranges over the prime numbers between a to b including a and b if they are prime More precisely the value of X is incremented to the smallest prime strictly larger than X at the end of each iteration Nothing is done if a gt b Note that a and b must be in R forprime p 2 12 print p if p 3 p 6 RON 3 11 6 forstep X a b s seq evaluates seq where the formal variable X goes from a to b in increments of s Nothing is done if s gt 0 and a gt bor if s lt 0 and a lt b s must be in R ora vector of steps s1 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 3 11 7 forsubgroup H G bound seq evaluates 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 B 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 ind
56. 48 6 wok a BO ae e g 195 SUMIM urea So ws 194 195 197 SUMNUM sop 8 bo a a ab gs ode we Be 195 197 sumnumalt 197 198 sumnuminit 0 198 sumpoS 195 197 198 SUMPOS2 22 64 Ronee ew Ye Eo eee Hoe 198 SUPPL ius oe tre a eo ee 176 sylvestermatrix 165 symmetric powers 165 system 42 54 210 213 T A betes eee eee oes amp 119 taille sass ge ace a RA Re me a ae gee 79 taille sor eae we we 79 Tamagawa number 110 112 GAM 2 5 dae BR ie Se SR ee a ola 88 CMA eee eee a Re 88 Taniyama Weil conjecture 109 WAG ie eed aoa wo SP Rad hk Go ee a 108 tate o eee a eee Rea ew a 108 Tal cias aa e 167 Taylor Series o 65 Taylor gea aeo e un a ee Re 109 taylor pos eh cee E 167 A eae ee ere Bac eh a 88 teichmuller 2000 ce 88 Lex2maldl eso aa RR e 52 53 TeXstyle vo dom i porto pie h 52 54 theta 26456 ee ee bee eee ee 88 thetanwlik aia cos ge eB ew ew es 88 o hee god es ee Gis A ke ve og oie es 167 thueinit lt e sso eee a Be Pee 167 168 time expansion 48 TimMer sorga Sows noan Ke ged ae ek Ye ole 54 o A 180 TAROT g bea e 131 Erap i Goa es ae Ge eg elk Gos 42 44 213 trapO o sea eee RE AoE eae 214 ETICO Nest eos a a ee es 80 EYUNCATS Yosh oa Bg ho ee Be 76 79 tschirnhaus 152 CU en meie By we ee Be ee eee ae es 119 PUTU o aaa Oe we ok ae a Ga 119 o 2 xa a be Bee oe ee
57. 65 Euler product 92 101 193 Euler totient function 89 92 EULOE sagorna ele ed he ee a 82 Euler Maclaurin 88 eulerphi 9 4 eee eda eee egia 89 92 Vale eww ew Rae 30 32 42 71 161 GXP asias ra Bo fa as 84 expression sequence 15 EXPTESSION is x We ie he EH Gs sk Gc HOS HG 15 extended ged os soe soose ace o 90 OXTOTO f2 4 8b sasa dana 42 54 209 external prettyprint os ss rera o 52 EXLEACEO acesi paa en S RO ae ws 181 F factcantor 6 4 a nck Goes o a Be as 94 factor e as ce Se PRC aa 92 93 factor ss wae an a er 93 TactorbDackKo ico ases ias 93 94 factorbackO s aon g e 2 94 factorcantor 94 factorff 12 84 seed dee ws 93 94 95 factorial 6 bw ee tbe 2 en 95 factorint 93 95 factormod oka dee ge wb ee as 93 95 229 FactormodO s e a es a a Ge a a 95 FACEOINE sao ee aie Sey Ss Guach es 93 131 factorpadic 6 Se ew o 161 factorpadicO 04 162 factor_add_primes 50 factor_proven 50 92 You cdaed eee Phas EKG BESS SG 39 A 18 95 finit 4 4 reina o e G 18 95 TITIO sde 8s ban ses ee Be elated A 96 Fronde che eit de Beas Ge ase et ee te 96 ff PriIMToOb 46 ape Gos we Oe a 96 97 TADO i eo see a A we 97 Fibonacci 2122900 ms as 97 field discriminant 142 filename gio sie Goh ee ek ee we He 48 finite field element 7 8 18 finite field 4225686040 see 20 fixed
58. BO a 73 ViOCSOFG laa ks he gE i E 181 vecsortO lt 24454 4544 e ee 24 S 182 VOCUCUL e cor a 6 ele ee eR eG ed es 183 vecteursmall 183 vecthetanullk 88 VECIOS cod woe echoes Ac OP ae ee cs 8 vector feb Wise boss he ahi ee ba we aca oh 182 183 vectorsmall 183 a e s se 8 ag s be doa eee eS 183 version MUMber 57 A E ee ek a e e 60 VVECECCUL gt i os sa ae 183 W Wess Soe ae ces ae hee oe NO 108 weber 2 2 444 404 44 46 AOR S 88 weberO s ios 5 eee eee eee ba 88 weberf Virada doe Be ede Gk ee 88 Webertldl 88 weberf2 00048 88 Weierstrass g function 116 Weierstrass equation 108 Weil curve 114 Wwelpelli cui gion Gow Be ww eee dr 115 WhATNOW 56 24 8 e amp Gf a 0 4 oe 42 214 While nissan triana oe 207 Wiles 109 Write coco lt a ee 42 54 57 214 Heitel nadar ss 214 WEIITODIO bs ai ra a ee es 214 WE ItOteX esmas a ew n 215 X IEAI odo da a de ba 74 mm css ra A 74 Sms de ect eB ra a a hee eB 74 Sey Se ee ye ee ads Ss 74 Z Aassenhaus espada as 94 161 ZBYeENt asa Se woe Be oe E a a 194 Zell o se ne 113 GOTO ng ecse Boa Bale OM ee Se oai 9 Zeropadic s wee ee eR Re ds 161 ZOSO cow Ke Ye g a a E S 161 zeta function ao Zeta si sc 44 684 a A Ew OED 88 Zetak comes bem ha ewe ee 160 ZOtaKINGt conil ce amp Ah ae E 160 zideallog se c ece wea aa
59. GEN nf GEN x GEN a NULL 3 6 70 idealval nf x pr gives the valuation of the ideal x at the prime ideal pr in the number field nf where pr is in idealprimedec format The library syntax is long idealval GEN nf GEN x GEN pr 140 3 6 71 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 GEN principalidele GEN nf GEN x long prec 3 6 72 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 same name The library syntax is GEN matalgtobasis GEN nf GEN x 3 6 73 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
60. General use All the functions which are specific to relative extensions number fields Buchmann s number fields Buchmann s number rays share the prefix rnf nf bnf bnr respectively They take 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 On the other hand if the function requires a bnf it will not launch bnfinit for you which is a costly operation Instead it will give you a specific error message In short the types nf lt bnf lt bnr are ordered each function requires a minimal type to work properly but you may always substitute a larger type The data types corresponding to the structures described above are rather complicated Thus as we already have seen it with elliptic curves GP provides member functions to retrieve data from these structures once they have been initialized of course The relevant types of number fields are indicated between parentheses bid bnr bid ideal structure bnf bnr bnf Buchmann s 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 codi
61. Mestre s AGM algorithm The latter is much faster than the other two both in theory converges quadratically and in practice The library syntax is GEN ellheightO GEN E GEN x long flag long prec Also avail able is GEN ghell GEN E GEN x long prec flag 2 3 5 14 ellheightmatrix F 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 x 31 The rank of this matrix at least in some approximate sense gives the rank of the set of points and if x is 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 F is assumed to be integral given by a minimal model The library syntax is GEN mathe11 GEN E GEN x long prec 3 5 15 ellidentify E look up the elliptic curve E over Z in the elldata database and return N M G C where N is the name of the curve in J E Cremona database M the minimal model G a Z basis of the free part of the Mordell Weil group of E and C the coordinates change see ellchangecurve The library syntax is GEN ellidentify GEN E 3 5 16 ellinit x flag 0 initialize an ell structure associated to the elliptic curve E E is either a 5 component vector a1 az a3 a4 ag defining the elliptic curve with Weierstrass equation Y a XY
62. OP Y Oy Z OPy Y Ops Y is equivalent to op y opa 2 op x ops y GP contains quite a lot of different operators some of them unary having only one argument some binary plus special selection operators Unary operators are defined for either prefix pre ceding 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 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 be more legible Here is the complete list in order of decreasing priority binary unless mentioned otherwise e Priority 10 and unary postfix r 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 9 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 logic
63. R X sig in other words inverse Mellin transform of the function corresponding to expr at the value z sig is coded as follows Either it is a real number equal to the abscissa of integration and then the integrated is assumed to decrease exponentially fast of the order of exp t when the imaginary part of the variable tends to 00 Or it is a two component vector o a where is as before and either a 0 for slowly decreasing functions or a gt 0 for functions decreasing like exp at such as gamma products Note that it is not necessary to choose the exact value of a and that a 1 equivalent to sig alone is usually sufficient tab is as in intnun 186 As all similar functions this function is provided for the convenience of the user who could use intnum directly However it is in general better to use intmellininvshort Ap 105 intmellininv s 2 4 gamma s 3 time 1 190 ms reasonable Xp 308 intmellininv s 2 4 gamma s 3 time 51 300 ms slow because of T s The library syntax is intmellininv void E GEN eval GEN void GEN sig GEN z GEN tab long prec 3 9 9 intmellininvshort sig z tab numerical integration of 2i7 s X z with respect to X on the line R X sig In other words inverse Mellin transform of s X at the value z Here s X is implicitly contained in tab in intfuncinit format typically tab intfuncinit T 1 1 s sig I T or similar com
64. 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 4 2 will have a different name if they are implemented some day 81 3 3 1 If y is not of type integer x y has the same effect as exp y log x It can be applied to p adic numbers as well as to the more usual types The library syntax is GEN gpow GEN x GEN n long prec for xn 3 3 2 Euler Euler s constant y 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 GEN mpeuler long prec 3 3 3 I the complex number y 1 The library syntax is GEN geni 3 3 4 Pi the constant 7 3 14159 The library syntax is GEN mppi long prec 3 3 5 abs x absolute value of x modulus if x is complex 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 11 1 abs 3 7 4 7 1 72 5 7 abs 1 1 13 1 414213562373095048801688724 If x is a polynomial returns x if the leading c
65. a divide conquer tree and should be much more efficient especially when using the GMP multiprecision kernel and more subquadratic algorithms become available y vector 1074 i random lcm v time 323 ms 1 v 1 for i 1 tv 1 lem 1 v i time 833 ms The library syntax is GEN glcmO GEN x GEN y NULL 3 4 41 moebius xz Moebius y function of x z must be of type integer The library syntax is GEN gmu GEN x 3 4 42 nextprime z finds the smallest pseudoprime see ispseudoprime greater than or equal to x x can be of any real type Note that if x is a pseudoprime this function returns x and not the smallest pseudoprime strictly larger than x To rigorously prove that the result is prime use isprime The library syntax is GEN gnextprime GEN x 3 4 43 numbpart n gives the number of unrestricted partitions of n usually called p n in the literature in other words the number of nonnegative integer solutions to a 2b 8c n n must be of type integer and 1 lt n lt 1015 The algorithm uses the Hardy Ramanujan Rademacher formula The library syntax is GEN numbpart GEN n 100 3 4 44 numdiv x number of divisors of x must be of type integer The library syntax is GEN gnumbdiv GEN x 3 4 45 omega x number of distinct prime divisors of x x must be of type integer The library syntax is GEN gomega GEN x 3 4 46 precprime x finds the largest pseudoprime see ispseudoprime
66. a row vector of column vectors is not a matrix for example multiplication will not work in the same way It is easy to go from one representation to the other using Vec Mat though 1 2 3 4 5 6 1 1 2 3 4 5 6 Vech 2 1 4 2 51 3 6 Mat 13 1 2 3 4 5 6 It is possible to create matrices with a given positive number of columns each of which has zero rows e g using Mat as above or using the matrix function It is not possible to create or represent matrices with zero columns and a nonzero number of rows If x is a matrix z m n refers to its m n entry 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 x 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 an expression such as x 1 1 3 4 1 is perfectly valid and actually identical to x 1 1 4 3 1 assuming that all matrices along the way have compatible dimensions 2 3 16 Lists t_LIST lists can be input directly as in List 1 2 3 4 but in most cases one creates an empty list then appends elements using listput a List listput a 1 listput a 2 Ta 712 List 1 2 Elements can be accessed directly as with the vector types described above 2 3 17 Strings t_STR to enter a string just enclose it between double quote
67. account but this time by increasing order of degree In this last case Col is the reciprocal function of Pol and Ser respectively Note that the function Colrev does not exist use Vecrev The library syntax is GEN gtocol GEN x NULL 3 2 2 List x transforms a row or column vector x into a list whose components are the entries of x Similarly for a list but rather useless in this case For other types creates a list with the single element x Note that except when x is omitted this function creates a small memory leak so either initialize all lists to the empty list or use them sparingly The library syntax is GEN gtolist GEN x NULL The variant GEN listcreate void cre ates an empty list 69 3 2 3 Mat x transforms the object x into a matrix If x is already a matrix a copy of x is created 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 unless all elements are column resp row vectors of the same length in which case the vectors are concatenated sideways and the associated big matrix is returned Mat x 1 ae x 1 Vec matid 3 2 1 0 07 0 1 O 0 O 1 Mat 13 1 0 0 0 1 0 0 O 1 Co1 1 2 3 4 74 1 2 3 4 1 Mat 75 1 2 3 4 The library syntax is GEN gtomat GEN x NULL 3 2 4 Mod x y creates the PARI object
68. allowed to be an nf etc Computes technical data needed by rnfisnorm to solve norm equations Nx a for x in L and a in K If flag 0 do not care whether L K is Galois or not If flag 1 L K is assumed to be Galois unchecked which speeds up rnfisnorm If flag 2 let the routine determine whether L K is Galois The library syntax is GEN rnfisnorminit GEN pol GEN polrel long flag 3 6 145 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 the full ray class field if subgroup is omitted If deg is positive outputs the list of all relative equations of degree deg contained in the ray class field defined by bnr with the same conductor as bnr subgroup 157 Warning this routine only works for subgroups of prime index It uses Kummer theory adjoining necessary roots of unity it needs to compute a tough bnfinit here and finds a generator via Hecke s characterization of ramification in Kummer extensions of prime degree If your extension does not have prime degree for the time being you have to split it by hand as a tower compositum of such extensions The library syntax is GEN rnfkummer GEN bnr GEN subgroup NULL long deg long prec 3 6 146 rnflllgram nf pol order given a polynomial pol with coefficients in nf defining a relative extension L and a suborder order of L of maxima
69. an unbound variable in GP You have access to this default value using the quote operator t always evaluates to the above monomial of degree 1 independently of assignments made since then e g t 1 2G 2 1 41 t72 1 t 2 t2 1 42 5 1 43 t72 1 eval 41 14 5 In the above t is initially a free variable later bound to 2 We see that assigning a value to a variable does not affect previous expressions involving it to take into account the new variable s value one must force a new evaluation using the function eval see Section 3 7 3 It is preferable to leave alone your polynomial variables never assigning values to them and to use subst and its more powerful variants rather than eval You will avoid the following kind of problems p t 2 1 subst p t 2 ht 5 t 2 subst p t 3 t is no longer free it evaluates to 2 xxx variable name expected subst p t 3 OK More generally any expression has a value and is replaced by its value as soon as it is read it never stays in an abstract form 27 13 10 A statement like x x in effect restores x as a free variable 2 5 3 Variable priorities multivariate objects A multivariate polynomial in PARI is just a polynomial in one variable whose coefficients are themselves polynomials arbitrary but for the fact that they do not involve the main variable PARI currently has no sparse representation for pol
70. 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 xl 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 18 plotlinetype w type change the type of lines subsequently plotted in rectwindow w type 2 corresponds to frames 1 to axes larger values may correspond to something else w 1 changes highlevel plotting This is only taken into account by the gnuplot interface 3 10 19 plotmove w x y move the virtual cursor of the rectwindow w to position x y 3 10 20 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 simultaneousl
71. are familiar with the languages they are based on The first is the Math Pari Perl module see any CPAN mirror written by Ilya Zakharevich The second is PariPython by St fane Fermigier which is no longer maintained Starting from Fermigier s work William Stein has embedded PARI into his Python based SAGE system Finally Michael Stoll has integrated PARI into CLISP which is a Common Lisp implementation by Bruno Haible Marcus Daniels and others this interface has been updated for pari 2 by Sam Steingold These provide interfaces to gp functions for use in perl python or Lisp programs respectively see http www fermigier com fermigier PariPython see http modular fas harvard edu sage see http clisp cons org x KKK 47 2 12 Defaults 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 14 but some of them are useful interactively set timer on increase precision etc The function used to manipulate these values is called default which is described in Sec tion 3 12 5 The basic syntax is default def value which sets the default def to value In interactive use most of these can be abbreviated using gp metacommands mostly starting with which we shall describe
72. 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 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 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 1t 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 v fa b c d el vecextract v 5 mask 41 a c vecextract v 4 2 1 component list 42 d b al vecextract v 2 4 interval 43 b c d vecextract v 1 3 interval reverse order 14 e d
73. 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 GEN idealmul0 GEN nf GEN x GEN y long flag long prec Alsof available are GEN idealmul GEN nf GEN x GEN y flag 0 or GEN idealmulred GEN nf GEN x GEN y long prec flag 0 138 3 6 63 idealnorm nf x computes the norm of the ideal x in the number field nf The library syntax is GEN idealnorm GEN nf GEN x 3 6 64 idealpow 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 is GEN idealpowO GEN nf GEN x GEN k long flag long prec Alsof available are GEN idealpow GEN nf GEN x GEN k and GEN idealpows GEN nf GEN x long k flag 0 Corresponding to flag 1 is GEN idealpowred GEN nf GEN vp GEN k long prec 3 6 65 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 p is given
74. asY X 4 a2X 4X ag or a string in this case the coefficients of the curve with matching name are looked in the elldata database if available For the time being only curves over a prime field F and over the p adic or real numbers including rational numbers are fully supported Other domains are only supported for very basic operations such as point addition The result of ellinit is an ell structure by default and a shorter sellif flag 1 Both contain the following information in their components Q1 42 43 44 46 ba ba be bg C4 C6 J All are accessible via member functions In particular the discriminant is E disc and the j invariant is F j 111 The other six components are only present if flag is O or omitted in which case the computation will be 10 p adic to 200 complex times slower Their content depends on whether the curve is defined over R or not e When E is defined over R F roots is a vector whose three components contain the roots of the right hand side of the associated Weierstrass equation y a12 2 a3 2 g a If the roots are all real they are ordered by decreasing value If only one is real it is the first component Then w E omega 1 is the real period of E integral of dx 2y a1 1 a3 over the connected component of the identity element of the real points of the curve and wa E omega 2 is a complex period E omega forms a basis of the complex lattice defining E such
75. become R x y sqrt x 2 y 2 sq x x72 The semicolon serves the same purpose as above preventing the printing of the resulting function object compare sq x x72 no output sq x x 2 print the result a function object 12 x gt x 2 Of course the sequence seg can be arbitrarily complicated in which case it will look better written on consecutive lines with properly scoped variables ACT Ti an my tg ti AN variables lexically scoped to the function body Note that the following variant would also work f x X15 O my to t1 variables lexically scoped to the function body the first newline is disregarded due to the preceding sign and the others because of the enclosing braces The my statements can actually occur anywhere within the function body scoping the variables to more restricted blocks than the whole function body 33 Arguments are passed by value not as variables modifying a function s argument in the function body is allowed but does not modify its value in the calling scope In fact a copy of the actual parameter is assigned to the formal parameter when the function is called Formal parameters are lexically scoped to the function body It is not allowed to use the same variable name for different parameters of your function f x x 1 KK variable declared twice f x x 1 a Finishing touch You can add a specific help message for yo
76. 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 any expression when a string is expected 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 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 41 Warning expression involving strings are not handled in a special way even in string context the largest possible expression is evaluated hence print a 1 is incorrect since a is not an object whose first component can be extracted On the other hand print a 1 is correct two distinct argument each converted to a string and so is print a 1 since a 1 is not a valid expression only a gets expanded t
77. 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 xis a matrix with two rows bo b1 bn and ag a1 this is then considered as a generalized continued fraction and we have similarly pn qn 1 bola9 b1 a1 bp an Note that in this case one usually has by 1 The library syntax is GEN pnqn GEN x 3 4 11 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 GEN coreO GEN n long flag Also available are GEN core GEN n flag 0 and GEN core2 GEN n flag 1 91 3 4 12 coredisc n flag 0 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 The library syntax is GEN corediscO GEN n long flag Also available are GEN core disc GEN n flag 0 and GEN coredisc2 GEN n flag 1 3 4 13 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 GEN dirdiv GEN x GEN y 3 4 14 direuler p a b expr c computes the Dirichlet series associated to the Euler product
78. c vecextract v 2 complement 5 a c d el vecextract matid 3 2 6 0 1 0 0 O 1 The library syntax is GEN extractO GEN x GEN y GEN z NULL 181 3 8 60 vecsort x cmp flag 0 sorts the vector x in ascending order using a mergesort method x must be a vector and its components integers reals or fractions If cmp is present it is understood as a comparison function and we sort according to it The following possibilities exist e an integer k sort according to the value of the k th subcomponents of the components of x Note that mergesort is stable hence the initial ordering of equal entries with respect to the sorting criterion is not changed ea vector sort lexicographically according to the components listed in the vector For example if cmp 2 1 3 sort 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 e a comparison function t_CLOSURE with two arguments x and y and returning an integer which is lt 0 gt 0 or 0 if x lt y x gt y or x y respectively The sign function is very useful in this context vecsort v x y gt sign x y XX reverse sort vecsort v x y gt sign abs y abs x sort by increasing absolute value cmp x y my dx poldisc x dy poldisc y sign abs dx abs dy vecsort x 2 1 x 3 2 x 4 5 x 1 cmp NN NN The las
79. command which is evaluated when you hit the lt Return gt key and the result is printed as during the main gp loop except that no history of results is kept Then the break loop prompt reappears and you can type further commands as long as you do not exit the loop If you are using readline the history of commands is kept and line editing is available as usual If you type in a command that results in an error you are sent back to the break loop prompt errors do not terminate the loop To get out of a break loop you can use next break return or C d EOF any of which will let gp perform its usual cleanup and send you back to the gp prompt If the error is not fatal inputing an empty line i e hitting the lt Return gt key at the break gt prompt will continue the temporarily interrupted computation An empty line has no effect in case of a fatal error to ensure you do not get out of the loop prematurely thus losing most debugging data during the cleanup since user variables will be restored to their former values In current version 2 4 2 an error is non fatal if and only if it was initiated by a C c typed by the user Break loops are useful as a debugging tool You may inspect the values of gp variables to understand why an error occurred or change gp s state in the middle of a computation increase 44 debugging level start storing results in a logfile set variables to different values hit C c type in your modif
80. conjunction with the function mathnfmod which needs to know such a multiple To obtain the exact determinant assuming the rank is maximal you can compute matdet mathnfmod x matdetint x Note that as soon as one of the dimensions gets large m or n is larger than 20 say it will often be much faster to use mathnf x 1 or mathnf x 4 directly The library syntax is GEN detint GEN x 3 8 15 matdiagonal z x being a vector creates the diagonal matrix whose diagonal entries are those of x The library syntax is GEN diagonal GEN x 3 8 16 mateigen x gives the eigenvectors of x as columns of a matrix The library syntax is GEN eigen GEN x long prec 3 8 17 matfrobenius M flag v x returns the Frobenius form of the square matrix M If flag 1 returns only the elementary divisors as a vectr of polynomials in the variable v If flag 2 returns a two components vector F B where F is the Frobenius form and B is the basis change so that M B FB The library syntax is GEN matfrobenius GEN M long flag long v 1 where visa variable number 3 8 18 mathess 1 Hessenberg form of the square matrix x The library syntax is GEN hess GEN x 3 8 19 mathilbert n x being a long creates the Hilbert matrixof order x i e the matrix whose coefficient i j is 1 i j 1 The library syntax is GEN mathilbert long n 3 8 20 mathnf z flag 0 if x is a not necessarily square matrix with integer
81. eS 110 116 ellgenerators 110 ellglobalred 110 111 CLINI SEE essey as or 1il ellh ightO paaano ee ewe ed g 111 ellheightmatrix 111 ellidontily fuss Boe we we sa 111 ELLA a nr ce 108 111 ellinitO sac sxe Ge ss sas ae i 112 ellisoncurve 112 LLJ acy k ara E Gree Gk ew g 112 elllocalred 2s ae enog eare a 112 113 elllsSeries mm Be Oe ewe DE 113 ellminimalmodel 110 113 ellorder 224 420 844 odas 113 ellordinate ss aes eche aa eae 113 CLlpOINGtOZ so ae te 113 UID OW site each a oe yp e oh aes Gyre 114 ellrootno arios ae 114 OUTS SA cia A 113 ellS arch 5 24 464 a a e 114 ellsearchcurve 114 A CA 114 ellSsub sarees sis e aN 114 elltaniyama 114 115 elltOrs seco oe naa aoi to 115 eLILOESO i si sia aa Es 115 SL VP uba rai o a Se he 115 SLIVDO 220 Gost hos E da Be es 115 Cll zeta ea 44 oa bak os 112 115 116 elIZtOpoint 2 6 6 we Be a we 116 EMACS ge ek se ek a es gs 61 ENTES aou s sonaba gE Re ee o ee a 64 environment expansion 12 environment expansion 48 environment variable 12 B G nh ee RR eae eR RR we 84 error handler ocaso 45 error TECOVETY s e soa di ee ek E 44 enor LTQDDING 2 i BG PR e A 44 OTTO emm A es 42 44 209 eta normar ee eS 84 108 193 A ee eee Be Edi Re 84 PCH Gs cia aie es Grae amas Ge 97 Euclidean quotient 65 Euclidean remainder
82. eea a 138 a RN 119 zncoppersmith 106 ZOLOB ii ie A he a HE Ae 106 107 ZNOLACY se ge ed ee a Ne 107 ZOPYAMTOOE oe hk ees a Ges 107 gnstar omic roms ron 107 108 240
83. elleta 1 I 1 3 141592653589793238462643383 9 424777960769379715387930149 I The library syntax is GEN elleta GEN om long prec 3 5 11 ellgenerators E returns a Z basis of the free part of the Mordell Weil group associated to E This function depends on the elldata database being installed and referencing the curve and so is only available for curves over Z of small conductors The library syntax is GEN ellgenerators GEN E 110 3 5 12 ellglobalred calculates the arithmetic conductor the global minimal model of E and the global Tamagawa number c E must be an sell as output 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 gives the coordinate change for E over Q to the minimal integral model see ellminimalmodel 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 GEN ellglobalred GEN E 3 5 13 ellheight E x flag 2 global N eron Tate height of the point z on the elliptic curve E defined over Q given by a standard minimal integral model E must be an ell as output by ellinit flagselects the algorithm used to compute the archimedean local height 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 If flag 2 use
84. 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 GEN removeprimes GEN x NULL 105 3 4 68 sigma x k 1 sum of the kt powers of the positive divisors of x x and k must be of type integer The library syntax is GEN gsumdivk GEN x long k 3 4 69 sqrtint x integer square root of x which must be a non negative integer The result is non negative and rounded towards zero The library syntax is GEN racine GEN x 3 4 70 stirling n k flag 1 Stirling number of the first kind s n k flag 1 default or of the second kind n k flag 2 The former is 1 times the number of permutations of n symbols with exactly k cycles the latter is the number of ways of partitioning a set of n elements into k non empty subsets Note that if all s n k are needed it is much faster to compute Y s n kja 2 2 1 z n 1 k Similarly if a large number of S n k are needed for the same k one should use ak Deane l a 1 ka Should be implemented using a divide and conquer product Here is a simple variant for n fixed list of S n k k 1 n vecstirling2 n my Q x n 1 t vector n i t divrem Q x i Q t 1 t 2 The library syntax is GEN stirling long n long k long flag Also available are GEN stirling1 long n long k flag 1 and GEN stirling2 long n long k flag 2
85. environment a step by step solution can be found in the PARI FAQ see http pari math u bordeaux fr 3 6 Testing 3 6 1 Known problems if BUG shows up in make bench e program the GP function install may not be available on your platform triggering an error message not yet available for this architecture Have a look at the MACHINES files to check if your system is known not to support it or has never been tested yet e If when running gp dyn you get a message of the form ld so warning libpari so xrx has older revision than expected xxIX 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 like an Illegal Instruction on startup It does not affect gp sta e Some implementations of the diff utility on HPUX for instance output No differences encountered or some similar message instead of the expected empty input Thus producing a spurious BUG message 221 3 6 2 Some more testing Optional You can test GP in compatibility mode with make test compat If you want to test the graphic routines use make test ploth You will have to click on the mouse button after seeing each image There will be eight of them probably shown twice try to resize at least one of them as a further tes
86. eto a ree a wk we 112 Kronecker symbol 99 kronecker 22 ew 9 99 L Iple aa ed e e ae G 166 LOMA 100 Leech lattice 179 Legendre polynomial 164 Legendre symbol 99 length s tho gui los Be at ee ae a a 76 O 95 162 LEX 26 G44 64 oe eS ERE EE RO Ss 68 LEXCMP so a ae ew Bea A ee WS ee 68 lexical scoping 30 LIDPAT Sa a 0 ssp e 5 BIDIA ye god Gr ooh aes aes ag eee 95 Tift ook ra SG Ge a aS 74 76 L TO soe aios he wR ee Ew ae a 76 Limit oi a a we ew 37 Tindep noe sgine a we ee eae LS 168 170 TMIMGSpO i eer gk ceca Bk ae ne Ra 170 line editor 60 linear dependence 170 Tines o eo eae ew A ol Disp 230 ER eR SE E 47 SCA Lara a Grea a ee Y 28 LIST s i esna aon ati a a eS 69 listcreate 69 170 listinsert 170 171 LiStkill errada ae we ce 171 TAStPOP y ua eos A a Ok BS a T71 Tigtp t s g s ga a Be aE eae E ks Iri ITSESOFE 5 same 45 5 Be oe HS G4 171 LLL pi ea ane 139 144 170 172 174 177 Mt bee oe ee we ee ee Bae Bs 177 AAA ee Se aie wee eas ae 178 TIA Pram Nts ois are ed ws hd Goce Ba ee 178 lllgramkerim 178 LLLIME w ee a A ea ae ww LAT LLVUKSTiM ss eck BR ww ds we Ley li sss eos Pe Se we ee ee ee 85 LOCAL lc aoe eos Beh e ah gh Ge te a 30 LOS soou e446 4445 51 55 56 85 211 logfile s s aw we er ee 211 Logfile ici o we E 52 M MAG schon oo 6 wer Gok th ee
87. except for the following inputs e integers use modified right shift binary plus minus variant e univariate polynomials with coeffients in the same number field in particular rational use modular gcd algorithm e general polynomials use the subresultant algorithm if coefficient explosion is likely exact non modular coefficients The library syntax is GEN ggcdO GEN x GEN y NULL Also available are GEN ggcd GEN x GEN y if y is not NULL and GEN content GEN x if y NULL 3 4 32 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 O meaning the place at infinity Otherwise p needs not be given and x and y can be of compatible types integer fraction real intmod a prime result is undefined if the modulus is not prime or p adic The library syntax is long hilO GEN x GEN y GEN p NULL 3 4 33 isfundamental x true 1 if z is equal to 1 or to the discriminant of a quadratic field false 0 otherwise The library syntax is GEN gisfundamental GEN x 97 3 4 34 ispower z k amp n if k is given returns true 1 if x is a k th power false 0 if not If k is omitted only integers and fractions are allowed for x and the function returns the maximal k gt 2 such that x n is a perfect power or 0 if no such k exist in particular ispower 1 ispower 0 and ispower 1 all return 0 If a thi
88. floating point format 50 PLUG si ae ee eae ok OR ed Rw 63 FLOOR ea pka rhe Seed Gee owe sy 75 PUCK oy os act Goo I sy Se ee 198 FOR ye ea Goes eS Ge ee He A 205 Ford mre See ead Se ee ee Boe ae a 141 TOLGIV cua aw te es Oke a aw 205 forell ap Ye se ote he ee ob g oh ake e fe dR 206 formal integration 162 format 444 ved od e ae h 50 FOYPYIMe occiso 206 TOTSTOD 24 ws b a vee ea Pe ed oe as 206 forsubgroup 159 206 TOGOG ab ed ee ee ee wht be od SG 207 FM K r ia ds ee ae Se ee eh ah S 174 PVA eH a Be a wa Gee 76 free variable 2r fUn aara Aa A 119 fundamental units 10 L19 121 199 G Cabs ii Pa A AA a ew x 82 MAN 82 B COS auos ioe ec e ee Rea we 82 AA at tara Seca ee ae ae aa ht 65 GALOS 25 ad gun a8 Aad sas 39 Galois 124 144 149 150 157 207 galoisapply 144 aloisconjO s sag dad eel dee o 145 galoisexport 131 132 galoisfixedfield 131 132 207 galoisidentify 132 galoisinit e ele wow 3 t31 132 133 galoisisabelian 133 galoispermtopol 133 galoissubcyclo 130 133 134 165 207 galoissubfields 134 149 galoissubgroups 134 135 Gamma 2 2 ee Le be we es 85 gamma 85 BITE e ia in a eS es 82 Gash ee bb we ee eR eee ee Es 83 CASI sta Se te ate a Geom Go Ged 82 GALAN sica We eRe Ae ok ae a 83 Bathe ee ee BS ww eR ee es 83 CAMI fon Yeti ke
89. for various reasons If when running extgcd dyn you get a message of the form DLL not found then stick to statically linked binaries or look at your system documentation to see how to indicate at linking time where the required DLLs may be found E g on Windows you will need to move 1libpari d11 somewhere in your PATH 5 3 GP scripts Several complete sample GP programs are also given in the examples directory for example Shanks s 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 See the file examples EXPLAIN for some explanations 5 4 The PARI Community PARI s home page at the address http pari math u bordeaux fr maintains an archive of mailing lists dedicated to PARI documentation including Frequently Asked Questions a download area and our Bug Tracking System BTS Bug reports should be submitted online to the BTS which may be accessed from the navigation bar on the home page or directly at http pari math u bordeaux fr Bugs Further information can be found at that address but to report a configuration problem make sure to include the relevant dif files in the Oxxx directory and the file pari cfg There are three mailing lists devoted to PARI GP run courtesy of Dan Bernstein and most feedback should be directed to those They are e pari announce to announce major version
90. foresee that some error may occur are unable to prevent it but quite capable of recovering from it given the chance Examples include lazy factorization cf addprimes where you knowingly use a pseudo prime N as if it were prime you may then encounter an impossible situation but this would usually exhibit a factor of N enabling you to refine the factorization and go on Or you might run an expensive computation at low precision to guess the size of the output hence the right precision to use You can then encounter errors like precision loss in truncation e g when trying to convert 1E1000 known to 28 digits of accuracy to an integer or division by 0 e g inverting 0E1000 when all accuracy has been lost and no significant digit remains It would be enough to restart part of the computation at a slightly higher precision We now describe error trapping a useful mechanism which alleviates much of the pain in the first situation and provides a satisfactory way out of the second one Everything is handled via the trap function whose different modes we now describe 2 10 3 Break loop A break loop is a special debugging mode that you enter whenever an error occurs freezing the gp state and preventing cleanup until you get out of the loop Any error syntax error library error user error from error even user interrupts like C c Control C When a break loop starts a prompt is issued break gt You can type in a gp
91. from complicated structures you can define your own but they won t be shown here We will soon describe these commands in more detail More generally commands starting with the symbols or are not computing commands but are metacommands which allow you 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 13 2 1 3 Input Just type in an instruction e g 1 1 or Pi No action is undertaken until you hit the lt Return gt key Then computation starts and a result is eventually printed To suppress printing of the result end the expression with a sign Note that many systems use to indicate end of input Not so in gp a final semicolon means the result should not be printed Which is certainly useful if it occupies several screens 2 1 4 Interrupt Quit Typing quit at the prompt ends the session and exits gp At any point you can type Ctrl C that is press simultaneously the Control and C keys the current computation is interrupted and control given back to you at the gp prompt together with a message like gcd user interrupt after 840 ms telling you how much time ellapsed since the last command was typed in and in which GP function the computation was aborted It does not mean that that much time was spent in the function only that the evaluator was busy processing that s
92. generators of the image of the cyclic groups Z d i Z The library syntax is GEN znstar GEN n 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 agy z 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 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 which initializes and returns an ell structure by default If a specific flag is added a shortened sell for small ell is returned which is much faster to compute but contains less information The following member functions are available to deal with the output of ellinit both ell and sell 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 w3 periods forming a basis of the complex lattice defining E w1 is the real period and w w belongs to Poincar s half plane eta quasi periods 11 92 such that mw
93. 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 GEN imagecomp1 GEN x 3 8 26 matindexrank x x being a matrix of rank r returns a vector with two t_VECSMALL components 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 GEN indexrank GEN x 3 8 27 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 GEN intersect GEN x GEN y 173 3 8 28 matinverseimage z y given a matrix M and a column vector or matrix y returns a pre image z of y by M if one exists i e such that Mz y an empty vector or matrix otherwise The complete inverse image is z KerM where a basis of the kernel of M may be obtained by matker M 1 2 2 4 matinverseimage M 1 2 2 1 0 matinverseimage M 3 4 13 1 no solution matinverseimage M 1 3 6 2 6 12 4 1 3 6 o O 0
94. i 1 ex 1 is 1 The library syntax is GEN signunits GEN bnf 125 3 6 22 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 ideals 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 GEN bnfsunit GEN bnf GEN S long prec 3 6 23 bnfunit bnf bnf being as output by bnfinit outputs the vector of fundamental units of the number field This function is mostly useless since it will only succeed if bnf contains the units in which case bnf fu is recommended instead or bnf was produced with bnfinit 2 which is itself deprecated The library syntax is GEN buchfu GEN bnf 3 6 24 bnrL1 bnr subgroup flag 0 bnr being the number field data which is output by bnrinit 1 and subgroup being a square matrix d
95. if gp is running in an Emacs or TeXmacs shell see Section 2 16 READL true if gp is compiled with readline support see Section 2 15 1 VERSION op number where op is in the set gt lt lt gt and number is a PARI version number of the form Major Minor patch where the last two components can be omitted i e 1 is understood as version 1 0 0 This is true if gp s version number satisfies the required inequality 58 2 14 1 2 Commands After the preprocessing the remaining lines are executed as sequence of expressions as usual separated by if necessary Only two kinds of expressions are recognized e default value where default is one of the available defaults see Section 2 12 which will be set to value on actual startup Don t forget the quotes around strings e g for prompt or help e 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 In particular file input is delayed until the gprc has been fully loaded This is the right place to input files containing alias commands or your favorite macros For instance you could set your prompt in the following portable way self modifying prompt looking like 18 03 gp gt prompt H 7M el imgp elm gt readline wants non printing characters to be braced between A B pairs if READL prompt H M A e 1m Bgp A e m B gt e
96. 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 52 EMACS 2 12 21 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 preempted 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 Environment expansion is performed 2 12 22 prettyprinter default tex2mail TeX noindent ragged by par the name of an external prettyprinter to use when output is 3 alternate prettyprinter Note that the default tex2mail looks much nicer than the built in beautified format output 2 2 12 23 primelimit default 500k 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
97. is void addhelp entree S char str 3 12 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 The library syntax is void aliasO char newkey char key 3 12 3 allocatemem s 0 this very special operation allows the user to change the stack size after initialization x must be a non negative integer If x 0 a new stack of size 16 x 1 16 bytes is allocated If x 0 the size of the new stack is twice the size of the old one The old stack is discarded 208 Warning This function should be typed at the gp prompt in interactive usage or left by itself at the start of batch files It cannot be used meaningfully in loop like constructs or as part of a larger expression sequence e g allocatemem x 1 This will not set x In fact all loops are immediately exited user functions terminated and the rest of the sequence following allocatemem is silently discarded as well as all pending sequences of instructions We just go on read
98. j are the same as before they were started Note that lexical scoping has the unfortunate side effect of making break loops see Sec tion 2 10 3 almost useless break loops are run outside of the relevant scopes and are unable to access all lexically scoped variables On the other hand eval is just as powerful as before it is evaluated in the given scope and can access values of lexical variables x 1 my x 0 eval x 42 0 we see the local x scoped to this command line not the global one Variables dynamically scoped using local should more appropriately be called temporary val ues since they are in fact local to the function declaring them and any subroutine called from within In practice you almost certainly want true private variables hence should use almost exclusively my We strongly recommended to explicitly scope lexically all variables to the smallest possible block Should you forget this in expressions involving such rogue variables the value used will be the one which happens to be on top of the value stack at the time of the call which depends on the whole calling context in a non trivial way This is in general not what you want 2 7 User defined functions The most important thing to understand about user defined functions is that they are ordinary GP objects bound to variables just like any other object Those variables are subject to scoping rules as any other while you can define all your fu
99. k and a prime ideal pr in modpr format see nfmodprinit computes z modulo the prime ideal pr The library syntax is GEN element_powmodpr GEN nf GEN x GEN k GEN pr 3 6 90 nfeltreduce nf a id given an ideal id in Hermite normal form and an element a of the number field nf finds an element r in nf such that a r belongs to the ideal and r is small The library syntax is GEN element_reduce GEN nf GEN a GEN id 3 6 91 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 GEN nfreducemodpr GEN nf GEN x GEN pr 143 3 6 92 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 long element_val GEN nf GEN x GEN pr 3 6 93 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 vector The main variable of nf must be of lower priority than that of x see Section 2 5 3 However if the polynomial defining the number field occurs explicitly in the coefficients of x as modulus of a t_POLMOD its main
100. 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 To rigorously prove that the result is prime use isprime The library syntax is GEN gprecprime GEN x 3 4 47 prime n the 2 prime number which must be among the precalculated primes The library syntax is GEN prime long n 3 4 48 primepi x the prime counting function Returns the number of primes p p lt x Uses a naive algorithm so that x must be less than primelimit The library syntax is GEN primepi GEN x 3 4 49 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 GEN primes long x 3 4 50 qfbclassno D flag 0 ordinary class number of the quadratic order of discriminant D In the present version 2 4 2 a O D1 algorithm is used for D gt 0 using Euler product and the functional equation so D should not be too large say D lt 10 for the time to be reasonable On the other hand for D lt 0 one can reasonably compute qfbclassno D for D lt 10 since the routine uses Shanks s method which is in O D 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 D Important warning For D lt 0 this function may give incorrect
101. library syntax is GEN galoisidentify GEN gal 3 6 42 galoisinit pol den computes the Galois group and all necessary information for com puting the fixed fields of the Galois extension K Q where K is the number field defined by pol 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 nfgaloisconj This is a prerequisite for most of the galoisxxx routines For instance P x76 108 G galoisinit P L galoissubgroups G vector L i galoisisabelian L i 1 vector L i galoisidentify L i The output is an 8 component vector gal gal 1 contains the polynomial pol gal pol 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 e is an integer and q p gal mod 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 132 gal 8 co
102. 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 In 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 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 int
103. 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 If optional parameter o is given it is assumed to be a multiple of the order used to limit the search space for instance o eulerphi n This o may be given as a factorization matrix which is especially useful if many orders are to be computed for the same n use o factor eulerphi n thus factoring n only once The library syntax is GEN znorder GEN x GEN o NULL Also available is GEN order GEN x 3 4 74 znprimroot n returns a primitive root generator of Z nZ whenever this latter group is cyclic n 4 or n 2p or n p where p is an odd prime and k gt 0 If the group is not cyclic the result is undefined If n is a prime then the smallest positive primitive root is returned This is no longer true for composites Note that this function requires factoring n and p 1 for each prime divisor p of n in order to determine the exact order of elements in Z nZ this is likely to be very costly if n is large The library syntax is GEN ggener GEN n 107 3 4 75 znstar n gives the structure of the multiplicative group Z nZ as a 3 component row vector v where v 1 p n is the order of that group v 2 is a k component row vector d of integers d i such that dli gt 1 and dli d i 1 for i gt 2 and Z nZ T Z d iZ and v 3 is a k component row vector giving
104. nf GEN x GEN y flag 0 and GEN idealdivexact GEN nf GEN x GEN y flag 1 3 6 54 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 GEN idealfactor GEN nf GEN x 3 6 55 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 bZk 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 GEN idealhnfO GEN nf GEN a GEN b NULL Also available is GEN idealhermite GEN nf GEN a 3 6 56 idealintersect nf A B intersection of the two ideals A and B in the number field nf The result is given in HNF nf nfinit x 2 1 idealintersect nf 2 x 1 42 2 0 o 2 This function does not apply to general Z modules e g orders since its arguments are replaced by the ideals they generate The following script intersects Z modules A and B given by matrices of compatible dimensions with integer coefficients ZM_intersect A B 1 my Ker matkerint concat A B
105. now 27 roots roots Of the associated Weierstrass equation tate u u v in the notation of Tate wW Mestre s w this is technical Warning as for the orientation of the basis of the period lattice beware that many sources use the inverse convention where wa w1 has positive imaginary part and our wa is the negative of theirs Our convention T w1 w2 ensures that the action of PSLa is the natural one la b c d T ar b cr d aw bw2 cw1 dw instead of a twisted one Our tau is 1 7 in the above inverse convention 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 The use of member functions is best described by an example E ellinit 0 0 0 0 11 The curve y z 1 7 E a6 12 1 7 E c6 108 13 864 E disc 4 432 Some functions in particular those relative to height computations see ellheight require also that the curve be in minimal Weierstrass form which is duly stressed in their description below This is achieved by the function ellminimalmodel Using a non minimal model in such a routine will yield a wrong result 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 The requirements are given as the minimal one
106. number is printed in e format 2 3 3 Intmods t_INTMOD to create the image of the integer a in Z bZ for some non zero integer b type Mod a b not afb Internally all operations are done on integer representatives belonging to 0 5 1 Note that this type is available for convenience not for speed each elementary operation involves a reduction modulo b If x is a t_INTMOD Mod a b the following member function is defined x mod return the modulus b 2 3 4 Rational numbers t_FRAC all fractions are automatically reduced to lowest terms so it is impossible to work with reducible fractions To enter n m just type it as written As explained in Section 3 1 4 floating point division is not performed only reduction to lowest terms Note that rational computation are almost never the fastest method to proceed in the PARI implementation each elementary operation involves computing a gcd It is generally a little more efficient to cancel denominators and work with integers only P Pol vector 1073 i 1 1 big polynomial with small rational coeffs P 2 time 1 392 ms c content P c 2 P c 72 same computation in integers time 1 116 ms And much more efficient but harder to setup to use homomorphic imaging schemes and modular computations As the simple exemple below indicates if you only need modular information it is very much worthwile to work with t_INTMODs directly rather than deal with t_
107. of f The library syntax is GEN reduceddiscsmith GEN f 3 7 13 polhensellift x y p e given a prime p an integral polynomial x whose leading coefficient is a p unit a vector y of integral polynomials that are pairwise relatively prime modulo p and whose product is congruent to x modulo p lift the elements of y to polynomials whose product is congruent to x modulo p The library syntax is GEN polhensellift GEN x GEN y GEN p long e 3 7 14 polhermite n a xP nt Hermite polynomial H evaluated at a x by default i e N ET 32 e EE Hx 1 e aa The library syntax is GEN polhermite_eval long n GEN a NULL 3 7 15 polinterpolate za ya x amp e given the data vectors za and ya of the same length n xa containing the z coordinates and ya the corresponding y coordinates this function finds the interpolating polynomial passing through these points and evaluates it at x If ya is omitted return the polynomial interpolating the i xa 7 If present e will contain an error estimate on the returned value The library syntax is GEN polint GEN xa GEN ya NULL GEN x NULL GEN e NULL 163 3 7 16 polisirreducible pol pol being a polynomial univariate in the present version 2 4 2 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 GEN gisirreducible GEN po
108. of this default allow gp to use less rigid TeX formatting commands in the logfile This default is only taken into account when log 3 The bits of TeXstyle have the following meaning 2 insert right left pairs where appropriate 4 insert discretionary breaks in polynomials to enhance the probability of a good line break 2 12 34 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 including the time for printing the results see and 54 2 13 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 case sensitive For example Q is not 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 cause 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 12 30 2 13 1 command gp on line hel
109. of x and y on their sizes and also on the size of x y From this data PARI works out the right precision for the result Even if it is working in calculator mode gp where there is a notion of default precision which is only used to convert exact types to inexact ones In particular if an operation involves objects of different accuracies some digits will be dis regarded 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 0 E 28 1 E 100 1 0 E 28 0 E100 1 92 0 E100 As an exercise if a 27 100 why do a O anda 1 differ The second principle is that PARI operations are in general quite permissive For instance taking the exponential of a vector should not make sense However it frequently happens that one wants to apply a given function to all elements in a vector This is easily done using a simple loop but in fact PARI assumes that this is exactly what you want to do when you apply a scalar function to a vector Taking the exponential of a vector will do just that so no work is necessary Most transcendental functions work in the same way In the same spirit when objects of different types are combined they are first automatically mapped to a suitable ring where the co
110. polyno mial use x D 1 9 x1 to compute it evaluated use 1 Tajn x 1 4 _ In the evaluated case the algorithm can deal with all rational values a otherwise it assumes that a 1 is invertible for all d n If this is not the case use subst polcyclo n x a The library syntax is GEN polcyclo_eval long n GEN a NULL The variant GEN polcy clo long n long v returns the n th cyclotomic polynomial in variable v 3 7 10 poldegree x v degree of the polynomial x in the main variable if v is omitted in the variable v otherwise The degree of 0 is a fixed negative number whose exact value should not be used The degree of a non zero scalar is 0 Finally when x is a non zero polynomial or rational function returns the ordinary degree of x Raise an error otherwise The library syntax is long poldegree GEN x long v 1 where v is a variable number 3 7 11 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 GEN poldiscO GEN pol long v 1 where v is a variable number 3 7 12 poldiscreduced 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
111. redefining the variable The previous definition is lost of course Important technical note Built in function are a different matter since they are read only you cannot overwrite their default meaning and they use features not available to user functions In the present version 2 4 2 it is not possible to assign a built in function to a variable nor to use a built in function name to create an anonymous function For instance the built in function name sin does not evaluate to a valid t_CLOSURE to define a function evaluating to the built in sin function you must write x gt sin x explicitly 34 2 7 2 Function call Default arguments You may now call your function as in 1 2 supplying values for the formal variables The number of parameters actually supplied may be less than the number of formal variables in the function definition An uninitialized formal variable is given an implicit default value of the integer 0 i e after the definition nil eee O eee you may call 1 2 supplying values for the two formal parameters or for example 2 equivalent to 2 0 fO f 0 0 f 3 f 0 3 Empty argument trick More generally the argument list is filled with user supplied values in order A comma or closing parenthesis where a value should have been signals we must use a default value When no input arguments are left the defaults are used instead to fill in remaining formal parameters Of course y
112. returns a matrix having only integral entries having the same Q image as x such that the GCD of all its n x n subdeterminants is coprime to p hence equal to 1 when p is equal to 0 If p 1 this function returns a matrix whose columns form a basis of the lattice equal to 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 GEN matrixqzO GEN x GEN p NULL 3 8 38 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 GEN matsize GEN x 175 3 8 39 matsnf X flag 0 if X is a singular or non singular 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 UX V is the diagonal matrix D Otherwise output only the diagonal of D 2 generic input if set allows polynomial entries in which case the input matrix must be square Otherwise assume that X has integer coefficients with arbitrary shape 4 cleanup if set cleans up the output This means that elementary divisors equal to 1 will be de
113. say x pushes a new value on a stack associated to the name x possibly empty at this point which is popped out when the control flow leaves the scope Evaluating x in any context possibly outside of the given block always yields the top value on this dynamic stack GP implements both lexical and dynamic scoping using the keywords my lexical and local dynamic x 0 fQ x go my x 1 fO h local x 1 fO The function g returns 0 since the global x binding is unaffected by the introduction of a private variable of the same name in g On the other hand h returns 1 when it calls f O the binding stack for the x identifier contains two items the global binding to 0 and the binding to 1 introduced in h which is still present on the stack since the control flow has not left h yet The names are borrowed from the Perl scripting language 30 2 6 2 Scoping rules Named parameters in a function definition as well as all loop indices have lexical scope within the function body and the loop body respectively p 0 forprime p 2 11 print p p Ml prints 0 at the end x 0 f x x f 1 Ml returns 2 and leave global x unaffected 0 If you exit the loop prematurely e g using the break statement you must save the loop index in another variable since its value prior the loop will be restored upon exit For instance for i 1 n if ok i break J3 if i gt n return failure is
114. size using histsize 2 2 3 Special editing characters A GP program can of course have more than one line Since your commands are executed as soon as you have finished typing them there must be a way to tell gp to wait for the next line or lines of input before doing anything There are three ways of doing this The first one is 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 You can type a anywhere It is interpreted as above only if apart from ignored whitespace characters it is immediately followed by a newline For example you can type 3 4 instead of typing 3 4 The second one is a variation on the first and is mostly useful when defining a user function see Section 2 7 since an equal sign can never end a valid expression gp disregards a newline immediately following an a 123 1 123 The third one is in general much more useful and uses braces and An opening brace 4 signals that you are typing a multi line command and newlines are ignored until you type a closing brace There are two important but easily obeyed restrictions first braces do not nest second inside an open brace close brace pair all input lines are concatenated suppressing any newlines Thus al
115. square integer congruent to 0 or 1 modulo 4 The command w quadgen d assigns to w the canonical generator for the integer basis of the order of discriminant d i e w Vd 2 if d 0mod 4 and w 1 Vd 2 if d 1mod4 The name w is of course just a suggestion but corresponds to traditional usage You can use any variable name that you like but quadgen d is always printed as w regardless of the discriminant So beware two t_QUADs can be printed in the same way and not be equal however gp will refuse to add or multiply them for example Since the order is Z wZ any other element can be input as x y w for some integers x and y In fact you may work in its fraction field Q Vd and use t_FRAC values for x and y 2 3 9 Polmods t_POLMOD exactly as for intmods to enter z mod y where x and y are polyno mials type Mod x y not x4 y 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 Q or finite fields Note that this type is available for convenience not for speed each elementary operation involves a reduction modulo y If p is a t_POLMOD the following members functions are defined p pol return a representative of the polynomial class of minimal degree p mod return the modulus Important remark Mathematically
116. syntax is GEN ellsigma GEN E GEN z long flag long prec 114 3 5 29 ellsub 21 22 difference of the points z1 and z2 on the elliptic curve corresponding to E The library syntax is GEN subell GEN E GEN z1 GEN z2 3 5 30 elltaniyama E computes the modular parametrization of the elliptic curve E where E is an sell as 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 ayu az 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 x which is implicitly understood to be equal to exp 2imz It is assumed that the curve is a strong Weil curve and that the Manin constant is equal to 1 The equation of the curve E must be minimal use ellminimalmodel to get a minimal equation The library syntax is GEN elltaniyama GEN E long precdl 3 5 31 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 Ef must be an ell as output by ellinit
117. the specific use of the gp programmable calculator If you have GNU Emacs and use the PariEmacs package you can work in a special Emacs shell described in Section 2 16 Specific features of this Emacs shell are indicated by an EMACS sign in the left margin 2 1 1 Startup To start the calculator the general command line syntax is gp s stacksize p primelimit files where items within brackets are optional The files argument is a list of files written in the GP scripting language which will be loaded on startup The ones starting with a minus sign are flags setting some internal parameters of gp or defaults See Section 2 12 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 If a preferences file to be discussed in Section 2 14 is found gp then reads it and executes the commands it contains This provides an easy way to customize gp The files argument is processed right after the gpre A copyright banner then appears which includes the version number and a lot of useful tech nical information After the copyright the computer writes the top level help information some initial defaults and then waits after printing its prompt which is by default Whether ex tended on line help and line editing are available or not
118. the fixed field and x is a root of P 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 see Section 2 5 3 Example G galoisinit x74 1 131 galoisfixedfield G G group 2 2 12 x72 2 Mod x73 x x 4 1 x 2 y x 1 x 2 y x 1 computes the factorization 1 1 x 2x 1 2 Y 2x 1 The library syntax is GEN galoisfixedfield GEN gal GEN perm long flag long v 1 where v is a variable number 3 6 41 galoisidentify gal gal being be a Galois field as output by galoisinit output the isomorphism class of the underlying abstract group as a two components vector o i where o is the group order and 7 is the group index in the GAP4 Small Group library by Hans Ulrich Besche Bettina Eick and Eamonn O Brien This command also accepts subgroups returned by galoissubgroups The current implementation is limited to degree less or equal to 127 Some larger easy orders are also supported The output is similar to the output of the function IdGroup in GAP4 Note that GAP4 IdGroup handles all groups of order less than 2000 except 1024 so you can use galoisexport and GAP4 to identify large Galois groups The
119. the library you still need to send at least an empty vector coded as NULL 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 nrpid you must give some values as well for c and c2 and provide a vector c c2 nrpid Note also that you can use an nf instead of P which avoids recomputing the integral basis and analogous quantities 3 6 8 bnfcertify bnf bnf being as output by bnfinit checks whether the result is correct i e whether it is possible to remove the assumption of the Generalized Riemann Hypothesis It is correct if and only if the answer is 1 If it is incorrect the program may output some error message or loop indefinitely You can check its progress by increasing the debug level The library syntax is long certifybuchall GEN bnf 3 6 9 bnfclassunit P flag 0 tech this function is DEPRECATED use bnfinit Buchmann s sub exponential algorithm for computing 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 integer coefficients The result of this function is a vector v with many components which for ease of presentation is in fact output as a one column matrix It is not a bnf you need bnfinit for that First we describe the default behaviour flag 0 v 1 is equal to the polynomial P v 2 is the 2 component
120. the vector of columns comprising the matrix is return e a character string a vector of individual characters is returned e 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 In this last case Vec is the reciprocal function of Pol and Ser respectively The library syntax is GEN gtovec GEN x NULL 72 3 2 15 Vecrev x as Vec except when x is a polynomial In this case Vecrev is the reciprocal function of Polrev the coefficients of the vector start with the constant coefficient of the polynomial and the others follow by increasing degree The library syntax is GEN gtovecrev GEN x NULL 3 2 16 Vecsmall x transforms the object x into a row vector of type t_VECSMALL This acts as Vec but only on a limited set of objects the result must be representable as a vector of small integers In particular polynomials and power series are forbidden If x is a character string a vector of individual characters in ASCII encoding is returned Strchr yields back the character string The library syntax is GEN gtovecsmall GEN x NULL 3 2 17 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 p
121. to decide whether the element a in K is the norm of some x in the extension L K The output is a vector x q where a Norm x x q The algorithm looks for a solution x which is an S integer with S a list of places of K containing at least the ramified primes the generators of the class group of L as well as those primes dividing a If L K is Galois then this is enough otherwise flag is used to add more primes to S all the places above the primes p lt flag resp p flag if flag gt 0 resp flag lt 0 The answer is guaranteed i e a is a norm iff q 1 if the field is Galois or under GRH if S contains all primes less than 12 log disc M where M is the normal closure of L K If rnfisnorminit has determined or was told that L K is Galois and flag 0 a Warning is issued so that you can set flag 1 to check whether L K is known to be Galois according to T Example bnf bnfinit y 3 y 2 2xy 1 p x 2 Mod y 2 2 y 1 bnf pol T rnfisnorminit bnf p rnfisnorm T 17 checks whether 17 is a norm in the Galois extension Q 8 Q a where a a 2a 1 0 and B a 2a 1 0 it is The library syntax is GEN rnfisnorm GEN T GEN a long flag 3 6 144 rnfisnorminit pol polrel flag 2 let K be defined by a root of pol and L K the extension defined by the polynomial polrel As usual pol can in fact be an nf or bnf etc if pol has degree 1 the base field is Q polrel is also
122. vg a is equal to the exponent of p in x and for all other prime ideals vola gt 0 This generalizes idealappr nf x 0 since zero exponents are allowed Note that the algorithm used is slightly different so that idealappr nf idealfactor nf x may not be the same as idealappr nf x 1 The library syntax is GEN idealapprO GEN nf GEN x long flag 3 6 51 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 Vo b Yo gt Volx for all prime ideals in x and v b gt 0 for all other p The library syntax is GEN idealchinese GEN nf GEN x GEN y 3 6 52 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 is an integral ideal coprime to y The library syntax is GEN idealcoprime GEN nf GEN x GEN y 135 3 6 53 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 GEN idealdivO GEN nf GEN x GEN y long flag Also available are GEN idealdiv GEN
123. were assigned into variables In addition the value of the seq is printed if the line does not end with a semicolon 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 only this one is evaluated 15 2 2 2 The gp history This is not to be confused with the history of your commands maintained by readline The gp history contains the results they produced in sequence More precisely several inputs act through side effects and produce a void result for instance a print statement or a for loop The gp history consists exactly of the non void results The successive elements of the history array are called 1 2 As a shortcut the latest computed expression can also be called the previous one the one before that and so on The total number of history entries is When you suppress the printing of the result with a semicolon it is still stored in the history but its history number will not appear either It is a better idea to assign it to a variable for later use than to mentally recompute what its number is Of course on the next line you may just use This history array is in fact better thought of as a queue its size is limited to 5000 entries by default after which gp starts forgetting the initial entries So 1 becomes unavailable as gp prints 5001 You can modify the history
124. whereas 3 24 X 1 7 2 X 2 roun xX X An important use of round is to get exact results after an approximate computation when theory tells you that the coefficients must be integers The library syntax is GEN roundO GEN x GEN e NULL Also available are GEN grnd toi GEN x long e and GEN ground GEN x 3 2 45 simplify x this function simplifies x as much as it can Specifically a complex or quadratic number whose imaginary part is an exact 0 i e not an approximate one as a 0 3 or 0 E 28 is converted to its real part and a polynomial of degree 0 is converted to its constant term Simplifications occur recursively This function is especially useful before using arithmetic functions which expect integer argu ments x 1 y y 41 1 divisors x xxx divisors not an integer argument in an arithmetic function type x 2 t POL type simplify x 13 t_INT Note that GP results are simplified as above before they are stored in the history Unless you disable automatic simplification with Xy that is In particular type 1 94 t_INT The library syntax is GEN simplify GEN x 3 2 46 sizebyte x outputs the total number of bytes occupied by the tree representing the PARI object x The library syntax is long taille2 GEN x Also available is long taille GEN x returning a number of words 3 2 47 sizedigit x outputs a quick bound for the number of decimal digits of the compon
125. x 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 quite technical and the calling interface may change they are not documented yet Look at the code in basemath alglin1 c 3 8 21 mathnfmod z 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 GEN hnfmod GEN x GEN d 3 8 22 mathnfmodid z d outputs the upper triangular Hermite normal form of x concate nated with d times the identity matrix Assumes that x has integer entries The library syntax is GEN hnfmodid GEN x GEN d 3 8 23 matid n creates the n x n identity matrix The library syntax is GEN matid long n 3 8 24 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 of any type If flag 0 use standard Gauss pivot If flag 1 use matsupplement The library syntax is GEN matimageO GEN x long flag Also available is GEN image GEN x flag 0 3 8 25 matimagecompl z
126. 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 y y 2 1 these two are OK factornf x 2 Mod z z72 1 y 2 1 xxx factornf inconsistent data in rnf function factornf x 2 z y 2 1 xxx factornf incorrect variable in rnf function The library syntax is GEN polfnf GEN x GEN t 3 6 39 galoisexport gal flag gal being be a Galois field as output by galoisinit export the underlying permutation group as a string suitable for no flags or flag 0 GAP or flag 1 Magma The following example compute the index of the underlying abstract group in the GAP library G galoisinit x 6 108 s galoisexport G 2 Group 1 2 3 4 5 6 1 4 2 6 3 5 extern echo IdGroup s gap q 43 6 1 galoisidentify G 44 6 1 This command also accepts subgroups returned by galoissubgroups The library syntax is GEN galoisexport GEN gal long flag 3 6 40 galoisfixedfield gal perm flag Lv yy gal being be a Galois field as output by ga loisinit and perm an element of gal group or a vector of such elements computes the fixed field of gal by the automorphism defined by the permutations perm of the roots gal roots P is guaranteed to be squarefree modulo gal p If no flags or flag 0 output format is the same as for nfsubfield returning P x such that P is a polynomial defining
127. 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 test 1 x 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 Use the op operators as often as possible since they make complex assignments more legible one needs not parse complicated expressions twice to make sure they are indeed identical Compare v i j 1 v i j 1 1 gt v i j 1 M i i j M i i j 2 gt M i i 3 2 Remark Less important but still interesting The and op operators are slightly more efficient a 10 76 i 0 while i lt a i i 1 time 365 ms i 0 while i lt a i time 352ms For the same reason the shift operators should be preferred to multiplication a 1 lt lt 10 5 i 1 while i lt a i i 2 time 1 052 ms i 1 while i lt a i lt lt 1 time 617 ms 26 2 5 Variables and symbolic expressions In this section we use variable in the standard mathematical sense symbols representing algebraically independent elements used to build rings of polynomials and power series and explain
128. 00 PLOtCDOX pes kasa ses 200 ploteliPp ses saas a hk eae Bee 200 plotcolor ss os eoe 84404 e a 51 200 P O COPY 2 2 sab eee eee ee ees 200 PlOtcursor ia Oe ee E 200 plotdrawW 2 24 bee ee be Re ee 200 PLOCE sop Pardina pon Be ee ae a 64 201 plothraw 2 26 6 eb eee ee ee ee es 202 plothsizes oo eee we ee Be es 202 PLOCINIG seresa d ek ee ke a 202 plotkill sse sosy be eee ew bee Bs 203 PLOCIINGS ica Gras Gace aon 203 plotlinetype s sesa eroa rausa s 203 plotmove 2 24 se s weie e eds 203 Plotpoint e si ee drade ittak 203 plotpointsize 203 plotpointtype 203 PLOTEDOX s o ieee a oe eet we ws hh 203 plotrecth ss 224444 satiwdi 201 204 plotrecthraw 204 plotrline 204 plotrmove s sosog aoa gi a a En 204 PLOCEPOINT S y i a e e ee a 204 235 plotscalle 64 4044 ae ses 201 204 plotstring e s s ioe r ea Ss 42 204 pPlotterm e doce e o Re e 42 POQO eu a el pointell sarerea wee ee we eo 116 POM s he Sark a pe AA 64 Pol sce ee Ba oe OS Se ih ELE E 20 71 polchebyshev 162 165 polchebyshevl 162 165 polchebyshev2 162 polchebyshev_eval 162 polcoeff se rore yee eh ne es 74 162 POLCOGTIO ra wo Hid eee t Grime Ge a amp 162 polcompositum 149 polcompositumO 150 POUCY CUS sr a at o ee Be 162 polcyclo_eval 162 poldegree 2 2 ii co ee sd asas 163 POVGISG area A oe Ge
129. 00000000 2 3 2 Real numbers t_REAL after an optional leading or type a number with a decimal point Leading zeroes may be omitted up to the decimal point but trailing zeroes are important your t_REAL is assigned an internal precision which is the supremum of the input precision and the default precision expressed in decimal digits For example if the default precision is 28 digits typing 2 yields a precision of 28 digits but 2 0 0 with 45 zeros gives 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 As usual en is interpreted as x10 for all integers n Since the result is converted to a t_REAL you may often omit the decimal point in this case 6 02 E 23 or 1e 5 are fine but e10 is not By definition 0 E n returns a real 0 of exponent n whereas 0 returns a real 0 of default precision of exponent realprecision see Section 1 3 7 behaving like the machine epsilon for the current default accuracy any float of smaller absolute value is undistinguishable from 0 17 Note on output formats A zero real number is printed in e format as 0 Exx where xx is the usually negative decimal exponent of the number cf Section 1 3 7 This allows the user to check the accuracy of that particular zero 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
130. 000000000000000000000000 1 000000000000000000000000000 An endpoint equal to 00 is coded as the single component vector 1 You are welcome to set e g oo 1 or INFINITY 1 then using 00 oo INFINITY etc will have the expected behaviour oo 1 for clarity intnum x 1 00 1 x 2 2 1 000000000000000000000000000 In basic usage it is assumed that the function does not decrease exponentially fast at infinity intnum x 0 00 exp x exp exponent expo overflow We shall see in a moment how to avoid the last problem after describing the last argument tab which is both optional and technical The routine uses weights which are mostly independent of the function being integrated evaluated at many sampling points If tab is e a positive integer m we use 2 sampling points hopefully increasing accuracy But note that the running time is roughly proportional to 2 One may try consecutive values of m until they give the same value up to an accepted error If tab is omitted the algorithm guesses a reasonable value for m depending on the current precision only which should be sufficient for regular functions That value may be obtained from intnumstep and increased in case of difficulties e a set of integration tables as output by intnuminit they are used directly This is useful if several integrations of the same type are performed on the same kind of interval and func tions for a give
131. 1 n then x is isomorphic to b1e1 B D bnen a1A1 0 BAanAn 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 GEN nfsmith GEN nf GEN x 3 6 110 nfsolvemodpr nf a b pr solution of a x b in ZK pr where a is a matrix and ba column vector and where pr is in modpr format see nfmodprinit The library syntax is GEN nfsolvemodpr GEN nf GEN a GEN b GEN pr 3 6 111 nfsubfields pol d 0 finds all subfields of degree d of the number field defined by the monic integral polynomial pol 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 routine uses J Kliiners s algorithm in the general case and B Allombert s galoissubfields when nf is Galois with weakly supersolvable Galois group The library syntax is GEN subfieldsO GEN pol long d 3 6 112 polcompositum P Q flag 0 P and Q being squarefree polynomials in Z X in the same variable outputs the simple factors of the tale Q algebra A Q X Y P X Q Y The factors are given by a list of polynomials R in Z X associated to the number field Q X R and sorted by increasing degree with respect to lexicographic ordering for factors of equal d
132. 1 43 X lift x Mod 1 3 Mod 2 3 44 x 2 lift x Mod y y 2 1 Mod 2 3 5 y x Mod 2 3 do you understand this one lift x Mod y y 2 1 Mod 2 3 x 6 Mod y y 2 1 x Mod 2 y 2 1 The library syntax is GEN 1iftO GEN x long v 1 where v is a variable number Also available is GEN 1ift GEN x corresponding to 1ift0 x 1 3 2 35 norm zx 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 GEN gnorm GEN x 76 3 2 36 norml2 square of the L norm of x More precisely if x is a scalar norm12 1 is defined to be x conj a If x is a row or column vector or a matrix norm12 x is defined recursively as norm12 x where x run through the components of x In particular this yields the usual D xi resp X x z if x is a vector resp matrix with complex components norml2 1 2 3 vector 1 14 norml2 1 2 3 4 matrix 1 30 norml2 I x 43 x 24 1 norml2 1 2 3 4 5 6 recursively defined 4 91 The library syntax is GEN gnorm12 GEN x 3 2 37 numerator x numerator of x The meaning of this is clear when x is a rational num
133. 11 gin g cia e bk a as 76 gisfundamental 97 gisirreducible 163 gisprite 60 reka 98 gispseudoprime 99 SISSQUaTO fa ghd SG oh we dat ea gS 99 gissquareall ssi eccer tersa 99 gissquarefree 99 gkronecko e saose ld de 100 glambdak og a e a 160 SlcmO sope be ge ae Ae e eed beg 100 Clength is oak dead gine os BSS 76 gligamma eres a Ge Ge ee a 85 global comme rs a 210 A E hat sie ee ghd hd et ae sh 85 A A 68 OMIM ssaa ee bg eee Ha ES eh ag 68 CMOd snc hae Gr AN 66 SMOQU O caca ie we ee wes 70 BM kek be ele hp ae A 100 MUS seo eta a ese ee a o 65 SMUIIN 2s ge eR a Re He s 68 ONES fe ee ea eee dane we Oe e 64 SNOXtPYIMS oia aaa dl Gri GR dey 100 ENOM a ha ewe Wad See Sab eb es 76 ONO oo Baw ER es A Oe e ors gntumbdid stede eee eo cee Bd 100 gomega 2a bi ck PRE das 100 BP gas tave kane e bebe be eee ba 5 GP gin ei Ge uke oe G eg ee 5 BP eeaeee oS o a Ete ee Bee 13 BPC o 6 se bk wn Fp Ree de bee oe wo 5 pphelp retede de ee Be a eG 56 Sphi eee 5 owe RS GR ee He 92 Bpolvar e be ke ee eee ds eee bla 4 80 SpOlVIlOR di gia Soe ad wb eae ee 86 EPON A a Se ae he ao ae eS 67 82 EDIC se caas bee Rea 13 28 48 52 58 GPR ie Saree Pe ew Pa bee me was 59 BPLEC ak Bug ke ok Be tee Be St 78 PYecprime 6 ses see sa bende as 101 PEL ig chek at oD weet Se RG eee as 86 SPWYIteDIM s aea aok a ea we hh ate a ag 215 gp_readvec_file 212 graphcolormap
134. 122 129 DATINI ae los popas aeg 103 116 122 DOTIDITO ds ebb e a o ES G 123 bnfisintnorm 123 124 bnfisnorm escocia wah ade es 124 bnfisprincipal 103 123 124 bHRETSSUTIT eco mamo A ee a 124 bnfisunit 124 DRATMAke sds os bo wk Be ae eK Boe e 125 bnfnarrow 104 125 bnfnewprec ooo o 148 D EZ osos saone o eee eB 125 bHfSsignunit s ss satsa Pesa me ee 125 DATSUN ses u ir a e ae 125 126 DAFUN a 4G oa ek ey Ges a Oe Ey SHS a 126 ONT ee a ee ea ee Ree 39 116 DOFC ASS sus sop mga al eee tw x 127 bHrelassOv Liam e 127 bnrelassno o s ion Boek ae 127 129 bnrclassnolist 127 137 bnrconductor ocara sokin enaa 127 bnrconductorofchar 128 DOTATSC arsle pon sagos Boe e eee 128 129 DATATSCO sa otoa a a de 128 bnrdisclist sens rss 440 84 128 137 b rdis l isto ne he eee a eS eS S 129 bnrinit 22 2 ee eee ee 127 129 DACINTEO tose te a 8 8 ote Oe A ce ae a 129 bnrisconductor 129 bnrisprincipal 123 129 DOTEA 2 a5 se wee ah Pte we ps 126 127 bnrnewprec 0 0 148 bnrrootnumber 129 130 bnretark 6 geek ae aS 105 130 159 boolean operators 68 DOUNdEact ss raid en ea ES 93 brace characters 0 4 16 break LOOPr s ecos ww eS g BRS 44 214 break ra aie be oe eh ee 44 205 Breuil 2d usa eS dw ee 109 DACHU sows oe aoe PADS we Re SS 126 Buchmann 120 121 122 139 162
135. 14 power series o TsO 21 POWETMMBS oe eon ek Se Rk 66 81 PONEN J se ft Se ein Be ee ee Bee ts 103 Pl eee hae RERES RS RE REE AT amp 139 procdl ces eae YG ee ee ees 81 PTECISION s 08 i Ee Ge 80 precision 2 4 4 susa erws 77 78 precisionO 0 78 precprime oo 101 preferences file 13 47 58 prettymatriz format 0 52 prettyprint format icr ae wiri sana ia 52 prettyprinter 52 53 Prid ake ew eos whee Artes OP e 39 PELI cos Ce ok See cls Bk he et lh ee es 101 primede lt a sar nesas wwe ee eo a 139 primeform s sss sssi esa sreske 103 primelimit s su sor aai po ia 53 151 152 primepi ss ser eae ek A 101 PE MOS 2 2 eek KR Re E Be ees 101 principal ideal 124 139 principalideal 139 principalidele 141 PANG abr dom aa a Ge 41 42 211 Print one a0 4 8 by a ds 211 PEAMtp a d dh ead a oid Bie es 211 printpl fedea eok Beek aoe ek Sn es 211 PE INTLEX sraa rosaa PG SEES ZA 211 PLOOY pea mar eh we bee eee E 24 Prode ek ee ooh ee ek a 193 prodeuler 22 c s swear ese eee 193 prodinf oos sinsa aoa Ee a ee A 194 pr rodinf i ua A a E da 194 product 44 aaie aa h 2 65 PrOdUIC see bce oa ege a bee a 193 PrOSTAMMIMS uc ale eh aE 205 236 projective module o eee ee 118 PTOMPt codigos eae BE a aes 53 prompt Cont s s sa ceas a Gee a 53 PSdrAW maison ed E 204 pseudo basis o 118 pseudo matrig 2 118
136. 142 H dISC O 6 sae aa aS oe 142 N AIVOUC as 2246446 ge oa dae 24 142 nfdivrem 0 0 143 e s sk ae PEG SERS SS 142 NfEICGIVEUG sore ama a eee ee ae 142 nfeltdivmodpr s a iai Bice due Bs aa 142 nfeltdivrem o s 4 84 404 e Hee asn 143 nfeltmod 2 see eee ee ee 143 NfeMtMUL ceca Gee wae a es 143 nfeltmulmodpr 143 NESTEPOM dui son ee ae ae aS 143 nfeltpowmodpr 143 nfeltreduce 143 nfeltreducemodpr 143 nfeltval semea bee oe Ge doe ees 143 nifacton ro siess gs 93 131 144 148 234 nffactormod s eos ecs bas e ea a 144 nfgaloisapply 144 nfgaloisconj 132 144 MENSPMAGC fee iid a A ey 145 nfhermitemod 146 DEOhLIDETE do dk ie E de ee a Be 145 nfhilbertO 45 4248 4 4 4 4 6 644 145 D DDE o ow wae we o Ree We we 145 nfhnfmod gt os e ses e e e sonaa ook E 145 Mfinit yese pasne ss 116 132 146 151 DEAD CO Ges ga aaae a 147 ntisideal ais tas ses ee 147 NFISING s acios toe ma eae e Fee a 148 NEISISOM s e aos iia la es 148 nfkermodpr 0 148 MEMOG s ma d k e p a Be 143 nfmodprinit 142 143 148 nfnewprec cc o oo oo 146 148 nfreducemodpr 143 NETFOOUS 4 Se gaa a e 148 NEPOOUSOEL og Gok ce a RR a 148 pf Smithe ice cate oes Al cay a eS 149 DESNE sor s rne gu are Ss dy Gee eee ens 148 nfsolvemodpr 149 Hfsubtield osea ee a ewe 131 nfsubfields
137. 18 136 145 172 173 Hermite 24 64 28 6 eaa e RY Ea 163 hess meo Dou dont we a a ea 172 BILO 06 5 eros e ane eS oe ee h A 97 Hilbert class field 104 Hilbert matrix sr sopa acp oa oh amp ie i 172 Hilbert symbol 97 145 A A O E 97 E 946 ae das kee ee De we 42 HTSESUZO se gi as ae a eee ae weld 16 51 DAE a 8 a oo we Eh ees A a 73 Dafal ia e e A A 173 Hafod seriada a eek 173 hnfmodid 173 Hotevalara eo sedans Gri a e 161 Hurwitz class number 102 Hyper ee ace ge a eS 85 I Dh ec rana wh ee we 19 82 ibessel kad cuted ok wd a 83 WO COL AUS Gets aries ip Gee ane oes tae 118 Ideal a o oh Goo a ae e 117 idealadd cuicos aaa a aw BOs 135 idealaddtoone o sae sonsos su Bae 135 idealaddtooneO 135 idealappT 4 oo cc 88 dnra 135 idealapprO lt s sc cesca eee ewe 135 idealchinese 135 idealcoprime 135 idealdiW p cr eire de ee ork Ges 135 136 idealdivO exiliados wd os 136 idealdivexact 136 idealfactor s ioeo 2 whe Se we ee 136 idealhermite ara soaa ach a woes 136 idealini das don Wee a 6 8 136 154 idealhnfO 4 2 sacs al ade Sa ee 4 136 idealintersect 136 173 idealinv 136 146 ideallist 136 137 ideallistO 0 L37 ideallistarch sss sosesko 137 138 ideallllred cuco Desa a 140 ideallog sa s 2 whee s n 138 140 Vdealmin is ask ee a ge ws 138 i
138. 2 A right shift of an integer x by n corresponds to a Euclidean division of x by 2171 with a remainder of the same sign as x hence is not the same in general as 112 The library syntax is GEN gshift GEN x long n 3 1 14 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 shifts Euclidean division takes place when n lt 0 hence if x is an integer the result is still an integer The library syntax is GEN gmul2n GEN x long n 3 1 15 sign x sign 0 1 or 1 of x which must be of type integer real or fraction The library syntax is GEN gsigne GEN x 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 Error if x is empty The library syntax is GEN vecmax GEN x 68 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 Error if x is empty The library syntax is GEN vecmin GEN x 3 1 18 Comparison and boolean operators The six standard comparison operators lt lt gt gt are available in GP The result is 1 if the comparison is true 0 if it is false For the purpose of comparison t_STR objects are strictly larger than any other non string type two t_STR objects are compared using the standard lexicographic order GP acc
139. 2 are positive real numbers which control the execution time and the stack size For a given c1 set ca C to get maximum speed To get a rigorous result under GRH you must take c gt 6 Reasonable values for c are between 0 1 and 2 More precisely the algorithm will assume that prime ideals of norm less than cz log D generate the class group but the bulk of the work is done with prime ideals of norm less than c log D A larger c means that relations are easier to find but more relations are needed and the linear algebra will be harder The default is cy co 0 2 so the result is not rigorously proven The result is a vector v with 3 components if D lt 0 and 4 otherwise The correspond respectively to e v1 the class number e v2 a vector giving the structure of the class group as a product of cyclic groups e v 3 a vector giving generators of those cyclic groups as binary quadratic forms e v4 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 The library syntax is GEN quadclassunitO GEN D long flag GEN tech NULL long prec 3 4 60 quaddisc x discriminant of the quadratic field Q x where x Q The library syntax is GEN quaddisc GEN x 3 4 61 quadgen D creat
140. 22 23 69 169 Matadjoint e ssec 4 saena 169 171 matalgtobasis 141 matbasistoalg 141 Matcompanion i aa Matdet epica e bee a ye 171 233 matdetidt usara aa a ee Se 171 matdiagonal 172 Mateigen cai aa Sie a e E2 matfrobenius 172 Maths Pabi mada ao de Boke A A 47 mathell os scesa toa owa s aa 111 Mathess so eor ge aora ee a eens 172 mathilpert e s s es id aR uk a 172 mathnt Jsi e wince ee ate ale oe 168 172 Mathnt Occ bo lates be ee este aod aes 173 mathnfmod 2 266 6 escor S aa 173 mathnfmodid 173 matid sra cs wi aau ee BEE Se E 173 Matimage o 173 MatimageO sac roaro d en e 173 Matimagecompl 173 matindexrank 173 matintersect 1783 matinverseimage 173 matisdiagonal 174 MAatker care dianas e 174 MAtkerO la e bo ae ae RE ae 174 matkerint 174 MatkerintO 174 matmuldiagonal 174 matmultodiagonal 174 175 Matpascal se sos roe ie E e 175 matgpascal x spi e pa d e a ai e R 175 MAtramkK s ese om se o e aoan G i 4 175 MATLICO s s sec hos eais pa E n aa e Ge 175 o 6 il aa ale Bok Bok E oh T 622 42 Matrix oe ae a e a we Bee E 175 MATE XQZ acia ae 175 MALELXQZO ca ee ae ee ee we 175 MATSIZO e so w 2S aod da Hae s ir s Matsnf 2 6 ewe eae ed ed 175 MatsntO oa eke es eee a GR EE 175
141. 54 a hale ga 109 GREE sesen Sid i ech ay Gee oe te Bee aos 119 difference ss sier famae a aa 64 dilo ce ge von a e 84 ALCAAY ads bow o ee R E aa 92 Gireuler Sa g oma hoe ee a Bs As 92 Dirichlet series 92 130 Giymul aka e eee eee ew e 92 dirzetak oc ew we ee 130 131 GiS s oe eh ee aoa a ii OE 108 119 disci Aue cots ate oo Gee E e 142 Givisors besa wae es 92 205 GiVreM a Gdn ack Ge Gee a ae BG 29 67 GiVSUM e ea s toem ma moade eS 195 ANL eg gme e aa oe Sone eA oe ee ia 61 dynamic scoping 30 E 228 CHO ecg te ig a ye Se eG 50 56 ECM e di 26 bee oe eke Hone 89 95 editing characters 16 CABE o i aop p ee e a eZ Cintl Lomo carr ee RR 84 element_div 142 element_divmodpr 143 element_mul 143 element_mulmodpr 143 element_pow 143 element_powmodpr 143 element_reduce 143 element Val suba we Slee ed 143 Cl toe Betws gk ewe bo 39 108 109 111 CU es rta OS oe AA 111 ellada ceba e de rc i a a a E 109 ellak peenaa eee ewe ewe eR a 109 CUTAN sd seek a ee ee eo 109 oLlap ea Seed Grek a eee ee ot we ha eee S 109 Cllbil se cee 6 Be he A ew ww 109 ellchangecurve 109 110 ellchangepoint 110 ellchangepointinv 110 ellconvertname 110 elldata 4 s co ci e dou e 110 111 114 206 elleisnum 110 elleta ave eye ba A Oe BO
142. 6 5 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 9 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 go 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 of Archimedean components of the relations of the matrix WIB bnf bnf 6 used to contain a permutation of the prime factor base but has been obsoleted It 5 contains the prime factor base i e the list of prime ideals used in finding the relations 6 contains a dummy 0 7 8 bnf bnf 8 is a vector containing the classgroup bnf clgp as a finite abelian group the regulator bnf reg a 1 used to contain an obsolete check number the number of roots of unity and a generator bnf tu the fundamental units bnf fu or bnf nf is equal to the number field data nf as would be given by nfinit bnf 9 is a 3 element row vector used in bnfisprincipal only and obtained as follows Let D UWV obtained by applying the Smith normal form algorithm to the matrix W bnf 1 and let U be the reduction of U modulo D The first elements of the factorbase are given in terms of bnf gen by the columns of U wi
143. ACY co rm ura Pw a a 9 ACOs cups a ee 82 ACOSH Bk in e Ke oe 82 addell wai A4 eb 44 85 64 4a eS 109 addhelp oosa tine o aro e inad a 42 208 addprimes 44 89 151 152 AGG ek e er aS SE Gee i Gl adjoint matrix 171 OGM ce bee ee Poe ele a Pace ee es 82 akell user do ces Moe ee 109 algdep 28 88544 68 82 5 4 168 169 algdepO s sa ses se wom Ae e te 169 algebraic dependence 168 algebraic number 2 ee ee 116 algtobasis 141 Alias pe ele o ote oe a e 42 208 aliasO ox 4b dk m e eel oe de 208 allocatemem 52 208 212 allocatememO 209 alternating series 194 and ae 466 4 Go eck e eG a ee GS 69 and sv beet be wR Ma Pe a 13 anell poy era raa ei S ek E E a 109 apell sopp esmarra Be e Bed 109 apply 264 6c oe boa sis stos 209 APPLYO srana e Ae We ee E 209 ATER spb gon ee Pe Es eo Eee eo 108 ALO Gage ea aes as ee GS oe ae a Ge 82 Artin L function 129 Artin root number 129 ASIN ng o bk eo RE dee He ee 82 asinh 3345 44 eb ase SAS 6 ERG 82 aSssmat saora oe a a eca moe a i i a 171 Avan A od we eo ee ee 83 ACA gee wee See Be Be Goa of urd 83 automatic simplification 54 available commands 56 B backslash character 16 LasiStOalE sice ae eS oi ek pw eed 142 226 Berlekamp si 4 4 russia 95 DETD TAC 64 a be ee eR ew we a 83 Bernoulli numbers
144. EN hbessel2 GEN nu GEN x long prec 3 3 19 besseli nu x Bessel function of index nu and argument x If x converts to a power series the initial factor 1 2 D v 1 is omitted since it cannot be represented in PARI when v is not integral The library syntax is GEN ibessel GEN nu GEN x long prec 83 3 3 20 besselj nu x J Bessel function of index nu and argument x If x converts to a power series the initial factor 1 2 TD v 1 is omitted since it cannot be represented in PARI when v is not integral The library syntax is GEN jbessel GEN nu GEN x long prec 3 3 21 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 4 2 this function is not very accurate when x is small The library syntax is GEN jbesselh GEN n GEN x long prec 3 3 22 besselk nu x K Bessel function of index nu and argument z The library syntax is GEN kbessel GEN nu GEN x long prec 3 3 23 besseln nu x N Bessel function of index nu and argument z The library syntax is GEN nbessel GEN nu GEN x long prec 3 3 24 cos x cosine of x The library syntax is GEN gcos GEN x long prec 3 3 25 cosh x hyperbolic cosine of z The library syntax is GEN gch GEN x long prec 3 3 26 cotan zx cotangent of x The library syntax is GEN gcotan GEN x long prec 3 3 27 dilog x princip
145. HE ee 56 ype ss es Habs Be ey da Be GE 214 TIPOO e at goa ck a es Goal ae ak a As 214 t CEOSURE 3 gc 226 8 as Re ee eS E 24 AL ope alinea e Eh aaa ed 7 22 E GOMPLEZR rn a Ge Sow 7 19 EPT ers sas 7 18 ELER CO unidas See OO 7 18 HUNG ote tis dna amp A 7 i7 t_INTMOD 7 18 e aose ac eg opr ce doe bg gs oh 7 28 CUE e e o da a 7 99 EBIDI oe cge e Ss Ged we SS ao 7 19 A Soke dow ak em 7 ot A concn Bak mek Red 7 20 e a AG bow 3 4 oe Fe BSG 7 2 o e ait ie tere oe eek ape ag te 7 22 OUND hose ot de Sk ws ee a 7 20 239 COREA cesos reis eee SS a7 CRIM oa coe Sead ehadke de we 7 22 ESER gas ene te eee Wik ok Ee 7 2 ESTR ors a saaa ee Eee ii 7 05 VEO Serias area 7 2 t VECSMALE lt 0 2 0 ps T 23 U WIM ee sara Sd Ree SG 37 UN GAS siora Hon et est ee se ee 207 user defined functions 32 V VallatliolM eie a a c a ek oe oS i G 80 van Hoeij 93 131 variable priority 20 28 variable SCOPe 30 variable acs ae s a a 20 24 26 variable spre sia ro BA ee a 28 80 VOC fic Be bok ee Pe ae 22 23 12 vecbezout erse g aao E n GE e N 90 vecbezoutres 90 vecbinome 004 90 VECCING ete a wok oe Oe a ee we te 84 VECEMETAGE ion deci we vd Be 4 173 180 V CMAX 24 4 44 sonas 4 6 Bee ea 4 68 VECD e cw A Skee HR GR Re ee 68 VECrOV w ked arcs Gt God aS a T2 vecsmall ri sea Mo ias r oa ay os wD a 7 Vecsmall ee ain rs Bok Hee
146. IC In this case the result is the vector of roots belonging to the same extension of Q as a The library syntax is GEN padicappr GEN pol GEN a 3 7 7 polchebyshev n flag 1 a x returns the nt Chebyshev polynomial of the first kind Tn flag 1 or the second kind Un flag 2 evaluated at a x by default The library syntax is GEN polchebyshev_eval long n long flag GEN a NULL Also available are GEN polchebyshevi long n long v and GEN polchebyshev2 long n long v for Ta and U respectively 3 7 8 polcoeff x n v coefficient of degree n of the polynomial x with respect to the main variable if v is omitted with respect to v otherwise If n is greater than the degree the result is Zero Naturally applies to scalars polynomial of degree 0 as well as to rational functions whose denominator is a monomial It also applies to power series if n is less than the valuation the result is zero If it is greater than the largest significant degree then an error message is issued For greater flexibility vector or matrix types are also accepted for x and the meaning is then identical with that of compo x n The library syntax is GEN polcoeff0 GEN x long n long v 1 where v is a variable number 162 3 7 9 polcyclo n a x n th cyclotomic polynomial evaluated at a x by default The integer n must be positive Algorithm used reduce to the case where n is squarefree to compute the cyclotomic
147. If fl 1 compute only the conductor of the abelian extension as a module If fl 2 output pol N where pol is the polynomial as output when fl 0 and N the conductor as output when fl 1 The following function can be used to compute all subfields of Q C of exact degree d if d is set polsubcyclo n d 1 my bnr L IndexBound IndexBound if d lt 0 n d bnr bnrinit bnfinit y n 1 1 L subgrouplist bnr IndexBound 1 vector L i galoissubcyclo bnr L i Setting L subgrouplist bnr IndexBound would produce subfields of exact conductor noo The library syntax is GEN galoissubcyclo GEN N GEN H NULL long fl long v 1 where v is a variable number 3 6 46 galoissubfields G flags 0 v outputs all the subfields of the Galois group G as a vector This works by applying galoisfixedfield to all subgroups The meaning of the flag ff is the same as for galoisfixedfield The library syntax is GEN galoissubfields GEN G long flags long v 1 where vis a variable number 134 3 6 47 galoissubgroups G outputs all the subgroups of the Galois group gal A subgroup is a vector gen orders with the same meaning as for gal gen and gal orders Hence gen is a vector of permutations generating the subgroup and orders is the relatives orders of the generators The cardinal of a subgroup is the product of the relative orders Such subgroup can be used instead of a Galois group i
148. If one wants more information one could do instead nf nfinit x 2 1 L ideallist nf 100 0 1 L 25 vector 1 i 1 i clgp 3 20 20 16 4 41 20 20 1 1 mod 4 25 18 0 1 O 1 2 mod ko 5 0 0 5 033 1 3 mod 40 25 7 0 1 0 where we ask for the structures of the Z 1 1 for all three ideals of norm 25 In fact for all moduli with finite part of norm 25 and trivial archimedean part as the last 3 commands show See ideallistarch to treat general moduli The library syntax is GEN ideallistO GEN nf long bound long flag 137 3 6 59 ideallistarch nf list arch list is a vector of vectors of bid s as output by ideallist with flag 0 to 3 Return a vector of vectors with the same number of components as the original list The leaves give information about moduli whose finite part is as in original list in the same order and archimedean part is now arch it was originally trivial The information contained is of the same kind as was present in the input see ideallist in particular the meaning of flag bnf bnfinit x 2 2 bnf sign 12 2 0 two places at infinity L ideallist bnf 100 0 1 L 98 vector 1 i 1 i clgp 4 42 42 36 6 611 42 4211 La ideallistarch bnf L 1 1 add them to the modulus 1 La 98 vector 1 i 1 i c1lgp 76 168 42 2 2 144 6 6 2 211 168 42 2
149. 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 WKSS if it contains a super solvable normal subgroup H such that G H is trivial or isomorphic to A4 or S4 Abelian and nilpotent groups are WKSS In practice almost all small groups are WKSS 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 Note that the result is rigorous whereas factorisations modulo small primes are not enough when the polynomial is indeed Galois This method is much faster than nfroots and can be applied to polynomials of huge degree This routine can only compute Q automorphisms but it may be used to get K automorphism for any base field K as follows rnfgaloisconj nfK R K automorphisms of L K X R my polabs N H R Mod 1 nfK pol convert coeffs to polmod elts of K polabs rnfequation nfK R N nfgaloisconj polabs R Q automorphisms of L H for i 1 N select the ones that fix K if subst R variable R Mod N i R 0 H concat H N i H K nfinit y 2 7 polL x 4 y x 3 3 x72 y x 1 rnfgaloisconj K polL K automorphisms of L The library syntax is GEN galoisconjO GEN nf long flag GEN d NULL
150. K as output by rn finit and zx being a relative ideal which can be as in the absolute case of many different types including of course elements computes the HNF pseudo matrix associated to x viewed as a Zk module The library syntax is GEN rnfidealhermite GEN rnf GEN x 3 6 135 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 GEN rnfidealmul GEN rnf GEN x GEN y 3 6 136 rnfidealnormabs rnf x rnf being a relative number field extension L K as output by rnfinit and v 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 but faster The library syntax is GEN rnfidealnormabs GEN rnf GEN x 3 6 137 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 GEN rnfidealnormrel GEN rnf GEN x 3 6 138 rnfidealreltoabs rnf x rnf being a relative number field extension L K as output by rnfinit
151. LEX exists 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 i rational numbers Q i real numbers R i C or even elements of Z nZ in Z nZ t t2 1 or p adic numbers when p 3mod4 Q i This feature must not be used too rashly in library mode for example you are in principle allowed to create objects which are complex numbers of complex numbers This is not possible under gp But do not expect PARI to make sensible use of such objects you will mainly get nonsense On the other hand it is allowed to have components of different but compatible types which can be freely mixed in basic ring operations or x For example taking again complex numbers the real part could be an integer and the imaginary part a rational number On the other hand if the real part is a real number the imaginary part cannot be an integer modulo 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 t_xxx 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 Intmods integers modulo n type t_FRAC Q Rational numbers in irreducible form type t_FFELT F Finite field element typ
152. QS 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 see ispseudoprime 3 4 1 addprimes x adds the integers contained in the vector x or the single integer x to a special table of user defined primes and returns that table Whenever factor is subsequently called it will trial divide by the elements 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 and in fact they need only be positive integers The algorithm makes sure that all elements in the table are pairwise coprime so it may end up containing divisors of the input integers It is a useful trick to add known composite numbers which the function factor x 0 was not able to factor In case the message impossible inverse modulo some INTMOD 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 To remove primes from the list use removeprimes The library syntax is GEN addprimes GEN x NULL 89 3 4 2 bestappr A B if B is omitted finds the best rational approximation to x R or R X or R with denominator at most equal to A using continued fractions If B is present x is assumed to be of type t_INTMOD modulo M
153. RFRACs all the way through p nextprime 10 7 sum i 1 1075 1 i p time 13 288 ms hi 2759492 sum i 1 1075 Mod 1 i p time 60 ms 12 Mod 2759492 10000019 18 2 3 5 Finite field elements t_FFELT first you must create a irreducible polynomial T F X defining your finite field over F for instance using ffinit Then the ffgen function creates a generator of the finite field namely the class of X in F X T from which you can build all other elements For instance to create the field F s we write T ffinit 2 8 y ffgen T y ys 13 y6 y5 y4 y3 y 1 The second optional parameter to ffgen is the name used to display the result so it is customary to use the name of the variable we assign the generator to If f is a t_FFELT the following member function is defined f pol returns the polynomial with reduced integers coefficients expressing f in term of the field generator f p returns the characteristic of the finite field f mod returns the minimal polynomial with reduced integers coefficients of the the field generator 2 3 6 Complex numbers t_COMPLEX to enter x iy type x I y That s I not i The letter I stands for y 1 The real and imaginary parts x and y can be of type t_INT t_REAL t_INTMOD t_FRAC or t_PADIC 2 3 7 p adic numbers t_PADIC Typing 0 p k where p and k are integers yields a p adic 0 of accuracy k representing an
154. See PariEmacs s documentation 2 12 25 prompt_cont default a string that will be printed to prompt for continuation lines e g in between braces or after a line terminating backslash Everything that applies to prompt applies to prompt_cont as well 2 12 26 psfile default pari ps name of the default file where gp is to dump its PostScript drawings these are appended so that no previous data are lost Environment and time expansion are performed 2 12 27 readline default 1 switches readline line editing facilities on and off This may be useful if you are running gp in a Sun cmdtool which interacts badly with readline Of course until readline is switched on again advanced editing features like automatic completion and editing history are not available 53 2 12 28 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 Ap 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 p 2 lt 10 default realprecision 2 realprecision 9 significant digits 2 digits displayed 2 12 29 secure default 0 this is a toggle which can be either 1 on or 0 off If on the syste
155. See eh ee we A ag 75 COMIVCC pe e gute a eae Sa ak g 75 Conrad esaa ea a a Ra a 109 CONTENT si hee Gos es Aw 28 29 90 91 97 CONT TAG 24 ks fk ee A Rs 91 contiracO 2 4 4 48 844 84 6 bs 91 contfracpngqn se ee orsa 91 continued fraction 91 CONVO lt i Gee ss Gees Ge athe Gg 166 COLE ss kiabi Be ee wd 91 COTOO s His bs bow oe A Re 91 COLE 2G ak eae Soak Fee A 91 COredis s re bead wee eh ag bee s b 91 COrediscO ce wks bee Ao ee RE od 91 COFedisc2 e gop aty e aoe ew a 91 COS nb beeen baSse nae eh ees 84 COSH e He Ym Gr a ee 84 COLA 324 sones Soa n e 84 CPU tie te en a oie bo we Abe Ae we 54 CYC iwi is vx dik a Be th tee Ck hs PED D datadit esa a i E i E a i E DA 50 dEDUE iia ie ia ew a a 4 50 56 debugfiles 50 56 debuglevel 5 2684 000 2 0 95 debugmem 0 4 50 56 decodemodule 122 decomposition into squares 177 Dedekind 84 130 153 160 deep recursion 04 ar default precision 9 defaults ai Ged gi de Ges 42 209 defaulto 1 55 sarro sia a 209 defaults et He Roe Bess dk Are 47 56 d6nom 2 isa Spe REE a we 75 denominator 28 29 75 ASLIV pop A bow Seok Bk cae He Be bw 161 derivnum 04 184 det aes Ob wee ee eG PLR ee ea os 171 d tO socia 171 GCt2 is soy eb ee eo AY ee we E s 171 d tint osle dos oog aoe le d 172 diagonal yos rice gad gid aca a asd 172 Diamond 2432442
156. User s Guide to PARI GP version 2 4 2 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 pari math u bordeaux fr Copyright 2000 2006 The PARI Group Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies Permission is granted to copy and distribute modified versions or translations of this manual under the conditions for verbatim copying provided also that the entire resulting derived work is distributed under the terms of a permission notice identical to this one PARI GP is Copyright 2000 2006 The PARI Group PARI GP is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation It is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY WHATSOEVER Table of Contents Chapter 1 Overview of the PARI system o 5 1 1 Introduction a A a nd ee Slee A e 5 1 2 Multiprecision kernels Portability ici a e a a 6 13 The PARD types cists ean gana u Me ee a a oe a le ee 7 1 4 The PARI philosophy 02 ee ee 9 1 5 Operations and functions 2 1 a 10 Chapter 2 The gp Calculator se so ee o
157. a Gi hd eo a a e G 165 FOOLS adas a 3 108 119 164 FOOGSO aa aa e 164 TOOUSOEL obd a a aan A we A 148 round 2 e ma o Se Slate oes 141 round A ee pe rores 4684 141 142 161 TOUMA 6 fhe aa e BAS Ea a E a 78 roundO s scs ge sce isaac 78 TOW VECHOL 5 2 2 hb 24 eee ab ede es T 22 S scalar product so s sioa a de ea 65 Scalar type e e dce Goad g Mik ek i a 7 Schertz o 104 Schonage asia ses 5 Be Ged 164 scientific format 50 SECURE d ween We Se PA Be 54 Select Mission were ac a el 212 Select O fc dow cals o Ba hs 213 BOS te oo 1 E E E E 108 111 SEP panda Aaa yl serconvol isso Se es 166 seriesprecision 54 57 serlaplacer a duc aed arado Gada ore 166 serreverse 0 0004 166 Se Ud gil setintersect 180 setisset sueca roca Bee 180 setminus 0 24 180 SOTA 4 6 6 ah s k Bea oe amp 718 210 213 setsearch 180 SOTUDIOO e s soe e ana eee we eee 180 Shanks SQUFOF 89 95 Shanks YA 101 102 103 SHITE aer e o a o A 68 Shiftmul cenar 68 Sigma 92 105 195 SION erica e ee a 68 SIM een e e 68 182 Signunits 125 Simplify 4 4 4 46 mis aseos 54 55 79 Sin osuna Doron Re wee eS 86 Sib p macar E roa cee ee we we He 86 SIZODYLS ss Bo ee eee Pa Be ee 79 Sizedigit s ert anm r Be eo ae eg a TO smallinitell 112 119 123 125 140 148 175 206 Smith normal fo
158. a ee S 163 POLdISCO sds et GR he OR Ge as 163 poldiscreduced 163 A A sae at aan at at 161 POLINE dea ke at des RS EE ee 131 polgalois 52 150 151 polhensellift aia doce ias eed x 163 polhermite sa stre ros cha GE ee 163 polhermite_eval 163 POLING hd da dre te et cia he 163 polinterpolate 163 polisirreducible 163 Pollard Rho 89 95 pollead seca we be iom a ee 0 s 164 pollegendre 164 pollegendre_eval 164 polm d ig kee ahs ee PRS ee a EES 7 polmod 00 8 20 A r ea wi eS Gre Ge a 164 polred 22 24 884 444 Seabed es 151 POLEO eiii 151 polr dabs durmio Bw 151 polredabsO s so reserse enira 152 polredord ss 2 iee sarda est 152 polresultant sss owe k o es 8 164 polresultantO 164 ROLES asas ed A 70 71 POLEO tE ere a a ee ee we 164 168 polrootsmod 106 164 polrootspadic 106 165 POLLS GU z ka dia Gow ee wl be oe Oe e 165 polsubcyclo soe sasssa ay ee 0 0 165 polsylvestermatrix 165 POLlSyM s eeso ia es 165 poltchebi 2 seek hee eee 600 4 165 poltschirnhaus 152 pollylog 2 4 Bs ee ee Po sa bee ee 85 POLFLOZO 6 ici e ew we a a A 86 polymodrecip 141 polynomial s warc aese ee ke Ok POLZAg s Bat aan Gln Me a ts Saeed 165 polzagier carrasco eee te 165 POSESCTIDOE ss ssa s e pi eee ee es 199 powell red si eatea aa a a 1
159. ains prime divisors p of x 1 such that p gt zt the second the corresponding elements a as in Proposition 8 3 1 in GTM 138 and the third the output of isprime p 1 The algorithm fails if one of the pseudo prime factors is not prime which is exceedingly unlikely and well worth a bug report Note that if you monitor isprime at a high enough debug level you may see warnings about untested integers being declared primes This is normal we ask for partial factorisations sufficient to prove primality if the unfactored part is not too large and factor warns us that the cofactor hasn t been tested It may or may not be tested later and may or may not be prime This does not affect the validity of the whole isprime procedure If flag 2 use APRCL The library syntax is GEN gisprime GEN x long flag 98 3 4 36 ispseudoprime z flag true 1 if x is a strong pseudo prime see below false 0 otherwise If this function returns false x is not prime if on the other hand it returns true it is only highly likely that x is a prime number Use isprime which is of course much slower to prove that x is indeed prime If flag 0 checks whether x is a Baillie Pomerance Selfridge Wagstaff pseudo prime strong Rabin Miller pseudo prime for base 2 followed by strong Lucas test for the sequence P 1 P smallest positive integer such that P 4 is not a square mod z There are no known composite numbers passing thi
160. al x op y assigns x op y to x and returns the new value of x This is not a reference to the variable x i e an lvalue thus x 2 3 24 is invalid e Priority 8 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 a statement like x 1 is always true i e non zero and sets x to 1 The right hand side of the assignment operator is evaluated before the left hand side If the left hand side cannot be modified raise an error e Priority 7 is the selection operator x i returns the i th component of vector x i j x j and x i respectively return the entry of coordinates i j the j th column and the i th row of matrix x If the assignment operator immediately follows a sequence of selections it assigns its right hand side to the selected component E g x 1 1 0 is valid but beware that x 1 1 0 is not because the parentheses force the complete evaluation of x 1 and the result is not modifiable e Priority 6 unary prefix quote its argument a variable name without evaluating it a x 1 x 1 subst a x 1 Ak variable name expected subst a x 1 subst a x 1 1 2 powering unary postfix derivative with respect to the main variable If f is a GP or user function f x is allowed If x is a scalar the operator performs numerical derivation def
161. al branch of the dilogarithm of x i e analytic continuation of the power series log2 1 inst x m The library syntax is GEN dilog GEN x long prec 3 3 28 eint1 x n exponential integral f 2 dt x R If n is present outputs the n dimensional vector eint1 x einti nx x gt 0 This is faster than repeatedly calling eint1 i x The library syntax is GEN veceint1 GEN x GEN n NULL long prec Also available is GEN eint1 GEN x long prec 3 3 29 erfc x complementary error function 2 y 7 Le e dt ER The library syntax is GEN gerfc GEN x long prec 3 3 30 eta x flag 0 Dedekind s 7 function without the q 2 This means the following if x is a complex number with positive imaginary part the result is 1 q where q e 7 If x is a power series or can be converted to a power series with positive valuation the result is M 1 g 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 4 The library syntax is GEN eta0 GEN x long flag long prec 84 3 3 31 exp 1 exponential of x p adic arguments with positive valuation are accepted The library syntax is GEN gexp GEN x long prec 3 3 32 gamma x gamma function of x The library syntax is GEN ggamma GEN x long prec 3 3 33 gammah z gamma function evaluated at the argument x 1 2 The library syntax is GEN ggamd GEN x
162. al for all documented functions hence the amp will always appear between brackets as in Z_issquare z amp e About library programming The library function foo as defined at the beginning of this section is seen to have two mandatory arguments x and flag no function seen in the present chapter has been implemented so as to accept a variable number of arguments so all arguments are mandatory when programming with the library often variants are provided corresponding to the various flag values We include an default value token in the prototype to signal how a missing argument should be encoded Most of the time it will be a NULL pointer or 1 for a variable number The entree type is used by the library to implement iterators loops sums integrals etc when a formal variable has to successively assume a number of values in a given set When programming with the library it is easier and much more efficient to code loops and the like directly Hence this type is not documented although it does appear in a few library function prototypes below See Section 3 9 for more details 64 3 1 Standard monadic or dyadic operators 3 1 1 The expressions x and x refer to monadic operators the first does nothing the second negates x The library syntax is GEN gneg GEN x for x 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
163. al mathematical research while building a large user community linked by helpful mailing lists and a tradition of great user support from the developers And of course PARI GP is Free Software covered by GNU s General Public License PARI is used in three different ways 1 as a library libpari which can be called from an upper level language application for instance written in ANSI C or C 2 as a sophisticated programmable calculator named gp whose language GP contains most of the control instructions of a standard language like C 3 the compiler gp2c translates GP code to C and loads it into the gp interpreter A typical script compiled by gp2c runs 3 to 10 times faster The generated C code can be edited and optimized by hand It may also be used as a tutorial to libpari programming The present Chapter 1 gives an overview of the PARI GP system gp2c is distributed separately and comes with its own manual Chapter 2 describes the GP programming language and the gp calculator Chapter 3 describes all routines available in the calculator Programming in library mode is explained in Chapters 4 and 5 in a separate booklet User s Guide to the PARI library libpari dvi Important note A tutorial for gp is provided in the standard distribution A tutorial for PARI GP tutorial dvi and you should read this first You can then start over and read the more boring stuff which lies ahead You can have a quick idea of what is availab
164. al of the map multiplication by A if A is a scalar in particular a polmod E g charpoly I x72 1 The value of flag is only significant for matrices Let n be the dimension of A 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 Le Verrier s method Assumes that n is invertible If flag 1 uses Lagrange interpolation which is usually the slowest method Assumes that n is invertible If flag 2 uses the Hessenberg form Assumes that the base ring is a field If flag 3 uses Berkowitz s division free algorithm valid over any ring commutative with unit In practice one should use the default Berkowitz unless the base ring is a field where coefficient explosion does not occur e g a finite field or the reals In which case the Hessenberg form is usually faster All algorithms use O n scalar operations if A has dimension n The library syntax is GEN charpolyO GEN A long v 1 long flag where v is a vari able number Also available are GEN caract GEN A long v flag 1 GEN carhess GEN A long v flag 2 GEN carberkowitz GEN A long v flag 3 and GEN caradj GEN A long v GEN pt In this last case if pt is not NULL pt receives the address of the adjoint matrix of A see matadjoint so both can be obtained at once 3 8 3 concat z y concatenation of x and y If x or y is not a vector or matrix it is consi
165. and 3 is surprising Why does 2 contain a spurious constant term which cannot be deduced from the input Well we ignored the rule that forbids to substitute an expression involving high priority variables to a low priority variable The result 4 is correct 29 according to our rules since the implicit constant in O x may depend on z It is obviously wrong if z is allowed to have negative valuation in x Of course the correct error term should be O xz but this is not possible in PARI 2 6 Variables and Scope This section is rather technical and strives to explain potentially confusing concepts Skip to the last subsection for practical advice if the next discussion does not make sense to you After learning about user functions study the example in Section 2 7 3 then come back 2 6 1 Definitions A scope is an enclosing context where names and values are associated A user s function body the body of a loop an individual command line all define scopes the whole program defines the global scope The argument of eval is evaluated in the enclosing scope Variables are bound to values within a given scope This is traditionnally implemented in two different ways e lexical or static scoping the binding makes sense within a given block of program text The value is private to the block and may not be accessed from outside Where to find the value is determined at compile time e dynamic scoping introducing a local variable
166. and x being a relative ideal gives the ideal eZ as an absolute ideal of L Q in the form of a Z basis given by a vector of polynomials modulo rnf pol The following routine might be useful return y rnfidealreltoabs rnf as an ideal in HNF form associated to nf nfinit rnf pol idealgentoHNF nf y mathnf Mat nfalgtobasis nf y The library syntax is GEN rnfidealreltoabs GEN rnf GEN x 3 6 139 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 Zz expressed as polmods with polmod coefficients The library syntax is GEN rnfidealtwoelement GEN rnf GEN x 155 3 6 140 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 1Z as an absolute ideal of L Q in the form of a Z basis given by a vector of polynomials modulo rnf pol The following routine might be useful return y rnfidealup rnf as an ideal in HNF form associated to nf nfinit rnf pol idealgentoHNF nf y mathnf Mat nfalgtobasis nf y The library syntax is GEN rnfidealup GEN rnf GEN x 3 6 141 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
167. ands 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 A set of default colors for dark reverse video or PC console and light backgrounds respectively is activated when colors is set to darkbg resp lightbg or any proper prefix d is recognized as an abbreviation for darkbg A bold variant of darkbg called boldfg is provided if you find the former too pale In the present version this default is incompatible with PariEmacs Changing it will just fail silently the alternative would be to display escape sequences as is since Emacs will refuse to interpret them You must customize color highlighting from the PariEmacs side see its documentation Technical note 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 as 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 capabili
168. are coded as in intnum and are not necessarily at infinity but if they are oscillations i e 1 a1 are forbidden The library syntax is intfouriersin void E GEN eval GEN void GEN a GEN b GEN z GEN tab long prec 3 9 6 intfuncinit X a b expr flag 0 m 0 initialize tables for use with integral transforms such as intmellininv etc where a and b are coded as in intnum expr is the function s X to which the integral transform is to be applied which will multiply the weights of integration and m is as in intnuminit If flag is nonzero assumes that s X s X which makes the computation twice as fast See intmellininvshort for examples of the use of this function which is particularly useful when the function s X is lengthy to compute such as a gamma product The library syntax is intfuncinit void E GEN eval GEN void GEN a GEN b long m long flag long prec Note that the order of m and flag are reversed compared to the GP syntax 185 3 9 7 intlaplaceinv X sig z expr tab numerical integration of 2i71r texpr X e with respect to X on the line R X sig In other words inverse Laplace transform of the function corresponding to expr at the value z sig is coded as follows Either it is a real number equal to the abscissa of integration and then the integrand is assumed to be slowly decreasing when the imaginary part of the variable tends to too Or it is a two component
169. art one for the fractional part or a vector matrix The library syntax is GEN binaire GEN x 3 2 18 bitand z y bitwise and of two integers x and y that is the integer So 2 and y 2 i Negative numbers behave 2 adically i e the result is the 2 adic limit of bitand n Yn where Zn and yn are non negative integers tending to x and y respectively The result is an ordinary integer possibly negative bitand 5 3 1 1 bitand 5 3 42 3 bitand 5 3 13 7 The library syntax is GEN gbitand GEN x GEN y 3 2 19 bitneg x n 1 bitwise negation of an integer x truncated to n bits that is the integer n 1 5 not 1 2 i 0 The special case n 1 means no truncation an infinite sequence of leading 1 is then represented as a negative number See Section 3 2 18 for the behaviour for negative arguments The library syntax is GEN gbitneg GEN x long n 73 3 2 20 bitnegimply x y bitwise negated imply of two integers x and y or not x gt y that is the integer a andnot y 2 See Section 3 2 18 for the behaviour for negative arguments The library syntax is GEN gbitnegimply GEN x GEN y 3 2 21 bitor z y bitwise inclusive or of two integers x and y that is the integer Y a or y 2 See Section 3 2 18 for the behaviour for negative arguments The library syntax is GEN gbitor GEN x GEN y 3 2 22 bittest x n outputs the n bit of x starting from the right
170. as CM by a principal imaginary quadratic order we use an explicit formula involving essentially Kronecker symbols and Cornacchia s al gorithm hence very fast O log p Otherwise we use Shanks Mestre s baby step giant step method which runs in time O p using O p storage hence becomes unreasonable when p has about 30 digits No checking is done that p is indeed prime E must be an sell as output by ellinit defined over Q F or Q E must be given by a Weierstrass equation minimal at p The library syntax is GEN apell GEN E GEN p 3 5 5 ellbil E 21 22 if z1 and 22 are points on the elliptic curve E assumed to be integral given by a minimal model this function computes the value of the canonical bilinear form on z1 z2 h E 21422 h E 21 h E 22 2 where denotes of course addition on E In addition z1 or 22 but not both can be vectors or matrices The library syntax is GEN bilhel1 GEN E GEN z1 GEN z2 long prec 109 3 5 6 ellchangecurve E v changes the data for the elliptic curve E by changing the coordinates using the vector v u r s t i e if x and y are the new coordinates then x u tz r y uy su x t E must be an sell as output by ellinit The library syntax is GEN ellchangecurve GEN E GEN 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 t i e if x and y are the new coordinates then x
171. at your shell prompt to get a complete list This is applied to prompt psfile and logfile For instance default prompt H M 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 many shells by itself stands for your home directory and user is expanded to user s home directory This is applied to all filenames We shall now describe all the available defaults specifying each time whether time and or environment expansion is performed 48 EMACS 2 12 1 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 Accepted 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 on transparent background e an integer between 0 and 15 corresponding to the aforementioned colormap e a triple co c1 c2 where co st
172. at it is unnecessary to add a my n declaration to the function body Surprisingly this gives very good accuracy in a larger region than expected check z gt ZETA z zeta z check 2 71 1 000000000000000000000000000 check 200 2 1 000000000000000000000000000 check 0 3 0 9999999999999999999999999994 check 5 4 1 00000000000000007549266557 check 11 5 0 9999752641047824902660847745 check 1 2 14 134 I MAN very close to a non trivial zero 76 1 000000000000000000003747432 7 62329066 E 21 I check 1 10x1 7 7 1 000000000000000000000002511 2 989950968 E 24x I Now wait a minute not only are we summing a series which is certainly no longer alternating it has complex coefficients but we are also way outside of the region of convergence and still get decent results No programming mistake this time sumalt is a magic function providing very good convergence acceleration in effect we are computating the analytic continuation of our original function To convince ourselves that sumalt is a non trivial implementation let us try a simpler exemple sum n 1 1077 1 n n 0 log 2 approximates the well known formula time 7 417 ms 71 0 9999999278652515622893405457 sumalt n 1 1 n n log 2 accurate and fast time O ms 2 1 000000000000000000000000000 No we are not using a powerful simplification tool here only numerical computations Rem
173. ax is GEN basistoalg GEN nf GEN x 3 6 79 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 GEN nfdetint GEN nf GEN x 3 6 80 nfdisc z flag 0 fa field discriminant of the number field defined by the integral preferably monic irreducible polynomial x flag and fa are exactly as in nfbasis That is fa 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 GEN nfdiscfO GEN x long flag GEN fa NULL Also available is GEN discf GEN x flag 0 3 6 81 nfeltdiv nf x y given two elements x and y in nf computes their quotient x y in the number field nf The library syntax is GEN element_div GEN nf GEN x GEN y 142 3 6 82 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 GEN nfdiveuc GEN nf GEN x GEN y 3 6 83 nfeltdivmodpr nf zx y pr g
174. ay be as above except that t_REAL is not allowed 1 3 5 Polynomials power series vectors matrices and lists they are completely recur sive their components can be of any type and 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 In the present version 2 4 2 of PARI it is not possible to handle conveniently 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 This is a difficult design problem the mathematical problem itself contains some amount of imprecision and it is not easy to design an intuitive generic interface for such beasts 1 3 6 Strings These contain objects just as they would be printed by the gp calculator 1 3 7 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 there are infinitely many distinct zeros of each of these types For p adics and power series the answer is as follows every such object including 0 has an exponent e This p adic or X adic zero is understood to be equal to O p or O X respectively Real numbers also have exponents and a real zero is in
175. ay on the accuracy of both the zetakinit program and the current accuracy Be wary in particular that x of large imaginary part or on the contrary very close to an ordinary integer will suffer from precision loss yielding fewer significant digits than expected Computing with 28 digits of relative accuracy we have zeta 3 1 1 202056903159594285399738161 zeta 3 1e 20 2 1 202056903159594285401719424 zetak zetakinit x 3 1e 20 13 1 2020569031595952919 5 digits are wrong zetak zetakinit x 3 1e 28 4 25 33411749 junk e As the precision increases results become unexpectedly completely wrong p100 zetak zetakinit x 2 5 1 1 30 1 7 26691813 E 108 AN perfect p150 zetak zetakinit x 2 5 1 1 30 2 2 486113578 E 156 AN perfect p200 zetak zetakinit x 2 5 1 1 30 13 4 47 E 75 more than half of the digits are wrong p250 zetak zetakinit x 2 5 1 1 30 4 1 6 E43 junk The library syntax is GEN gzetakall GEN nfz GEN x long flag long prec GEN glamb dak GEN znf GEN x long prec or GEN gzetak GEN znf GEN x long prec 160 3 6 154 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 vecto
176. b 1 time 230 ms similar speed to sumnum b sumalt n 1 1 7n n 3 n 1 time O ms infinitely faster a b time O ms 1 1 66 E 308 perfect The library syntax is sumnumalt void E GEN eval GEN void GEN a GEN sig GEN tab long flag long prec 3 9 25 sumnuminit sig m 0 sgn 1 initialize tables for numerical summation using sumnum with sgn 1 or sumnumalt with sgn 1 sig is the abscissa of integration coded as in sumnum and m is as in intnuminit The library syntax is GEN sumnuminit GEN sig long m long sgn long prec 3 9 26 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 then we use sumalt For regular functions the function sumnum is in general much faster once the initializations have been made using sumnuminit The routine is heuristic and assumes that expr is more or less a decreasing function of X In particular the result will be completely wrong if expr is 0 too often We do not check either that all terms have the same sign As sumalt this function should be used to try and guess the value of an infinite sum If flag 1 use slightly different polynomials Sometimes faster The library syntax is sumpos void E GEN eval GEN void GEN a lon
177. beddings of the number field into C the first r1 components are real the next r2 have positive imaginary part nf 7 is an integral basis for Zg nf zk expressed on the powers of 0 Its first element is guaranteed to be 1 This basis is LLL reduced with respect to To strictly speaking it is a permutation of such a basis due to the condition that the first element be 1 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 146 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 nf nfinit x 3 12 initialize number field Q X X73 12 nf pol defining polynomial 12 x 3 12 nf disc field discriminant 13 972 nf index index of power basis order in maximal order 14 2 nf zk integer basis lifted to Q X 45 1 x 1 2 x 2 nf sign signature 46 1 1 factor abs nf disc determines ramified primes ht 2 2 3 5 idealfactor nf 2 78 2 0 0 1 3 1 0 1 0 3 3 In case pol has a huge discriminant which is difficult to factor the special input format pol B is also accepted where pol is a polynomial as above and B is the integ
178. ber or function If x is an integer or a polynomial it is treated as a rational number of function respectively and the result is x itself For polynomials you probably want to use numerator content x instead In other cases numerator x is defined to be denominator x x This is the case when zx is a vector or a matrix but also for t_COMPLEX or t_QUAD In particular since a t_PADIC or t_INTMOD has denominator 1 its numerator is itself Warning multivariate objects are created according to variable priorities with possibly surprising side effects 1 y is a polynomial but y z is a rational function See Section 2 5 3 The library syntax is GEN numer GEN x 3 2 38 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 GEN numtoperm long n GEN k 3 2 39 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 machines or 263 1 for 64 bit machines if x is an exact object The library syntax is long padicprec GEN x GEN p 3 2 40 permtonum x 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 GEN permtonum GEN x TT 3 2 41 precision x n gives the precision in decimal digits of
179. ber Riemann s zeta function s X gt n computed using the Euler Maclaurin summation 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 For s a p adic number Kubota Leopoldt zeta function at s that is the unique continuous p adic function on the p adic integers that interpolates the values of 1 p7 C k at negative integers k such that k 1 mod p 1 resp k is odd if p is odd resp p 2 The library syntax is GEN gzeta GEN s long 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 4 2 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 Shanks SQUFOF Pollard Rho ECM and MP
180. between a scalar type and a vector or a matrix between vector matrices of incompatible sizes and between an intmod and a real number The library syntax is GEN gadd GEN x GEN y for x y GEN gsub GEN x GEN y for x 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 intmod 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 GEN gmul GEN x GEN y for x y Also available is GEN gsqr GEN x for x x 3 1 4 The expression x y is the quotient of x and y In addition to the impossibilities for multiplication 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 t
181. btained as rnf pol vabs 2 expresses 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 3 is an abstract root of pol and a the generator of nf the generator whose root is vabs will be 8 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 156 rnf 12 is by default unused and set equal to 0 This field is used to store further information about the field as it becomes available which is rarely needed hence would be too expensive to compute during the initial rnfinit call The library syntax is GEN rnfinitalg GEN nf GEN pol long prec 3 6 142 rnfisfree bnf x given bnf as output by bnfinit and either a polynomial x with co efficients 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 long rnfisfree GEN bnf GEN x 3 6 143 rnfisnorm T a flag 0 similar to bnfisnorm but in the relative case T is as output by rnfisnorminit applied to the extension L K This tries
182. by just multiplying by an appropriate constant Note that infinity can be represented with essentially no loss of accuracy by 1e1000 However beware of real underflow when dealing with rapidly decreasing functions For example if one wants to compute the tor e dx to 28 decimal digits then one should set infinity equal to 10 for example and certainly not to 1e1000 The library syntax is intnumromb void E GEN eval GEN void GEN a GEN b long flag long prec where eval E returns the value of the function at x You may store any additional information required by eval in EF or set it to NULL 3 9 14 intnumstep give the value of m used in all the intnum and sumnum programs hence such that the integration step is equal to 1 2 The library syntax is long intnumstep long prec 3 9 15 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 it 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
183. c GEN D assumes b 4ac gt 0 3 2 8 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 precdl 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 also applies here this is not a substitution function The library syntax is GEN gtoser GEN x long v 1 where v is a variable number 3 2 9 Set x converts x into a set i e into a row vector of character strings with strictly increasing entries with respect to lexicographic ordering 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 GEN gtoset GEN x NULL 71 3 2 10 Str x converts its argument list into a single 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 9 x2 0 i 2 Str x i 91 xo eval 42 0 Th
184. can get the source and compile it there you do not 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 You can also invoke Configure with one of the following arguments with readline prefix to 1ib libreadline rr and include readline h with readline lib path to libreadline zz with readline include path to readline h Technical note Configure can build GP on different architectures simultaneously from the same toplevel sources Instead of the readline link alluded above you can create readline osname arch using the same naming conventions as for the Oxxx directory e g readline linux i686 Known problems e on Linux Linux distributions have separate readline and readline devel packages You need both of them installed to compile gp with readline support If only readline is installed Configure will complain Configure may also complain about a missing libncurses so in which case you have to install the ncurses devel package some distributions let you install readline devel without ncurses devel which is a bug in their package dependency handling e on OS X 4 Tiger comes equipped with a fake readline which is not sufficient for our purpose As a result gp is built without readline support Since readline is not trivial to install in this
185. 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 TRX 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 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 13 2 comment Everything between the stars is ignored by gp These comments can span any number of lines 2 13 3 one line comment The rest of the line is ignored by gp 2 13 4 Na n prints the object number n n in raw format If the number n is omitted print the latest computed object 2 13 5 b nj Same as Na in prettyprint i e beautified format 2 13 6 c prints the list of all available hardcoded functions under gp not including operators written as special symbols see Section 2 4 More info
186. case you need a working plain T X installation After that the doc directory contains various dvi files libpari dvi manual for the PARI library users dvi manual for the gp calculator tutorial dvi a tutorial and refcard dvi a reference card for GP You can send these files to your favourite printer in the usual way probably via dvips The reference card is also provided as a PostScript document which may be easier to print than its dvi equivalent it is in Landscape orientation and assumes A4 paper size If the pdftex package is part of your TX setup you can produce these documents in PDF format which may be more convenient for online browsing the manual is complete with hyperlinks type make docpdf All these documents are available online from PARI home page see the last section 223 5 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 extgcd c program which is commented in the manual This should produce a statically linked binary extgcd sta standalone a dynamically linked binary extgcd dyn loads libpari at runtime and a shared library libextgcd which can be used from gp to install your new extgcd command The standalone binary should be bulletproof but the other two may fail
187. ce Configure pg will create an Oxxx prf directory where a suitable version of PARI can be built The GP binary built above with make all or make gp is optimized If you have run Configure g or pg and want to build a special purpose binary you can cd to the dbg or prf directory and type make gp there You can also invoke make gp dbg or make gp prf directly from the toplevel 3 4 Multiprecision kernel The kernel can be fully specified via the kernel fqkn switch The PARI kernel is build from two kernels called level 0 LO operation on words and level 1 L1 operation on multi precision integer and real Available kernels LO auto none and alpha hppa hppa64 ia64 ix86 x86_64 m68k ppc sparcv7 sparcv8_micro sparcv8_super L1 auto none and gmp auto means to use the auto detected value LO none means to use the portable C kernel no assembler Ll none means to use the PARI L1 kernel e A fully qualified kernel name fgkn is of the form Lo e A name not containing a dash is an alias An alias stands for name none but gmp stand for auto gmp e The default kernel is auto none 220 3 5 Problems related to readline Configure does not try very hard to find the readline library and include files If they are not in a standard place it will not 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
188. changes You cannot 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 The BTS forwards the mail it receives to this list e pari users for everything else You may send an email to the last two without being subscribed You will have to confirm that your message is not unsollicited bulk email aka Spam To subscribe send empty messages respectively to pari announce subscribe list cr yp to pari users subscribe list cr yp to pari dev subscribe list cr yp to You can also write to us at the address 224 pariCmath u bordeaux fr but we cannot promise you will get an individual answer If you have used PARI in the preparation of a paper please cite it in the following form BibTeX format manual PARI2 organization The PARI Group title PARI GP Version 2 4 2 year 2006 address Bordeaux note available from tt http pari math u bordeaux fr J In any case if you like this software we would be indebted if you could send us an email message giving us some information about yourself and what you use PARI for Good luck and enjoy 225 Index Some Word refers to PARI GP concepts SomeWord is a PARI GP keyword SomeWord is a generic index entry A Abelian extension 153 158 QDS h hh Sy Groh ety ey SOE Re eh Gre os 82 ACCUL
189. compute numerically integrals to thousands of decimal places in reasonable time as long as the integrand is regular It is also reasonable to compute numerically integrals in several variables although more than two becomes lengthy The integration domain may be non compact and the integrand may have reasonable singularities at endpoints To use intnum the user must split the integral into a sum of subintegrals where the function has possible singularities only at the endpoints Polynomials in logarithms are not considered singular and neglecting these logs singularities are assumed to be algebraic in other words asymptotic to C x a for some a such that a gt 1 when z is close to a or to correspond to simple discontinuities of some higher derivative of the function For instance the point 0 is a singularity of abs x See also the discrete summation methods below sharing the prefix sum 3 9 1 derivnum X a expr numerical derivation of expr with respect to X at X a derivnum x 0 sin exp x cos 1 1 1 262177448 E 29 Another more clumsy approach is f x sin exp x f 0 cos 1 1 1 262177448 E 29 which would not work in library mode The library syntax is derivnum void E GEN eval GEN void GEN a long prec 184 3 9 2 intcirc X a R expr tab numerical integration of 2ir terpr with respect to X on the circle X a R In other words when expr is a meromorphic f
190. 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 intmod or a polmod An ambiguity arises with square matrices PARI always considers that you want to do com ponentwise function evaluation in this context hence to get for example the standard exponential of a square matrix you would need to implement a different function 10 1 5 3 Transcendental functions They usually operate on any complex number power series and some also on p adics The list is everexpanding and of course contains all the elementary functions exp log trigonometric func tions plus many others modular functions Bessel functions polylogarithms Recall that by extension PARI usually allows a transcendental function to operate componentwise on vectors or matrices 1 5 4 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 A number of factoring methods are used by a rather sophisticated factoring engine to name a few Shanks s SQUFOF Pollard s rho Lenstra s ECM the MPQS quadratic sieve These routines output strong pseudoprimes which may be certified by the APRCL test There
191. creates with the same type a z in the same residue 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 If y is omitted and x is a vector chinese is applied recursively to the components of x yielding a residue belonging to the same class as all components of x Finally chinese x x 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 GEN chinese GEN x GEN y NULL Also available is GEN chinese1 GEN x 90 3 4 8 content 1 computes the gcd of all the coefficients of x when this gcd makes sense This is the natural definition if x is a polynomial and by extension a power series or a vector matrix This is in general a weaker notion than the ideal generated by the coefficients content 2 x y 41 1 ged 2 y over Qly If x is a scalar this simply returns the absolute value of x if x is rational t_INT or t_FRAC and either 1 inexact input or x exact input otherwise the result should be identical to gcd x 0 The content of a rational function is the ratio of the contents of the numerator and the de nominator In recursive structures if a matrix or vector coefficient x appears the gcd i
192. d 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 31 psdraw list flag 0 same as plotdraw except that the output is a PostScript program appended to the psfile and flag 0 scales the plot from size of the current output device to the standard PostScript plotting size 3 10 32 psploth X a b ezpr flags 0 n 0 same as ploth except that the output is a PostScript program appended to the psfile 3 10 33 psplothraw list listy flag 0 same as plothraw except that the output is a PostScript program appended to the psfile 204 3 11 Programming in GP control statements A number of control statements are available in 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 Caveat in constructs like for X a b seq the variable X is lexically scoped to the loop leading to possibly unexpected behaviour n 5 for n 1 10 if something_nic
193. dealmul ess HR we i ee 138 idealmulO oo oo 138 idealmulred 138 1ACALNDOED s gii o Gh 138 ideal pow a s sr Se tea e ow A 139 idealpowO o ooo 139 idealpowred ooo oo 139 idealpows ar asi o 139 idealprimedec 139 idealprincipal 139 idealfred o m s soene aono biia a 139 idealstar porcaria t Ee aos e ia 140 idealetarO o ooe s ecni a ea ee ds 140 idealtwoelt o 140 ideslval wu os 6 ease Ee 8 ee eR 140 ideal twoLelto oo dc we 140 UdElE tee ah e e Re WR e ee E 117 ideleprincipal 140 TS iiss Hos 6 ts bout atlas p len Ge woe Moet do 207 IMA vk ke e we he 76 IMAGE y sea dica EG OM Ee a 173 IMASSCOMPI e uris oy aig oe Gas Gard 173 INGRAM ica ic He hee D we a 85 INEZAMO ero re 85 AMC OAM a os a o 85 inclusive OP a s ee o 69 MAX espro E E 119 o aop Ga ru a a ee a ie we eg Sea 119 indexrank 173 infinite product so esos s s a dis 194 infinite SUM gt su soa k oe ao e a Eo ae 195 infinity eek ga a eop ia e ee ae es 193 inttell 2 6 eiea ep eee a 112 IOTUZOLA 3 ur tee a Gre a ahah 161 INPUL eme bee e a 210 MMS Gals 2 aii an a cet 42 46 210 e e ke ba Seok Bee a cee A 184 185 INteS cum cosas eR es 162 a wou s Boe ee ete ee ee 7 8 17 integral basis 141 internal longword format 57 internal representation 57 interpolating polynomial
194. decimals because of singularity at oo b sumnum n 1 2 4 3 n 4 3 omitted 1 of real type time 12 210 ms b zeta 4 3 3 1 05 E 300 better Since the complex values of the function are used beware of determination problems For instance p 308 tab sumnuminit 2 3 2 time 1 870 ms sumnum n 1 2 3 2 1 n sqrt n tab 1 zeta 3 2 time 690 ms 1 1 19 E 305 fast and correct sumnum n 1 2 3 2 1 sqrt n 3 tab 1 zeta 3 2 time 730 ms A2 1 55 nonsense However sumnum n 1 2 3 2 1 n7 3 2 tab 1 zeta 3 2 time 8 990 ms 3 1 19 E 305 perfect as 1 n x y n above but much slower For exponentially decreasing functions sumnum is given for completeness but one of suminf or sumpos should always be preferred If you experiment with such functions and sumnum anyway indicate the exact rate of decrease and increase m by 1 or 2 suminf n 1 27 n 1 time 10 ms 1 1 11 E 308 fast and perfect sumpos n 1 2 n 1 time 10 ms 12 2 78 E 308 also fast and perfect sumum n 1 2 2 n 1 xxx sumnum precision too low in mpscl nonsense sumnum n 1 2 log 2 2 n omitted 1 1 of real type time 5 860 ms 13 1 5 E 236 slow and lost 70 decimals m intnumstep 14 9 sumnum n 1 2 log 2 2 n m 1 1 1 time 11 770 ms 15 1 9 E 305
195. dered 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 use Mat instead see the example there Concatenating a row vector to a matrix having the same number of columns will add the row to the matrix 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 Ed 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 4 169 1 1 2 3 4 a 1 2 3 4 concat a 12 1 3 2 4 concat 1 2 3 4 5 6 93 1 2 5 3 4 6 concat 7 8 1 2 3 4 45 1 25 7 3 4 6 8 1 2 3 4 The library syntax is GEN concat GEN x GEN y NULL 3 8 4 lindep z flag 0 x being a vector with p adic or real complex coefficients finds a small integral linear combination among these coefficients If x is p adic flag is meaningless and the algorithm LLL reduces a suitable dual lattice Otherwise the value of f
196. e 3 10 4 And library mode 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 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 5 plot X a b expr Ymin Ymaz crude ASCII plot of the function represented by expression expr 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 6 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 x1 y1 and 12 y2 are opposite corners Only the part of the rectangle which is in w is drawn The virtual cursor does not move 3 10 7 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 committing the part you re interested in to the final picture 3 10 8 plotcolor w c set default color to c in rectwindow w This is only implemented for the X wind
197. e break J5 at this pointn is 5 If the sequence seq modifies the loop index then the loop is modified accordingly for n 1 10 n 2 print n 3 6 9 12 3 11 1 break n 1 interrupts execution of current seg 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 2 for X a b seq evaluates seq where the formal variable X goes from a to b Nothing is done if a gt b a and b must be in R 3 11 3 fordiv n X seq evaluates seq where the formal variable X ranges through the divisors of n see divisors which is used as a subroutine It is assumed that factor can handle n without negative exponents Instead of n it is possible to input a factorization matrix i e the output of factor n This routine uses divisors as a subroutine then loops over the divisors In particular if n is an integer divisors are sorted by increasing size To avoid storing all divisors possibly using a lot of memory the following much slower routine loops over the divisors using essentially constant space FORDIV N my P E P factor N E P 2 P PL 1 forvec v vector E i 0 E i X factorback P v Noe 205 for i 1 10 5 FORDIV i time 3 445 ms for i 1 10 5 fordiv i d time 490 ms 3 11
198. e Be de ak he ke 176 gaussmodulo 176 gaussmodulo2 176 gbigomega 90 ebitand soa sor a eee a he eee ws 13 SOMES A eR ae we 73 gbitnegimply 73 BDILOL 26a mpos a ee e A a 74 EDILES E ia gos g in ee ee 74 GDLUKOn ua ario ex Oe te Gus 2 art 74 eboundcf camera Ge Bk eae 91 Ed aa pr Ae e 97 PCO op Av gos hoe Ba de ed cee Bh eo 74 SCE oe ota eda toe GA ee ee A we 91 BCD as ome kea a au a e BG ee eee ae 84 ECOD JE aa a a ee GS ee a ee a 75 PCOS ei e a a we e ke E 84 ECO msi ea oe Re we 84 a kry a wil a sok Be Go ae ae a ho 80 BI sc eee wwe PR ws 65 SGIVENE rios ose 65 PAIVENTLES s u d ge la da Ge 67 gdivround scs serasa t wba es 65 gen member function 119 GEN lt a dd at Gee ee ae ake T generic matrix o se saasa se braa 42 B ni ea mea dn ee he as 82 genrand gs giers ae Ca o i i ae a 78 GENtOStE sica a anp We oe es 72 Berfe ste wc YP bee fe ke ws 84 getheap 209 210 getrand visos 78 210 getstack 2 keke eg de css 210 GOUCIMG cdg wo a ee ii ek Goan 210 230 geval BP oscuros 161 BERD na Sew ad be aw ea A 84 BELOOF eh welts a ie oe a we 76 frac occa Ow eM GA we Ee S 76 STUNGUNIt e ne wee a ew me es 105 Geamd sr eee bg a ee ee Ee ewe es 85 aA sara ds eos E eae 85 BECO ica e la 97 BecdO kek aoe a e 97 genef a n aa a A ia 107 gerando a at cc o hE Tg che A 161 Bevel rep poaa Sew ER ra 80 shell capea ah amp Gee BG o Graces amp 1
199. e elements in Z NZ invertibles N select vector N i i x gt gcd x N 1 Finally select M x gt x selects the non 0 entries in M If the latter is a t_MAT we extract the matrix of non 0 columns Note that removing entries instead of selecting them just involves replacing the selection function f with its negation select vector 50 i1 i 2 1 x gt isprime x The library syntax is GEN selectO GEN A GEN f 3 12 25 setrand n reseeds the random number generator using the seed n No value is returned The seed is either a technical array output by getrand or a small positive integer used to generate deterministically a suitable state array For instance running a randomized computation starting by setrand 1 twice will generate the exact same output The library syntax is void setrand GEN n 3 12 26 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 3 12 27 trap e rec seq tries to evaluate seq trapping error e that is effectively preventing it from aborting computations in 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 excepti
200. e integral basis are very large If the fundamental units are simply too large to be represented in this form an error message is issued They could be obtained using the so called compact representation of algebraic numbers as a formal product of algebraic integers The latter is implemented internally but not publicly accessible yet When flag 2 on the contrary it is initially agreed that units are not computed Note that the resulting bnf will not be suitable for bnrinit and that this flag provides negligible time savings compared to the default In short it is deprecated When flag 3 computes a very small version of bnfinit a small Buchmann s 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 It is supposed to be used in conjunction with bnfmake tech is a technical vector empty by default see 3 6 7 Careful use of this parameter may speed up your computations considerably The components of a bnf or sbnf are technical and never used by the casual user In fact never access a component directly always use a proper member function However for the sake of 122 completeness and internal documentation their description is as follows We use the notations ex plained in the book by H Cohen A Course in Computational Algebraic Number Theory Graduate Texts in Maths 138 Springer Verlag 1993 Section
201. e natural calc sin Pi does not work since typing in the name of a built in function does not generate proper function objects built in function names are not bound to proper t_CLOSUREs as would be the case for user functions On the other hand g x x 2 calc g Pi works since g is a user function not a built in Here is a variation trigs x gt cos x x gt sin x x gt tan x an array of functions call i x trigs i x evaluates the appropriate function on argument x provided 1 lt i lt 3 Finally a more useful example APPLY f v vector v i f v i applies the function f to every element in the vector v The built in function apply is more powerful since it also applies to lists and matrices 2 7 6 Defining functions within a function Defining a single function is easy init x add y gt x y Basically we are defining a global variable add whose value is the function y gt x y The parentheses were added for clarity and are not mandatory init 5 add 2 92 7 A more refined approach is to avoid global variables and return the function init x y gt x y add init 5 Then add 2 still returns 7 as expected Of course if add is in global scope there is no gain but we can lexically scope it to the place where it is useful my add init 5 How about multiple functions then We can use the last idea and return a vector of functions but if we insist
202. e over F This is intended to be used with ffgen above For instance if P ffinit 3 2 you can represent elements in F32 in term of g ffgen P g This function uses a fast variant of Adleman Lenstra s algorithm The library syntax is GEN ffinit GEN p long n long v 1 where vis a variable num ber 3 4 27 fflog x g o discrete logarithm of the finite field element x in base g If present o is the factorization of the multiplicative order of g If no o is given assume that g is a primitive root t ffgen ffinit 7 5 o fforder t 2 5602 not a primitive root fflog t 10 t 3 11214 indeed correct modulo o fflog t 10 t factor o 4 10 The library syntax is GEN fflog GEN x GEN g GEN o NULL 3 4 28 fforder x 0 multiplicative order of the finite field element x If o is present it is assumed to be a multiple of the order of the element This multiple can also be given by a factorization matrix which is the preferred format t ffgen ffinit nextprime 10 8 5 g ffprimroot t o g not needed here but o will be useful fforder g 1000000 o time O ms 5 5000001750000245000017150000600250008403 fforder g 1000000 time 16 ms noticeably slower 6 5000001750000245000017150000600250008403 The library syntax is GEN fforder GEN x GEN o NULL 3 4 29 ffprimroot z amp o return a primitive root of the multiplicative group of the definition
203. e t_COMPLEX T i Complex numbers type t_PADIC Qp p adic numbers type t_QUAD Qu Quadratic Numbers where Z w Z 2 type t_POLMOD T X P Polmods polynomials modulo P T X type t_POL T X Polynomials type t_SER T X Power series finite Laurent series type t_RFRAC T X Rational functions in irreducible form type t_VEC Tr Row i e horizontal vectors type t_COL T Column i e vertical vectors type t_MAT Mm n T Matrices type t_LIST Jr Lists type t_STR Character strings type t_CLOSURE Functions and where the types T in recursive types can be different in each component The first nine basic types from t_INT to t_POLMOD are called scalar types because they essentially occur as coefficients of other more complicated objects Type t_POLMOD is used to define algebraic extensions of a base ring and as such is a scalar type In addition there exist types t_QFR and t_QFI for integral binary quadratic forms and the in ternal type t_VECSMALL The latter holds vectors of small integers whose absolute value is bounded by 23 resp 263 on 32 bit resp 64 bit machines They are used internally to represent permu tations polynomials or matrices over a small finite field etc T Every PARI object called GEN in the sequel belongs to one of these basic types Let us have a closer look 1 3 1 Integers and reals they are of arbitrary and varying length each number carrying in its internal representation its own len
204. e the remaining arguments without a trailing newline same output as print1 3 12 32 writebin filename x writes appends to filename the object x in binary format This format is not human readable but contains the exact internal structure of x and is much faster to save load than a string expression as would be produced by write The binary file format includes a magic number so that such a file can be recognized and correctly input by the regular read or r function If saved objects refer to polynomial variables that are not defined in the new session they will be displayed in a funny way see Section 3 12 15 If x is omitted saves all user variables from the session together with their names Reading such a named object back in a gp session will set the corresponding user variable to the saved value E g after x 1 writebin log reading log into a clean session will set x to 1 The relative variables priorities see Section 2 5 3 of new variables set in this way remain the same preset variables retain their former priority but are set to the new value In particular reading such a session log into a clean session will restore all variables exactly as they were in the original one User functions installed functions and history objects can not be saved via this function Just as a regular input file a binary file can be compressed using gzip provided the file name has the standard gz extension In the prese
205. e v i 7 is understood to be in fact V 2 i 1 j of a unique big vector V This awkward scheme allows for larger vectors than could be otherwise represented V k is itself a vector W whose length is the number of ideals of norm k We consider first the case where arch was specified Each component of W corresponds to an ideal m of norm k and gives invariants associated to the ray class field L of bnf of conductor m arch Namely each contains a 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 its absolute discriminant We set d r D 0 if m is not the finite part of a conductor 128 If arch was omitted all t 2 possible values are taken and a component of W has the form im d1 71 D1 d 7 D where mis the finite part of the conductor as above and d ri Di are the invariants of the ray class field of conductor m v where v is the i th archimedean component ordered by inverse lexicographic order so v 0 0 ve 1 0 0 etc Again we set dj ri D 0 if m ui is not a conductor Finally each prime ideal pr p a e f 8 in the prime factorization m is coded as the integer p n 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 bnfdecode
206. e x coordinates and the other ones contain the y coordinates of curves to plot 3 10 26 plotrline w dx dy draw in the rectwindow w the part of the segment x1 y1 11 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 dz yl dy even if it is outside the window 3 10 27 plotrmove w dx dy move the virtual cursor of the rectwindow w to position 1 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 28 plotrpoint w dx dy draw the point 11 dx yl dy on the rectwindow w if it is inside w where 21 y1 is the current position of the cursor and in any case move the virtual cursor to position x1 dx yl dy 3 10 29 plotscale w 11 12 y1 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 30 plotstring w x flags 0 draw on the rectwindow w the String x see Section 2 9 at the current position of the cursor flag is use
207. ecode then run When the error occurs we have nothing but the bytecode at our disposal which is not easy to understand 45 2 10 4 Error handlers The break loop described above is a sophisticated example of an error handler a function that is executed whenever an error occurs supposedly to try and recover The break loop is quite a satisfactory error handler but it may not be adequate for some purposes for instance when gp runs in non interactive mode detached from a terminal So you can define a different error handler to be used in place of the break loop This is the purpose of the second argument of trap to specify an error handler We will discuss the first argument at the very end For instance trap writebin crash note the comma argi is omitted After that whenever an error occurs the list of all user variables is printed and they are all saved in binary format in file crash ready for inspection Of course break loops are no longer available the new handler has replaced the default one Besides user defined handlers as above there are two special handlers you can use in trap which are e trap do nothing handler to disable the trapping mechanism and let errors propa gate which is the default situation on startup etrap omitted argument default handler to trap errors by a break loop 2 10 5 Protecting code Finally trap can define a temporary handler used within the scope of a code fra
208. ed 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 archer not available on this architecture or operating system errpile the PARI stack overflows gdiver division by 0 invmoder impossible inverse modulo siginter SIGINT received usually from Control C talker miscellaneous error typeer wrong type user user error from the error function The library syntax is GEN trapO char e char rec NULL char seq NULL 3 12 28 type s this is useful only under gp Returns the internal type name of the PARI object x as a string Check out existing type names with the metacommand t For example type 1 will return t_INT The library syntax is GEN typeO GEN x The macro typ is usually simpler to use since it returns a long that can easily be matched with the symbols t_ The name type was avoided since it is a reserved identifier for some compilers 3 12 29 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 12 30 write filename str writes appends to filename the remaining arguments and ap pends a newline same output as print 214 3 12 31 writel filename str writes appends to filenam
209. efining a congruence subgroup of the ray class group corresponding to bnr the trivial congruence subgroup if omitted 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 xy For the value at s 0 the function returns in fact for each character x a vector r cy where r 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 cy sx O s xt1 near 0 flag is optional 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 y 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 bnrL1 bnr 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 126 bnrL1 bnr2 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 gro
210. egative Although imaginary forms could be positive or negative definite only positive definite forms are implemented In the case of forms with positive discriminant t_QFR you may add an optional fourth 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 22 2 3 14 Row and column vectors 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 If the variable x contains a row or column vector x m refers to its m th entry You can assign a result to a m i e write something like z k expr 2 3 15 Matrices 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
211. egration step is 1 2 Reasonable values of m are m 6 or m 7 for 100 decimal digits and m 9 for 1000 decimal digits The result is technical but in some cases it is useful to know the output Let x t be the change of variable which is used tab 1 contains the integer m as above either given by the user or computed from the default precision and can be recomputed directly using the function intnumstep tab 2 and tab 3 contain respectively the abscissa and weight corresponding to t 0 0 and 0 tab 4 and tab 5 contain the abscissas and weights corresponding to positive t nh for 1 lt n lt N and h 1 2 nh and Y nh Finally tab 6 and tab 7 contain either the abscissas and weights corresponding to negative t nh for N lt n lt 1 or may be empty but not always if p t is an odd function implicitly we would have tab 6 tab 4 and tab 7 tab 5 The library syntax is GEN intnuminit GEN a GEN b long m long prec 3 9 12 intnuminitgen t a b ph m 0 flag 0 initialize tables for integrations from a to b using abcissas ph t and weights ph t Note that there is no equal sign after the variable name t since t always goes from oo to infty but it is ph t which goes from a to b and this is not checked If flag 1 or 2 multiply the reserved table length by gflag to avoid corresponding error The library syntax is GEN intnuminitgen0 GEN t GEN a long b long ph lon
212. egrees Returns an error if one of the polynomials is not squarefree Note that it is more efficient to reduce to the case where P and Q are irreducible first The routine will not perform this for you since it may be expensive and the inputs are irreducible in most applications anyway Assuming P is irreducible of smaller degree than Q for efficiency it is in general much faster to proceed as follows nf nfinit P L nffactor nf Q 1 vector L i rnfequation nf L i to obtain the same result If you are only interested in the degrees of the simple factors the rnfequation instruction can be replaced by a trivial poldegree P poldegree L i If flag 1 outputs a vector of 4 component vectors R a b k where R ranges through the list of all possible compositums as above and a resp b expresses the root of P resp Q as an element of Q X R Finally k is a small integer such that b ka X modulo R A compositum is quite often defined by a complicated polynomial which it is advisable to reduce before further work Here is a simple example involving the field Q 5 5 z polcompositum x 5 5 polcyclo 5 1 1 pol z 1 pol defines the compositum 12 x720 5 x719 15 x718 35x x 17 70 x716 141 x715 260 x714 149 355 x713 95 x712 1460 x711 3279 x 10 3660 x 9 2005 x78 705 x77 9210 x 6 13506 x75 7145 x74 2740 x73 1040 x72 320 x 256 a z 2 a5 5
213. ember PARI is not a computer algebra system sumalt is heuristic but its use can be rigorously justified for a given function in particular our s formula Indeed Peter Borwein An efficient algorithm for the Riemann zeta function CMS Conf Proc 27 2000 pp 29 34 proved that the formula used in sumalt with n terms computes 1 2 s with a relative error of the order of 3 V 8 I s 71 36 2 7 3 Beware scopes Be extra careful with the scopes of variables What is wrong with the following definition FirstPrimeDiv x my p forprime p 2 x if x p 0 break P FirstPrimeDiv 10 1 0 Hint the function body is equivalent to my newp 0 forprime p 2 x if x p 0 break newp Detailed explanation The index p in the forprime loop is lexically scoped to the loop and is not visible to the outside world Hence it will not survive the break statement More precisely at this point the loop index is restored to its preceding value The initial my p although well meant adds to the confusion it indeed scopes p to the function body with initial value 0 but the forprime loop introduces another variable unfortunately also called p scoped to the loop body which shadows the one we wanted So we always return 0 since the value of the p scoped to the function body never changes and is initially 0 To sum up the routine returns the p declared local to it not the one which
214. en triple would design a unique group Specifically for polynomials of degree lt 7 the groups are coded as follows using standard notations 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 Moo 20 1 1 As 60 1 1 Ss 120 1 1 In degree 6 Cs 6 1 1 S3 6 1 2 De 12 1 1 A4 12 1 1 Gis 18 1 1 Sg 24 1 1 A4 x C2 24 1 2 S 24 1 1 E 86 1 1 G3 86 1 1 S4 x C2 48 1 1 As PSL 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 PSL2a M PSLs 2 168 1 1 A7 2520 1 1 S7 5040 1 1 This is deprecated and obsolete but for reasons of backward compatibility we cannot change this behaviour yet So you can use the default new_galois_format to switch to a consistent naming scheme namely k is always the standard numbering of the group among all transitive subgroups of Sn If this default is in effect the above groups will be coded as 150 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 2 In degree 4 Cy 4 1 1 Va 4 1 2 Da
215. entries 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 zx If flag 0 uses the naive algorithm This should never be used if the dimension is at all large larger than 10 say It is recommended to use either mathnfmod x matdetint x when x has maximal rank or mathnf x 1 Note that the latter is in general faster than mathnfmod and also provides a base change matrix If flag 1 uses Batut s algorithm which is much faster than the default Outputs a two component row vector H U where H is the upper triangular Hermite normal form of x defined as above and U is the unimodular transformation matrix such that zU 0 H U has in general huge coefficients in particular when the kernel is large If flag 3 uses Batut s algorithm but 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 The matrix U is smaller than with flag 1 but may still be large 172 If flag 4 as in case 1 above but uses a heuristic variant of LLL reduction along the way The matrix U is in general close to optimal in terms of smallest L norm but the reduction is slower than in case 1 The library syntax is GEN mathnf0 GEN x long flag Also available are GEN hnf GEN x flag 0 and GEN hnfal1 GEN
216. ents of x off by at most 1 If you want the exact value you can use Str x which is slower The library syntax is long sizedigit GEN x 79 3 2 48 truncate x 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 applies componentwise on vector matrices e is then the maximal number of error bits If x is a rational function the result is the integer part Euclidean quotient of numerator by denominator and e is not set 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 GEN truncO GEN x GEN e NULL Also available are GEN gcvtoi GEN x long e and GEN gtrunc GEN x 3 2 49 valuation x p computes the highest exponent of p dividing x If p is of type integer x must be an integer an intmod whose modulus is divisible by p a fraction a q adic number with q p or a polynomial or power s
217. epts the following synonyms for some of the above functions 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 it is the assignment statement We do not use the customary C operators for bitwise and or bitwise or use bitand or bitor The standard boolean operators inclusive or amp amp and and not are also available 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 Col z transforms the object x into a column vector The vector has a single component except when x is e a vector or a quadratic form in which case the resulting vector is simply the initial object considered as a column vector e a matrix the column of row vectors comprising the matrix is returned e a character string a column of individual characters is returned e 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
218. equal to the index G H 117 3 6 4 Relative extensions We now have a look at data structures associated to relative extensions of number fields L K and to projective Zkx modules When defining a relative extension L K the nf associated to the base field K must be defined by a variable having a lower priority see Section 2 5 3 than the variable defining the extension For example you may use the variable name y to define the base field K and x to define the relative extension L K e rnf denotes a relative number field i e a data structure output by rnfinit associated to the extension L K The nf associated to be base field K is rnf nf e A relative matrix is a matrix whose entries are elements of K always expressed as column vectors on the integral basis rnf nf zk This is an interface bug elements of K in arbitrary form should be allowed Most functions can in fact handle them Hence it is a matrix of vectors e An ideal list is a row vector of fractional ideals of the number field nf in HNF form This is an interface bug ideals in arbitrary form should be allowed e A pseudo matrixis a pair A T 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 is represented by a 2 component row vector e If J a a is an ideal list and A Aj A is a vector of the same length of elements in some Zx module the projective module generated by A I is the Z
219. er basis as would be computed by nfbasis This is useful if the integer basis is known in advance or was computed conditionally pol polcompositum x 5 101 polcyclo 7 1 B nfbasis pol 1 faster than nfbasis pol but conditional nf nfinit pol B factor abs nf disc 5 18 7 25 101 24 NN NN B is conditional when its discriminant which is nf disc can t be factored In this example the above factorization proves the correctness of the computation 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 2 pol gives the 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 GEN nfinitO GEN pol long flag long prec 147 3 6 101 nfisideal nf x returns 1 if x is an ideal in the number field nf 0 otherwise The library syntax is long isideal GEN nf GEN x 3 6 102 nfisincl z y tests whether the number field K defined by
220. eries 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 long ggval GEN x GEN p 3 2 50 variable z gives the main variable of the object x and p if x is a p adic number Gives an error if x has no variable associated to it If x is omitted returns the list of user variables known to the interpreter by order of decreasing priority Highest priority is x which always come first The library syntax is GEN gpolvar GEN x NULL However in library mode this function should not be used for x non NULL since gvar is more appropriate Instead for x a p adic type t_PADIC pis gel x 2 otherwise use long gvar GEN x which returns the variable number of x if it exists NO_VARIABLE otherwise which satisfies the property varncmp NO_VARIABLE v gt 0 for all valid variable number v i e it has lower priority than any variable 80 3 3 Transcendental functions As a general rule which of course in some cases
221. eries 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 long ellrootno GEN E GEN p NULL 3 5 27 ellsearch N if N is an integer it is taken as a conductor else if N is a string it can be a curve name 11a1 a isogeny class 1la or a conductor 11 This function finds all curves in the elldata database with the given property If N is a full curve name the output format is N a a2 a3 a4 ag G where a a2 a3 a4 ag are the coefficients of the Weierstrass equation of the curve and G is a Z basis of the free part of the Mordell Weil group associated to the curve If N is not a full curve name the output is a vector of all matching curves in the above format The library syntax is GEN ellsearch GEN N Also available is GEN ellsearchcurve GEN N that only accepts complete curve names 3 5 28 ellsigma E z flag 0 E being given by ellinit returns the value at z of the Weierstrass o function of the period lattice L of E z z2 o z L z II 1 estaa W wEL Alternatively one can input a lattice basis w1 w2 directly instead of E 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
222. ermtopol is applied to all components recursively Note that G galoisinit pol galoispermtopol G G 6 is equivalent to nfgaloisconj pol if degree of pol is greater or equal to 2 The library syntax is GEN galoispermtopol GEN gal GEN perm 133 3 6 45 galoissubcyclo N H fl 0 v computes the subextension of Q C fixed by the subgroup H C Z nZ By the Kronecker Weber theorem all abelian number fields can be generated in this way uniquely if n is taken to be minimal The pair n H is deduced from the parameters N H as follows e N an integer then n N H is a generator i e an integer or an integer modulo n or a vector of generators e N the output of znstar n H as in the first case above or a matrix taken to be a HNF left divisor of the SNF for Z nZ of type N cyc giving the generators of H in terms of N gen e N the output of bnrinit bnfinit y m 1 where mis a module H as in the first case or a matrix taken to be a HNF left divisor of the SNF for the ray class group modulo m of type N cyc giving the generators of H in terms of N gen In this last case beware that H is understood relatively to N in particular if the infinite place does not divide the module e g if m is an integer then it is not a subgroup of Z nZ but of its quotient by 1 If fl 0 compute a polynomial in the variable v defining the the subfield of Q fixed by the subgroup H of Z nZ
223. ero and the derivative of a vector or matrix is done componentwise One can use x as a shortcut if the derivative is with respect to the main variable of x By definition the main variable of a t_POLMOD is the main variable among the coefficients from its two polynomial components representative and modulus in other words assuming a polmod represents an element of R X T X the variable X is a mute variable and the derivative is taken with respect to the main variable used in the base ring R The library syntax is GEN deriv GEN x long v 1 where v is a variable number 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 If x is a character string eval x executes x as a GP command as if directly input from the keyboard and returns its output For convenience x is evaluated as if strictmatch was off In particular unused characters at the end of x do not prevent its evaluation eval 1a eval Warning unused characters a 4 1 1 The library syntax is GEN geval_gp GEN x Also available are GEN poleval GEN q GEN x GEN qfeval GEN q GEN x and GEN hgfeval GEN q GEN x to evaluate q at x where q is respectively assumed to be a polynomial a quadratic form a symmetric matrix or an Hermitian form a Hermitian complex matrix 161 3 7
224. ers have three components the prime p the modulus p and an ap proximation to the p adic number Here Z is considered as the projective limit lim Z p Z via its finite quotients and Q as its field of fractions Like real numbers the codewords contain an exponent giving the p adic valuation of the number and also the information on the precision of the number which is redundant with p but is included for the sake of efficiency 1 3 3 Finite field elements The exact internal format depends of the finite field size but it includes the field characteristic p an irreducible polynomial T F X defining the finite field F X T and the element expressed as a polynomial in the class of X 1 3 4 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 0 mod 4 and w 1 Vd 2 when d 1 mod 4 where d is the discriminant of a quadratic order Complex numbers correspond to the important special case w 1 Complex numbers are partially recursive the two components a and b can be of type t_INT t_REAL t_INTMOD t_FRAC or t_PADIC 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 1 mod 4 hence we must exclude these p when one explicitly uses a complex p adic type Quadratic numbers are more restricted their components m
225. ertible polynomial in RgXQ_inv a Mod 3 4 ry73 Mod 1 4 b y 6ty 5 y 4 y 3 y 2 y 1 Mod a b 1 non invertible polynomial in RgXQ_inv In fact the latter polynomial is invertible but the algorithm used subresultant assumes the base ring is a domain If it is not the case as here for Z 4Z a result will be correct but chances are an error will occur first In this specific case one should work with 2 adics In general one can try the following approach inversemod a b my m m polsylvestermatrix polrecip a polrecip b m matinverseimage m matid m 1 Polrev vecextract m Str poldegree b variable b inversemod a b 12 Mod 2 4 y 5 Mod 3 4 y 3 Mod 1 4 y 2 Mod 3 4 y Mod 2 4 This is not guaranteed to work either since it must invert pivots See Section 3 8 The library syntax is GEN gpow GEN x GEN n long prec for xn 3 1 9 divrem z y v creates a column vector with two components the first being the Eu clidean quotient x y the second the Euclidean remainder x x y y of the division of zx by y This avoids the need to do two divisions if one needs both the quotient and the remainder If v is present and x y are multivariate polynomials divide with respect to the variable v Beware that divrem x y 2 is in general not the same as x y no GP operator corresponds to it divrem 1 2 3 2 1 1 2 1 2 3 42 2 divrem Mod 2 9
226. es the quadratic number w a VD 2 where a 0 if D 0 mod 4 a 1 if D 1 mod4 so that 1 w is an integral basis for the quadratic order of discriminant D D must be an integer congruent to 0 or 1 modulo 4 which is not a square The library syntax is GEN quadgen GEN D 104 3 4 62 quadhilbert D pq relative equation defining the Hilbert class field of the quadratic field of discriminant D If D lt 0 uses complex multiplication Schertz s variant The technical component pq if supplied is a vector p q where p q are the prime numbers needed for the Schertz s method More precisely prime ideals above p and q should be non principal and coprime to all reduced representatives of the class group In addition if one of these ideals has order 2 in the class group they should have the same class Finally for efficiency ged 24 p 1 q 1 should be as large as possible The routine returns 0 if p q is not suitable If D gt 0 Stark units are used and in rare cases a vector of extensions may be returned whose compositum is the requested class field See bnrstark for details The library syntax is GEN quadhilbert GEN D GEN pq NULL long prec 3 4 63 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 D D must be an integer congruent to 0 or 1 modulo 4 which is not a square The library
227. ewprec GEN nf long prec One may call directly GEN bnfnew prec GEN bnf long prec or GEN bnrnewprec GEN bnr long prec 3 6 107 nfroots nf x roots of the polynomial x in the number field nf given by nfinit without multiplicity in Q if nf is omitted 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 see Section 2 5 3 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 GEN nfroots GEN nf NULL GEN x 3 6 108 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 z where z is a column vector expressing a primitive w th root of unity on the integral basis nf zk The library syntax is GEN rootsof1 GEN nf 148 3 6 109 nfsnf nf x given a torsion module x as a 3 component row vector A 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 di O 9 Zg dn and di 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 b1 bn and J a
228. ex less than bound If bound is a vector containing a single positive integer B then only subgroups of index exactly equal to B are computed For instance subgrouplist 6 2 1 6 0 O 2 2 0 O 2 6 3 O 1 2 1 O 1 3 0 O 2 1 0 0 2 6 0 O 1 2 0 O 1 3 0 0 1 1 0 0 1 subgrouplist 6 2 3 index less than 3 12 2 1 0 1 1 0 O 2 2 0 O 11 3 0 O 1 1 0 O 1 subgrouplist 6 2 1 31 index 3 43 3 0 0 11 bnr bnrinit bnfinit x 120 1 1 L subgrouplist bnr 8 In the last example L corresponds to the 24 subfields of Q 120 of degree 8 and conductor 12000 by setting flag we see there are a total of 43 subgroups of degree 8 159 vector L i galoissubcyclo bnr L i will produce their equations For a general base field you would have to rely on bnrstark or rnfkummer The library syntax is GEN subgrouplistO GEN bnr GEN bound NULL long flag 3 6 153 zetak nfz x 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 function by its gamma and exponential factors CAVEAT This implementation is not satisfactory and must be rewritten In particular e The accuracy of the result depends in an essential w
229. ex less than 2 in G Z 2Zg1 x Z 2Z qo G 2 2 forsubgroup H G 2 print H 1 1 1 2 2 1 1 O 1 1 206 The last one for instance is generated by 91 91 92 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 21 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 See galois subcyclo and galoisfixedfield for nfsubfields applications to Galois theory Warning the present implementation cannot treat a group G if one of its p Sylow subgroups has a cyclic factor with more than 2 resp 2 elements on a 32 bit resp 64 bit architecture 3 11 8 forvec X v seq flag 0 Let v be an n component vector where n is arbitrary of two component vectors a b for 1 lt i lt n This routine evaluates seq where the formal variables X 1 X n go from a to bj from a to bn ie X goes from a1 n to b1 bn with respect to the lexicographic ordering The formal variable with the highest index moves the fastest If flag 1 generate only nondecreasing vectors X and if flag 2 generate only strictl
230. f siN x lt eps do_something kkk function siN not yet defined no arrow The code is syntactically correct and compiled correctly even though the siN function a typo for sin is not defined at this point When trying to evaluate the bytecode however it turned out that siN was still undefined so we cannot evaluate the function call siN x The original input lines are long lost at this point however so we cannot give any meaningful context Runtime errors from the library will usually be clearer since by definition they answer a correctly worded query where all terms have a proper definition otherwise the evaluator would have protested first Also they have more mathematical content which should be easier to grasp than a parser s logic For instance 43 1 0 _ _ division by zero telling us that a runtime error occured while evaluating the binary operator the _ surrounding the operator are placeholders 2 10 2 Error recovery It is quite annoying to wait for some program to finish and find out the hard way that there was a mistake in it like the division by 0 above sending you back to the prompt First you may lose some valuable intermediate data Also correcting the error may not be obvious you might have to change your program adding a number of extra statements and tests to try and narrow down the problem A slightly different situation still related to error recovery is when you you actually
231. f the function is exponentially decreasing sumnum is slower and less accurate than sumpos or suminf so should not be used The function uses the intnum routines and integration on the line R s o The optional argument tab is as in intnum except it must be initialized with sumnuminit instead of intnuminit When tab is not precomputed sumnum can be slower than sumpos when the latter is applicable It is in general faster for slowly decreasing functions Finally if flag is nonzero we assume that the function f to be summed is of real type i e satisfies f z f Z which speeds up the computation Xp 308 a sumpos n 1 1 n 3 n 1 time 1 410 ms tab sumnuminit 2 time 1 620 ms slower but done once and for all b sumnum n 1 2 1 n 3 n 1 tab time 460 ms 3 times as fast as sumpos a b 4 1 0 E 306 0 E 320 I perfect sumnum n 1 2 1 n 3t n 1 tab 1 a function of real type time 240 ms 12 1 0 E 306 twice as fast no imaginary part c sumnum n 1 2 1 n72 1 tab 1 time 170 ms fast d sumpos n 1 1 n 2 1 time 2 700 ms slow d c time O ms 5 1 97 E 306 perfect For slowly decreasing function we must indicate singularities Xp 308 a sumnum n 1 2 n 4 3 time 9 930 ms slow because of the computation of n a zeta 4 3 time 110 ms 196 1 2 42 E 107 lost 200
232. f 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 Note also that member functions will not work on sbnf you have to use bnfmake explicitly first The library syntax is GEN bnfinitO GEN P long flag GEN tech NULL long prec 123 3 6 13 bnfisintnorm bnf x computes a complete system of solutions modulo units of positive norm of the absolute norm equation Norm a x where a is an integer in bnf If bnf has not been certified the correctness of the result depends on the validity of GRH See also bnfisnorm The library syntax is GEN bnfisintnorm GEN bnf GEN x 3 6 14 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 Assuming 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 See also bnfisintnorm The library syntax is GEN bn
233. fact O 2 where e is now usually a negative binary exponent This of course is printed as usual for a floating point number 0 00 or 0 Exx depending on the output format and not with a O symbol as with p adics or power series With respect to the natural ordering on the reals we make the following convention whatever its exponent a real zero is smaller than any positive number and any two real zeroes are equal 1 4 The PARI philosophy The basic principles which govern PARI is that operations and functions should firstly give as exact a result as possible and secondly be permitted if they make any kind of sense In this respect we make an important distinction between exact and inexact objects by definition types t_REAL t_PADIC or t_SER are imprecise A PARI object having one of these imprecise types anywhere in its tree is inexact and exact otherwise No loss of accuracy rounding error is involved when dealing with exact objects Specifically an exact operation between exact objects will yield an exact object For example dividing 1 by 3 does not give 0 333 but the rational number 1 3 To get the result as a floating point real number evaluate 1 3 or 0 1 3 Conversely the result of operations between imprecise objects although inexact by nature will be as precise as possible Consider for example the addition of two real numbers x and y The accuracy of the result is a priori unpredictable it depends on the precisions
234. ff bnr bnf nf the codifferent inverse of the different in the ideal group disc bnr bnf nf discriminant fu bnr bnf nf fundamental units index bnr bnf nf index of the power order in the ring of integers nf bnr bnf nf number field r bnr bnf nf the number of real embeddings r2 bnr bnf nf the number of pairs of complex embeddings reg bnr bnf regulator 119 roots of the polynomial generating the field the T2 matrix see nfinit a generator for the torsion units w u1 Uy ui is a vector of fundamental units w generates the torsion units integral basis i e a Z basis of the maximal order roots bnr bnf nf t2 bnr bnf nf tu bnr bnf tufu bnr bnf zk bnr bnf nf o O IN 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 3 6 7 Class group units and the GRH Some of the functions starting with bnf 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
235. field of the finite field element x not necessarily the same as the field generated by x If present o is set to the factorization of the order of the primitive root useful in fflog t ffgen ffinit nextprime 1078 5 g ffprimroot t to o 3 2 1 71 1 491 1 39191 1 101833 1 1594407138061 1 96 22540118872981 1 fflog g 1000000 g time 3 380 ms 75 1000000 fflog g 1000 g time 24 ms fflog g 1000 8 0 time 12 ms For simple inputs as the above last two providing the extra argument o yields interesting speedups The library syntax is GEN ffprimroot GEN x GEN o NULL 3 4 30 fibonacci x xt Fibonacci number The library syntax is GEN fibo long x 3 4 31 gced zx y creates the greatest common divisor of x and y x and y can be of quite general types for instance both rational numbers If y is omitted and zx is a vector returns the gcd of all components of x i e this is equivalent to content x When z and y are both given and one of them is a vector matrix type the GCD is again taken recursively on each component but in a different way If y is a vector resp matrix then the result has the same type as y and components equal to gcd x y il resp gcd x y i1 Else if x is a vector matrix the result has the same type as x and an analogous definition Note that for these types gcd is not commutative The algorithm used is a naive Euclid
236. fisnorm GEN bnf GEN x long flag long prec 3 6 15 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 ideal 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 v2 where v is the vector of components c of the class of the ideal x in the class group expressed on the generators g given by bnfinit specifically bnf gen The c are chosen so that 0 lt ci lt ni where n is the order of g the vector of n being bnf cyc v2 gives on the integral basis the components of a such that x a g In particular x is principal if and only if v is equal to the zero vector In the latter case x aZx 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 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 computations The library syntax is GEN isprincipalall GEN bnf GEN x long flag 3 6 16 bnf
237. for the Sparc architecture version 7 version 8 with SuperSparc processors and version 8 with MicroSparc I or II processors UltraSparcs use the MicroSparc II version e the DEC Alpha 64 bit processor e the Intel Itanium 64 bit processor e the PowerPC equipping old macintoshs G3 G4 etc e the HPPA processors both 32 and 64 bit A third version uses the GNU MP library to implement most of its multiprecision kernel It improves significantly on the native one for large operands say 100 decimal digits of accuracy or more You should enable it if GMP is present on your system Parts of the first version are still in use within the GMP kernel but are scheduled to disappear An historical version of the PARI GP kernel written in 1985 was specific to 680x0 based computers and was entirely written in MC68020 assembly language It ran on SUN 3 xx Sony News NeXT cubes and on 680x0 based Macs It is no longer part of the PARI distribution to run PARI with a 68k assembler micro kernel use the GMP kernel 1 3 The PARI types The GP language is not typed in the traditional sense in particular variables have no type In library mode the type of all PARI objects is GEN a generic type On the other hand it is dynamically typed each object has a specific internal type depending on the mathematical object 1t represents The crucial word is recursiveness most of the PARI types are recursive For example the basic internal type t_COMP
238. function does not depend on the system s random number generator Up to version 2 4 included pseudo random numbers were obtained by means of linear congruences and were not well distributed in arithmetic progressions We now use Brent s XORGEN algorithm based on Feed back Shift Registers see http wwwmaths anu edu au brent random html The generator has period 24096 1 passes the Crush battery of statistical tests of L Ecuyer and Simard but is not suitable for cryptographic purposes one can reconstruct the state vector from a small sample of consecutive values thus predicting the entire sequence The library syntax is GEN genrand GEN N NULL 3 2 43 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 GEN greal GEN x 3 2 44 round z amp e If x is in R rounds z to the nearest integer rounding to 00 in case of ties then 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 78 Important remark 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 24x
239. function has higher priority To get the default help use 77 default log default simplify 7 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 n where n would yield merely a list of functions Finally a few key concepts in gp are 59 documented in this way metacommands e g defaults e g 7 psfile and type names 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
240. g prec 3 9 13 intnumromb X a b expr flag 0 numerical integration of expr smooth in Ja bl with respect to X This function is deprecated use intnum instead 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 have 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 192 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 accomplished 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
241. g prec Also available is sumpos2 with the same arguments flag 1 198 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 suggested ideas or submitted patches for this section of the code There are three types of graphic functions 3 10 1 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 3 10 2 Low level plotting functions called rectplot functions sharing the prefix plot where every drawing primitive point line box etc is specified by the user These low level functions 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 win dows using a default color associated to that window which can be changed using the plotc
242. gebra defined by pol If pol is not squarefree an error message will be issued The library syntax is GEN rnfequation0 GEN nf GEN pol long flag 3 6 131 rnfhnfbasis bnf x given 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 and returns 0 otherwise The library syntax is GEN rnfhnfbasis GEN bnf GEN x 3 6 132 rnfidealabstorel rnf x let rnf be a relative number field extension L K as output by rnfinit and x an ideal of the absolute extension L Q given by a Z basis of elements of L Returns the relative pseudo matrix in HNF giving the ideal x considered as an ideal of the relative extension L K If x is an ideal in HNF form associated to an nf structure for instance as output by idealhnf nf use rnfidealabstorel rnf nf zk x to convert it to a relative ideal The library syntax is GEN rnfidealabstorel GEN rnf GEN x 154 3 6 133 rnfidealdown rnf x let rnf be a relative number field extension L K as output by rnfinit and x an ideal of L given either in relative form or by a Z basis of elements of L see Section 3 6 132 returns the ideal of K below zx i e the intersection of x with K The library syntax is GEN rnfidealdown GEN rnf GEN x 3 6 134 rnfidealhnf rnf x rnf being a relative number field extension L
243. gment protecting it from errors by providing replacement code should the trap be activated The expression trap recovery statements evaluates and returns the value of statements unless an error occurs during the evaluation in which case the value of recovery is returned As in an if else clause with the difference that statements has been partially evaluated with possible side effects For instance one could define a fault tolerant inversion function as follows inv x trap oo 1 x for i 1 1 print inv i 00 f Protected codes can be nested without adverse effect the last trap seen being the first to spring 2 10 6 Trapping specific exceptions We have not yet seen the use of the first argument of trap which has been omitted in all previous examples It simply indicates that only errors of a specific type should be intercepted to be chosen among gdiver division by 0 invmoder impossible inverse modulo archer not available on this architecture or operating system typeer wrong type errpile the PARI stack overflows Omitting the error name means we are trapping all errors For instance the following can be used to check in a safe way whether install works correctly in your gp 46 broken_install trap archer return 0S install addii GG 2 trap USE if addii 1 1 2 BROKEN The function returns 0 if everything works the omitted else clause of the if OS if the o
244. gth 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 nonexistent integers must be in absolute value less than 228435451 i e roughly 80807123 decimal 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 279 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 the native PARI kernel does not contain asymptotically fast DF T based techniques Hence although it is possible to use PARI to do computations with 107 decimal digits better programs can be written for such huge numbers At the very least the GMP kernel should be used at this point For reasons of backward compatibility we do not enable GMP by default but you should enable it Integers and real numbers are non recursive types 1 3 2 Intmods rational numbers p adic numbers polmods and rational functions these are recursive but in a restricted way For intmods or polmods there are two components the modulus which must be of type integer resp polynomial and the representative number resp 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 numb
245. hat 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 36 The library syntax is GEN gdiv GEN x GEN y for x y 3 1 5 The expression x y is the Euclidean quotient of x and y If y is a real scalar this is defined as floor a y if y gt 0 and ceil x y if y lt 0 and the division is not exact Hence the remainder x 2 y y is in 0 y Note that when y is an integer and x a polynomial y is first promoted to a polynomial of degree 0 When is a vector or matrix the operator is applied componentwise The library syntax is GEN gdivent GEN x GEN y for a y 65 3 1 6 The expression x y evaluates to the rounded Euclidean quotient of x and y This is the same as x y except for scalar division the quotient is such that the corresponding remainder is smallest in absolute value and in case of a tie the quotient closest to 00 is chosen hence the remainder would belong to y 2 y 2 When x is a vector or matrix the operator is applied componentwise The library syntax is GEN gdivround GEN x GEN y for x y 3 1 7 The expression x
246. hat Re atan 7 2 7 2 The library syntax is GEN gatan GEN x long prec 3 3 13 atanh x principal branch of tanh x 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 GEN gath GEN x long 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 GEN bernfrac long x 3 3 15 bernreal x Bernoulli number Bz as bernfrac but B is returned as a real number with the current precision The library syntax is GEN bernreal long x long prec 3 3 16 bernvec x creates a vector containing as rational numbers the Bernoulli numbers Bo Bo Box This routine is obsolete Use bernfrac instead each time you need a Bernoulli number in exact form Note this routine is implemented using repeated independent calls to bernfrac which is faster than the standard recursion in exact arithmetic It is only kept for backward compatibility it is not faster than individual calls to bernfrac its output uses a lot of memory space and coping with the index shift is awkward The library syntax is GEN bernvec long x 3 3 17 besselh1 nu x H Bessel function of index nu and argument z The library syntax is GEN hbessel1 GEN nu GEN x long prec 3 3 18 besselh2 nu x H Bessel function of index nu and argument z The library syntax is G
247. hen 1 and the result is concatenated as explained above In case of doubt you can surround part of your text by parenthesis to force immediate interpretation of a subexpression print a 1 is another solution 2 9 2 Keywords Since there are cases where expansion is not 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 a2 b 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 Reference The arguments of the following functions are processed in string context Str addhelp second argument default second argument error extern plotstring second argument plotterm first argument read and readvec system all the pr
248. 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 See Section 3 2 18 for the behaviour at negative arguments The library syntax is GEN gbittest GEN x GEN n 3 2 23 bitxor z y bitwise exclusive or of two integers x and y that is the integer Se xorg See Section 3 2 18 for the behaviour for negative arguments The library syntax is GEN gbitxor GEN x GEN y 3 2 24 ceil x ceiling of x 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 Euclidean quotient of the numerator by the denominator The library syntax is GEN gceil GEN x 3 2 25 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 A t_PADIC is lifted as above if its valuation v is non negative if not returns the fraction p centerlift x in particular note that rational reconstruction is not attempted If x is of type fraction complex quadratic polynomial power series rational function vector or matrix the lift is done for each coefficient Reals are forbidden The library syntax is GEN centerliftO GEN x long v 1 where vis a variable number Also available is GEN centerlift GEN x
249. ibly use a suborder of the maximal order The primes dividing the index of the order chosen are larger than primelimit or divide integers stored in the addprimes table 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 fa is given it is assumed that it is the two column matrix of the factorization of the discriminant of the polynomial x The library syntax is GEN polredO GEN x long flag GEN fa NULL Also available is GEN polred GEN x flag 0 3 6 115 polredabs x flag 0 finds one of the polynomial defining the same number field as the one defined by x and such that the sum of the squares of the modulus of the roots i e the T2 norm is minimal All x accepted by nfinit are also allowed here e g non monic polynomials nf bnf x Z_K_basis 151 Warning this routine uses an exponential time algorithm to enumerate all potential generators and may be exceedingly slow when the number field has many subfields hence a lot of elements of small T norm E g do not try it on the compositum of many quadratic fields use polred instead 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 x 4 gives all polynomials of minimal T norm of the tw
250. icant width and height of characters If flag 0 sizes of ticks and characters are in pixels otherwise are fractions of the screen size 202 3 10 15 plotinit w x 0 y 0 flag 0 initialize the rectwindow w destroying any rect objects you may have already drawn in w The virtual cursor is set to 0 0 The rectwindow size is set to width x and height y If flag 0 x and y represent pixel units Otherwise x and y are understood as fractions of the size of the current output device hence must be between 0 and 1 and internally converted to pixels 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 independent of the output device a window of maximal size accessed through coordinates in the 0 1000 x 0 1000 range s plothsizes plotinit 0 s 11 1 s 2 1 plotscale 0 0 1000 0 1000 3 10 16 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 plotinit first to specify the new size So it s better in this case to use plotinit directly as this throws away any previous work in the given rectwindow 3 10 17 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
251. ications then let the computation go on as explained above A break loop looks like this v 0 1 v _ _ division by zero x Break loop type break or Control d to go back to GP break gt So the standard error message is printed first The break gt at the bottom is a prompt and hitting v then lt Return gt we see break gt v 0 explaining the problem We could have typed any gp command not only the name of a variable of course There is no special set of commands becoming available during a break loop as they would in most debuggers Unfortunately lexically scoped variables are inaccessible to the evaluator during the break loop for v 2 2 print 1 v 1 2 1 xxx _ _ division by zero Break loop type break or Control d to go back to GP break gt v v Since loop indices are automatically lexically scoped they no longer exist when the break loop is run Important Note upon startup this mechanism is off Type trap or include it in a script to start trapping errors in this way By default you will be sent back to the prompt Technical Note When you enter a break loop due to a PARI stack overflow the PARI stack is reset so that you can run commands otherwise the stack would immediately overflow again Still as explained above you do not lose the value of any gp variable in the process Unfortunately we can never have context here since the code if first compiled into byt
252. if a vector with negative norm occurs non positive matrix or too many roudoff errors 3 8 46 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 GEN jacobi GEN x long prec 3 8 47 qflll x flag 0 LLL algorithm applied to the columns of the matrix x The columns of x must be linearly independent unless specified otherwise below The result is a unimodular transformation matrix T such that T is an LLL reduced basis of the lattice generated by the column vectors of x If flag 0 default the computations are done with floating point numbers using House holder matrices for orthogonalization If x has integral entries then computations are nonetheless approximate with precision varying as needed Lehmer s trick as generalized by Schnorr If flag 1 it is assumed that x is integral The computation is done entirely with integers In this case x needs not be of maximal rank but if it is not T will not be square This is slower and no more accurate than flag 0 above if x has small dimension say 100 or less If flag 2 x should be an integer matrix whose columns are linearly independent Returns a partially reduced basis for x using an unpublished algorithm by Peter Montgomery a ba
253. il 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 13 while a seq while a is non zero evaluates the expression sequence seg The test is made before evaluating the seq hence in particular if a is initially equal to zero the seq will not be evaluated at all 3 12 Programming in GP other specific functions 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 9 the latter don t get expanded at all and you can type them without any enclosing quotes The former are dynamic objects where everything outside quotes gets immediately expanded 3 12 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 will not protest if you skip this Nothing prevents you from modifying the help of built in PARI functions But if you do we would like to hear why you needed to do it The library syntax
254. ilable is GEN gis square GEN x 3 4 38 issquarefree x true 1 if x is squarefree false 0 if not Here x can be an integer or a polynomial The library syntax is GEN gissquarefree GEN x 99 3 4 39 kronecker z y Kronecker symbol x y where x and y must be of type integer By definition this is the extension of Legendre symbol to Z x Z by total multiplicativity in both arguments with the following special rules for y 0 1 or 2 e x 0 1 if z 1 and 0 otherwise e x 1 1ifx gt 0 and 1 otherwise e 1 2 0 if x is even and 1 if x 1 1mod8 and 1 if x 3 3 mod 8 The library syntax is GEN gkronecker GEN x GEN y 3 4 40 lem z y least common multiple of x and y i e such that lem x y gcd x y abs a x y If y is omitted and x is a vector returns the lcm of all components of x When z and y are both given and one of them is a vector matrix type the LCM is again taken recursively on each component but in a different way If y is a vector resp matrix then the result has the same type as y and components equal to 1cm x y il resp 1cm x y i1 Else if x is a vector matrix the result has the same type as x and an analogous definition Note that for these types 1cm is not commutative Note that 1cm v is quite different from 1 v 1 for i 1 v 1 1cm 1 vf i Indeed 1cm v is a scalar but 1 may not be if one of the v i is a vector matrix The computa tion uses
255. ilistic primality test is used thus composites might not be detected although no example is known You are invited to play with the flag settings and watch the internals at 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 If you see anything funny happening please let us know The library syntax is GEN factorint GEN x long flag 3 4 24 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 GEN factormod0 GEN x GEN p long flag 3 4 25 ffgen P v return the generator g X mod P X of the finite field defined by the polynomial P which must have t_INTMOD coefficients If v is given the variable name is used to display g else the variable of the polynomial P is used The library syntax is GEN ffgen GEN P long v 1 where v is a variable number 95 3 4 26 ffinit p n v x computes a monic polynomial of degree n which is irreducibl
256. ily minimal 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 NV algorithm The library syntax is GEN elllseries GEN E GEN s GEN A NULL long prec 3 5 21 ellminimalmodel amp v return the standard minimal integral model of the rational elliptic curve E If present sets v to the corresponding change of variables which is a vector lu r s t with rational components The return value is identical to that of ellchangecurve E v The resulting model has integral coefficients is everywhere minimal a is 0 or 1 az is 0 1 or 1 and ag is 0 or 1 Such a model is unique and the vector v is unique if we specify that u is positive which we do The library syntax is GEN ellminimalmodel GEN E GEN v NULL 3 5 22 ellorder E z o gives the order of the point z on the elliptic curve E If the curve is defined over Q return zero if the point has infinite order The parameter o if present is a non zero multiple of the order of z For a curve defined over F it is very important to supply o since its computation is very expensive and should only be done once using o p 1 ellap E p or ellsea from the SEA package The library s
257. in the next section 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 factory settings using command line switches or a gprc Note the suffixes k M or G can be appended to a value which is a numeric argument with the effect of multiplying it by 10 10 and 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 saw in Section 2 9 the second argument to default is subject to string context expansion which means you can use run time values In other words something like a 3 default logfile file a log logs the output in file3 1log Some special defaults corresponding to filenames and prompts expand further the resulting value at the time they are set Two kinds of expansions may be 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 str time
258. in the relative extension The main variable of pol must be of higher priority see Section 2 5 3 than that of nf and the coefficients of pol must be in nf The result is a row vector whose components are technical 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 ra the number of real and complex places of K rnf 1 contains the relative polynomial pol rnf 2 is currently unused rnf 3 is a two component row vector d L K s where d 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 kx f70 L K rnf 5 is currently unused rnf 6 is currently unused rnf T 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 is currently unused rnf 10 is nf rnf 11 is the output of rnfequation nf pol 1 Namely a vector vabs with 3 entries describing the absolute extension L Q vabs 1 is an absolute equation more conveniently o
259. incorrect since the value of i tested by the i gt n is quite unrelated to the loop index One ugly workaround is for i 1 n if ok i isave i break if isave gt n return failure But it is usually more natural to wrap the loop in a user function and use return instead of break try for i 1 n if ok i return i O failure A list of variables can be lexically or dynamically scoped to the block between the declaration and the end of the innermost enclosing scope using a my or local declaration for i 1 10 my x y Z 12 172 temps needed within the loop body Note how the declaration can include optional initial values i2 i 2 in the above Variables for which no explicit default value is given in the declaration are initialized to 0 It would be more natural to initialize them to free variables but this would break backward compatibility To obtain this behaviour you may explicitly use the quoting operator my x x yy z z More generally in all iterative constructs which use a variable name for prod sum vector matrix plot etc the given variable is lexically scoped to the construct s body 31 A more complicated example for i 1 3 print main loop my x i local to the outermost loop for j 1 3 my y x72 local to the innermost loop print y y 2 xt When we leave the loops the values of x y i
260. ined as f a e f x e 2e for a suitably small epsilon depending on current precision It behaves as f x otherwise unary postfix vector matrix transpose unary postfix factorial x x a 1 1 member unary postfix member extracts member from structure x see Section 2 8 e Priority 5 unary prefix logical not x return 1 if x is equal to 0 specifically if gemp0 x 1 and 0 otherwise unary prefix cardinality 2 returns 1length 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 4 Euclidean quotient and remainder i e if qy r then x y q x y r If x and y are scalars q is an integer and r satisfies 0 lt r lt y if x and y are polynomials q and r are polynomials such that degr lt deg y and the leading terms of r and x have the same sign 25 rounded Euclidean quotient for integers rounded towards 00 when the exact quotient would be a half integer lt lt gt gt left and right binary shift By definition x lt lt n 2x2 ifn gt 0 and truncate 127 otherwise Right shift is defined by 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
261. ing environment variable override the defaults if set CC C compiler DLLD Dynamic library linker LD Static linker For instance Configure may avoid bin cc on some architectures due to various problems which may have been fixed in your version of the compiler You can try env CC cc Configure and compare the benches Also if you insist on using a C compiler and run into trouble with a fussy g try to use g fpermissive 219 The contents of the following variables are appended to the values computed by Configure CFLAGS Flags for CC CPPFLAGS Flags for CC preprocessor LDFLAGS Flags for LD The contents of the following variables are prepended to the values computed by Configure C_INCLUDE_PATH is prepended to the list of directories searched for include files Note that adding I flags to CFLAGS is not enough since Configure sometimes relies on finding the include files and parsing them and it does not parse CFLAGS at this time LIBRARY PATH is prepended to the list of directories searched for libraries You may disable inlining by adding DDISABLE_INLINE to CFLAGS and prevent the use of the volatile keyword with DDISABLE_VOLATILE 3 3 Debugging profiling If you also want to debug the PARI library Configure g creates a directory Oxxx dbg containing a special Makefile ensuring that the GP and PARI library built there is suitable for debugging If you want to profile GP or the library using gprof for instan
262. ing the next instruction sequence from the file we re in or from the user In particular we have the following possibly unexpected behaviour in read file gp x 1 were file gp contains an allocatemem statement the x 1 is never executed since all pending instructions in the current sequence are discarded The technical reason is that this routine moves the stack so temporary objects created during the current expression evaluation are not correct anymore In particular byte compiled expressions which are allocated on the stack To avoid accessing obsolete pointers to the old stack this routine ends by a longjmp The library syntax is void allocatememO GEN s NULL 3 12 4 apply f A Apply the t_CLOSURE f to the entries of A If A is a scalar return f A If A is a polynomial or power series apply f on all coefficients If A is a vector or list return the elements f x where x runs through A If A is a matrix return the matrix whose entries are the f A i j apply x gt x 2 1 2 3 4 1 1 4 9 16 apply x gt x 2 1 2 3 4 42 1 4 9 16 apply x gt x72 4 x72 3 x 2 13 16xx 2 9 x 4 The library syntax is GEN applyO GEN f GEN A 3 12 5 default key val returns the default corresponding to keyword key If val is present sets the default to val first which is subject to string expansion first Typing default or Xd yields the complete default list as well as their c
263. intzzx functions all the writezrx functions The arguments of the following functions are processed as keywords alias default first argument install all arguments but the last trap first argument whatnow 2 9 3 Useful examples The function Str converts its arguments into strings and concatenate them Coupled with eval it is very powerful The following example creates generic matrices genmat u v s x matrix u v i j eval Str s i j genmat 2 3 genmat 2 3 m 1 x11 m11 x12 m12 x13 m13 x21 m21 x22 m22 x23 m23 Two last examples hist 10 20 returns all history entries from 10 to 20 neatly packed into a single vector histlast 10 returns the last 10 history entries 42 hist a b vector b a 1 i eval Str a 1 i histlast n vector n i eval Str i 1 2 10 Errors and error recovery 2 10 1 Errors Your input program is first compiled to some more efficient bytecode then the latter is evaluated calling appropriate functions from the PARI library Accordingly there are two kind of errors syntax errors occuring during the compilation phase and runtime errors produced by functions in the PARI library Both kinds are fatal to your computation gp will report the error perform some cleanup restore variables modified while evaluating the erroneous command close open files reclaim unused memory etc and output its usual prompt When reporting a syntax error gp trie
264. ironment variable HOME is defined gp then tries HOME gprc on a Unix system HOME _gprce 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 gpre file you will 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 list it 2 15 Using readline This very useful library provides line editing and contextual completion to gp You are en couraged to read the readline user manual but we describe basic usage here 2 15 1 A too short introduction to readline In the following 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
265. is also a large package to work with algebraic 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 Galois and class field theory and also many functions dealing with elliptic curves over Q or over local fields 1 5 5 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 addi tion standard numerical analysis routines like univariate integration using the double exponential method real root finding when the root is bracketed polynomial interpolation infinite series evaluation and plotting are included And now you should really have a look at the tutorial before proceeding 11 12 EMACS Chapter 2 The gp Calculator 2 1 Introduction Originally gp was designed as a debugging device for the PARI system library Over the years it has become a powerful user friendly stand alone calculator The mathematical functions available in PARI and gp are described in the next chapter In the present one we describe
266. is function is mostly useless in library mode Use the pair strtoGEN GENtostr to convert between GEN and char The latter returns a malloced string which should be freed after usage The library syntax is GEN Str char x 3 2 11 Strchr x converts x to a string translating each integer into a character Strchr 97 1 a Vecsmall hello world 2 Vecsmal1 104 101 108 108 111 32 119 111 114 108 100 Strchr 3 hello world The library syntax is GEN Strchr GEN x 3 2 12 Strexpand x converts its argument list into a single character string type t_STR the empty string if x is omitted Then perform environment expansion see Section 2 12 This feature can be used to read environment variable values Strexpand HOME doc 1 home pari doc The individual arguments are read in string context see Section 2 9 The library syntax is GEN Strexpand char x 3 2 13 Strtex x translates its arguments to TeX format and concatenates the results into a single character string type t_STR the empty string if x is omitted The individual arguments are read in string context see Section 2 9 The library syntax is GEN Strtex char x 3 2 14 Vec x transforms the object x into a row vector That vector has a single component except when is e a vector or a quadratic form in which case the resulting vector is simply the initial object considered as a row vector e a matrix
267. is indicated in this gp banner between the version number and the copyright message Consider investigating the matter with the person who installed gp if they are not Do this as well if there is no mention of the GMP kernel 13 2 1 2 Getting help To get help type a and hit return A menu appears describing the eleven main categories of available functions and how to get more detailed help If you now type n with 1 lt n lt 11 you 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 13 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 elliptic curve or quadratic field If gp was properly installed see Appendix A a line editor is available to correct the command line get automatic completions and so on See Section 2 15 1 or readline for a short summary of the line editor s commands 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
268. is set only one curve can be drawn at a 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 fast and usually more precise than usual plot Compare the results of ploth X 1 1 sin 1 X Recursive 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 Recursive to see why Hence it s usually a good idea to try and plot the same curve with slightly different parameters 201 The other values toggle various display options e 4 no_Rescale do not rescale plot according to the computed extrema This is used in conjunction with plotscale when graphing multiple functions on a rectwindow as a plotrecth call s plothsizes plotinit 0 s 2 1 s 21 1 plotscale 0 1 1 1 1 plotrecth 0 t 0 2 Pi cos t sin t Parametric no_Rescale plotdraw 0 1 1 This way we get a proper circle instead of the dis
269. ise because the variable ordering defines an implicit variable with respect to which division takes place This is the price to pay to allow and operators on polynomials instead of requiring a more cumbersome divrem x y var which also exists Unfortunately in some functions like content and denominator there is no way to set explicitly a main variable like in divrem and remove the dependence on implicit orderings This will hopefully be corrected in future versions 2 5 4 Multivariate power series Just like multivariate polynomials power series are funda mentally single variable objects It is awkward to handle many variables at once since PARI s implementation cannot handle multivariate error terms like O x y It can handle the polyno mial O y x x which is a very different thing see below The basic assumption in our model is that if variable x has higher priority than y then y does not depend on x setting y to a function of x after some computations with bivariate power series does not make sense a priori This is because implicit constants in expressions like O x depend on y whereas in O y they can not depend on x For instance O x x y 1 O x 0 y x 12 OCy x Here is a more involved example A 1 x72 1 0 x B 1 x 1 0 x73 subst z A z B 12 x 3 x7 2 x7 1 1 OCx 7 Be A 13 x 3 x 2 x7 1 0 1 T7Z A 74 z x 2 z 0 x The discrepancy between 2
270. issunit 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 GEN bnfissunit GEN bnf GEN sfu GEN x 124 3 6 17 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 if u1 Ur are the fundamental units and is the generator of the group of roots of unity bnf tu the output is a vector 1 Ur r 41 such that xz uy uz rt 1 The x are integers for i lt r and is an integer modulo the order of for i r 1 The library syntax is GEN isunit GEN bnf GEN x 3 6 18 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 i
271. iven two elements x and y in nf and pr a prime ideal in modpr format see nfmodprinit computes their quotient x y modulo the prime ideal pr The library syntax is GEN element_divmodpr GEN nf GEN x GEN y GEN pr 3 6 84 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 GEN nfdivrem GEN nf GEN x GEN y 3 6 85 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 GEN nfmod GEN nf GEN x GEN y 3 6 86 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 GEN element_mul GEN nf GEN x GEN y 3 6 87 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 GEN element_mulmodpr GEN nf GEN x GEN y GEN pr 3 6 88 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 GEN element_pow GEN nf GEN x GEN k 3 6 89 nfeltpowmodpr nf x k pr given an element x in nf an integer
272. l 3 7 17 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 GEN pollead GEN x long v 1 where v is a variable number 3 7 18 pollegendre n a x n Legendre polynomial evaluated at a x by default The library syntax is GEN pollegendre_eval long n GEN a NULL The variant GEN pol legendre long n long v returns the n th Legendre polynomial in variable v 3 7 19 polrecip pol reciprocal polynomial of pol i e the coefficients are in reverse order pol must be a polynomial The library syntax is GEN polrecip GEN pol 3 7 20 polresultant z y v 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 assumes the base ring is a domain If flag 0 uses the subresultant algorithm 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 GEN polresultantO GEN x GEN y long v 1 long flag where v is a variable nu
273. l One may use idealhnf to convert an ideal to the last preferred format Note Some routines accept non square matrices but using this format is strongly discouraged Nevertheless their behaviour is as follows If strictly less than N K Q generators are given it is assumed they form a Zk basis If N or more are given a Z basis is assumed If exactly N are given it is further assumed the matrix is in HNF If any of these assumptions is not correct the behaviour of the routine is undefined e an idele is a 2 component vector the first being an ideal as above the second being a 71 r2 component row vector giving Archimedean information as complex numbers usually representing logarithms of complex embeddings 3 6 3 Finite abelian groups A finite abelian group G in user readable format is given by its Smith Normal Form as a pair h d or triple h d g Here h is the cardinality of G di is the vector of elementary divisors and gi is a vector of generators In short G i lt n Z d Z g with dn da d and d h This information can also be retrieved as G no G cyc and G gen e a character on the abelian group Z d Z g is given by a row vector x a1 such that x 19 exp 2ia gt gt ayn d e given such a structure a subgroup H is input as a square matrix whose column express generators of H on the given generators gi Note that the absolute value of the determinant of that matrix is
274. l 1 2 3 1 1 2 3 Vecrev Polrev 1 2 3 2 1 2 3 Warning this is not a substitution function It will not transform an object containing variables of higher priority than v Pol x y y Pol variable must have higher priority in gtopoly The library syntax is GEN gtopoly GEN x long v 1 where v is a variable number 3 2 6 Polrev x v x transform the object x into a polynomial with main variable v If x isa scalar this gives a constant polynomial If x is a power series the effect is identical to truncate i e it chops off the O X The main use of this function is when z is a vector it creates the polynomial whose coefficients are given by x with x 1 being the constant term Pol can be used if one wants x 1 to be the leading coefficient Polrev 1 2 3 1 3 x72 2 x 1 Pol 11 231 12 x 2 2xx 3 The reciprocal function of Pol resp Polrev is Vec resp Vecrev The library syntax is GEN gtopolyrev GEN x long v 1 where v is a variable number 3 2 7 Qfb a b c D 0 creates the binary quadratic form ax bry cy If b 4ac gt 0 initialize Shanks distance function to D Negative definite forms are not implemented use their positive definite counterpart instead The library syntax is GEN QfbO GEN a GEN b GEN c GEN D NULL long prec Also available are GEN qfi GEN a GEN b GEN c assumes b dac lt 0 and GEN qfr GEN a GEN b GEN
275. l newlines should occur after a semicolon a comma or an operator for clarity s sake never split an identifier over two lines in this way For instance the following program 16 would silently produce garbage since this is interpreted as a bb c which assigns the value of c to both bb and a It should have been written jon I Q 2 3 The PARI types We 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 A note on efficiency The following types are provided for convenience not for speed t_INTMOD t_FRAC t_PADIC t_QUAD t_POLMOD t_RFRAC Indeed they always perform a reduction of some kind after each basic operation even though it is usually more efficient to perform a single reduction at the end of some complex computation For instance in a convolution product gt jan TiYj in Z NZ common when multiplying polynomials it is wasteful to perform n reductions modulo N In short basic individual operations on these types are fast but recursive objects with such components could be handled more efficiently programming with libpari will save large constant factors here compared to GP 2 3 1 Integers t_INT after an optional leading or type in the decimal digits of your integer No decimal point 1234567 1 1234567 3 12 3 1 oops not an integer 3 1 0000000000000000000
276. l rank as output by rnfpseudobasis nf pol or similar gives neworder U where neworder is a reduced order and U is the unimodular transformation matrix The library syntax is GEN rnflllgram GEN nf GEN pol GEN order long prec 3 6 147 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 pol 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 GEN rnfnormgroup GEN bnr GEN pol 3 6 148 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 4 2 this is slower and less efficient than rnfpolredabs The library syntax is GEN rnfpolred GEN nf GEN pol long prec 3 6 149 rnfpolredabs nf pol flag 0 relative version of polredabs Given a monic polyno mial pol with coefficients i
277. lag determines the algorithm used in the current version of PARI we suggest to use non negative values since it is by far the fastest and most robust implementation See the detailed example in Section 3 8 1 algdep If flag gt 0 uses a floating point variable precision LLL algorithm This is in general much faster than the other variants If flag 0 the accuracy is chosen internally using a crude heuristic If flag gt 0 the computation is done with an accuracy of flag decimal digits In that case the parameter flag should be between 0 6 and 0 9 times the number of correct decimal digits in the input If flag 1 uses a variant of the LLL algorithm due to Hastad Lagarias and Schnorr STACS 1986 If the precision is too low the routine may enter an infinite loop If flag 2 x is allowed to be and in any case interpreted as a matrix Returns a non trivial element of the kernel of x or 0 if x has trivial kernel The element is defined over the field of coefficients of x and is in general not integral If flag 3 uses the PSLQ algorithm This may return a real number B indicating that the input accuracy was exhausted and that no relation exist whose sup norm is less than B If flag 4 uses an experimental 2 level PSLQ which does not work at all Should be rewritten The library syntax is GEN lindepO GEN x long flag long prec Also available is GEN lindep GEN x long prec flag 0 3 8 5 listcreate
278. le a 2 1 1 a2 1 kill a hi 92 lt 1 gt 2 1 If you simply want to restore a variable to its undefined value monomial of degree one use the quote operator a a Predefined symbols x and GP function names cannot be killed The library syntax is void killO entree s 3 12 16 print strj outputs its string arguments in raw format ending with a newline 3 12 17 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 12 18 printp str outputs its string arguments in prettyprint beautified format ending with a newline 3 12 19 printp1 str outputs its string arguments in prettyprint beautified format with out ending with a newline 211 3 12 20 printtex str outputs its string arguments in T X format This output can then be used in a T X 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 12 You could for instance do default logfile new tex default log 1 printtex result 3 12 21 quit exits gp 3 12 22 read filename reads in the file filename subject to string expansion If filename is omitted re reads the last file that was fed into gp The return value is the result of the las
279. le by looking at the gp reference card refcard dvi or refcard ps In case of need you can refer to the complete function description in Chapter 3 How to get the latest version Everything can be found on PARI s home page http pari math u bordeaux fr From that point you may access all sources some binaries version information the complete mailing list archives frequently asked questions and various tips All threaded and fully searchable How to report bugs Bugs are submitted online to our Bug Tracking System available from PARI s home page or directly from the URL http pari math u bordeaux fr Bugs Further instructions can be found on that page 1 2 Multiprecision kernels Portability The PARI multiprecision kernel comes in three non exclusive flavours See Appendix A for how to set up these on your system various compilers are supported but the GNU gcc compiler is the definite favourite A first version is written entirely in ANSI C with a C compatible syntax and should be portable without trouble to any 32 or 64 bit computer having no drastic memory constraints We do not know any example of a computer where a port was attempted and failed In a second version time critical parts of the kernel are written in inlined assembler At present this includes e the whole ix86 family Intel AMD Cyrix starting at the 386 up to the Xbox gaming console including the Opteron 64 bit processor e three versions
280. let K the field represented by bnf as output by bnfinit Misa projective Z g module of rank n M amp K is an n dimensional K vector space given by a pseudo basis of size n The routine returns either a true Zx basis of M of size n if it exists or an n l element generating set of M if not It is allowed to use an irreducible polynomial P in K X instead of M in which case M is defined as the ring of integers of K X P viewed as a Zx module The library syntax is GEN rnfbasis GEN bnf GEN M 3 6 120 rnfbasistoalg rnf x computes the representation of x as a polmod with polmods coeffi cients Here rnf is a relative number field extension L K as output by rnfinit and x an element of L expressed on the relative integral basis The library syntax is GEN rnfbasistoalg GEN rnf GEN x 152 3 6 121 rnfcharpoly nf T a var 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 GEN rnfcharpoly GEN nf GEN T GEN a long var 1 where var is a variable number 3 6 122 rnfconductor bnf pol flag 0 given bnf as output by bnfinit and pol a relative polynomial defining an Abelian extension computes the class field theory conductor of this Abelian extension The result is a 3 component vector conductor rayclgp subgroup where conductor is the conductor of the extension given as a 2 comp
281. leted 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 GEN matsnfO GEN X long flag Also available is GEN smith GEN X flag 0 3 8 40 matsolve M B M being an invertible matrix and B a column vector finds the solution X of MX B using Gaussian elimination This has the same effect as but is a bit faster than M xB The library syntax is GEN gauss GEN M GEN B 3 8 41 matsolvemod M D B flag 0 M being any integral matrix D a vector of positive integer moduli and B an integral column vector gives a small integer solution to the system of congruences M j b mod d if one exists otherwise returns zero Shorthand notation B resp D can be given as a single integer in which case all the b resp d above are taken to be equal to B resp D M 1 2 3 4 matsolvemod M 3 4 1 2 42 2 0 matsolvemod M 3 1 M X 1 1 over F_3 13 1 1 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 column
282. lgebra and sets 2 o so 168 3 9 Sums products integrals and similar functions 020 0004 183 3 10 Plotting functions zap OS gk ee S Dok Ge bane GAR OR Sb ane Be Re eA ee 199 3 11 Programming in GP control statements 0 000000 pees 205 3 12 Programming in GP other specific functions 2 2 o 208 Appendix A Installation Guide for the UNIX Versions 217 A A A A A A tein EE Ras 226 Chapter 1 Overview of the PARI system 1 1 Introduction PARI GP is a specialized computer algebra system primarily aimed at number theorists but has been put to good use in many other different fields from topology or numerical analysis to physics Although quite an amount of symbolic manipulation is possible PARI does badly compared to systems like Axiom Magma Maple Mathematica or Maxima or Reduce on such tasks e g multi variate polynomials formal integration etc On the other hand the three main advantages of the system are its speed the possibility of using directly data types which are familiar to mathemati cians and its extensive algebraic number theory module from the above mentioned systems only Magma provides similar features Non mathematical strong points include the possibility to program either in high level scripting languages or with the PARI library a mature system development started in the mid eighties that was used to conduct and disseminate origin
283. lly an optional argument between braces followed by a star like means that any number of such arguments possibly none can be given This is in particular used by the various print routines Flags A flag is an argument which rather than conveying actual information to the routine instructs it to change its default behaviour e g return more or less information All such flags are optional and will be called flag in the function descriptions to follow There are two different kind of flags e generic all valid values for the flag are individually described If flag is equal to 1 then e binary use customary binary notation as a compact way to represent many toggles with just one integer Let po pn be a list of switches i e of properties which take either the value 0 or 1 the number 2 2 40 means that p3 and ps are set that is set to 1 and none of the others are that is they are set to 0 This is announced as The binary digits of flag mean 1 po 2 p 4 p2 and so on using the available consecutive powers of 2 63 Mnemonics for flags Numeric flags as mentioned above are obscure error prone and quite rigid should the authors want to adopt a new flag numbering scheme for instance when noticing flags with the same meaning but different numeric values across a set of routines it would break backward compatibility The only advantage of explicit numeric values is that they are fast to
284. lobal understanding of the computation 14 1 y 0 1 Beds 0 y B denominator A 12 0 E 28 OCy A B eK division by zero A B k Warning normalizing a series with O leading term eK division by zero A 1 B k Warning normalizing a series with O leading term 13 1 000000000000000000000000000 y 1 0 1 If a series with a zero leading coefficient must be inverted then as a desperation measure that coefficient is discarded and a warning is issued C 0 y 02 1 C Warning normalizing a series with 0 leading term 12 y 1 0 1 The last output could be construed as a bug since it is a priori impossible to deduce such a result from the input 0 represents any sufficiently small real number But it was thought more useful to try and go on with an approximate computation than to raise an early exception In the A 1 B example above the denominator of A was converted to a power series then inverted exhibiting this behaviour 2 3 12 Rational functions t_RFRAC as for fractions all rational functions are automatically reduced to lowest terms All that was said about fractions in Section 2 3 4 remains valid here 2 3 13 Binary quadratic forms of positive or negative discriminant t_QFR and t_QFT these are input using the function Qfb see Chapter 3 For example Qfb 1 2 3 creates the binary form 2 2xy 3y It is imaginary of internal type t_QFI since 2 4 3 8 is n
285. luated An expression is formed by combining constants variables operator symbols functions and control statements It is evaluated using the conventions about operator priorities and left to right associativity An expression always has a value which can be any PARI object 1 1 1 2 XX an ordinary integer x 12 x a polynomial of degree 1 in the unknown x print Hello Hello void return value f x x72 713 x gt x 2 NX a user function In the third example Hello is printed as a side effect but is not the return value The print command is a procedure which conceptually returns nothing But in fact procedures return a special void object meant to be ignored in particular it does not clutter the history but evaluates to 0 in a numeric context The final example assigns to the variable f the function gt x the alternative form f x gt x 2 achieving the same effect the return value of a function definition is unsurprisingly a function object of type t_CLOSURE Several expressions are combined on a single line by separating them with semicolons Such an expression sequence will be called a seg A seq also has a value which is the value of the last expression in the sequence Under gp the value of the seg and only this last value becomes an history entry The values of the other expressions in the seq are discarded after the execution of the seq is complete except of course if they
286. m 3 4 51 qfbcompraw x 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 GEN compraw GEN x GEN y 3 4 52 qfbhclassno x Hurwitz class number of x where x is non negative and congruent to 0 or 3 modulo 4 For z gt 5 10 we assume the GRH and use quadclassunit with default parameters The library syntax is GEN hclassno GEN x 3 4 53 qfbnucomp z y L composition of the primitive positive definite binary quadratic forms x and y type t_QFI using the NUCOMP and NUDUPL algorithms of Shanks la Atkin L is any positive constant but for optimal speed one should take L D 4 where D is the common discriminant of x and y When zx and y do not have the same discriminant the result is undefined The current implementation is straightforward and in general slower than the generic routine since the latter takes advantage of asymptotically fast operations and careful optimizations The library syntax is GEN nucomp GEN x GEN y GEN L Also available is GEN nudupl GEN x GEN L when z y 102 3 4 54 qfbnupow z n n th power of the primitive positive definite binary quadratic form x using Shanks s NUCOMP and NUDUPL algorithms see gfbnucomp in particular the final warning The library syntax is GEN nupow GEN x GEN n 3 4 55 qfbpowraw z 7 n th power of the binary quadratic form x computed wi
287. m 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 confirmation before letting you or a script unset this toggle 2 12 30 seriesprecision default 16 number of significant terms when converting a polynomial or rational function to a power series see ps 2 12 31 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 2 12 32 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 12 33 TeXstyle default 0 the bits
288. mands Take the example of the inverse Mellin transform of T s given in int mellininv p 105 oo 1 for clarity A intmellininv s 2 4 gamma s 3 time 2 500 ms not too fast because of T s function of real type decreasing as exp 31 2 t tab intfuncinit t 00 3 Pi 2 oo 3 Pi 2 gamma 2 1 t 73 1 time 1 370 ms intmellininvshort 2 4 tab A time 50 ms 74 1 26 3 25 E 109 I 50 times faster than A and perfect tab2 intfuncinit t 00 oo gamma 2 I t 73 1 intmellininvshort 2 4 tab2 6 1 2 E 42 3 2 E 109 I 63 digits lost In the computation of tab it was not essential to include the exact exponential decrease of T 2 4t But as the last example shows a rough indication must be given otherwise slow decrease is assumed resulting in catastrophic loss of accuracy The library syntax is GEN intmellininvshort GEN sig GEN z GEN tab long prec 187 3 9 10 intnum X a b expr tab numerical integration of expr on Ja b with respect to X The integrand may have values belonging to a vector space over the real numbers in particular it can be complex valued or vector valued But it is assumed that the function is regular on Ja b If the endpoints a and b are finite and the function is regular there the situation is simple intnum x 0 1 x72 71 0 3333333333333333333333333333 intnum x 0 Pi 2 cos x sin x 2 1 000
289. mber 3 7 21 polroots z 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 in 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 nhage s 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 not to give accurate results but is often rather fast If you get the messages too many iterations in roots or INTERNAL ERROR incorrect result in roots use the default algorithm This used to be the default root finding function in PARI until version 1 39 06 The library syntax is GEN rootsO GEN x long flag long prec Also available is GEN roots GEN x long prec 164 3 7 22 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 is very small you may set flag 1 which uses a naive search The library syntax is GEN rootmodO GEN pol GEN p long flag 3 7 23 polrootspadic z p r row vector of p adic roots of the polyno
290. me chunk of memory no equality test is 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 As an exception if the exponent is a rational number p q and x an integer modulo a prime or a p adic number return a solution y of y x if it exists Currently q must not have large prime factors Beware that Mod 7 19 7 1 2 1 Mod 11 19 is any square root sqrt Mod 7 19 12 Mod 8 19 is the smallest square root Mod 7 19 7 3 5 13 Mod 1 19 1 37 5 3 14 Mod 1 19 Mod 7 19 is just another cubic root 66 If the exponent is a negative integer an inverse must be computed For non invertible t_INTMOD this will fail and implicitly exhibit a non trivial factor of the modulus Mod 4 6 1 kk impossible inverse modulo Mod 2 6 Here a factor 2 is obtained directly In general take the gcd of the representative and the modulus This is most useful when performing complicated operations modulo an integer N whose factorization is unknown Either the computation succeeds and all is well or a factor d is discovered and the computation may be restarted modulo d or N d For non invertible t_POLMOD this will fail without exhibiting a factor Mod x 2 x 3 x 1 non inv
291. mial pol given to p adic precision r Multiple roots are not repeated p is assumed to be a prime and pol to be non zero modulo p Note that this is not the same as the roots in Z p Z rather it gives approximations in Z p Z of the true roots living in Qp If pol has inexact t_PADIC coefficients this is not always well defined in this case the equation is first made integral then lifted to Z Hence the roots given are approximations of the roots of a polynomial which is p adically close to the input The library syntax is GEN rootpadic GEN x GEN p long r 3 7 24 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 The library syntax is long sturmpart GEN pol GEN a NULL GEN b NULL 3 7 25 polsubcyclo n d v x gives polynomials in variable v defining the sub Abelian extensions of degree d of the cyclotomic field Q where d n If there is exactly one such extension the output is a polynomial else it is a vector of polyno mials possibly empty To get a vector in all cases use concat polsubcyclo n d The function galoissubcyclo allows to specify more closely which sub Abelian extension should be computed The library syntax is GEN polsubcyclo long n long d long v 1 where v is a vari able number 3 7 26 polsylvestermatrix z y forms the Sylvester matrix corresponding t
292. mials of degree less or equal to 7 Install this package if you want to handle polynomials of degree bigger than 7 and less than 11 To install package pack you need to fetch the separate archive pack tgz which you can download from the pari server Copy the archive in the PARI toplevel directory then extract its contents these will go to data pack Typing make install installs all such packages 4 2 The GPRC file Copy the file misc gprc dft or gprc dos if you are using GP EXE to HOME gprc Modify it to your liking For instance if you are not using an ANSI terminal remove control characters from the prompt variable You can also enable colors If desired read datadir misc gpalias from the gprc file which provides some common shortcuts to lengthy names fix the path in gprc first Unless you tampered with this via Configure datadir is prefix share pari If you have superuser privileges and want to provide system wide defaults copy your customized gprc file to etc gprc In older versions gphelp was hidden in pari lib directory and was not meant to be used from the shell prompt but not anymore If gp complains it cannot find gphelp check whether your gprc or the system wide gprc does contain explicit paths If so correct them according to the current misc gprc dft 5 Getting Started 5 1 Printable Documentation Building gp with make all also builds its documentation You can also type directly make doc In any
293. mod 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 x x for example if x 1 4 0 2 and y 1 0 25 then x y 1 O 2 while sqr x 1 0 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 v n gt 0 Remark note that if we wanted to be strictly consistent with the PARI philosophy we should have xx y 4mod8 and sqr x 4mod32 when both x and y are congruent to 2 modulo 4 However since intmod 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 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 precdl 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
294. module Note that to compute such data for a single field either bnrclassno or bnrdisc is more efficient The library syntax is GEN bnrdisclistO GEN bnf GEN bound GEN arch NULL 3 6 32 bnrinit bnf f flag 0 bnf is as output by bnfinit f is a modulus initializes data linked to the ray class group structure corresponding to this module a so called bnr structure The following member functions are available on the result bnf is the underlying bnf mod the modulus bid the bid structure associated to the modulus finally clgp no cyc clgp refer to the ray class group as a finite abelian group its cardinality its elementary divisors its generators The last group of functions are different from the members of the underlying bnf which refer to the class group use bnr bnf xxx to access these e g bnr bnf cyc to get the cyclic decomposition of the class group They are also different from the members of the underlying bid which refer to Zx f use bnr bid xxx to access these e g bnr bid no to get f If flag 0 default the generators of the ray class group are not computed which saves time Hence bnr gen would produce an error If flag 1 as the default except that generators are computed The library syntax is GEN bnrinitO GEN bnf GEN f long flag 3 6 33 bnrisconductor al a2 a3 al a2 a3 represent an extension of the base field given by class field theory for some modulus encoded in
295. mputation becomes meaningful 1 3 Mod 1 5 1 Mod 3 5 I 0 579 A2 2 5 2 572 573 3x5 4 4 575 2 5 6 3xb5 7 0 579 Mod 1 15 Mod 1 10 13 Mod 2 5 The first example is straightforward since 3 is invertible mod 5 1 3 is easily mapped to Z 5Z In the second example I stands for the customary square root of 1 we obtain a 5 adic number 5 adically close to a square root of 1 The final example is more problematic but there are natural maps from Z 15Z and Z 10Z to Z 5Z and the computation takes place there 1 5 Operations and functions The available operations and functions in PARI are described in detail in Chapter 3 Here is a brief summary 1 5 1 Standard arithmetic operations Of course the four standard operators exist We emphasize once more 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 Euclidean division Euclidean remainder exist 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 O false 1 5 2 Conversions and similar functions Many
296. n 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 Note that the default new_galois_format is another compatibility setting which is completely independent of compatible 2 12 3 datadir default the location of installed precomputed data the name of directory containing the optional data files For now only the galdata and elldata packages 2 12 4 debug default 0 debugging level If it is non zero some extra messages may be printed some of it in French according to what is going on see g 2 12 5 debugfiles default 0 file usage debugging level If it is non zero gp will print information on file descriptors in use from PARI s point of view see gf 2 12 6 debugmem default 0 memo
297. n accuracy in particular for multivariate integrals since we then skip expensive precomputations Specifying the behaviour at endpoints This is done as follows An endpoint a is either given as such a scalar real or complex or 1 for too or as a two component vector a a to indicate the behaviour of the integrand in a neighbourhood of a If a is finite the code a a means the function has a singularity of the form x a up to logarithms If a gt 0 we only assume the function is regular which is the default assumption If a wrong singularity exponent is used the result will lose a catastrophic number of decimals intnum x 0 1 x7 1 2 assume 71 2 is regular at 0 1 1 999999999999999999990291881 intnum x 0 1 2 1 x7 1 2 no it s not 2 2 000000000000000000000000000 intnum x 0 1 10 1 x 1 2 13 1 999999999999999999999946438 using a wrong exponent is bad If a is 00 which is coded as 1 the situation is more complicated and 1 a means 188 e a 0 or no q at all i e simply 1 assumes that the integrand tends to zero but not exponentially fast and not oscillating such as sin a e a gt 0 assumes that the function tends to zero exponentially fast approximately as exp az This includes oscillating but quickly decreasing functions such as exp x sin x oo 1 intnum x 0 00 exp 2 x exp exponent e
298. n 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 To save on disk space you can manually gzip some of the documentation files if you wish usersch tex and all dvi files assuming your xdvi knows how to deal with compressed files the online help system can handle it By default if a dynamic library libpari so could be built the static library libpari a 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 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 is no risk of breaking them by installing a new pari library 222 4 1 Extra packages The following optional packages endow PARI with some extra capabilities only two packages for now e elldata This package contains the elliptic curves in John Cremona s database It is needed by the functions ellidentify ellsearch and can be used by ellinit to initialize a curve given by its standard code e galdata The default polgalois function can only compute Galois groups of polyno
299. n nf finds a simpler relative polynomial defining the same field The binary digits of flag mean 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 2 returns an absolute polynomial same as rnfequation nf rnfpolredabs nf pol but faster 16 possibly use a suborder of the maximal order This is slower than the default when the relative discriminant is smooth and much faster otherwise See Section 3 6 115 158 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 the function rnf111gram which deserves to be improved The library syntax is GEN rnfpolredabs GEN nf GEN pol long flag 3 6 150 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 J for the maximal order Zz viewed as a Zkx module and the relative discriminant of L This is output as a four element row vector 4 1 D d where D is the relative ideal discriminant and d is the relative discriminant considered as an element of nf nf aS The library syntax is GEN rnfpseudobasis GEN nf GEN pol 3 6 151 rnfs
300. n optional one flag whose default value is 0 The should not 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 When none are left the defaults are used instead Thus assuming that foo s prototype had been foo 1 y 2 2 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 argument 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 do not 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 Fina
301. n the following command galoisisabelian galoissubgroups galoisexport and galoisidentify To get the subfield fixed by a subgroup sub of gal use galoisfixedfield gal sub 1 The library syntax is GEN galoissubgroups GEN G 3 6 48 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 GEN idealadd GEN nf GEN x GEN y 3 6 49 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 elt xl for 1 lt i lt k and Y rez eli 1 The library syntax is GEN idealaddtooneO GEN nf GEN x GEN y NULL 3 6 50 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 gp is non zero we have vola v x and vg a gt 0 for all other If flag is non zero x must be given as a prime ideal factorization as output by idealfactor but possibly with zero or negative exponents This yields an element such that for all prime ideals p occurring in x
302. n to retrieve information from complicated structures The built in structures are bid ell galois ff nf bnf bnr and prid which will be described at length in Chapter 3 The syntax structure member is taken to mean retrieve member from structure e g E j returns the j invariant of the elliptic curve E or outputs an error message if E is not a proper ell structure To define your own member functions use the syntax var member seq where the formal variable var is scoped to the function body seg This is of course reminiscent of a user function with a single formal variable var For instance the current implementation of the ell type is a vector the j invariant being the thirteenth component It could be implemented as 39 x j if type x t_VEC x lt 14 error not an elliptic curve x x 13 As for user functions you can redefine your member functions simply by typing new definitions On the other hand as a safety measure you cannot redefine the built in member functions so attempting to redefine x j as above would in fact produce an error you would have to call it e g x myj in order for gp to accept it Rationale In most cases member functions are simple accessors of the form x a x 1 x b x 2 x c x 3 where x is a vector containing relevant data There are at least three alternative approaches to the above member functions 1 hardcode x 1 etc in the program text 2 define consta
303. name The library syntax is GEN matbasistoalg GEN nf GEN x 3 6 74 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 GEN polymodrecip GEN a 3 6 75 newtonpoly z 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 2 1 on 32 bit resp 64 bit machines see Section 3 2 49 The library syntax is GEN newtonpoly GEN x GEN p 3 6 76 nfalgtobasis nf this is the inverse function of nfbasistoalg Given an object x whose 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 GEN algtobasis GEN nf GEN x 141 3 6 77 nfbasis x flag 0 fa integral basis of the number field defined by the irreducible preferably monic polynomial x using a modified version of the r
304. nctions in global scope it is usually possible and cleaner to lexically scope your private helper functions to the block of text where they will be needed Whenever gp meets a construction of the form expr argument list and the expression expr evaluates to a function an object of type t_CLOSURE the function is called with the proper arguments For instance constructions like funcs i x are perfectly valid assuming funcs is an array of functions 32 2 7 1 Defining a function A user function is defined as follows list of formal variables gt seq The list of formal variables is a comma separated list of distinct variable names and allowed to be empty It there is a single formal variable the parentheses are optional This list corresponds to the list of parameters you will supply to your function when calling it In most cases you want to assign a function to a variable immediately as in R x y gt sqrt x 2 y 2 sq x gt x72 or equivalently x gt x72 but it is quite possible to define a priori short lived anonymous functions The trailing semicolon is not part of the definition but as usual prevents gp from printing the result of the evaluation i e the function object The construction f list of formal variables seq is available as an alias for f list of formal variables gt seq Using that syntax it is not possible to define anonymous functions obviously and the above two examples
305. nductorofchar GEN bnr GEN chi 3 6 30 bnrdisc al a2 a3 flag 0 al a2 a3 defining a big ray number field L over a ground field K see bnr at the beginning of this section for the meaning of al a2 a3 outputs a 3 component row vector N r1 D where N is the absolute degree of L r 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 r times the relative degree N and D is the relative discriminant ideal of L K If flag 2 as the default case except that if the modulus is not the exact conductor corre sponding to the L no data is computed and the result is 0 If flag 3 as case 2 but output relative data The library syntax is GEN bnrdiscO GEN al GEN a2 NULL GEN a3 NULL long flag 3 6 31 bnrdisclist bnf bound arch bnf being as output by bnfinit with units computes a list of discriminants of Abelian extensions of the number field by increasing modulus norm up to bound bound The ramified Archimedean places are given by arch all possible values are taken if arch is omitted The alternative syntax bnrdisclist bnf list is supported where list is as output by ideal list or ideallistarch with units in which case arch is disregarded The output v is a vector of vectors wher
306. ng the last line shown with if further material has been suppressed The various print commands see Section 3 12 are unaffected so you can always type print Na or b to view the full result If the actual screen width cannot be determined a line is assumed to be 80 characters long 51 2 12 16 log default 0 this can be either 0 off or 1 2 3 on see below for the various modes 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 M1 In case a file with this precise name already existed it will not be erased your data will be appended at the end The specific positive values of log have the following meaning 1 plain logfile 2 emit color codes to the logfile if colors is set 3 write LaTeX output to the logfile can be further customized using TeXstyle 2 12 17 logfile default pari log name of the log file to be used when the log toggle is on Environment and time expansion are performed 2 12 18 new_galois_format default 0 if this is set the polgalois command will use a different more consistent naming scheme for Galois groups This default is provided to ensure that scripts can control this behaviour and do not break unexpectedly Note that the default value of 0 unset will change to 1 set in the next major version 2 12 19 output default 1 there are four po
307. ng when copy pasting E 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 do not want a toggle you can use M 0 M 1 to specifically switch it on or off Note In some versions of readline 2 1 for instance the Alt or Meta key can give funny re sults output 8 bit accented characters for instance If you do not 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 15 2 Command completion and online help Hitting lt TAB gt will complete words for you This mechanism is 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
308. ngthening a Warning is printed Otherwise the result is unconditional barring bugs For instance here s how to solve the Thue equation gid 5y 4 tnf thueinit x 13 5 thue tnf 4 41 1 111 Hence the only solution is 1 y 1 and the result is unconditional On the other hand tnf thueinit x 3 2 x 2 3 x 17 thue tnf 15 thue Warning Non trivial conditional class group xxx May miss solutions of the norm equation 42 1 41 This time the result is conditional All results computed using this tnf are likewise conditional except for a right hand side of 1 The library syntax is GEN thue GEN tnf GEN a GEN sol NULL 167 3 7 38 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 unconditionally Otherwise assume GRH this being much faster of course If the conditional computed class group is trivial or you are only interested in the case a 1 then results are unconditional anyway So one should only use the flag is thue prints a Warning see the example there The library syntax is GEN thueinit GEN P long flag long prec 3 8 Vectors matrices linear algebra and sets Note that most linear algebra functions operating on subspaces defined by generating sets such as mathnf qf111 etc take matrices a
309. nrclassnolist bnf L H 98 74 1 3 1 1 L 1 98 ids vector 1 i 1 i mod 1 5 98 88 0 1 14 0 O 7 98 10 O 1 The weird 1 i mod 1 is the first component of 1 i mod i e the finite part of the con ductor This is cosmetic since by construction the archimedean part is trivial I do not want to see it This tells us that the ray class groups modulo the ideals of norm 98 printed as 5 have respectively order 1 3 and 1 Indeed we may check directly bnrclassno bnf ids 2 16 3 The library syntax is GEN bnrclassnolist GEN bnf GEN list 127 3 6 28 bnrconductor al a2 a3 flag 04 conductor f of the subfield of a ray class field as defined by a1 a2 az see bnr at the beginning of this section If flag 0 returns f If flag 1 returns f Cl H where Cl is the ray class group modulo f as a finite abelian group finally H is the subgroup of Cl defining the extension If flag 2 returns f bnr f H as above except Cl is replaced by a bnr structure as output by bnrinit f 1 The library syntax is GEN bnrconductor GEN a1 GEN a2 NULL GEN a3 NULL GEN flagi NULL 3 6 29 bnrconductorofchar bnr chi bnr being a big ray number field as output by bnrinit 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 GEN bnrco
310. nt global variables AINDEX 1 BINDEX 2 and hardcode x AINDEX 3 user functions a x x 1 and so on Even if 2 improves on 1 these solutions are neither elegant nor flexible and they scale badly 3 is a genuine possibility but the main advantage of member functions is that their namespace is independent from the variables and functions namespace hence we can use very short identifiers without risk The j invariant is a good example it would clearly not be a good idea to define j E E 13 because clashes with loop indices are likely Note Typing Num will output all user defined member functions Technical warning Do not apply a member whose name starts with e or E to an integer constant where it would be confused with the usual floating point exponent E g compare x e2 x 1 1 e2 71 100 000000000 taken to mean 1 0 2 1 e2 12 2 7 1 0 e2 73 2 00000000000 40 2 9 Strings and Keywords 2 9 1 Strings GP variables can 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 concate nation 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
311. nt implementation the binary files are architecture dependent and compatibility with future versions of gp is not guaranteed Hence binary files should not be used for long term storage also they are larger and harder to compress than text files The library syntax is void gpwritebin char filename GEN x NULL 3 12 33 writetex filename str as write in TREX format 215 216 Appendix A Installation Guide for the UNIX Versions 1 Required tools Compiling PARI requires an ANSI C or a C compiler If you do not have one we suggest that you obtain the gcc g compiler As for all GNU software mentioned afterwards you can find the most convenient site to fetch gcc at the address http www gnu org order ftp html On Mac OS X this is also provided in the Xcode tool suite You can certainly compile PARI with a different compiler but the PARI kernel takes advantage of optimizations provided by gcc This results in at least 20 speedup on most architectures Optional packages The following programs and libraries are useful in conjunction with gp but not mandatory In any case get them before proceeding if you want the functionalities they provide All of them are free The download page on our website http pari math u bordeaux fr download html contains pointers on how to get these e GNU MP library This provides an alternative multiprecision kernel which is faster than PARI s native one but unfortunately binar
312. nt numbers using House holder matrices for orthogonalization If G has integral entries then computations are nonetheless approximate with precision varying as needed Lehmer s trick as generalized by Schnorr If flag 1 G has integer entries still positive but not necessarily definite i e x needs not have maximal rank The computations are all done in integers and should be slower than the default unless the latter triggers accuracy problems flag 4 G has integer entries gives the kernel and reduced image of x flag 5 same as case 4 but G may have polynomial coefficients The library syntax is GEN gflllgramO GEN G long flag long prec Also available are GEN lllgram GEN G long prec flag 0 GEN 111gramint GEN G flag 1 and GEN 111 gramkerim GEN G flag 4 3 8 49 qfminim x b m flag 0 x being a square and symmetric matrix representing a positive definite quadratic form this function deals with the vectors of x whose norm is less than or equal to b enumerated using the Fincke Pohst algorithm storing at most m vectors no limit if m is omitted The function searches for the minimal non zero vectors if b is omitted The precise behaviour depends on flag If flag 0 default seeks at most 2m vectors The result is a three component vector the first component being the number of vectors found the second being the maximum norm found and the last vector is a matrix whose columns are the vectors f
313. ntains the relative orders o1 0 of the generators of S gal orders Let A be the maximal normal supersolvable subgroup of G we have the following properties o if G H As then o1 0y ends by 2 2 3 e if G H S4 then o1 0g ends by 2 2 3 2 e else G is super solvable 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 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 a unique family e1 eg such that no exceptions for 1 lt i lt g we have 0 lt e lt 0 9I 9 On If present den must be a suitable value for gal 5 The library syntax is GEN galoisinit GEN pol GEN den NULL 3 6 43 galoisisabelian gal flag 0 gal being as output by galoisinit return 0 if gal is not an abelian group and the HNF matrix of gal over gal gen if fl 0 1 if fl 1 This command also accepts subgroups returned by galoissubgroups The library syntax is GEN galoisisabelian GEN gal long flag 3 6 44 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 galoisp
314. number fields i e excluding quadclassunit involves a polynomial P and a technical vector tech cl c2 nrpid where the parameters are to be understood as follows P is the defining polynomial for the number field which must be in Z X irreducible and monic In fact if you supply a non monic polynomial at this point gp issues a warning then transforms your polynomial so that it becomes monic The nfinit routine will return a different result in this case instead of res you get a vector res Mod a Q where Mod a Q Mod X P gives the change of variables In all other routines the variable change is simply lost The tech interface is obsolete and you should not tamper with these parameters Indeed from version 2 4 0 on e the results are always rigorous under GRH before that version they relied on a heuristic strengthening hence the need for overrides e the influence of these parameters of execution time and stack size is marginal They can be useful to fine tune and experiment with the bnfinit code but you will be better off modifying all tuning parameters in the C code there are many more than just those three We nevertheless describe it for completeness The numbers c lt cz are positive real numbers For i 1 2 let B c log ldx and denote by S B the set of maximal ideals of K whose norm is less than B We want S B to generate Cl i and hope that S B2 can be proven to generate Cl K More precisel
315. o 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 is eventually called by the operator of course install addii GG addii 1 2 11 3 Re installing a function will print a Warning and update the prototype code if needed but will reload a symbol from the library even it the latter has been recompiled 210 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 12 15 kill s kills the present value of the variable alias or user defined function s 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 WE t f x 0 OK unused characters f x 0 a kill f x 0 fO 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 For examp
316. o polynomials P x and P z only one is given 16 possibly use a suborder of the maximal order The primes dividing the index of the order chosen are larger than primelimit or divide integers stored in the addprimes table In that case it may happen that the output polynomial does not have minimal T norm The library syntax is GEN polredabsO GEN x long flag 3 6 116 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 GEN ordred GEN x 3 6 117 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 library syntax is GEN tschirnhaus GEN x 3 6 118 rnfalgtobasis rnf x expresses x on the relative integral basis Here rnf is a relative number field extension L K as output by rnfinit and x an element of L in absolute form i e expressed as a polynomial or polmod with polmod coefficients not on the relative integral basis The library syntax is GEN rnfalgtobasis GEN rnf GEN x 3 6 119 rnfbasis bnf M
317. o 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 GEN sylvestermatrix GEN x GEN y 3 7 27 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 GEN polsym GEN x long n 3 7 28 poltchebi n v x creates the nt Chebyshev polynomial T of the first kind in variable v This function is retained for backward compatibility only Use polchebyshev The library syntax is GEN polchebyshevi long n long v 1 where vis a variable num ber 165 3 7 29 polzagier n m creates Zagier s polynomial PP used in the functions sumalt and sumpos with flag 1 One must have m lt n The exact definition can be found in Convergence acceleration of alternating series Cohen et al Experiment Math vol 9 2000 pp 3 12 The library syntax is GEN polzag long n long m 3 7 30 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 Y by X then serconvol z y ax by X The library syntax is GEN convol GEN x GEN y 3 7 31 serlaplace x x must be a p
318. oefficient is real and negative else returns x For a power series the constant coefficient is considered instead The library syntax is GEN gabs GEN x long prec 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 GEN gacos GEN x long 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 GEN gach GEN x long 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 always 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 GEN agm GEN x GEN y long prec 3 3 9 arg x argument of the complex number x such that r lt arg x lt r The library syntax is GEN garg GEN x long prec 82 3 3 10 asin x principal branch of sin x ie such that Re asin w 7 2 7 2 Ife R and x gt 1 then asin x is complex The library syntax is GEN gasin GEN x long prec 3 3 11 asinh x principal branch of sinh x i e such that Im asinh x 7 2 7 2 The library syntax is GEN gash GEN x long prec 3 3 12 atan x principal branch of tan x i e such t
319. 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 local factor expr p The series is output as a vector of coefficients If c is present output only the first c coefficients in the series The following command computes the sigma function associated to s s 1 direuler p 2 10 1 1 X 1 p X 11 1 3 4 7 6 12 8 15 13 18 The library syntax is direuler void E GEN eval GEN void GEN a GEN b 3 4 15 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 GEN dirmul GEN x GEN y 3 4 16 divisors x creates a row vector whose components are the divisors of x The factorization of x as output by factor can be used instead By definition these divisors are the products of the irreducible factors of n as produced by factor n raised to appropriate powers no negative exponent may occur in the factorization If n is an integer they are the positive divisors in increasing order The library syntax is GEN divisors GEN x 3 4 17 eulerphi x Euler s totient function of x in other words Z xZ x must be of type integer The library syntax is GEN gphi GEN x 92 3 4 18 factor z lim general factorization function If x is of type integer ra
320. olor function and only the part of the object which is inside the window will be drawn with the ex ception of polygons and strings which are drawn entirely 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 Finally the actual physical drawing is done using plotdraw The rectwindows are preserved so that further drawings using the same windows at different positions or different windows can be done without extra work To erase a window use plotkill It is not possible to partially erase a window erase it completely initialize it again then fill it with the graphic objects that you want to keep In addition to initializing the window you may use a scaled window to avoid unnecessary conversions For this use plotscale 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 Plotting functions are platform independant but a number of graphical drivers are available for screen output X11 windows hence also for GUI s based on X11 such as Openwindows and Motif and the Qt and FLTK graphical libraries The physical window opened by plotdraw or any of the ploth functions is completely separated from gp technically a fo
321. olors in the colormap may be freely used in plotcolor calls A color is either given as in the default by character strings see the standard rgb txt file in X11 distributions or by an RGB code a vector with 3 integer entries between 0 and 255 For instance 250 235 215 and antique white represent the same color RGB codes are a little cryptic but more portable some graphic drivers may not be able to understand all symbolic names currently f1tk unrecognized color names behave as white 2 12 12 graphcolors default 4 5 Entries in the graphcolormap that will be used to plot multi curves The successive curves are drawn in colors graphcolormap graphcolors 1 graphcolormap graphcolors 2 cycling when the graphcolors list is exhausted 2 12 13 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 13 1 or M H under readline see Section 2 15 1 2 12 14 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 13 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 do not need anymore 2 12 15 lines default 0 if set to a positive value gp prints at most that many lines from each result terminati
322. olynomial but y x is a rational function See Section 2 5 3 The library syntax is GEN denom GEN x 3 2 30 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 returns the Euclidean quotient of the numerator by the denominator The library syntax is GEN gfloor GEN x 3 2 31 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 GEN gfrac GEN x 3 2 32 imag z 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 GEN gimag GEN x 3 2 33 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 long glength GEN x 3 2 34 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 whose modulus has main variable v if v does not occur in zx lifts only intmods If x is of recursive non modular type the lift is done coefficientwise For p adics this routine acts as truncate It is not allowed to have x of type t_REAL lift Mod 5 3 wi 2 1ift 3 0 379 42 3 lift Mod x x72
323. on See Section 2 10 2 for an introduction to error recovery under gp trap division by 0 inv x trap gdiver INFINITY 1 x inv 2 11 1 2 inv 0 12 INFINITY Note that seq is effectively evaluated up to the point that produced the error and the recovery sequence is evaluated starting from that same context it does not undo whatever happened in the other branch restore the evaluation context x 1 trap recover x try x 0 1 x 213 hi 0 If seg is omitted defines rec as a default action when catching exception e provided no other trap as above intercepts it first The error message is printed as well as the result of the evaluation of rec and control is given back to the gp prompt In particular current computation is then lost For instance the following error handler prints the list of all user variables then stores in the file crash their names and values trap print variable writebin crash If no recovery code is given rec is omitted a break loop will be started see Section 2 10 3 In particular typing trapO by itself installs a default error handler that will start a break loop whenever an exception is raised If rec is the empty string the default handler for that error if e is present is disabled Note The interface is currently not adequate for trapping individual exceptions In the current version 2 4 2 the following keywords are recogniz
324. on global variables The first idea 38 init x add y xty mul y x y does not work since in the construction seq the function body contains everything until the end of the expression Hence executing init defines the wrong function add itself defining a function mul The way out is to use parentheses for grouping to that enclosed subexpressions be evaluated independently init x add y x y mul y x y init 5 add 2 43 7 mul 3 4 15 This defines two global functions which have access to the lexical variables private to init The following would work in exactly the same way init5 my x 5 add y x y mul y x y 2 7 7 Closures as Objects Contrary to what you might think after the preceding examples GP s closures may not be used to simulate true objects with private and public parts and methods to access and manipulate them In fact closures indeed incorporate an existing context they may access lexical variables that existed at the time of their definition but then may not change it More precisely they access a copy which they are welcome to change but a further function call still accesses the original context as it existed at the time the function was defined init my count 0 inc count dec count inc 1 1 inc 12 1 inc 13 1 2 8 Member functions Member functions use the dot notatio
325. onent row vector fo foo 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 If flag is non zero check that pol indeed defines an Abelian extension return O if it does not The library syntax is GEN rnfconductor GEN bnf GEN pol long flag 3 6 123 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 could be proven to be pr maximal and to 0 otherwise it may be maximal in the latter case if pr is ramified in L 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 GEN rnfdedekind GEN nf GEN pol GEN pr 3 6 124 rnfdet nf M given a pseudo matrix M over the maximal order of nf computes its determinant The library syntax is GEN rnfdet GEN nf GEN M 3 6 125 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
326. or a recursive combination of those and the routine returns the unique fraction a b in coprime integers a lt A and b lt B which is congruent to x modulo M If M lt 2AB uniqueness is not guaranteed and the function fails with an error message If rational reconstruction is not possible no such a b exists for at least one component of x returns 1 The library syntax is GEN bestapprO GEN A GEN B GEN NULL Also available is GEN bestappr GEN x GEN A 3 4 3 bezout x y finds u and v minimal in a natural sense such that x x u y v gcd x 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 GEN vecbezout GEN x GEN y 3 4 4 bezoutres z y as bezout with the resultant of x and y replacing the gcd The algorithm used subresultant assumes that the base ring is a domain The library syntax is GEN vecbezoutres GEN x GEN y 3 4 5 bigomega x number of prime divisors of x counted with multiplicity x must be an integer The library syntax is GEN gbigomega GEN x 3 4 6 binomial z y binomial coefficient e Here y must be an integer but x can be any PARI object The library syntax is GEN binomial GEN x long y Also available GEN vecbinome long n returns a vector v with n 1 components such that v k 1 binomial n k for k from 0 up ton 3 4 7 chinese z y if x and y are both intmods or both polmods
327. ot of expression expr between a and b under the con dition expr X a x expr X b lt 0 You will get an error message roots must be bracketed in solve if this does not hold 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 void E GEN eval GEN void GEN a GEN b long prec 3 9 19 sum X a b expr x 0 sum of expression expr initialized 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 10 4 1 1 rational number denominator has 4345 digits time 236 ms sum i 1 5000 1 i 0 time 8 ms 42 9 787606036044382264178477904 The library syntax is somme GEN a GEN b char expr GEN x 3 9 20 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 Use an algorithm of Cohen Villegas and Zagier Experiment Math 9 2000 no 1 3 12 If flag 1 use a variant with slightly different polynomials Sometimes faster The routine is heuristic and a rigorous proof assumes that the values of expr are the moments of a positive measure on 0 1 Divergent alternating series can sometimes be summed by this method as well as series which are not exactly alternating
328. ou can change these default values to something more useful than 0 In the function definition you can append expr to a formal parameter to give that variable an explicit default value The expression gets evaluated the moment the function is called and may involve the preceding function parameters a default value for x may involve x for j lt i For instance after f x 1 y 2 z ytle typing in 3 4 would give you 3 4 5 In the rare case when you want to set some far away argument and leave the defaults in between as they stand use the empty argument trick 6 1 would yield 6 2 1 Of course f by itself yields f 1 2 3 as was to be expected More specifically f x y 2 z 3 print x y z defines a function which prints its arguments at most three of them separated by colons f 6 7 6 7 3 f 5 0 5 3 0 0 2 3 35 Example We conclude with an amusing example intended to illustrate both user defined func tions and the power of the sumalt function Although the Riemann zeta function is included as zeta among the standard functions let us assume that we want to check other implementations Since we are highly interested in the critical strip we use the classical formula 21 5 1 s X 1 n Rs gt 0 The implementation is obvious ZETA s sumalt n 1 1 n n s 27 1 s 1 Note that n is automatically lexically scoped to the sumalt loop so th
329. ound only one being given for each pair v at most m such pairs unless m was omitted The vectors are returned in no particular order If flag 1 ignores m and returns the first vector whose norm is less than b In this variant an explicit b must be provided In these two cases x is assumed to have integral entries The implementation uses low precision floating point computations for maximal speed which gives incorrect result when x has large entries The condition is checked in the code and the routine will raise an error if large rounding errors occur A more robust but much slower implementation is chosen if the following flag is used If flag 2 x can have non integral real entries In this case if b is omitted the minimal vectors only have approximately the same norm If bis omitted m is an upper bound for the number of vectors that will be stored and returned but all minimal vectors are nevertheless enumerated If m is omitted all vectors found are stored and returned note that this may be a huge vector x matid 2 qfminim x 4 minimal vectors of norm 1 0 1 1 0 42 4 1 10 1 1 0 x 492 18 18 18 18 18 18 18 18 18 18 18 32 32 32 32 32 32 32 32 32 32 32 18 18 4 2 2 2 2 2 2 2 2 2 2 1 2 1 0 0 1 2 2 1 1 1 4 18 2 4 2 2 2 2 2 2 2 2 2 2 2 1 1 0 2 2 1 1 1 0 4 gt gt gt gt 178 18 2 2 4 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 2 0 2 0 4 18 2 2 2 4 2 2 2 2 2 2 2 1 1 1
330. ound 4 algorithm by default due to David Ford Sebastian Pauli and Xavier Roblot 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 fa 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 GEN nfbasisO GEN x long flag GEN fa NULL An extended ver sion is GEN nfbasis GEN x GEN d long flag GEN fa NULL where d receives the dis criminant of the number field not of the polynomial x 3 6 78 nfbasistoalg nf x 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 synt
331. ower series with non negative exponents If az k X then the result is Y az X The library syntax is GEN laplace GEN x 3 7 32 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 GEN recip GEN x 3 7 33 subst z 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 zero In particular beware that subst 1 x 1 2 3 4 1 1 0 o 1 subst 1 x Mat 0 1 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 Use the function substvec to replace several variables at once or the function substpol to replace a polynomial expression The library syntax is GEN gsubst GEN x long y GEN z 3 7 34 substpol x y z replace the variable y by the argument z in the polynomial expression x Every type is allowed for x but the same behaviour as subst above apply The difference with subst is that y is allowed to be any polynomial here The substitution is done as per the following script subst_poly pol from to 1 my t subst_poly_t M from t subst lift Mod pol M
332. ows fitk and Qt graphing engines Possible values for c are given by the graphcolormap default factory setting are 1 black 2 blue 3 sienna 4 red 5 green 6 grey 7 gainsborough but this can be considerably extended 3 10 9 plotcopy sourcew destw dx dy flag 0 copy the contents of rectwindow sourcew to rectwindow destw with offset dx dy If flag s bit 1 is set dx and dy express fractions of the size of the current output device otherwise dx and dy are in pixels dx and dy are relative positions of northwest corners if other bits of flag vanish otherwise of 2 southwest 4 southeast 6 northeast corners 3 10 10 plotcursor w give as a 2 component vector the current scaled position of the virtual cursor corresponding to the rectwindow w 200 3 10 11 plotdraw list flag 0 physically draw the rectwindows given in list which must be a vector whose number of components is divisible by 3 If list wl x1 yl w2 12 y2 the windows wl w2 etc are physically placed with their upper left corner at physical position a1 y1 12 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 If flag 4 0 x1 yl etc express fractions of the size of the current output device 3 10 12 ploth X a b expr flags 0 n 0 high precision plot of the function y f z
333. p interface 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 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 If the line before the copyright message indicates that extended help is available this means perl is present on your system and the 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 ending the keyword with followed by the chapter number e g Hello 2 will look in Chapter 2 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
334. pecific function when you stopped it 14 2 2 The general gp input line The gp calculator uses a purely interpreted language GP 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 and the main loop does not really execute but rather evaluates sequences of expressions Of course it is by no means a true LISP and has been strongly influenced by C and Perl since then 2 2 1 Introduction User interaction with a gp session proceeds as follows First one types a sequence of characters at the gp prompt see Section 2 15 1 for a description of the line editor When you hit the lt Return gt key gp gets your input evaluates it then prints the result and assigns it to an history array More precisely the input is case sensitive and outside of character strings blanks are com pletely ignored Inputs are either metacommands or sequences of expressions Metacommands are shortcuts designed to alter gp s internal state such as the working precision or general verbosity level we shall describe them in Section 2 13 and ignore them for the time being The evaluation of a sequence of instructions proceeds in two phases your input is first digested byte compiled to a bytecode suitable for fast evaluation in particular loop bodies are compiled only once but a priori evaluated many times then the bytecode is eva
335. pected results Have a look and decide for yourself if something is amiss If it looks like a bug in the Pari system we would appreciate a report see the last section 3 Troubleshooting and fine tuning In case the default Configure run fails miserably try Configure a interactive mode and answer all the questions there are not that many Of course Configure still provides 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 see the last section 3 1 Installation directories The precise default destinations are as follows the gp binary the scripts gphelp and tex2mail go to prefix bin The pari library goes to prefix lib and include files to prefix include pari Other system dependant data go to prefix lib pari Architecture independent files go to various subdirectories of share_prefix which defaults to prefix share and can be specified via the share prefix argument Man pages go into share_prefix man and other system independant data under share_prefix pari documen tation sample GP scripts and C code extra packages like elldata or galdata You can also set directly bindir executables libdir library includedir include files mandir manual pages datadir other architecture independent data and finally sysdatadir other architecture dependent data 3 2 Environment variables Configure lets the follow
336. perating system does not support install USE if using an installed function triggers an error and BROKEN if the installed function did not behave as expected 2 11 Interfacing GP with other languages The PARI library was meant to be interfaced with C programs This specific use is dealt with extensively in the User s guide to the PARI library Of course gp itself provides a convenient interpreter to execute rather intricate scripts see Section 3 11 Scripts when properly written tend to be shorter and 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 if speed is paramount The GP2C compiler often eases this part The install command see Section 3 12 14 efficiently imports foreign functions for use under gp which can of course be written using other libraries than PARI Thus you may code only critical parts of your program in C and still maintain most of the program as a GP script We are aware of four PARL related Free Software packages to embed PARI in other languages We neither endorse nor support any of them but you may want to give them a try if you
337. precision for 3 consecutive evaluations The expressions must always evaluate to a complex number If the series converges slowly make sure realprecision is low even 28 digits may be too much In this case if the series is alternating or the terms have a constant sign sumalt and sumpos should be used instead 7 p28 suminf i 1 1 7i i suminf user interrupt after 10min 20 100 ms sumalt i 1 1 i i log 2 time O ms 11 2 524354897 E 29 The library syntax is suminf void E GEN eval GEN void GEN a long prec 195 3 9 23 sumnum X a sig expr tab flag 0 numerical summation of expr the variable X taking integer values from ceiling of a to 00 where expr is assumed to be a holomorphic function FX for R X gt 0 The parameter o R is coded in the argument sig as follows it is either e a real number Then the function f is assumed to decrease at least as 1 X at infinity but not exponentially e a two component vector o a where is as before a lt 1 The function f is assumed to decrease like X In particular a lt 2 is equivalent to no a at all e a two component vector o a where o is as before a gt 0 The function f is assumed to decrease like exp aX In this case it is essential that a be exactly the rate of exponential decrease and it is usually a good idea to increase the default value of m used for the integration step In practice i
338. r 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 coef ficients 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 For instance zetakinit x78 2 needs 440MB of memory at default precision The library syntax is GEN initzeta GEN x long prec 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 of the functions described here can be applied to other types 3 7 1 O p e if p is an integer greater than 2 returns a p adic 0 of precision e In all other cases returns a power series zero with precision given by ev where v is the X adic valuation of p with respect to its main variable The library syntax is GEN ggrando GEN zeropadic GEN p long e for a p adic and GEN zeroser long v long e for a power series zero in variable v 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 The derivative of a scalar type is z
339. rd argument amp n is given and x is indeed a k th power sets n to a k th root of x For a t_FFELT x instead of omitting k which is not allowed for this type it may be natural to set k x p poldegree x pol 1 fforder x The library syntax is long ispower GEN x GEN k NULL GEN n NULL 3 4 35 isprime z flag 0 true 1 if x is a prime number false 0 otherwise A prime number is a positive integer having exactly two distinct divisors among the natural numbers namely 1 and itself This routine proves or disproves rigorously that a number is prime which can be very slow when x is indeed prime and has more than 1000 digits say Use ispseudoprime to quickly check for compositeness See also factor If flag 0 use a combination of Baillie PSW pseudo primality test see ispseudoprime Selfridge p 1 test if x 1 is smooth enough and Adleman Pomerance Rumely Cohen Lenstra APRCL for general x If flag 1 use Selfridge Pocklington Lehmer p 1 test and output a primality certificate as follows return e 0 if x is composite e 1 if x is small enough that passing Baillie PSW test guarantees its primality currently x lt 1015 e 2 if x is a large prime whose primality could only sensibly be proven given the algorithms implemented in PARI using the APRCL test e Otherwise x is large and x 1 is smooth output a three column matrix as a primality certificate The first column cont
340. results when the class group has many cyclic factors because implementing Shanks s method in full generality slows it down immensely It is therefore strongly recommended to double check results using either the version with flag 1 or the function quadclassunit 101 Warning Contrary to what its name implies this routine does not compute the number of classes of binary primitive forms of discriminant D which is equal to the narrow class number The two notions are the same when D lt 0 or the fundamental unit e has negative norm when D gt 0 and Ne gt 0 the number of classes of forms is twice the ordinary class number This is a problem which we cannot fix for backward compatibility reasons Use the following routine if you are only interested in the number of classes of forms QFBclassno D qfbclassno D if D lt O norm quadunit D lt 0 1 2 Here are a few examples gfbclassno 400000028 time 3 140 ms hi 1 quadclassunit 400000028 no time 20 ms much faster 12 1 gfbclassno 400000028 time O ms 13 7253 correct and fast enough quadclassunit 400000028 no time O ms 4 7253 See also qfbhclassno The library syntax is GEN qfbclassno0 GEN D long flag Also available GEN classno GEN D flag 0 GEN classno2 GEN D flag 1 and GEN hclassno GEN D which computes the class number of an imaginary quadratic field by counting reduced forms an O D algorith
341. rk 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 This window can be closed enlarged or reduced using the standard window manager functions No zooming procedure is implemented though yet Among these special thanks go to Klaus Peter Nischke who suggested the recursive plotting and forking resizing stuff the graphical window and Ilya Zakharevich who rewrote the graphic code from scratch implementing many new primitives splines clipping Nils Skoruppa and Bill Allombert wrote the Qt and f1tk graphic drivers respectively 199 3 10 3 Functions for PostScript output in the same way that printtex allows you to have a TEX output corresponding to printed results the functions starting with ps allow you to have PostScript output of the plots This will not be identical with the screen output but 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 you probably want to remove this file or change the value of psfile in between plots On the other hand in this manner as many plots as desired can be kept in a single fil
342. rm SUIT etileno eee e ee wc 175 SOLVE ig Gg goatee a Bee E 194 BONNO c eaa ow hs Hs FA ee a OS 194 SQ stand he edo e 86 BOTT e hab ea e a ee ek A 87 SAKTINE e s fn se bale AG eee a 105 SOTEN yack we a a e eek ak 87 238 SUCK x hs So a ees Ge Fo Ee h 52 07 StACKSIZe orams aid Ga es Gee 37 Stark UNITS sa soe a a e a 104 130 StartUp se bee a wo ke ee 58 Steinitz class e soa ooa t e a 159 Stirling number 106 Stirling 2 cs ess 106 Stirlingi sa neg aatos E aeaa 106 Stirling s ns y a sri esnie aa i 106 StL mnara ae Gon g Geni 41 42 TL 72 SUCCHE fs gawd ekg db wee be T2 13 Strexpand esoo sea 72 Stritime gt eis ic ew eee ee Pe 48 53 strictmatch 12 wea a ee 1 54 string CONLEEE s siros ia ewe ok Ak ew Al SUPINE on esses gal on de Bek ae 7 23 40 SUTCOX 6 adh ge 6 eas e A a as T2 StrtoGEN lt lt sace det Tee He ka 2 SLUTMPATE koe cc e kh 4 165 subell ss bs dae Soe Ee ee Hy Sg 114 sublield aos ke oe Soa ao 149 subfieldsO museos a bes 149 SUDOTOWM lt lt ep G5 ES oe SI Sed 117 SUDETO D 2 aa s toe ew ee es 206 subgrouplist 159 206 subgrouplistO 160 subresultant algorithm 97 163 164 SUDSt sasad ee eb a hs 166 168 Substpol saser ias a ee we we 166 SUDSEVEC po bin ee eA Ee 8 ea we ee 167 SUT i ha E ah a ok Bok Boe GE E 64 SUM io erode a e Bed de 183 194 stimalt dais 191 194 195 198 SUMATEZ gc hie we a Bo awe De Ge we 195 SUMA 4
343. rmation can be obtained using the meta command see above For user defined functions member functions see u and um 2 13 7 Md prints the defaults as described in the previous section shortcut for default see Section 3 12 5 2 13 8 e n switches the echo mode on 1 or off 0 If n is explicitly given set echo to n 2 13 9 g n sets the debugging level debug to the non negative integer n 2 13 10 gf n sets the file usage debugging level debugfiles to the non negative integer n 2 13 11 gm n sets the memory debugging level debugmem to the non negative integer n 2 13 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 56 2 13 13 M1 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 13 14 m as a but using prettymatrix format 2 13 15 o n sets output mode to n 0 raw 1 prettymatrix 2 prettyprint 3 external prettyprint 2 13 16 p n sets realprecision to n decimal digits Prints its current value if n is omitted
344. rt 1 x 2 x 2 y72 time 54 410 ms slow intnum x 1 1 intnum y sqrt 1 x 2 sqrt 1 x72 x 2 y72 tab tab time 7 210 ms faster However the intnuminit program is usually pessimistic when it comes to choosing the integration step 2 It is often possible to improve the speed by trial and error Continuing the above example test M tab intnuminit 1 1 M intnum x 1 1 intnum y sqrt 1 x72 sqrt 1 x72 x 2 y72 tab tab Pi 2 m intnumstep what value of m did it take 11 7 test m 1 191 time 1 790 ms 2 2 05 E 104 4 2 times faster and still OK test m 2 time 430 ms 3 1 11 E 104 11 16 24 times faster and still OK test m 3 time 120 ms 3 7 23 E 60 11 64 2 times faster lost 45 decimals The library syntax isintnum void E GEN eval GEN void GEN a GEN b GEN tab long prec where an omitted tab is coded as NULL 3 9 11 intnuminit a b m 0 initialize tables for integration from a to b where a and b are coded as in intnum Only the compactness the possible existence of singularities the speed of decrease or the oscillations at infinity are taken into account and not the values For instance intnuminit 1 1 is equivalent to intnuminit 0 Pi and intnuminit 0 1 2 1 is equiv alent to intnuminit 1 1 1 2 If mis not given it is computed according to the current precision Otherwise the int
345. ry 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 the first functionality memory usage is disabled if you re not running a version compiled for debugging see Appendix A 2 12 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 e 2 12 8 factor_add_primes default 0 if this is set the integer factorization machinery will call addprimes on primes factor that were difficult to find so they are automatically tried first in other factorizations If a routine is performing or has performed a factorization and is interrupted by an error or via Control C this lets you recover the prime factors already found 2 12 9 factor_proven default 0 by default the factors output by the integer factorization machinery are only pseudo primes not proven primes If this is set a primality proof is done for each factor and all results depending on integer factorization are fully proven This flag does not affect partial factorization when it is explici
346. s nf 1 contains the polynomial pol nf pol nf 2 contains r1 r2 nf sign nf r1 nf r2 the number of real and complex places of K nf 3 contains the discriminant d K nf disc of K nf 4 contains the index of nf 1 nf index i e Zx Z 0 where 0 is any root of nf 1 nf 5 is a vector containing 7 matrices M G T2 T MD TI MDI useful for certain com putations 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 G is such that T2 GG where T2 is the quadratic form T gt x Y Jo x 1 o running over the embeddings of K into C e The 72 component is deprecated and currently unused 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 also that det T is equal to the discriminant of the field K Also when understood as an ideal the matrix T71 generates the codifferent ideal 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 the primitive part of T which has integral coefficients 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 the vector containing the r1 r2 roots nf roots of nf 1 corresponding to the rl 72 em
347. s like this this is a string The function Str can be used to transform any object into a string 23 2 3 18 Small vectors t_VECSMALL this is an internal type used to code in an efficient way vectors containing only small integers such as permutations Most gp functions will refuse to operate on these objects 2 3 19 Functions t_CLOSURE we will explain this at length in Section 2 7 For the time being suffices it to say that functions can be assigned to variables as any other object and the following equivalent basic forms are available to create new ones f x y gt x 2 y 2 f x y x 2 y 2 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 is performed first Operations at the same priority level are performed in the order they were written i e from left to right Anything enclosed between parenthesis is considered a complete subexpression and is resolved independently of the surrounding context For instance assuming that 0p1 op2 op3 are standard binary operators with increasing priorities think of for instance T
348. s any richer structure may replace the ones requested For instance in functions which have no use for the extra information given by an ell structure the curve can be given either as a five component vector as an sell or as an ell if an sell is requested an ell may equally be given 3 5 1 elladd z1 22 sum of the points z1 and 22 on the elliptic curve corresponding to E The library syntax is GEN addell GEN E GEN z1 GEN z2 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 an sell as output 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 ellminimalmodel before using ellak The library syntax is GEN akell GEN E GEN 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 description remain valid The library syntax is GEN anel1 GEN E long n 3 5 4 ellap E p computes the trace of Frobenius ap for the elliptic curve E and the prime number p This is 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 F If E F h
349. s apply rnfbasistoalg first otherwise PARI will believe you are dealing with a vector The library syntax is GEN rnfelementreltoabs GEN rnf GEN x 3 6 129 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 pol 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 GEN rnfelementup GEN rnf GEN x 3 6 130 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 an element of L a root a of the polynomial defining the base field nf and k is a small integer such that 0 6 ka where 0 is a root of z and GB a root of pol The main variable of nf must be of lower priority than that of pol see Section 2 5 3 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 equation of the tale al
350. s GEN bnfmake GEN sbnf long prec 3 6 19 bnfnarrow bnf bnf being as output by bnfinit computes the narrow class group of bnf The output is a 3 component 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 bnrinit The library syntax is GEN buchnarrow GEN bnf 3 6 20 bnfreg P tech bnf being as output by bnfinit computes its regulator The library syntax is GEN regulator GEN P GEN tech NULL long prec 3 6 21 bnfsignunit bnf bnf being as output by bnfinit this computes an r x r ra 1 matrix having 1 components giving the signs of the real embeddings of the fundamental units The following functions compute generators for the totally positive units exponents of totally positive units generators on bnf tufu tpuexpo bnf my S d K S bnfsignunit bnf d matsize S S matrix d 1 d 2 i j if Sli j lt 0 1 0 S concat vectorv d 1 i 1 S add sign 1 K lift matker S Mod 1 2 if K mathnfmodid K 2 2 matid d 1 totally positive units tpu bnf my vu bnf tufu ex tpuexpo bnf vector ex 1 i factorback vu ex
351. s arguments As usual the generating vectors are taken to be the columns of the given matrix Since PARI does not have a strong typing system scalars live in unspecified commutative base rings It is very difficult to write robust linear algebra routines in such a general setting The developers s choice has been to assume the base ring is a domain and work over its field of fractions If the base ring is not a domain one gets an error as soon as a non zero pivot turns out to be non invertible Some functions e g mathnf or mathnfmod specifically assume the base ring is Z 3 8 1 algdep z k flag 0 x being real complex or p adic finds a polynomial of degree at most k with integer coefficients having x as approximate root Note that the polynomial which is obtained is not necessarily the correct one In fact it is not even guaranteed to be irreducible One can check the closeness either by a polynomial evaluation use subst or by computing the roots of the polynomial given by algdep use polroots Internally lindep 1 x x flag is used If lindep is not able to find a relation and returns a lower bound for the sup norm of the smallest relation algdep returns that bound instead A suitable non zero value of flag may improve on the default behaviour AA LLL p200 algdep 2 1 6 37 1 5 30 wrong in 3 8s algdep 2 1 6 37 1 5 30 100 wrong in 1s algdep 2 1 6 37 1 5 30 170
352. s in all your gp sessions e g read in a file variables gp containing x y z t a b c d Important note PARI allows Euclidean division of multivariate polynomials but assumes that the computation takes place in the fraction field of the coefficient ring if it is not an integral domain the result will a priori not make sense This can become tricky for instance assume x has highest priority which is always the case then y 7xhy Al 0 Pyhx 2 y these two take place in Q y x x Mod 1 y 13 Mod 1 y x in Q y yQ y z Qlz Mod x y 4 0 In the last example the division by y takes place in Q y x hence the Mod object is a coset in Q y z yQ y z which is the null ring since y is invertible So be very wary of variable This is not strictly true the variable x is predefined and always has the highest possible priority 28 ordering when your computations involve implicit divisions and many variables This also affects functions like numerator denominator or content denominator x y hi 1 denominator y x 12 x content x y 3 1 y content y x 74 y content 2 x 15 2 Can you see why Hint 2 y 1 y x x is in Q y x and denominator is taken with respect to QU 2 y x yx20 x is in Q y z so y is invertible in the coefficient ring On the other hand 2 x involves a single variable and the coefficient ring is simply Z These problems ar
353. s of u If no solution exists returns zero The library syntax is GEN matsolvemodO GEN M GEN D GEN B long flag Also available are GEN gaussmodulo GEN M GEN D GEN B flag 0 and GEN gaussmodulo2 GEN M GEN D GEN B flag 1 3 8 42 matsupplement 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 GEN suppl GEN x 3 8 43 mattranspose 1 transpose of x also x This has an effect only on vectors and matrices The library syntax is GEN gtrans GEN x 176 3 8 44 minpoly A v x minimal polynomial of A with respect to the variable v i e the monic polynomial P of minimal degree in the variable v such that P A 0 The library syntax is GEN minpoly GEN A long v 1 where v is a variable number 3 8 45 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 off diagonal entries on each line represent the bilinear forms More precisely if a denotes the output one has g a Y anu 01323 i j i The library syntax is GEN qfgaussred GEN q GEN qfgaussred_positive GEN q assumes that q is positive definite and is a little faster returns NULL
354. s taken not with x but with its content content 2 4 matid 3 41 2 The library syntax is GEN content GEN x 3 4 9 contfrac z b nmaz returns the row vector whose components are the partial quotients of the continued fraction expansion of x That is a result ao means that x ay 1 a1 1 a The output is normalized so that a 4 1 unless we also have n 0 The number of partial quotients n is limited to nmax If x is a real number the expansion stops at the last significant partial quotient if nmax 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 instead of all equal to 1 as above The length of the result is then equal to the length of b unless a partial remainder is encountered which is equal to zero in 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 If b is an integer nmaz is ignored and the command is understood as contfrac z b The library syntax is GEN contfracO GEN x GEN b NULL long nmax Also available are GEN gboundcf GEN x long nmax and GEN gcf GEN x 3 4 10 contfracpnqn z when x is a vector or a one row matrix x is considered as the list of partial quotients ao a1 of a rational number and the result is the 2
355. s test although it is expected that infinitely many such numbers exist In particular all composites lt 10 are correctly detected checked using Galway s list of strong 2 pseudoprimes at http oldweb cecm sfu ca pseudoprime If flag gt 0 checks whether x is a strong Miller Rabin pseudo prime for flag randomly chosen bases with end matching to catch square roots of 1 The library syntax is GEN gispseudoprime GEN x long flag 3 4 37 issquare x amp n true 1 if x is a square false 0 if not What being a square means depends on the type of x all t_COMPLEX are squares as well as all non negative t_REAL for exact types such as t_INT t_FRAC and t_INTMOD squares are numbers of the form s with s in Z Q and Z NZ respectively issquare 3 as an integer hi 0 issquare 3 as a real number 42 1 issquare Mod 7 8 in Z 8Z 13 0 issquare 5 0 1374 MN in Q_13 14 0 If n is given a square root of x is put into n issquare 4 amp n 41 1 7 n 12 2 issquare 4 x72 amp n 13 1 11 both are squares n 4 2 x the square roots For polynomials either we detect that the characteristic is 2 and check directly odd and even power monomials or we assume that 2 is invertible and check whether squaring the truncated power series for the square root yields the original input The library syntax is GEN gissquareall GEN x GEN n NULL Also ava
356. s to give meaningful context by copying the sentence it was trying to read whitespace and comments stripped out indicating an error with a little caret like in factor x 2 1 kkk syntax error unexpected end expecting or factor x 2 1 a possibly enlarged to a full arrow given enough trailing context if isprime p do_something_nice kk syntax error unexpected if isprime p do_something_nice Error messages may be mysterious because gp cannot guess what you were trying to do and the error usually occurs once gp has been sidetracked Let us have a look at the two messages above The first error is a missing parenthesis but from gp s point of view you might as well have intended to give further arguments to factor this is possible and useful see the description of the function In fact gp expected either a closing parenthesis or a second argument separated from the first by a comma And this is exactly what the error message says we reached the end of the input end while expecting a ora The second error is a simple typo isprime p instead of isprime p What triggered the error was not the missing parenthesis but the ill formed addition p without a second operand This is detected when we read the ensuing comma and gp stops at this point Runtime errors from the evaluator are more annoying because they occur at a point where meaningful context no longer exists i
357. same type is returned The library syntax is GEN ellisoncurve GEN E GEN x Also available is int oncurve GEN E GEN x which does not accept vectors of points 3 5 18 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 GEN jell GEN x long prec 112 3 5 19 elllocalred E p calculates the Kodaira type of the local fiber of the elliptic curve E at the prime p E must be an sell as output 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 GEN elllocalred GEN E GEN p 3 5 20 elllseries E s A 1 E being an sell as output by ellinit this computes the value of the L series of E at s It is assumed that E is defined over Q not necessar
358. sary for a gp user 2 13 22 u prints the definitions of all user defined functions 2 13 23 um prints the definitions of all user defined member functions 2 13 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 13 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 arbitrary filenames 57 2 13 26 Xx prints the complete tree with addresses and contents in hexadecimal of the internal representation of the latest computed object in gp As for As this is used primarily as a debugging device for PARI and the format should be self explanatory a before an object typically a modulus means the corresponding component is out of stack However used on a PARI integer it can be used as a decimal hexadecimal converter 2 13 27 Xy n switches simplify on 1 or off 0 If n is explicitly given set simplify to n 2 13 28 switches the timer on or off 2 13 29 prints the time taken by the latest computation Useful when you forgot to turn on the timer
359. scape sequences not supported under emacs if EMACS prompt H M gp gt Note that any of the last two lines could be broken in the following way if EMACS prompt H M gp gt since the preprocessor directive applies to the next line if the current one is empty A sample gprc file called misc gprc dft is provided in the standard distribution It is a good idea to have a look at it and customize it to your needs Since this file does not use multiline constructs here is one note the terminating to separate the expressions Hif VERSION gt 2 2 3 read my_scripts syntax errors in older versions new_galois_format 1 default introduced in 2 2 4 if EMACS colors 9 5 no no 4 1 2 help gphelp detex ch 4 cb 0 cu 2 2 14 2 Where is it 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 loaded e On the Macintosh only gp looks in the directory which contains the gp executable itself for a file called gpre e gp checks whether the environment variable GPRC is set Under DOS you can set it in AU TOEXEC 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 59 e If GPRC is not set and if the env
360. se three functions satisfy the functional equation fm 1 2 1 f x The library syntax is GEN polylog0 long m GEN x long flag long prec Also avail able is GEN gpolylog long m GEN x long prec flag 0 3 3 40 psi x the function of z i e the logarithmic derivative I x T 2 The library syntax is GEN gpsi GEN x long prec 3 3 41 sin x sine of x The library syntax is GEN gsin GEN x long prec 3 3 42 sinh x hyperbolic sine of x The library syntax is GEN gsh GEN x long prec 86 3 3 43 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 274 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 00274 x x 3 1 0 275 1 0 274 74 44 1 0 276 note the difference between 2 and 3 above The library syntax is GEN gsqr GEN x 3 3 44 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 x gt 0 If x R and x l
361. see for example Section 2 7 It should be used to try and guess the value of an infinite sum However see the example at the end of Section 2 7 1 If the series already converges geometrically suminf is often a better choice 7 p28 sumalt i 1 1 7i i log 2 time O ms 194 11 2 524354897 E 29 suminf i 1 1 i i xxx suminf user interrupt after 10min 20 100 ms p1000 sumalt i 1 1 i i log 2 time 90 ms 12 4 459597722 E 1002 sumalt i 0 1 i i exp 1 time 670 ms 3 4 03698781490633483156497361352190615794353338591897830587 E 944 suminf i 0 1 i i exp 1 time 110 ms 4 8 39147638 E 1000 faster and more accurate The library syntax is sumalt void E GEN eval GEN void GEN a long prec Also available is suma1t2 with the same arguments flag 1 3 9 21 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 4 2 there is no way to indicate that expr is multi plicative in n hence specialized functions should be preferred whenever possible The library syntax is GEN divsum GEN n 3 9 22 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
362. set this to 1 The maximal value is a little less than 2 2 resp 2 4 on a 32 bit resp 64 bit machine Since almost all arithmetic functions eventually require some table of prime numbers PARI currently guarantees that the first 6547 primes up to and including 65557 are precomputed even if primelimit is 1 2 12 24 prompt default a string that will be printed as prompt Note that most usual escape sequences are available there e for Esc n 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 4H hour 24 hour clock and 4M 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 12 1 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 PariEmacs needs to know about the prompt pattern to separate your input from previous gp results without ambiguity It is not a trivial problem to adapt automatically this regular expression to an arbitrary prompt which can be self modifying
363. 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 into a set use the function Set The library syntax is long setisset GEN x 3 8 55 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 GEN setminus GEN x GEN y 3 8 56 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 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 long setsearch GEN x GEN y long flag 3 8 57 setunion z y union of the two sets x and y The library syntax is GEN setunion GEN x GEN y 3 8 58 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 GEN gtrace GEN x 180 3 8 59 vecextract z y 2 extraction of components of the vector or matrix x according to y In case x is a matrix its components
364. sis is said to be partially reduced if v v gt v for any two distinct basis vectors v vj This is significantly faster than flag 1 esp when one row is huge compared to the other rows Note that the resulting basis is not LLL reduced in general 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 represent a basis of the integer kernel of x not necessarily LLL reduced and the second matrix is the transformation matrix T such that x T is an LLL reduced Z basis of the image of the matrix zx If flag 5 case as case 4 but x may have polynomial coefficients If flag 8 same as case 0 but x may have polynomial coefficients The library syntax is GEN qf1110 GEN x long flag long prec Also available are GEN 111 GEN x long prec flag 0 GEN 111int GEN x flag 1 and GEN 111kerim GEN x flag 4 177 3 8 48 qflllgram G flag 0 same as qf111 except that the matrix G x x x is the Gram matrix of some lattice vectors x and not the coordinates of the vectors themselves In particular G must now be a square symmetric real matrix corresponding to a positive definite quadratic form The result is a unimodular transformation matrix T such that x T is an LLL reduced basis of the lattice generated by the column vectors of zx If flag 0 default the computations are done with floating poi
365. ss field It was decided that it was more useful to keep the extra information thus made available hence the user has to take the compositum herself Even if it exists the auxiliary conductor may be so large that later computations become unfeasible and of course Stark s conjecture may simply be wrong In case of difficulties one should try and come back to rnfkummer bnr bnrinit bnfinit y 8 12 xy 6 36 y 4 36 y72 9 1 2 1 bnrstark bnr bnrstark need 3919350809720744 coefficients in initzeta computation impos sible 1ift rnfkummer bnr time 24 ms 2 x72 1 3 y76 11 3xy 4 8xy 2 5 The library syntax is GEN bnrstark GEN bnr GEN subgroup NULL long prec 130 3 6 37 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 GEN dirzetak GEN nf GEN b 3 6 38 factornf x t factorization of the univariate polynomial x over the number field defined by the univariate polynomial t z may have coefficients in Q or in the number field The algorithm reduces to factorization over Q Trager s trick The direct approach of nffactor which uses van Hoeij s method in a relative setting is in general faster The main variable of t must be of lower priority than that of x see Section 2 5 3 However if non rational number field elements occur as polmods or polynomials as coefficients of
366. ssages prepended by which report genuine problems If anything should have been found and was not consider that Configure failed and follow the instructions in the next section Look especially for the gmp readline and X11 libraries and the perl and gunzip or zcat binaries 2 2 Compilation To compile the GP binary and build the documentation type make all To only compile the GP binary type make gp in the toplevel directory If your make program supports parallel make you can speed up the process by going to the Oxx directory that Configure created and doing a parallel make here for instance make j4 with GNU make It should even work from the toplevel directory 218 2 3 Basic tests 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 a few seconds 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 format in case your system is not listed and you nevertheless have a working GP executable If a BUG message shows up something went wrong The testing utility directs you to files containing the differences between the test output and the ex
367. ssible values 0 raw 1 prettymatrix 2 prettyprint or 3 external prettyprint This means that independently of the default format for reals which we explained above you can print results in four 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 paste it somewhere else The second format is the prettymatrix 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 4 2 this is not beautiful at all The fourth format is external prettyprint which pipes all gp output in TeX format to an external prettyprinter according to the value of prettyprinter The default script tex2mail converts its input to readable two dimensional text Independently of the setting of this default an object can be printed in any of the three formats at any time using the commands a m and b respectively see below 2 12 20 parisize default 4M resp 8M on a 32 bit resp 64 bit machine gp and in fact any program using the PARI library needs a stack
368. syntax is GEN quadpoly0 GEN D long v 1 where v is a variable number 3 4 64 quadray D f lambda relative equation for the ray class field of conductor f for the quadratic field of discriminant D using analytic methods A bnf for z D is also accepted in place of D For D lt 0 uses the o function If supplied lambda is is the technical element A of bnf necessary for Schertz s method In that case returns 0 if A is not suitable For D gt 0 uses Stark s conjecture and a vector of relative equations may be returned See bnrstark for more details The library syntax is GEN quadray GEN D GEN f GEN lambda NULL long prec 3 4 65 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 GEN gregula GEN x long prec 3 4 66 quadunit D fundamental unit of the real quadratic field Q VD where D is the positive discriminant of the field If D is not a fundamental discriminant this probably gives the funda mental unit of the corresponding order D must be an integer congruent to 0 or 1 modulo 4 which is not a square the result is a quadratic number see Section 3 4 61 The library syntax is GEN gfundunit GEN D long prec 3 4 67 removeprimes z removes the primes listed in x from the prime number table In particular removeprimes addprimes
369. t More generaly typing make without argument will print the list of available extra tests among all available targets 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 6 3 Heavy duty testing Optional There are a few extra tests which should be useful only for developpers make test kernel checks whether the low level kernel seems to work and provides simple diagnostics if it does not Only useful if make bench fails horribly e g things like 1 1 do not work make test all runs all available test suites Slow 4 Installation When everything looks fine type make install You may have to do this with superuser privileges depending on the target directories Tip for MacOS X beginners use sudo make install In this case it is advised to type make all first to avoid running unnecessary commands as root 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 are an avid gp fan do not forget to delete the old pari libraries once in a while This installs in the directories chose
370. t 0 then the result is complex with positive imaginary part Intmod a prime and p adics are allowed as arguments 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 intmods is in the interval 0 p 2 When the argument is an intmod a non prime or a non prime adic the result is undefined The library syntax is GEN gsqrt GEN x long prec 3 3 45 sqrtn x n amp z principal branch of the nth root of x i e such that Arg sqrt x 7 n 7 n Intmod a prime and p adics are allowed as arguments If z is present it is set to a suitable root of unity allowing to recover all the other roots If it was not possible z is set to zero In the case this argument is present and no square root exist 0 is returned instead or raising an error sqrtn Mod 2 7 2 11 Mod 4 7 sqrtn Mod 2 7 2 amp z z 92 Mod 6 7 sqrtn Mod 2 7 3 sqrtn nth root does not exist in gsqrtn sqrtn Mod 2 7 3 amp z 2 0 Z 3 0 The following script computes all roots in all possible cases sqrtnall x n nly V r z r2 87 r sqrtn x n amp z if z error Impossible case in sqrtn if type x t_INTMOD type x t_PADIC r2 r z n 1 while r2 r r2 z n V vector n V 1 r for i 2 n Vli Vli 1 xz V addhelp sqrtnall sqrtnall x n compute the vector of nth roots of x
371. t expression evaluated If a GP binary file is read using this command see Section 3 12 32 the file is loaded and the last object in the file is returned In case the file you read in contains an allocatemem statement to be generally avoided you should leave read instructions by themselves and not part of larger instruction sequences 3 12 23 readvec filename reads in the file filename subject to string expansion If filename is omitted re reads the last file that was fed into gp The return value is a vector whose components are the evaluation of all sequences of instructions contained in the file For instance if file contains 3 then we will get 7 ra wi 1 12 2 13 3 read a 74 3 readvec a 45 1 2 3 In general a sequence is just a single line but as usual braces and may be used to enter multiline sequences The library syntax is GEN gp_readvec_file char filename 212 3 12 24 select A f Given a vector list or matrix A and a t_CLOSURE f returns the elements x of A such that f x is non zero In other words f is seen as a selection function returning a boolean value select vector 50 i1 i 2 1 x gt isprime x 1 2 5 17 37 101 197 257 401 577 677 1297 1601 select x gt x lt 100 2 2 5 17 37 returns the primes of the form i 1 for some i lt 50 then the elements less than 100 in the preceding result The following function lists th
372. t example used the named cmp instead of an anonymous function and sorts polynomials with respect to the absolute value of their discriminant A more efficient approach would use precomputations to ensure a given discriminant is computed only once DISC perm vecsort vector v i i x y gt sign DISC x DISC y vecextract v perm vector v i abs poldisc v i Similar ideas apply whenever we sort according to the values of a function which is expensive to compute 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 e 4 use descending instead of ascending order e 8 remove duplicate entries with respect to the sorting function keep the first occuring entry If k is given entries having the same k th component as a given one are deleted vecsort 1 2 0 2 2 8 41 1 211 The library syntax is GEN vecsortO GEN x GEN cmp NULL long flag 182 3 8 61 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
373. t must be reallocated but in time O 1 on average k successive listput run in time O L k The library syntax is GEN listput GEN list GEN x long n 3 8 10 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 faster than the vecsort command since no copy has to be made The library syntax is GEN listsort GEN list long flag 3 8 11 matadjoint x adjoint matrix of x i e the matrix y of cofactors of x satisfying x y det x x Id z must be a non necessarily invertible square matrix The library syntax is GEN adj GEN x 3 8 12 matcompanion z the left companion matrix to the polynomial x The library syntax is GEN assmat GEN x 3 8 13 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 GEN detO GEN x long flag Also available are GEN det GEN x flag 0 and GEN det2 GEN x flag 1 171 3 8 14 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 zx if it is of rank m and returns zero otherwise This function can be useful in
374. tax is long getstack 3 12 11 gettime returns the time in milliseconds elapsed since either the last call to gettime or to the beginning of the containing GP instruction if inside gp whichever came last The library syntax is long gettime 3 12 12 global listof variables obsolete Scheduled for deletion 3 12 13 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 16 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 12 14 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 the Libpari Manual for an explanation of those If lib is omitted uses libpari so If gpname 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 t
375. teinitz nf given a number field nf as output 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 J not in HNF in general such that all the ideals of J 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 J which is well defined is the Steinitz class of the Zk module Zz its image in SKo Zx The library syntax is GEN rnfsteinitz GEN nf GEN x 3 6 152 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 Subgroups are given as HNF left divisors of the SNF matrix corresponding to G Warning the present implementation cannot treat a group G where any cyclic factor has more than 231 resp 2 elements on a 32 bit resp 64 bit architecture forsubgroup is a bit more general and can handle G if all p Sylow subgroups of G satisfy the condition above If flag 0 default and bnr is as output by bnrinit gives only the subgroups whose modulus is the conductor Otherwise the modulus is not taken into account If bound is present and is a positive integer restrict the output to subgroups of ind
376. tely requested Note that if affects all other factorizations and will in general lead to significant slowdowns 50 2 12 10 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 unless their integer part is not defined not enough significant digits 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 except when their absolute value is less than 2732 or they are real zeroes of arbitrary exponent 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 12 11 graphcolormap default value white black blue violetred red green grey gainsboro A vector of colors to be used by hi res graphing routines Its length is arbitrary but it must contain at least 3 entries the first 3 colors are used for background frame ticks and axes respectively All c
377. th Archimedean component ga let also GD be the Archimedean components of the generators of the principal ideals defined by the bnf gen i bnf cyc i Then bnf 9 U Ja GDa bnf 10 is by default unused and set equal to 0 This field is used to store further information about the field as it becomes available which is rarely needed hence would be too expensive to compute during the initial bnfinit call For instance the generators of the principal ideals bnf gen i bnf cyc i during a call to bdnrisprincipal or those corresponding to the relations in W and B when the bnf internal precision needs to be increased An sbnf 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 r1 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 S 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 o
378. that T Le has positive imaginary part E eta is a row vector containing the quasi periods 7 and 72 such that y 2 w 2 where is the Weierstrass zeta function associated to the period lattice see ellzeta In particular the Legendre relation holds nowi mw 2ir Finally E area is the volume of the complex lattice defining E e When is defined over Qp the p adic valuation of j must be negative Then F 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 tate yields the three component vector u u q in the notations of Tate If the u component does not belong to Q it is set to zero E w is Mestre s w this is technical For all other base fields or rings the last six components are arbitrarily set to zero See also the description of member functions related to elliptic curves at the beginning of this section The library syntax is GEN ellinitO GEN x long flag long prec Also available are GEN initell GEN E long prec flag 0 and GEN smallinitell GEN E long prec flag 1 3 5 17 ellisoncurve E x 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 take this into account i e an imprecise equality is checked not a precise one It is allowed for z to be a vector of points in which case a vector of the
379. 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 GEN precision0 GEN x long n Also available are GEN gprec GEN x long n and long precision GEN x In both the accuracy is expressed in words 32 bit or 64 bit depending on the architecture 3 2 42 random N 951 returns a pseudo random integer uniformly distributed between 0 and N 1 N is an integer which can be arbitrary large The random seed may be obtained via getrand and reset using setrand from a given seed the exact same values will be generated The same seed is used at each startup reseed the generator yourself if this is a problem Note that random 2731 is equivalent to random This was not the case up to version 2 4 This
380. the parameters Outputs 1 if this modulus is the conductor and 0 otherwise This is slightly faster than bnrconductor The library syntax is long bnrisconductor GEN al GEN a2 NULL GEN a3 NULL 3 6 34 bnrisprincipal bnr x flag 1 bnr being the number field data which is output by bnrinit 1 and z being an ideal in any form outputs the components of x on the ray class group generators in a way similar to bnfisprincipal That is a 2 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 If flag 0 outputs only v In that case bnr need not contain the ray class group generators i e it may be created with bnrinit 0 If x is not coprime to the modulus of bnr the result is undefined The library syntax is GEN bnrisprincipal GEN bnr GEN x long flag 129 3 6 35 bnrrootnumber bnr chi flag 0 if x chi is a character over bnr not necessarily primitive let L s x gt x 1d 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 x 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 x 57 bnr bnrinit bnf 7
381. 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 zo 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 GEN nfisincl GEN x GEN y 3 6 103 nfisisom z 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 GEN nfisisom GEN x GEN y 3 6 104 nfkermodpr nf x pr kernel of the matrix a in Zx pr where pr is in modpr format see nfmodprinit The library syntax is GEN nfkermodpr GEN nf GEN x GEN pr 3 6 105 nfmodprinit nf pr transforms the prime ideal pr into modpr format necessary for all operations modulo pr in the number field nf The library syntax is GEN nfmodprinit GEN nf GEN pr 3 6 106 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 quite slow many generators of principal ideals have to be computed The library syntax is GEN nfn
382. the result is undefined The result is a vector of pr structures each representing one of the prime ideals above p in the number field nf The representation P p a e f b of a prime ideal means the following The prime ideal is equal to pZk aZx where Zx is the ring of integers of the field and a gt gt ajw where the w form the integral basis nf zk e is the ramification index f is the residual index and b represents a 3 Zg such that P Zg B pZ k which will be useful for computing valuations but which the user can ignore The number a is guaranteed to have a valuation equal to 1 at the prime ideal this is automatic if e gt 1 The components of P should be accessed by member functions P p P e P f and P gen returns the vector p a The library syntax is GEN primedec GEN nf GEN p 3 6 66 idealprincipal nf x creates the principal ideal generated by the algebraic number x in the number field nf The result is a one column matrix For the converse problem testing whether an ideal is principal and finding a generator see bnfisprincipal However this requires a bnf structure FIXME this function is useless since all ideal related functions already accept number field elements as ideals and it returns an ideal in a non standard format which should be a square matrix in HNF It will disappear in future releases The library syntax is GEN principalideal GEN nf GEN x 139 3 6 67 idealred nf 1 vdir
383. the variables occurring in a polmod are not free variables But internally a congruence class in R t y is represented by its representative of lowest degree which is a t_POL in R t and computations occur with polynomials in the variable t PARI will not recognize that Mod y y72 1 is the same as Mod x x72 1 since x and y are different variables To avoid inconsistencies polmods must use the same variable in internal operations i e be tween polmods and variables of lower priority for external operations typically between a poly nomial and a polmod See Section 2 5 3 for a definition of priority and a discussion of PARI s idea of multivariate polynomial arithmetic For instance Mod x x72 1 Mod x x72 1 1 Mod 2 x x72 1 2i or 2i with i 1 x Mod y y 2 1 12 x Mod y y72 1 Al in Q i z y Mod x x72 1 3 Mod x y x72 1 Ain Q y 1 The first two are straightforward but the last one may not be what you want y is treated here as a numerical parameter not as a polynomial variable 20 If the main variables are the same it is allowed to mix t_POL and t_POLMODs The result is the expected t_POLMOD For instance x Mod x x 2 1 1 Mod 2 x x72 1 6699 2 3 10 Polynomials t_POL type the polynomial in a natural way not forgetting to put a x between a coefficient and a formal variable you may also use the functions Pol or Polrev
384. thout doing any reduction i e using qfbcompraw Here n must be non negative and n lt 2 1 The library syntax is GEN powraw GEN x long n 3 4 56 qfbprimeform p prime binary quadratic form of discriminant x whose first coefficient is the prime number p By abuse of notation p 1 is a valid special case which returns the unit form Returns an error if x is not a quadratic residue mod p In the case where x gt 0 p lt 0 is allowed and the distance component of the form is set equal to zero according to the current precision Note that negative definite t_QFI are not implemented The library syntax is GEN primeform GEN x GEN p long prec 3 4 57 qfbred z flag 0 D isqrtD sqrtD reduces the binary quadratic form x up dating Shanks s distance function if x is indefinite The binary digits of flag are toggles meaning 1 perform a single reduction step 2 don t update Shanks s distance 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 GEN qfbredO GEN x long flag GEN D NULL GEN isqrtD NULL GEN sqrtD NULL Also available are GEN redimag GEN x for definite x and for indefinite forms GEN redreal GEN x GEN rhoreal GEN x qfbred x 1 GEN redrealnod GEN x GEN isqrtD qfbred x
385. ties it just ignored them changing them would result in many annoying display bugs The specific thing to look for is to check the readline h include file wherever your readline include files are for the string RL_ PROMPT_START_IGNORE If it is there you are safe Another sensible way is to make some experiments and get a more recent readline if yours doesn t work the way you would like it to See the file misc gprc dft for some examples 2 12 2 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 12 29 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 obsolete 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 49 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 versio
386. tional 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 convention 0 is factored as 0 If x is of type integer or rational the factors are pseudoprimes see ispseudoprime and in general not rigorously proven primes In fact any factor which is lt 1015 is a genuine prime number Use isprime to prove primality of other factors as in fa factor 2 2 7 1 isprime fa 1 Another possibility is to set the global default factor_proven which will perform a rigorous primality proof for each pseudoprime factor An argument lim can be added meaning that we look only for prime factors p lt lim or up to primelimit whichever is lowest except when lim 0 where the effect is identical to setting lim primelimit In this case the remaining part may actually be a proven composite 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 See factormod and factorff for the algorithms used over finite fields factornf for the algorithms over number fields Over Q van Hoeij s method is used which is able to cope with h
387. torted ellipse produced by ploth t 0 2 Pi cos t sin t Parametric e 8 noX axis do not print the z axis e 16 no_Y_axis do not print the y axis e 32 no_Frame do not print frame e 64 no_Lines only plot reference points do not join them e 128 Points_too plot both lines and points e 256 Splines use splines to interpolate the points e 512 no_X_ticks plot no x ticks e 1024 no_Y_ticks plot no y ticks e 2048 Same_ticks plot all ticks with the same length e 4096 Complex is a parametric plot but where each member of expr is considered a complex number encoding the two coordinates of a point For instance ploth X 0 2 Pi exp I X Complex ploth X 0 2 Pi 1 I X exp I X Complex will draw respectively a circle and a circle cut by the line y zx 3 10 13 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 liste and listy Automatic positioning and scaling is done but with the same scaling factor on x and y If flag is 1 join points other non 0 flags toggle display options and should be combinations of bits 2 k gt 3 as in ploth 3 10 14 plothsizes flag 0 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 signif
388. tric 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 GEN perf GEN a 3 8 51 qfrep q B flag 0 q being a square and symmetric matrix with integer entries repre senting a positive definite quadratic form outputs the vector whose i th entry 1 lt i lt B is half the number of vectors v such that q v i This routine uses a naive algorithm based on qfminim and will fail if any entry becomes larger than 231 The binary digits of flag mean e 1 count vectors of even norm from 1 to 2B e 2 return a t_VECSMALL instead of a t_GEN The library syntax is GEN qfrepO GEN q GEN B long flag 179 3 8 52 qfsign x returns p m the signature of the quadratic form represented by the symmetric matrix x Namely p resp m is the number of positive resp negative eigenvalues of x The result is computed using Gaussian reduction The library syntax is GEN qfsign GEN x 3 8 53 setintersect z y intersection of the two sets x and y The library syntax is GEN setintersect GEN x GEN y 3 8 54
389. type so their use is only advised when using the calculator gp As an alternative one can replace a numeric flag by a character string containing symbolic identifiers For a generic flag the mnemonic corresponding to the numeric identifier is given after it as in fun x flag 0 If flag is equal to 1 AGM use an agm formula which means that one can use indifferently fun x 1 or fun z AGM For a binary flag mnemonics corresponding to the various toggles are given after each of them They can be negated by prepending no_ to the mnemonic or by removing such a prefix These toggles are grouped together using any punctuation character such as or For instance taken from description of ploth X a b expr flag 0 n 0 Binary digits of flags mean 1 Parametric 2 Recursive so that instead of 1 one could use the mnemonic Parametric no Recursive or simply Para metric since Recursive is unset by default default value of flag is 0 i e everything unset People used to the bit or notation in languages like C may also use the form Parametric no_Recursive 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 function may assign a value to e as a side effect When passing the argument the amp sign has to be typed in explicitly As of version 2 4 2 this pointer argument is option
390. u x r y uy su ta t see also ellchangecurve The library syntax is GEN ellchangepoint GEN x GEN v Also available is GEN ellchange pointinv GEN x GEN ch to invert the coordinate change 3 5 8 ellconvertname name converts an elliptic curve name as found in the elldata database from a string to a triplet conductor isogeny class index It will also convert a triplet back to a curve name Examples ellconvertname 123b1 1 123 1 1 ellconvertname 12 123b1 The library syntax is GEN ellconvertname GEN name 3 5 9 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 representing its periods and k being an even positive integer computes the numerical value of the Fisenstein series of weight k at E namely inwa 1 2 6 1 k Y nta 1 n gt 0 where q exp 2i77 and T w1 w2 belongs to the complex upper half plane When flag is non zero and k 4 or 6 returns the elliptic invariants g2 or 93 such that y 42 gox 93 is a Weierstrass equation for E The library syntax is GEN elleisnum GEN E long k long flag long prec 3 5 10 elleta om returns the quasi periods 71 72 associated to the lattice basis om w1 wa Alternatively om can be an elliptic curve E as output by ellinit in which case the quasi periods associated to the period lattice basis E omega namely E eta are returned
391. ucture output by nfinit This contains the basic arithmetic data associated to the number field signature maximal order given by a basis nf zk discriminant defining polynomial T etc e bnf denotes a Buchmann s number field i e a data structure output by bnfinit This contains nf and the deeper invariants of the field units U K class group Cl K as well as technical data required to solve the two associated discrete logarithm problems e bnr denotes a ray number field i e a data structure output by bnrinit corresponding to the ray class group structure of the field for some modulus f It contains a bnf the modulus f the ray class group Cl K and data associated to the discrete logarithm problem therein 116 3 6 2 Algebraic numbers and ideals An algebraic number belonging to K Q X T is given as e a t_INT t_FRAC or t_POL implicitly modulo T or e a t_POLMOD modulo T or e a t_COL v of dimension N K Q representing the element in terms of the computed integral basis as sum i 1 N v i nf zk i Note that a t_VEC will not be recognized An ideal is given in any of the following ways e an algebraic number in one of the above forms defining a principal ideal e a prime ideal i e a 5 component vector in the format output by idealprimedec e a t_MAT square and in Hermite Normal Form or at least upper triangular with non negative coefficients whose columns represent a basis of the idea
392. unction sum of the residues in the corresponding disk tab is as in intnum except that if computed with intnuminit it should be with the endpoints 1 1 p105 intcirc s 1 0 5 zeta s 1 1 2 398082982 E 104 7 94487211 E 107 I The library syntax is intcirc void E GEN eval GEN void GEN a GEN R GEN tab long prec 3 9 3 intfouriercos X a b z expr tab numerical integration of expr X cos 272X from a to b in other words Fourier cosine transform from a to b of the function represented by expr Endpoints a and b are coded as in intnum and are not necessarily at infinity but if they are oscillations i e 1 a1 are forbidden The library syntax is intfouriercos void E GEN eval GEN void GEN a GEN b GEN z GEN tab long prec 3 9 4 intfourierexp X a b z expr tab numerical integration of expr X exp 2im7zX from a to b in other words Fourier transform from a to b of the function represented by expr Note the minus sign Endpoints a and b are coded as in intnum and are not necessarily at infinity but if they are oscillations i e 1 a1 are forbidden The library syntax is intfourierexp void E GEN eval GEN void GEN a GEN b GEN z GEN tab long prec 3 9 5 intfouriersin X a b z expr tab numerical integration of expr X sin 27zX from a to b in other words Fourier sine transform from a to b of the function represented by expr Endpoints a and b
393. undreds of modular factors 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 needed you can always ask for the content explicitly factor t 2 5 2 t 1 1 2xt 1 1 t 2 1 content t 2 5 2 t 1 42 1 2 See also nffactor The library syntax is GEN factorO GEN x long lim Also available are GEN factor GEN x and GEN boundfact GEN x long lim 93 3 4 19 factorback f e nf gives back the factored object corresponding to a factorization The integer 1 corresponds to the empty factorization If the last argument is of number field type e g created by nfinit assume we are dealing with an ideal factorization in the number field The resulting ideal product is given in HNF form If e is present e and f must be vectors of the same length e being integral and the corre sponding factorization is the product of the f i 4 If not and f is vector it is understood as in the preceding case with e a vector of 1 the product of the f i is returned Finally f can be a regular factorization as produced with any factor command A few examples factorback 2 2 3 1 1 S12 factorback 2 2
394. up 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 GEN bnrL1 GEN bnr GEN subgroup NULL long flag long prec Jj 3 6 25 bnrclass bnf ideal flag 0 this function is DEPRECATED use bnrinit bnf being as output by bnfinit the units are mandatory unless the ideal is trivial and ideal being a modulus computes the ray class group of the number field for the modulus ideal as a finite abelian group The library syntax is GEN bnrclass0 GEN bnf GEN ideal long flag 3 6 26 bnrclassno bnf 1 bnf being as output by bnfinit units are mandatory unless the ideal is trivial and J being a modulus computes the ray class number of the number field for the modulus This is faster than bnrinit and should be used if only the ray class number is desired See bnrclassnolist if you need ray class numbers for all moduli less than some bound The library syntax is GEN bnrclassno GEN bnf GEN I 3 6 27 bnrclassnolist bnf list bnf being as output by bnfinit and list being a list of moduli with units as output by ideallist or ideallistarch outputs the list of the class numbers of the corresponding ray class groups To compute a single class number bnrclassno is more efficient bnf bnfinit x 2 2 7 L ideallist bnf 100 2 H b
395. ur 152 237 rnicharpoly ss se esames setaa 152 mnfconductor fre por e aa ee aa x 153 tnfdedekind s s r 2 3 sis he aia 153 TD ASE 4 4 4 646 sa 4 153 THidisG soe Ad ooo a wed mo 153 ENDTAOISC sss hon ce ew eee ee ee es 153 rnfelementabstorel 1593 rnfelementdown 153 rnfelementreltoabs 154 rnfelementup 154 rnfeltabstorel 153 rnfeltdown 0 103 rnfeltreltoabs t53 rmnfeltup eca 2 os a aoee eee aes 154 rnifequation osoase raor amen ey 154 rnfequation0 154 TNEHNTDASITS s na riene a aa 154 rnfidealabstorel 154 rnfidealdown pas 2684 eh kaos 154 155 rnfidealhermite 155 r fidealhnf oras BS Ey 155 yYofidealmil sucios E a 155 rnfidealnormabs 109 rnfidealnormrel 155 rnfidealreltoabs t55 rnfidealtwoelement 159 rnfidealtwoelt corsa i ea 155 rn fideal p sia ersada a ra eE 155 TODA e egr n ee ee me SS 156 EOTinitalS ioe sys se Pee hee eg 156 rnfisfree eog eu ee ee G 157 EDTISDOTM ati 8 we a 157 PHTUSHOMMINIE dae 157 rnfkummer 130 157 158 159 rnflllgram 2 cocos bee Daa 158 rnfNOTMBroup sos sa essees itsi 158 TA DOLrOd 16 e keema Gr a 158 rnfpolredabs 158 rnfpseudobasis 158 159 rnfsteinitZ o on srao mas Re 159 Robot ce 3 ak Bae ESO A 141 EOOEMOJO soss koa ia dea aoe ed 165 rootpadi s
396. ur function using addhelp but the online help system already handles it By default name will print the definition of the function name the list of arguments as well as their default values the text of seq as you input it Just as c prints the list of all built in commands u outputs the list of all user defined functions Backward compatibility lexical scope Lexically scoped variables were introduced in ver sion 2 4 2 Before that the formal parameters were dynamically scoped If your script depends on this behaviour you may use the following trick replace the initial f x by f x_orig local x x_orig Backward compatibility disjoint namespaces Before version 2 4 2 variables and functions lived in disjoint namespaces and it was not possible to have a variable and a function share the same name Hence the need for a kill function allowing to reuse symbols This is no longer the case There is now no distinction between variable and function names we have PARI objects functions of type t_CLOSURE or more mundane mathematical entities like t_INT etc and variables bound to them There is nothing wrong with the following sequence of assignments ffs assigns the integer 1 to f 41 1 210 1 a function with a constant value 2 gt 1 f x2 now holds a polynomial 13 x72 f x x72 MV and now a polynomial function 94 x gt x 2 Previously used names can be recycled as above you are just
397. urrent values See Section 2 12 for a list of available defaults and Section 2 13 for some shortcut alternatives Note that the shortcuts are meant for interactive use and usually display more information than default The library syntax is GEN defaultO char key char val long 3 12 6 error str outputs its argument list each of them interpreted as a string then inter rupts the running gp program returning to the input prompt For instance error n n is not squarefree 3 12 7 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 209 3 12 8 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 GEN getheap 3 12 9 getrand returns the current value of the seed used by the pseudo random number gener ator random Useful mainly for debugging purposes to reproduce a specific chain of computations The returned value is technical reproduces an internal state array and can only be used as an argument to setrand The library syntax is GEN getrand 3 12 10 getstack returns the current value of top avma i e the number of bytes used up to now on the stack Useful mainly for debugging purposes The library syn
398. urrently not available in GP If flag 2 the fundamental units and roots of unity are not computed Hence the result has only 7 components the first seven ones The library syntax is GEN bnfclassunitO GEN P long flag GEN tech NULL long prec 3 6 10 bnfclgp P tech as bnfinit but only outputs bnf clgp i e the class group The library syntax is GEN classgrouponly GEN P GEN tech NULL long prec 3 6 11 bnfdecodemodule nf m if m is a module as output in the first component of an exten sion given by bnrdisclist outputs the true module The library syntax is GEN decodemodule GEN nf GEN m 3 6 12 bnfinit P flag 0 tech initializes a bnf structure Used in programs such as bnfisprincipal bnfisunit or bnfnarrow By default the results are conditional on a heuristic strengthening of the GRH see 3 6 7 The result is a 10 component vector bnf This implements Buchmann s sub exponential algorithm for computing 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 integer coefficients 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 we insist on finding the fundamental units exactly Be warned that this can take a very long time when the coefficients of the fundamental units on th
399. 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 z7 2 1 WRONG NN NN The library syntax is GEN nffactor GEN nf GEN x 3 6 94 nffactormod nf pol pr factorization of the univariate polynomial x 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 intmod modulo the rational prime under pr polmod or polynomial with intmod coefficients column vector of intmod 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 see Section 2 5 3 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 GEN nffactormod GEN nf GEN pol GEN pr 3 6 95 nfgaloisapply nf aut x nf being a number field as output by nfinit and aut being a Galois automorphism of nf expressed 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 gi
400. vector o a where o is as before and either a 0 for slowly decreasing functions or a gt 0 for functions decreasing like exp at Note that it is not necessary to choose the exact value of a tab is as in intnum It is often a good idea to use this function with a value of m one or two higher than the one chosen by default which can be viewed thanks to the function intnumstep or to increase the abscissa of integration o For example p 105 intlaplaceinv x 2 1 1 x 1 time 350 ms 11 7 37 E 55 1 72 E 54x I not so good m intnumstep 12 7 intlaplaceinv x 2 1 1 x m 1 1 time 700 ms 13 3 95 E 97 4 76 E 98 I better intlaplaceinv x 2 1 1 x m 2 1 time 1400 ms 4 0 E 105 0 E 106 I perfect but slow intlaplaceinv x 5 1 1 x 1 time 340 ms 5 5 98 E 85 8 08 E 85 I better than 1 intlaplaceinv x 5 1 1 x m 1 1 time 680 ms 76 1 09 E 106 0 E 104 I perfect fast intlaplaceinv x 10 1 1 x 1 time 340 ms 7 4 36 E 106 0 E 102 I perfect fastest but why sig 10 intlaplaceinv x 100 1 1 x 1 time 330 ms 47 1 07 E 72 3 2 E 72xI XX too far now The library syntax is intlaplaceinv void E GEN eval GEN void GEN sig GEN z GEN tab long prec 3 9 8 intmellininv X sig z erpr tab numerical integration of 2ir lexpr X z with respect to X on the line
401. 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 deprecated maintained for backward compatibility and always equal to 1 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 121 If flag 1 and the precision happens to be insufficient for obtaining the fundamental units the internal precision is doubled and the computation redone until the exact results are obtained 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 large real quadratic fields For this case there are alternate compact representations for algebraic numbers implemented in PARI but c
402. ven by Zx 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 GEN galoisapply GEN nf GEN aut GEN x 3 6 96 nfgaloisconj nf flag 0 dj 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 also makes sense when the number field is not Galois since some conjugates may lie in the field 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 144 If flag 1 use nfroots require a number field If flag 2 use complex approximations to the roots and an integral LLL The 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
403. was local to forprime and ran through consecutive prime numbers Here is a corrected version FirstPrimeDiv x forprime p 2 x if x fp 0 return p 2 7 4 Recursive functions Recursive functions can easily be written as long as one pays proper attention to variable scope Here is an example used to retrieve the coefficient array of a multivari ate polynomial a non trivial task due to PARI s unsophisticated representation for those objects coeffs P nbvar if type P t_POL for i 1 nbvar P P return P vector poldegree P 1 i coeffs polcoeff P i 1 nbvar 1 If P is a polynomial in k variables show that after the assignment v coeffs P k the coefficient of xri x in P is given by v n1 1 rip 1 The operating system automatically limits the recursion depth dive n if n dive n 1 dive 20000 37 EK deep recursion There is no way to increase the recursion limit which may be different on your machine from within gp To increase it before launching gp you can use ulimit or limit depending on your shell and raise the process available stack space increase stacksize 2 7 5 Function which take functions as parameters Very easy calc f x f x calc x gt sin x Pi 42 5 04870979 E 29 Note that we used an anonymous function here since there was no reason to store x gt sin x into a variable just to immediately forget about it The mor
404. with r 0 1 components corresponding to the infinite part of the divisor More precisely the i th component of a corresponds to the real embedding associated to the i th real root of K roots That ordering is not canonical but well defined once a defining polynomial for K is chosen For instance 1 1 11 is a modulus for a real quadratic field allowing ramification at any of the two places at infinity and nowhere else A bid or big ideal is a structure output by idealstar needed to compute in Z x 1 where I is a modulus in the above sense It is a finite abelian group as described above supplemented by technical data needed to solve discrete log problems 118 Finally we explain how to input ray number fields or bnr using class field theory These are defined by a triple al a2 a3 where the defining set al a2 a3 can have any of the following forms bnr bnr subgroup bnf module bnf module subgroup e bnf is as output by bnfinit where units are mandatory unless the modulus is trivial bnr is as output by bnrinit This is the ground field K e module is a modulus f as described above e subgroup a subgroup of the ray class group modulo f of K As described above 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 the subfield of the ray class field of K modulo f fixed by the given subgroup 3 6 6
405. x J although the latter can reasonably be used in all cases while the former cannot To take a specific example in the inverse Mellin transform the integrand is almost always a product of an exponentially decreasing and an oscillating factor If we choose the oscillating type of integral we perhaps obtain the best results at the expense of having to recompute our functions for a different value of the variable z giving the transform preventing us to use a function such as intmellininvshort On the other hand using the exponential type of integral we obtain less accurate results but we skip expensive recomputations See intmellininvshort and intfuncinit for more explanations We shall now see many examples to get a feeling for what the various parameters achieve All examples below assume precision is set to 105 decimal digits We first type Ap 105 oo 1 for clarity 189 Apparent singularities Even if the function f x represented by expr has no singularities it may be important to define the function differently near special points For instance if f x 1 exp x 1 exp x x then fy f x de y Euler s constant Euler But f x 1 exp x 1 exp x x intnum x 0 00 1 x Euler 1 6 00 E 67 thus only correct to 67 decimal digits This is because close to 0 the function f is computed with an enormous loss of accuracy A better solution is f x 1 exp x 1 exp x x
406. x module gt gt a Aj In particular if A is a relative matrix whose columns A give the coordinates of some elements relative to a fixed basis we can speak of the projective module generated by a pseudo matrix e The pair 4 1 is a pseudo basis of the module it generates if the a are non zero and the A are K linearly independent We call n the size of the pseudo basis If A is a relative matrix the latter condition means it is square with non zero determinant 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 For instance the relative integer basis rnf zk is a pseudo basis A I of Zz where A rnf zk 1 is a vector of elements of L which are K linearly independent Most rnf routines return and handle Zx modules contained in L e g Zr ideals via a pseudo basis A 1 where A is a relative matrix representing a vector of elements of L in terms of the fixed basis rnf zk 1 e The determinant of a pseudo basis A J is the ideal equal to the product of the determinant of A by all the ideals of The determinant of a pseudo matrix is the determinant of any pseudo basis of the module it generates 3 6 5 Class field theory A modulus in the sense of class field theory is a divisor supported on the non complex places of K In PARI terms this means either an ordinary ideal I as above no archimedean component or a pair 7 a where a is a vector
407. xpo overflow intnum x 0 oo 2 exp 2 x 71 0 5000000000000000000000000000 OK intnum x 0 oo 4 exp 2 x 12 0 4999999999999999999961990984 wrong exponent gt imprecise result intnum x 0 oo 20 exp 2 x 12 0 4999524997739071283804510227 disaster e a lt 1 assumes that the function tends to 0 slowly like z Here it is essential to give the correct a if possible but on the other hand a lt 2 is equivalent to a 0 in other words to no a at all The last two codes are reserved for oscillating functions Let k gt 0 real and g x a nonoscil lating function tending slowly to 0 e g like a negative power of x then e a k x I assumes that the function behaves like cos kx g x e a k x I assumes that the function behaves like sin ka g x Here it is critical to give the exact value of k If the oscillating part is not a pure sine or cosine one must expand it into a Fourier series use the above codings and sum the resulting contributions Otherwise you will get nonsense Note that cos kx and similarly sin kx means that very function and not a translated version such as cos kzx a Note If f x cos kx g x where g a tends to zero exponentially fast as exp az it is up to the user to choose between 1 a and 1 kx1 but a good rule of thumb is that if the oscillations are much weaker than the exponential decrease choose 1 a otherwise choose 1 k
408. y 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 21 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 22 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 203 3 10 23 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 y1 is the current position of the cursor Only the part of the rectangle which is in w is drawn The virtual cursor does not move 3 10 24 plotrecth w X a b expr flags 0 n 0 writes to rectwindow w the curve output of ploth w X a b expr flag n 3 10 25 plotrecthraw w data flags 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 contains th
409. y S B is a factorbase used it to compute a tentative CI K by generators and relations We then check explicitly using essentially bnfisprincipal that the elements of S B2 belong to the span of S B Under the assumption that S B2 generates CI K we are done User supplied c are only used to compute initial guesses for the bounds B and the algorithm increases them until one can prove under GRH that S B2 generates CI K A uniform result of Bach says that c2 12 is always suitable but this bound is very pessimistic and a direct algorithm due to Belabas Diaz Friedman is used to check the condition assuming GRH The default values are c1 co 0 3 nrpid is the maximal number of small norm relations associated to each ideal in the factor base Set it to 0 to disable the search for small norm relations Otherwise reasonable values are between 4 and 20 The default is 4 120 Warning Make sure you understand the above By default most of the bnf routines depend on the correctness of the GRH In particular any of the class number class group structure class group generators regulator and fundamental units may be wrong independently of each other Any result computed from such a bnf may be wrong The only guarantee is that the units given generate a subgroup of finite index in the full unit group You must use bnfcertify to certify the computations unconditionally Remarks You do not need to supply the technical parameters under
410. y increasing vectors X 3 11 9 if a seq1 seqg2 evaluates the expression sequence seg1 if a is non zero otherwise the expression seg2 Of course seq1 or seq2 may be empty 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 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 as break and next operate on loops such as forxxx while until The if statement is not a loop obviously 3 11 10 next n 1 interrupts execution of current seq resume the next iteration of the innermost enclosing loop within the current function 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 3 11 11 return z 0 returns from current subroutine with result x If x is omitted return the void value return no result like print 207 3 11 12 until a seq evaluates seq unt
411. y incompatible To enable detection of GMP use Con figure with gmp You should really do this if you only intend to use GP and probably also if you will use libpari unless you have backwards compatibility requirements 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 com mandtools yet another reason to dump Suntools for X Windows e GNU emacs and the PariEmacs package 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 better automatic completion than is provided by Emacs s GP mode e GNU gzip gunzip gzcat package enables GP to read compressed data e perl provides extended online help full text from this manual about functions and concepts which can be used under GP or independently e A colour capable xterm which enables GP to use different user configurable colours for its output All xterm programs which come with current X11 distributions satisfy this requirement 217 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 attempts to configure PARI GP without outside help Note that if
412. y p adic number whose valuation is gt k To input a general non 0 p adic number write a suitably precise rational or integer approximation and add 0 p k to it Note that it is not checked whether p is indeed prime but results are undefined if this is not the case you can work on 10 adics if you want but disasters will happen as soon as you do something non trivial like taking a square root Note that 0 25 is not the same as 0 572 you want the latter For example you can type in the 7 adic number 2x7 1 3 4 7 2772 0 773 exactly as shown or equivalently as 905 7 0 773 If a is a t_PADIC the following member functions are defined a mod returns the modulus p a p returns p Note that this type is available for convenience not for speed internally t_PADICs are stored as p adic units modulo some p Each elementary operation involves updating p multiplying or dividing by powers of p and a reduction mod p In particular additions are slow n 1 0 2720 for i 1 10 6 n time 841 ms n Mod 1 2 20 for i 1 10 6 n time 441 ms n 1 for i 1 10 6 n 19 time 328 ms The penalty associated with maintaining p decreases steeply as p increases and updates become very rare But t_INTMODs remain at least 25 more efficient But they do not have denomina tors 2 3 8 Quadratic numbers t_QUAD This type is used to work in the quadratic order of discrim inant d where d is a non
413. y part equal to 7 if z R and x lt 0 In general the algorithm uses the formula T x mlog 2 2agm 1 4 s a log x if s 22 is large enough The result is exact to B bits provided s gt 28 2 At low accuracies the series expansion near 1 is used p adic arguments are also accepted for x with the convention that log p 0 Hence in particular exp log 1 x is not in general equal to 1 but to a p 1 th root of unity or 1 if p 2 times a power of p The library syntax is GEN glog GEN x long prec 85 3 3 39 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 Lim dons 2 n x lt 1 Uses the functional equation linking the values at x and 1 x to restrict to the case x lt 1 then the power series when x lt 1 2 and the power series expansion in log x otherwise Using flag computes a modified mt polylogarithm of x We use Zagier s notations let Rm denote R or S depending on whether m is odd or even If flag 1 compute D 1 defined for x lt 1 by Ro z Slog eD o e eoe Soa a k k 0 If flag 2 compute D 1 defined for x lt 1 by a 2 Cot a Coste l l k 2 m If flag 3 compute Pm x defined for z lt 1 by m 1 9k B 2m Bn pA Rm A E log x Lim 4 2 log r k 0 The
414. ynomials listing only non zero monomials All computations are then done formally on the coefficients as if the polynomial was univariate This is not symmetrical So if I enter x y in a clean session what happens This is understood as xt y 0 y xx Z y z but how do we know that x is more important than y Why not y y which is the same mathematical entity after all The answer is that variables are ordered implicitly by the interpreter when a new identifier e g x or y as above is input the corresponding variable is registered as having a strictly lower priority than any variable in use at this point To see the ordering used by gp at any given time type variable Given such an ordering multivariate polynomials are stored so that the variable with the highest priority is the main variable And so on recursively until all variables are exhausted A different storage pattern which could only be obtained via libpari programming and low level constructors would produce an invalid object and eventually a disaster In any case if you are working with expressions involving several variables and want to have them ordered in a specific manner in the internal representation just described the simplest is just to write down the variables one after the other under gp before starting any real computations You could also define variables from your gprc to have a consistent ordering of common variable name
415. yntax is GEN ellorder GEN E GEN z GEN o NULL 3 5 23 ellordinate E 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 GEN ordell GEN E GEN x long prec 113 3 5 24 ellpointtoz E P 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 p t z 1 t 2 2 In other words this is the inverse function of ellztopoint More precisely if w1 w2 are the real and complex periods of E t is such that 0 lt R t lt w1 and 0 lt S t lt S w2 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 output is t 1 t E must be an ell as output by ellinit The library syntax is GEN zell GEN E GEN P long prec 3 5 25 ellpow E x 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 GEN powell GEN E GEN x GEN n 3 5 26 ellrootno F p 1 E being an sell as output by ellinit this computes the local if p 1 or global if p 1 root number of the L s
Download Pdf Manuals
Related Search
Related Contents
Wintal DVDRX160 User's Manual NI 6124/6154 User Manual Crema para las estrías Cai OS User manual Commissions, mode d`emploi SNJ Polisseuse d`établi MANUAL DE INSTRUCCIONES USER MANUAL - Comprehensive Connectivity Company RECOVERY BAR Hoover Domestic Appliance User Manual Copyright © All rights reserved.
Failed to retrieve file