NAME

libPARI - Functions and Operations Available in PARI and GP


DESCRIPTION

X<Label se:functions>

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 \vers. It should be noted that many of these functions accept quite different types as arguments, but others are more restricted. The list of acceptable types will be given for each function or class of functions. Except when stated otherwise, it is understood that a function or operation which should make natural sense is legal. In this chapter, we will describe the functions according to a rough classification. For the functions in alphabetical order, see the general index. The general entry looks something like:

foo(x,{<EM>flag</EM>=0}): short description.

X<foo>The library syntax is foo(x,<EM>flag</EM>).

  
This means that the GP function C<foo> has one mandatory argument C<x>, and
an optional one, C<I<flag>>, whose default value is 0 (the C<{}> should never be
typed, it is just a convenient notation we will use throughout to denote
optional arguments). That is, you can type C<foo(x,2)>, or C<foo(x)>,
which is then understood to mean C<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 C<foo(x,)> is also accepted as a
synonym for our last expression. When a function has more than one optional
argument, the argument list is filled with user supplied values, in order.
And when none are left, the defaults are used instead. Thus, assuming that
C<foo>'s prototype had been
C<{
C<foo>>({x=1},{y=2},{z=3})C<,
}>
typing in C<foo(6,4)> would give
you C<foo(6,4,3)>. In the rare case when you want to set some far away
flag, and leave the defaults in between as they stand, you can use the
``empty arg'' trick alluded to above: C<foo(6,,1)> would yield
C<foo(6,2,1)>. By the way, C<foo()> by itself yields
C<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 C<()>: a
standalone C<foo> would be enough (though we don't really recommend it for
your scripts, for the sake of clarity). In defining GP syntax, we strove
to put optional arguments at the end of the argument list (of course, since
they would not make sense otherwise), and in order of decreasing usefulness
so that, most of the time, you will be able to ignore them.

For some of these optional flags, we adopted the customary binary notation as a compact way to represent many toggles with just one number. Letting (p_0,...,p_n) be a list of switches (i.e. of properties which can be assumed to take either the value 0 or 1), the number 2^3 + 2^5=40 means that p_3 and p_5 have been set (that is, set to 1), and none of the others were (that is, they were set to 0). This will usually be announced as ``The binary digits of <EM>flag</EM> mean 1: p_0, 2: p_1, 4: p_2'', and so on, using the available consecutive powers of 2.

To finish with our generic simple-minded example, the library function foo, as defined above, is seen to have two mandatory arguments, x and flag (no PARI mathematical function has been implemented so as to accept a variable number of arguments). When not mentioned otherwise, the result and arguments of a function are assumed implicitly to be of type GEN. Most other functions return an object of type long integer in C (see Chapter 4). The variable or parameter names prec and flag always denote long integers.

\misctitle{Pointers}. If a parameter in the function prototype is prefixed with a & sign, as in

foo(x,&e)

   it means that, besides the normal return value, the variable named
C<e> may be set as a side effect. When passing the argument, the & sign has
to be typed in explicitly. As of version \vers{}, this X<pointer>C<pointer> argument
is optional for all documented functions, hence the & will always appear
between brackets as in C<issquare>C<(x,{&e})>.


Standard monadic or dyadic operators

\subseckbd{+/-}: The expressions +x and -x refer to monadic operators (the first does nothing, the second negates x).

X<gneg>The library syntax is gneg(x) for -x.

\subseckbd{+}, -: The expression x + y is the X<sum>sum and x - y is the X<difference>difference of x and y. Among the prominent impossibilities are addition/subtraction between a scalar type and a vector or a matrix, between vector/matrices of incompatible sizes and between an integermod and a real number.

X<gadd>The library syntax is gadd(x,y) x + y, X<gsubgsub(x,y)> for x - y.

\subseckbd{*}: The expression x * y is the X<product>product of x and y. Among the prominent impossibilities are multiplication between vector/matrices of incompatible sizes, between an integermod and a real number. Note that because of vector and matrix operations, * is not necessarily commutative. Note also that since multiplication between two column or two row vectors is not allowed, to obtain the X< scalar product>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 Label se:linear_algebra).

If x and y are binary quadratic forms, compose them. See also qfbnucomp and qfbnupow.

X<gmul>The library syntax is gmul(x,y) for x * y. Also available is X<gsqrgsqr(x)> for x * x (faster of course!).

\subseckbd{/}: The expression x / y is the X<quotient>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 x*y^{-1}. Furthermore note that the result is as exact as possible: in particular, division of two integers always gives a rational number (which may be an integer if the quotient is exact) and not the Euclidean quotient (see x \ y for that), and similarly the quotient of two polynomials is a rational function in general. To obtain the approximate real value of the quotient of two integers, add 0. to the result; to obtain the approximate p-adic value of the quotient of two integers, add O(p^ k) to the result; finally, to obtain the X<Taylor series>Taylor series expansion of the quotient of two polynomials, add O(X^ k) to the result or use the taylor function (see Label se:taylor). X<Label se:gdiv>

X<gdiv>The library syntax is gdiv(x,y)for x / y.

\subseckbd{\}: The expression x \ y is the

X<Euclidean quotient>Euclidean quotient of x and y. The types must be either both integer or both polynomials. The result is the Euclidean quotient. In the case of integer division, the quotient is such that the corresponding remainder is non-negative.

X<gdivent>The library syntax is gdivent(x,y) for x \ y.

\subseckbd{\/}: The expression x \/ y is the Euclidean quotient of x and y. The types must be either both integer or both polynomials. The result is the rounded Euclidean quotient. In the case of integer division, the quotient is such that the corresponding remainder is smallest in absolute value and in case of a tie the quotient closest to +<EM>infty</EM> is chosen.

X<gdivround>The library syntax is gdivround(x,y) for x \/ y.

\subseckbd{%}: The expression x % y is the

X<Euclidean remainder>Euclidean remainder of x and y. The modulus y must be of type integer or polynomial. The result is the remainder, always non-negative in the case of integers. Allowed dividend types are scalar exact types when the modulus is an integer, and polynomials, polmods and rational functions when the modulus is a polynomial.

X<gmod>The library syntax is gmod(x,y) for x % y.


X<divrem>divrem<CODE>(x,y)</CODE>

creates a column vector with two components, the first being the Euclidean quotient, the second the Euclidean remainder, of the division of x by y. This avoids the need to do two divisions if one needs both the quotient and the remainder. The arguments must be both integers or both polynomials, and in the case of integers the remainder is of the sign of the dividend.

X<gdiventres>The library syntax is gdiventres(x,y).

\subseckbd{^}: The expression x{<CODE>^</CODE>}y is X<powering>powering. If the exponent is an integer, then exact operations are performed using binary (left-shift) powering techniques. In particular, in this case the first argument cannot be a vector or matrix unless it is a square matrix (and moreover invertible if the exponent is negative). If the exponent is not of type integer, this is treated as a transcendental function (see Label se:trans), and in particular has the effect of componentwise powering on vector or matrices.

X<gpow>The library syntax is gpow(x,y,<CODE>prec</CODE>) for x{<CODE>^</CODE>}y.


X<shift>shift<CODE>(x,n)</CODE> or <A HREF="#item_x">x</A> <CODE>&lt;&lt;</CODE> <A HREF="#item_n">n</A> (= <A HREF="#item_x">x</A> <CODE>&amp;gt;&amp;gt;</CODE> <CODE>(-n)</CODE>)

shifts x componentwise left by n bits if n&gt;=0 and right by |n| bits if n<0. A left shift by n corresponds to multiplication by 2^n. A right shift of an integer x by |n| corresponds to a Euclidean division of x by 2^{|n|} with a remainder of the same sign as x, hence is not the same (in general) as x <CODE>\</CODE> 2^n.

X<gshift>The library syntax is gshift(x,n) where n is a long.


X<shiftmul>shiftmul<CODE>(x,n)</CODE>

multiplies x by 2^n. The difference with shift is that when n<0, ordinary division takes place, hence for example if x is an integer the result may be a fraction, while for shift Euclidean division takes place when n<0 hence if x is an integer the result is still an integer.

X<gmul2n>The library syntax is gmul2n(x,n) where n is a long.


Comparison and boolean operators.X<boolean

operators> The six standard X<comparison operators>comparison operators <=, <, &gt;=, &gt;, ==, != are available in GP, and in library mode under the names X< gle>gle, X<glt>glt, X<gge>gge, X<ggt>ggt, X<geq>geq, X<gne>gne respectively. The library syntax is <EM>co</EM>(x,y), where co is the comparison operator. The result is 1 (as a GEN) if the comparison is true, 0 (as a GEN) if it is false.

The standard boolean functions || (X<inclusive or>inclusive or), && (X<and>and)X<or> and ! (X<not>not) are also available, and the library syntax is X<gorgor(x,y)>, X<gandgand(x,y)> and X<gnotgnot(x)> respectively.

In library mode, it is in fact usually preferable to use the two basic functions which are X<gcmpgcmp(x,y)> which gives the sign (1, 0, or -1) of x-y, where x and y must be in R, and X<gegalgegal(x,y)> which can be applied to any two PARI objects x and y and gives 1 (i.e. true) if they are equal (but not necessarily identical), 0 (i.e. false) otherwise. Particular cases of X< gegal>gegal which should be used are X<gcmp0gcmp0(x)> (x==0 ?), X<gcmp1gcmp1(x)> (x==1 ?), andX<gcmp_1> gcmp_1(x) (x==-1 ?).

Note that X<gcmp0gcmp0(x)> tests whether x is equal to zero, even if x is not an exact object. To test whether x is an exact object which is equal to zero, one must use X<isexactzeroisexactzero>.

Also note that the gcmp and gegal functions return a C-integer, and not a GEN like gle etc.

GP accepts the following synonyms for some of the above functions: since there is no bitwise and or bitwise or, | and & are accepted asX<bitwise and>X<bitwise or> synonyms of || and && respectively. Also, <E<gt> is accepted as a synonym for !=. On the other hand, = is definitely not a synonym for == since it is the assignment statement.


X<lex>lex<CODE>(x,y)</CODE>

gives the result of a lexicographic comparison between x and y. This is to be interpreted in quite a wide sense. For example, the vector [1,3] will be considered smaller than the longer vector [1,3,-1] (but of course larger than [1,2,5]), i.e. lex([1,3], [1,3,-1]) will return -1.

X<lexcmp>The library syntax is lexcmp(x,y).


X<sign>sign<CODE>(x)</CODE>

X<sign>sign (0, 1 or -1) of x, which must be of type integer, real or fraction.

X<gsigne>The library syntax is gsigne(x). The result is a long.


X<max>max<CODE>(x,y)</CODE> and X<min><EM>min</EM><CODE>(x,y)</CODE>

creates the maximum and minimum of x and y when they can be compared.

X<gmax>The library syntax is gmax(x,y) and X<gmingmin(x,y)>.


X<vecmax>vecmax<CODE>(x)</CODE>

if x is a vector or a matrix, returns the maximum of the elements of x, otherwise returns a copy of x. Returns -<EM>infty</EM> in the form of -(2^{31}-1) (or -(2^{63}-1) for 64-bit machines) if x is empty.

X<vecmax>The library syntax is vecmax(x).


X<vecmin>vecmin<CODE>(x)</CODE>

if x is a vector or a matrix, returns the minimum of the elements of x, otherwise returns a copy of x. Returns +<EM>infty</EM> in the form of 2^{31}-1 (or 2^{63}-1 for 64-bit machines) if x is empty.

X<vecmin>The library syntax is vecmin(x).


Conversions and similar elementary functions or commands

X<Label se:conversion>

  
Many of the conversion functions are rounding or truncating operations. In
this case, if the argument is a rational function, the result is the
Euclidean quotient of the numerator by the denominator, and if the argument
is a vector or a matrix, the operation is done componentwise. This will not
be restated for every function.


X<List>List<CODE>({x=[ ]})</CODE>

transforms a (row or column) vector x into a list. The only other way to create a t_LIST is to use the function listcreate.

This is useless in library mode.


X<Mat>Mat<CODE>({x=[ ]})</CODE>

transforms the object x into a matrix. If x is not a vector or a matrix, this creates a 1\times 1 matrix. If x is a row (resp. column) vector, this creates a 1-row (resp. 1-column) matrix. If x is already a matrix, a copy of x is created.

This function can be useful in connection with the function concat (see there).

X<gtomat>The library syntax is gtomat(x).


X<Mod>Mod<CODE>(x,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

X<Label se:Mod> creates the PARI object (x <EM>mod</EM> y), i.e. an integermod or a polmod. y must be an integer or a polynomial. If y is an integer, x must be an integer. If y is a polynomial, x must be a scalar or a polynomial. The result is put on the PARI stack.

This function is not the same as x % y, the result of which is an integer or a polynomial.

If <EM>flag</EM> is equal to 1, the modulus of the created result is put on the heap and not on the stack, and hence becomes a permanent copy which cannot be erased later by garbage collecting (see Label se:garbage). In particular, care should be taken to avoid creating too many such objects, since the heap is very small (typically a few thousand objects at most).

X<Mod0>The library syntax is Mod0(x,y,<EM>flag</EM>). Also available are

--- for <EM>flag</EM>=1: X<gmodulogmodulo(x,y)>.

--- for <EM>flag</EM>=0: X<gmodulcpgmodulcp(x,y)>.


X<Pol>Pol<CODE>(x,{v=x})</CODE>

transforms the object x into a polynomial with main variable v. If x is a scalar, this gives a constant polynomial. If x is a power series, the effect is identical to truncate (see there), i.e. it chops off the O(X^k). If x is a vector, this function creates the polynomial whose coefficients are given in x, with x[1] being the leading coefficient (which can be zero).

Warning: this is not a substitution function. It is intended to be quick and dirty. So if you try Pol(a,y) on the polynomial a = x+y, you will get y+y, which is not a valid PARI object.

X<gtopoly>The library syntax is gtopoly(x,v), where v is a variable number.


X<Polrev>Polrev<CODE>(x,{v=x})</CODE>

transform the object x into a polynomial with main variable v. If x is a scalar, this gives a constant polynomial. If x is a power series, the effect is identical to truncate (see there), i.e. it chops off the O(X^k). If x is a vector, this function creates the polynomial whose coefficients are given in x, with x[1] being the constant term. Note that this is the reverse of Pol if x is a vector, otherwise it is identical to Pol.

X<gtopolyrev>The library syntax is gtopolyrev(x,v), where v is a variable number.


X<Ser>Ser<CODE>(x,{v=x})</CODE>

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 applies here: this is not a substitution function.

X<gtoser>The library syntax is gtoser(x,v), where v is a variable number (i.e. a C integer).


X<Set>Set<CODE>({x=[ ]})</CODE>

converts x into a set, i.e. into a row vector with strictly increasing entries. x can be of any type, but is most useful when x is already a vector. The components of x are put in canonical form (type t_STR) so as to be easily sorted. To recover an ordinary GEN from such an element, you can apply X<eval>eval to it.

X<gtoset>The library syntax is gtoset(x).


X<Str>Str<CODE>({x={&lt;CODE&gt;&amp;quot;&amp;quot;&lt;/CODE&gt;}},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

converts x into a character string (type t_STR, the empty string if x is omitted). To recover an ordinary GEN from a string, apply eval to it. The arguments of Str are evaluated in string context (see Label se:strings). If flag is set, treat x as a filename and perform X<environment expansion>environment expansion on the string. This feature can be used to read X<environment variable>environment variable values.

\bprog ? i = 1; Str(``x'' i) %1 = ``x1'' ? eval(%) %2 = x1; ? Str(``dollar HOME'', 1) %2 = ``/home/pari'' \eprog

X<strtoGENstr>The library syntax is strtoGENstr(x,<EM>flag</EM>). This function is mostly useless in library mode. Use the pair X<strtoGEN>strtoGEN /X<GENtostr>GENtostr to convert between char* and GEN.


X<Vec>Vec<CODE>({x=[ ]})</CODE>

transforms the object x into a row vector. The vector will be with one component only, except when x is a vector/matrix or a quadratic form (in which case the resulting vector is simply the initial object considered as a row vector), but more importantly when x is a polynomial or a power series. In the case of a polynomial, the coefficients of the vector start with the leading coefficient of the polynomial, while for power series only the significant coefficients are taken into account, but this time by increasing order of degree.

X<gtovec>The library syntax is gtovec(x).


X<binary>binary<CODE>(x)</CODE>

outputs the vector of the binary digits of |x|. Here x can be an integer, a real number (in which case the result has two components, one for the integer part, one for the fractional part) or a vector/matrix.

X<binaire>The library syntax is binaire(x).


X<bittest>bittest<CODE>(x,n)</CODE>

outputs the n^{th} bit of |x| starting from the right (i.e. the coefficient of 2^n 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.

X<bittest>The library syntax is bittest(x,n), where n and the result are longs.


X<ceil>ceil<CODE>(x)</CODE>

ceiling of x. When x is in R, the result is the smallest integer greater than or equal to x.

X<gceil>The library syntax is gceil(x).


X<centerlift>centerlift<CODE>(x,{v})</CODE>

lifts an element x=a mod n of <STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG> to a in Z, and similarly lifts a polmod to a polynomial. This is the same as lift except that in the particular case of elements of <STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG>, the lift y is such that -n/2<yE<lt= n/2>. If x is of type fraction, complex, quadratic, polynomial, power series, rational function, vector or matrix, the lift is done for each coefficient. Real and p-adics are forbidden.

X<centerlift0>The library syntax is centerlift0(x,v), where v is a long and an omitted v is coded as -1. Also available is X<centerlift>centerlift(x) = centerlift0(<A HREF="#item_x">x</A>,-1).


X<changevar>changevar<CODE>(x,y)</CODE>

creates a copy of the object x where its variables are modified according to the permutation specified by the vector y. For example, assume that the variables have been introduced in the order x, a, b, c. Then, if y is the vector [x,c,a,b], the variable a will be replaced by c, b by a, and c by b, x being unchanged. Note that the permutation must be completely specified, e.g. [c,a,b] would not work, since this would replace x by c, and leave a and b unchanged (as well as c which is the fourth variable of the initial list). In particular, the new variable names must be distinct.

X<changevar>The library syntax is changevar(x,y).


components of a PARI object

There are essentially three ways to extract the X<components>components from a PARI object.

The first and most general, is the function X<componentcomponent(x,n)> which extracts the n^{th}-component of x. This is to be understood as follows: every PARI type has one or two initial X< code words>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^{th}-component of x, if x is a matrix, the n^{th} column, if x is a polynomial, the n^{th} coefficient (i.e. of degree n-1), and for power series, the n^{th} significant coefficient. The use of the function component implies the knowledge of the structure of the different PARI types, which can be recalled by typing \t under GP.

X<compo>The library syntax is compo(x,n), where n is a long.

The two other methods are more natural but more restricted. First, the function X<polcoeffpolcoeff(x,n)> gives the coefficient of degree n of the polynomial or power series x, with respect to the main variable of x (to see the order of the variables or to change it, use the function X<reorder>reorder, see Label se:reorder). In particular if n is less than the valuation of x or in the case of a polynomial, greater than the degree, the result is zero (contrary to compo which would send an error message). If x is a power series and n is greater than the largest significant degree, then an error message is issued.

For greater flexibility, vector or matrix types are also accepted for x, and the meaning is then identical with that of compo.

Finally note that a scalar type is considered by polcoeff as a polynomial of degree zero.

X<truecoeff>The library syntax is truecoeff(x,n).

The third method is specific to vectors or matrices under GP. If x is a (row or column) vector, then X<x[n]>x[n] represents the n^{th} component of x, i.e. compo(x,n). It is more natural and shorter to write. If x is a matrix, X<x[m,n]>x[m,n] represents the coefficient of row m and column n of the matrix, X<x[m,]>x[m,] represents the m^{th} row of x, and X<x[,n]>x[,n] represents the n^{th} column of x.

Finally note that in library mode, the macros X<coeff>coeff and X<mael>mael are available to deal with the non-recursivity of the GEN type from the compiler's point of view. See the discussion on typecasts in Chapter 4.


X<conj>conj<CODE>(x)</CODE>

conjugate of x. The meaning of this is clear, except that for real quadratic numbers, it means conjugation in the real quadratic field. This function has no effect on integers, reals, integermods, fractions or p-adics. The only forbidden type is polmod (see conjvec for this).

X<gconj>The library syntax is gconj(x).


X<conjvec>conjvec<CODE>(x)</CODE>

conjugate vector representation of x. If x is a polmod, equal to Mod(a,q), this gives a vector of length degree(q) containing the complex embeddings of the polmod if q has integral or rational coefficients, and the conjugates of the polmod if q has some integermod coefficients. The order is the same as that of the polroots functions. If x is an integer or a rational number, the result is x. If x is a (row or column) vector, the result is a matrix whose columns are the conjugate vectors of the individual elements of x.

X<conjvec>The library syntax is conjvec(x,<CODE>prec</CODE>).


X<denominator>denominator<CODE>(x)</CODE>

lowest denominator of x. The meaning of this is clear when x is a rational number or function. When x is an integer or a polynomial, the result is equal to 1. When x is a vector or a matrix, the lowest common denominator of the components of x is computed. All other types are forbidden.

X<denom>The library syntax is denom(x).


X<floor>floor<CODE>(x)</CODE>

floor of x. When x is in R, the result is the largest integer smaller than or equal to x.

X<gfloor>The library syntax is gfloor(x).


X<frac>frac<CODE>(x)</CODE>

fractional part of x. Identical to x-floor(x). If x is real, the result is in [0,1[.

X<gfrac>The library syntax is gfrac(x).


X<imag>imag<CODE>(x)</CODE>

imaginary part of x. When x is a quadratic number, this is the coefficient of <EM>omega</EM> in the ``canonical'' integral basis (1,<EM>omega</EM>).

X<gimag>The library syntax is gimag(x).


X<length>length<CODE>(x)</CODE>

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.

X<glength>The library syntax is glength(x) and the result is a C long.


X<lift>lift<CODE>(x,{v})</CODE>

lifts an element x=a mod n of <STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG> to a in Z, and similarly lifts a polmod to a polynomial if v is omitted. Otherwise, lifts only polmods with main variable v (if v does not occur in x, lifts only intmods). If x is of type fraction, complex, quadratic, polynomial, power series, rational function, vector or matrix, the lift is done for each coefficient. Forbidden types for x are reals and p-adics.

X<lift0>The library syntax is lift0(x,v), where v is a long and an omitted v is coded as -1. Also available is X<lift>lift(x) = lift0(<A HREF="#item_x">x</A>,-1).


X<norm>norm<CODE>(x)</CODE>

algebraic norm of x, 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^2-norm (see norml2). Note that the norm of an element of R is its square, so as to be compatible with the complex norm.

X<gnorm>The library syntax is gnorm(x).


X<norml2>norml2<CODE>(x)</CODE>

square of the L^2-norm of x. x must be a (row or column) vector.

X<gnorml2>The library syntax is gnorml2(x).


X<numerator>numerator<CODE>(x)</CODE>

numerator of x. When x is a rational number or function, the meaning is clear. When x is an integer or a polynomial, the result is x itself. When x is a vector or a matrix, then numerator(x) is defined to be denominator(x)*x. All other types are forbidden.

X<numer>The library syntax is numer(x).


X<numtoperm>numtoperm<CODE>(n,k)</CODE>

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 X<permtonum>permtonum.

X<permute>The library syntax is permute(n,k), where n is a long.


X<padicprec>padicprec<CODE>(x,p)</CODE>

absolute p-adic precision of the object x. This is the minimum precision of the components of x. The result is VERYBIGINT (2^{31}-1 for 32-bit machines or 2^{63}-1 for 64-bit machines) if x is an exact object.

X<padicprec>The library syntax is padicprec(x,p) and the result is a long integer.


X<permtonum>permtonum<CODE>(x)</CODE>

given a permutation x on n elements, gives the number k such that x=<CODE>numtoperm(n,k)</CODE>, i.e. inverse function of X<numtoperm>numtoperm.

X<permuteInv>The library syntax is permuteInv(x).


X<precision>precision<CODE>(x,{n})</CODE>

gives the precision in decimal digits of the PARI object x. If x is an exact object, the largest single precision integer is returned. If n is not omitted, creates a new object equal to x with a new precision n. This is to be understood as follows:

For exact types, no change. For x a vector or a matrix, the operation is done componentwise.

For real x, n is the number of desired significant decimal digits. If n is smaller than the precision of x, x is truncated, otherwise x is extended with zeros.

For x a p-adic or a power series, n is the desired number of significant p-adic or X-adic digits, where X is the main variable of x.

Note that the function precision never changes the type of the result. In particular it is not possible to use it to obtain a polynomial from a power series. For that, see truncate.

X<precision0>The library syntax is precision0(x,n), where n is a long. Also available are X<ggprecisionggprecision(x)> (result is a GEN) and X<gprecgprec(x,n)>, where n is a long.


X<random>random<CODE>({N=2^{31}})</CODE>

gives a random integer between 0 and N-1. N can be arbitrary large. This is an internal PARI function and does not depend on the system's random number generator. Note that the resulting integer is obtained by means of linear congruences and will not be well distributed in arithmetic progressions.

X<genrand>The library syntax is genrand(N).


X<real>real<CODE>(x)</CODE>

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,<EM>omega</EM>).

X<greal>The library syntax is greal(x).


X<round>round<CODE>(x,{&amp;e})</CODE>

If x is in R, rounds x to the nearest integer and set e to the number of error bits, that is the binary exponent of the difference between the original and the rounded value (the ``fractional part''). If the exponent of x is too large compared to its precision (i.e. e&gt;0), the result is undefined and an error occurs if e was not given.

Important remark: note that, contrary to the other truncation functions, this function operates on every coefficient at every level of a PARI object. For example truncate((2.4*X^2-1.7)/(X))=2.4*X, whereas round((2.4*X^2-1.7)/(X))=(2*X^2-2)/(X). An important use of round is to get exact results after a long approximate computation, when theory tells you that the coefficients must be integers.

X<grndtoi>The library syntax is grndtoi(x,&e), where e is a long integer. Also available is X<groundground(x)>.


X<simplify>simplify<CODE>(x)</CODE>

this function tries to simplify the object x as much as it can. The simplifications do not concern rational functions (which PARI automatically tries to simplify), but type changes. Specifically, a complex or quadratic number whose imaginary part is exactly equal to 0 (i.e. not a real zero) is converted to its real part, and a polynomial of degree zero is converted to its constant term. For all types, this of course occurs recursively. This function is useful in any case, but in particular before the use of arithmetic functions which expect integer arguments, and not for example a complex number of 0 imaginary part and integer real part (which is however printed as an integer).

X<simplify>The library syntax is simplify(x).


X<sizebyte>sizebyte<CODE>(x)</CODE>

outputs the total number of bytes occupied by the tree representing the PARI object x.

X<taille2>The library syntax is taille2(x) which returns a long. The function X<taille>taille returns the number of words instead.


X<sizedigit>sizedigit<CODE>(x)</CODE>

outputs a quick bound for the number of decimal digits of (the components of) x, off by at most 1.

X<gsize>The library syntax is gsize(x) which returns a long.


X<truncate>truncate<CODE>(x,{&amp;e})</CODE>

truncate x and set e to the number of error bits. When x is in R, this means that the part after the decimal point is chopped away, integer and set e to the number of error bits that 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.

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^k). Similarly, when applied to a p-adic number, it transforms it into an integer or a rational number by chopping away the O(p^k).

X<gcvtoi>The library syntax is gcvtoi(x,&e), where e is a long integer. Also available is X<gtrunc>gtrunc(x).


X<valuation>valuation<CODE>(x,p)</CODE>

X<Label se:valuation> computes the highest exponent of p dividing x. If p is of type integer, x must be an integer, an integermod whose modulus is divisible by p, a fraction, a q-adic number with q=p, or a polynomial or power series in which case the valuation is the minimum of the valuation of the coefficients.

If p is of type polynomial, x must be of type polynomial or rational function, and also a power series if x is a monomial. Finally, the valuation of a vector, complex or quadratic number is the minimum of the component valuations.

If x=0, the result is VERYBIGINT (2^{31}-1 for 32-bit machines or 2^{63}-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.

X<ggval>The library syntax is ggval(x,p), and the result is a long.


X<variable>variable<CODE>(x)</CODE>

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. Note that this function is useful only in GP, since in library mode the function gvar is more appropriate.

X<gpolvar>The library syntax is gpolvar(x). However, in library mode, this function should not be used. Instead, test whether x is a p-adic (type t_PADIC), in which case p is in x[2], or call the function <CODE>gvar</CODE>(x) which returns the variable number of x if it exists, BIGINT otherwise.


Transcendental functions}\label{se:trans

As a general rule, which of course in some cases may have exceptions, transcendental functions operate in the following way:

--- 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 X< precision>precision held in the default realprecision. Note that only exact arguments are converted, while inexact arguments such as reals are not.

Under GP this is transparent to the user, but when programming in library mode, care must be taken to supply a parameter prec as the last argument of the function if the first argument is an exact object (see 1.2.5.), or disasters will occur.

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 \p 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.

--- If the argument is an integermod or a p-adic, at present only a few functions like sqrt (square root), sqr (square), log, exp, powering, teichmuller (Teichm\``uller character) and agm (arithmetic-geometric mean) are implemented. Note that in the case of a 2-adic number, <CODE>sqr</CODE>(x) is not identical to x*x: for example if x = 1+O(2^5) then x*x = 1+O(2^5) while <CODE>sqr</CODE>(x) = 1+O(2^6). (Remark: note that if we wanted to be strictly consistent with the PARI philosophy, we should have x*y= (4 <EM>mod</EM> 8) when both x and y are congruent to 2 modulo 4, or <CODE>sqr</CODE>(x)=(4 <EM>mod</EM> 32) when x is congruent to 2 modulo 4. However, since an integermod is an exact object, PARI assumes that the modulus must not change, and the result is hence 0 <EM>mod</EM> 4 in both cases. On the other hand, p-adics are not exact objects, hence are treated differently.)

--- 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 X< precdl>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 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.

--- 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 \vers{} (see Appendix B however), will have a slightly different name if they are implemented some day.

\subseckbd{^}: If y is not of type integer, x^ y has the same effect as exp(y*ln(x)). It can be applied to p-adic numbers as well as to the more usual types.X<powering>

X<gpow>The library syntax is gpow(x,y,<CODE>prec</CODE>).


Euler

Euler's constant 0.57721.... Note that Euler is one of the few special reserved names which cannot be used for variables (the others are I and Pi, as well as all function names). X<Label se:euler>

X<mpeuler>The library syntax is mpeuler(<CODE>prec</CODE>) where <CODE>prec</CODE> must be given. Note that this creates <EM>gamma</EM> on the PARI stack. If one does not want to create it on the stack but stash it for later use under the global name X< geuler>geuler (with no parentheses), use instead X<consteulerconsteuler(prec)>.


I

the complex number <PRE> F&lt;sqrt&gt; {-1} </PRE> .

The library syntax is the global variable gi (of type GEN).


Pi

the constant <EM>pi</EM> (3.14159...).X<Label se:pi>

X<mppi>The library syntax is mppi(<CODE>prec</CODE>) where <CODE>prec</CODE> must be given. Note that this creates <EM>pi</EM> on the PARI stack. If one does not want to create it on the stack but stash it for later use under the global name X< gpi>gpi (with no parentheses), use instead X<constpiconstpi(prec)>.


X<abs>abs<CODE>(x)</CODE>

absolute value of x (modulus if x is complex). Polynomials, power series and rational functions are not allowed. Contrary to most transcendental functions, an integer is not converted to a real number before applying abs.

X<gabs>The library syntax is gabs(x,<CODE>prec</CODE>).


X<acos>acos<CODE>(x)</CODE>

principal branch of cos^{-1}(x), i.e. such that Re(acos(x))\in [0,<EM>pi</EM>]. If x\in <STRONG><EM>R</EM></STRONG> and |x|&gt;1, then acos(x) is complex.

X<gacos>The library syntax is gacos(x,<CODE>prec</CODE>).


X<acosh>acosh<CODE>(x)</CODE>

principal branch of cosh^{-1}(x), i.e. such that Im(acosh(x))\in [0,<EM>pi</EM>]. If x\in <STRONG><EM>R</EM></STRONG> and x<1, then acosh(x) is complex.

X<gach>The library syntax is gach(x,<CODE>prec</CODE>).


X<agm>agm<CODE>(x,y)</CODE>

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.

X<agm>The library syntax is agm(x,y,<CODE>prec</CODE>).


X<arg>arg<CODE>(x)</CODE>

argument of the complex number x, such that -<EM>pi</EM><arg(x)E<lt=pi>.

X<garg>The library syntax is garg(x,<CODE>prec</CODE>).


X<asin>asin<CODE>(x)</CODE>

principal branch of sin^{-1}(x), i.e. such that Re(asin(x))\in [-<EM>pi</EM>/2,<EM>pi</EM>/2]. If x\in <STRONG><EM>R</EM></STRONG> and |x|&gt;1 then asin(x) is complex.

X<gasin>The library syntax is gasin(x,<CODE>prec</CODE>).


X<asinh>asinh<CODE>(x)</CODE>

principal branch of sinh^{-1}(x), i.e. such that Im(asinh(x))\in [-<EM>pi</EM>/2,<EM>pi</EM>/2].

X<gash>The library syntax is gash(x,<CODE>prec</CODE>).


X<atan>atan<CODE>(x)</CODE>

principal branch of tan^{-1}(x), i.e. such that Re(atan(x))\in{} ]-<EM>pi</EM>/2,<EM>pi</EM>/2[.

X<gatan>The library syntax is gatan(x,<CODE>prec</CODE>).


X<atanh>atanh<CODE>(x)</CODE>

principal branch of tanh^{-1}(x), i.e. such that Im(atanh(x))\in{} ]-<EM>pi</EM>/2,<EM>pi</EM>/2]. If x\in <STRONG><EM>R</EM></STRONG> and |x|&gt;1 then atanh(x) is complex.

X<gath>The library syntax is gath(x,<CODE>prec</CODE>).


X<bernfrac>bernfrac<CODE>(x)</CODE>

Bernoulli numberX<Bernoulli numbers> B_x, where B_0=1, B_1=-1/2, B_2=1/6,..., expressed as a rational number. The argument x should be of type integer.

X<bernfrac>The library syntax is bernfrac(x).


X<bernreal>bernreal<CODE>(x)</CODE>

Bernoulli numberX<Bernoulli numbers> B_x, as bernfrac, but B_x is returned as a real number (with the current precision).

X<bernreal>The library syntax is bernreal(x,<CODE>prec</CODE>).


X<bernvec>bernvec<CODE>(x)</CODE>

creates a vector containing, as rational numbers, the X<Bernoulli numbers>Bernoulli numbers B_0, B_2,..., B_{2x}. These Bernoulli numbers can then be used as follows. Assume that this vector has been put into a variable, say bernint. Then you can define under GP:

\bprog bern(x) = { if (x==1, return(-1/2)); if ((x<0) || (x%2), return(0)); bernint[x/2+1] } \eprog and then bern(k) gives the Bernoulli number of index k as a rational number, exactly as bernreal(k) gives it as a real number. If you need only a few values, calling bernfrac(k) each time will be much more efficient than computing the huge vector above.

X<bernvec>The library syntax is bernvec(x).


X<besseljh>besseljh<CODE>(n,x)</CODE>

J-Bessel function of half integral index. More precisely, <CODE>besseljh</CODE>(n,x) computes J_{n+1/2}(x) where n must be of type integer, and x is any element of C. In the present version \vers, this function is not very accurate when x is small.

X<jbesselh>The library syntax is jbesselh(n,x,<CODE>prec</CODE>).


X<besselk>besselk<CODE>(&lt;CODE&gt;nu&lt;/CODE&gt;,x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

K-Bessel function of index nu (which can be complex) and argument x. Only real and positive arguments x are allowed in the present version \vers. If <EM>flag</EM> is equal to 1, uses another implementation of this function which is often faster.

X<kbessel>The library syntax is kbessel(<CODE>nu</CODE>,x,<CODE>prec</CODE>) and X<kbessel2kbessel2(nu,x,prec)> respectively.


X<cos>cos<CODE>(x)</CODE>

cosine of x.

X<gcos>The library syntax is gcos(x,<CODE>prec</CODE>).


X<cosh>cosh<CODE>(x)</CODE>

hyperbolic cosine of x.

X<gch>The library syntax is gch(x,<CODE>prec</CODE>).


X<cotan>cotan<CODE>(x)</CODE>

cotangent of x.

X<gcotan>The library syntax is gcotan(x,<CODE>prec</CODE>).


X<dilog>dilog<CODE>(x)</CODE>

principal branch of the dilogarithm of x, i.e. analytic continuation of the power series <PRE> F&lt;log&gt; _2(x)=F&lt;sum&gt;_{nE&lt;gt&gt;=1}x^n/n^2 </PRE> .

X<dilog>The library syntax is dilog(x,<CODE>prec</CODE>).


X<eint1>eint1<CODE>(x,{n})</CODE>

exponential integral <EM>int</EM>_x^<EM>infty</EM> (e^{-t})/(t) dt (x\in<STRONG><EM>R</EM></STRONG>)

If n is present, outputs the n-dimensional vector [<CODE>eint1</CODE>(x),...,<CODE>eint1</CODE>(nx)] (x &gt;= 0). This is faster than repeatedly calling eint1(<CODE>i</CODE> * x).

X<veceint1>The library syntax is veceint1(x,n,<CODE>prec</CODE>). Also available is X<eint1eint1(x,prec)>.


X<erfc>erfc<CODE>(x)</CODE>

complementary error function (2/ <EM>sqrt</EM> <EM>pi</EM>)<EM>int</EM>_x^<EM>infty</EM> e^{-t^2} dt.

X<erfc>The library syntax is erfc(x,<CODE>prec</CODE>).


X<eta>eta<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

X<Dedekind>Dedekind's <EM>eta</EM> function, without the q^{1/24}. This means the following: if x is a complex number with positive imaginary part, the result is <EM>prod</EM>_{n=1}^<EM>infty</EM>(1-q^n), where q=e^{2i<EM>pi</EM> x}. If x is a power series (or can be converted to a power series) with positive valuation, the result is <EM>prod</EM>_{n=1}^<EM>infty</EM>(1-x^n).

If <EM>flag</EM>=1 and x can be converted to a complex number (i.e. is not a power series), computes the true <EM>eta</EM> function, including the leading q^{1/24}.

X<eta>The library syntax is eta(x,<CODE>prec</CODE>).


X<exp>exp<CODE>(x)</CODE>

exponential of x. p-adic arguments with positive valuation are accepted.

X<gexp>The library syntax is gexp(x,<CODE>prec</CODE>).


X<gammah>gammah<CODE>(x)</CODE>

gamma function evaluated at the argument x+1/2. When x is an integer, this is much faster than using <CODE>gamma</CODE>(x+1/2).

X<ggamd>The library syntax is ggamd(x,<CODE>prec</CODE>).


X<gamma>gamma<CODE>(x)</CODE>

gamma function of x. In the present version \vers{} the p-adic gamma function is not implemented.

X<ggamma>The library syntax is ggamma(x,<CODE>prec</CODE>).


X<hyperu>hyperu<CODE>(a,b,x)</CODE>

U-confluent hypergeometric function with parameters a and b.

X<hyperu>The library syntax is hyperu(a,b,x,<CODE>prec</CODE>).


X<incgam>incgam<CODE>(s,x,{y})</CODE>

incomplete gamma function.

The arguments s and x must be positive. The result returned is <EM>int</EM>_x^<EM>infty</EM> e^{-t}t^{s-1} dt. When y is given, assume (of course without checking!) that y=<EM>Gamma</EM>(s). For small x, this will tremendously speed up the computation.

X<incgam>The library syntax is incgam(s,x,<CODE>prec</CODE>) and X<incgam4incgam4(s,x,y,prec)>, respectively. There exist also the functions X<incgam1>incgam1 and X<incgam2>incgam2 which are used for internal purposes.


X<incgamc>incgamc<CODE>(s,x)</CODE>

complementary incomplete gamma function.

The arguments s and x must be positive. The result returned is <EM>int</EM>_0^x e^{-t}t^{s-1} dt, when x is not too large.

X<incgam3>The library syntax is incgam3(s,x,<CODE>prec</CODE>).


X<log>log<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

principal branch of the natural logarithm of x, i.e. such that Im(ln(x))\in{} ]-<EM>pi</EM>,<EM>pi</EM>]. The result is complex (with imaginary part equal to <EM>pi</EM>) if x\in <STRONG><EM>R</EM></STRONG> and x<0.

p-adic arguments are also accepted for x, with the convention that <PRE> F&lt;ln&gt; (p)=0 </PRE> . Hence in particular <PRE> F&lt;exp&gt; ( F&lt;ln&gt; (x))/x </PRE> will not in general be equal to 1 but to a (p-1)-th root of unity (or <EM>+-</EM>1 if p=2) times a power of p.

If <EM>flag</EM> is equal to 1, use an agm formula suggested by Mestre, when x is real, otherwise identical to log.

X<glog>The library syntax is glog(x,<CODE>prec</CODE>) or X<glogagmglogagm(x,prec)>.


X<lngamma>lngamma<CODE>(x)</CODE>

principal branch of the logarithm of the gamma function of x. Can have much larger arguments than gamma itself. In the present version \vers, the p-adic lngamma function is not implemented.

X<glngamma>The library syntax is glngamma(x,<CODE>prec</CODE>).


X<polylog>polylog<CODE>(m,x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

one of the different polylogarithms, depending on flag:

If <EM>flag</EM>=0 or is omitted: m^th polylogarithm of x, i.e. analytic continuation of the power series Li_m(x)=<EM>sum</EM>_{n&gt;=1}x^n/n^m. The program uses the power series when |x|^2&lt;=1/2, and the power series expansion in <PRE> F&lt;log&gt; (x) </PRE> otherwise. It is valid in a large domain (at least |x|<230), but should not be used too far away from the unit circle since it is then better to use the functional equation linking the value at x to the value at 1/x, which takes a trivial form for the variant below. Power series, polynomial, rational and vector/matrix arguments are allowed.

For the variants to follow we need a notation: let <EM>Re</EM>_m denotes <EM>Re</EM> or \Im depending whether m is odd or even.

If <EM>flag</EM>=1: modified m^th polylogarithm of x, called ~ D_m(x) in Zagier, defined for |x|&lt;=1 by <EM>Re</EM>_m(<EM>sum</EM>_{k=0}^{m-1} ((- <EM>log</EM> |x|)^k)/(k!)Li_{m-k}(x) +((- <EM>log</EM> |x|)^{m-1})/(m!) <EM>log</EM> |1-x|).

If <EM>flag</EM>=2: modified m^th polylogarithm of x, called D_m(x) in Zagier, defined for |x|&lt;=1 by <EM>Re</EM>_m(<EM>sum</EM>_{k=0}^{m-1}((- <EM>log</EM> |x|)^k)/(k!)Li_{m-k}(x) -(1)/(2)((- <EM>log</EM> |x|)^m)/(m!)).

If <EM>flag</EM>=3: another modified m^th polylogarithm of x, called P_m(x) in Zagier, defined for |x|&lt;=1 by <EM>Re</EM>_m(<EM>sum</EM>_{k=0}^{m-1}(2^kB_k)/(k!)( <EM>log</EM> |x|)^kLi_{m-k}(x) -(2^{m-1}B_m)/(m!)( <EM>log</EM> |x|)^m).

These three functions satisfy the functional equation f_m(1/x)=(-1)^{m-1}f_m(x).

X<polylog0>The library syntax is polylog0(m,x,<EM>flag</EM>,<CODE>prec</CODE>).


X<psi>psi<CODE>(x)</CODE>

the <EM>psi</EM>-function of x, i.e. the logarithmic derivative <EM>Gamma</EM>'(x)/<EM>Gamma</EM>(x).

X<gpsi>The library syntax is gpsi(x,<CODE>prec</CODE>).


X<sin>sin<CODE>(x)</CODE>

sine of x.

X<gsin>The library syntax is gsin(x,<CODE>prec</CODE>).


X<sinh>sinh<CODE>(x)</CODE>

hyperbolic sine of x.

X<gsh>The library syntax is gsh(x,<CODE>prec</CODE>).


X<sqr>sqr<CODE>(x)</CODE>

square of x. Not identical to x*x in the case of 2-adics, where it returns a more precise result.

X<gsqr>The library syntax is gsqr(x).


X<sqrt>sqrt<CODE>(x)</CODE>

principal branch of the square root of x, i.e. such that Arg(sqrt(x))\in{} ]-<EM>pi</EM>/2, <EM>pi</EM>/2], or in other words such that <EM>Re</EM>(sqrt(x))&gt;0 or <EM>Re</EM>(sqrt(x))=0 and \Im(sqrt(x))&gt;= 0. If x\in <STRONG><EM>R</EM></STRONG> and x<0, then the result is complex with positive imaginary part.

Integermod 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 integermods) is in the interval [0,p/2]. When the argument is an integermod a non-prime (or a non-prime-adic), the result is undefined (and the function may not even return).

X<gsqrt>The library syntax is gsqrt(x,<CODE>prec</CODE>).


X<tan>tan<CODE>(x)</CODE>

tangent of x.

X<gtan>The library syntax is gtan(x,<CODE>prec</CODE>).


X<tanh>tanh<CODE>(x)</CODE>

hyperbolic tangent of x.

X<gth>The library syntax is gth(x,<CODE>prec</CODE>).


X<teichmuller>teichmuller<CODE>(x)</CODE>

Teichm\``uller character of the p-adic number x.

X<teich>The library syntax is teich(x).


X<theta>theta<CODE>(q,z)</CODE>

Jacobi sine theta-function.

X<theta>The library syntax is theta(q,z,<CODE>prec</CODE>).


X<thetanullk>thetanullk<CODE>(q,k)</CODE>

k-th derivative at z=0 of <CODE>theta</CODE>(q,z).

X<thetanullk>The library syntax is thetanullk(q,k,<CODE>prec</CODE>), where k is a long.


X<weber>weber<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

one of Weber's three f functions. If <EM>flag</EM>=0, returns f(x)= <EM>exp</EM> (-i<EM>pi</EM>/24) . <EM>eta</EM>((x+1)/2) / <EM>eta</EM>(x) {such that} j=(f^{24}-16)^3/f^{24} , where j is the elliptic j-invariant (see the function ellj). If <EM>flag</EM>=1, returns f_1(x)=<EM>eta</EM>(x/2) / <EM>eta</EM>(x) {such that} j=(f_1^{24}+16)^3/f_1^{24} . Finally, if <EM>flag</EM>=2, returns f_2(x)= <EM>sqrt</EM> 2<EM>eta</EM>(2x) / <EM>eta</EM>(x) {such that} j=(f_2^{24}+16)^3/f_2^{24}. Note the identities f^8=f_1^8+f_2^8 and ff_1f_2= <EM>sqrt</EM> 2.

X<weber0>The library syntax is weber0(x,<EM>flag</EM>,<CODE>prec</CODE>), or X<wfwf(x,prec)>, X<wf1wf1(x,prec)> or X<wf2wf2(x,prec)>.


X<zeta>zeta<CODE>(s)</CODE>

Riemann's zeta functionX<Riemann zeta-function> <EM>zeta</EM>(s)=<EM>sum</EM>_{n&gt;=1}n^{-s}, computed using the X<Euler-Maclaurin>Euler-Maclaurin summation formula, except when s is of type integer, in which case it is computed using X<Bernoulli numbers>Bernoulli numbers for s&lt;=0 or s&gt;0 and even, and using modular forms for s&gt;0 and odd.

X<gzeta>The library syntax is gzeta(s,<CODE>prec</CODE>).


Arithmetic functions}\label{se:arithmetic

These functions are by definition functions whose natural domain of definition is either Z (or <STRONG><EM>Z</EM></STRONG>_{&gt;0}), 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 \vers{}, all arithmetic functions in the narrow sense of the word --- Euler's totientX<Euler totient function> function, the M\``obiusX<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 X<Pollard Rho>Pollard Rho, X< ECM>ECM and X< MPQS>MPQS stages, and has an early exit option for the functions X< moebius>moebius and (the integer function underlying) X<issquarefree>issquarefree. Note that it relies on a (fairly strong) probabilistic primality test: numbers found to be strong pseudo-primes after 10 successful trials of the X<Rabin-Miller>Rabin-Miller test are declared primes.


X<Qfb>Qfb<CODE>(a,b,c,{D=0.})</CODE>

creates the binary quadratic form ax^2+bxy+cy^2. If b^2-4ac&gt;0, initialize X<Shanks>Shanks' distance function to D.

X<Qfb0>The library syntax is Qfb0(a,b,c,D,<CODE>prec</CODE>). Also available are X<qfiqfi(a,b,c)> (when b^2-4ac<0), and X<qfrqfr(a,b,c,d)> (when b^2-4ac&gt;0).X<binary quadratic form>


X<addprimes>addprimes<CODE>({x=[ ]})</CODE>

adds the primes contained in the vector x (or the single integer x) to the table computed upon GP initialization (by pari_init in library mode), and returns a row vector whose first entries contain all primes added by the user and whose last entries have been filled up with 1's. In total the returned row vector has 100 components. Whenever factor or smallfact is subsequently called, first the primes in the table computed by pari_init will be checked, and then the additional primes in this table. If x is empty or omitted, just returns the current list of extra primes.

The entries in x are not checked for primality. They need only be positive integers not divisible by any of the pre-computed primes. It's in fact a nice trick to add composite numbers, which for example the function <CODE>factor</CODE>(x,0) was not able to factor. In case the message ``impossible inverse modulo \langlesome integermod\rangle'' shows up afterwards, you have just stumbled over a non-trivial factor. Note that the arithmetic functions in the narrow sense, like X< eulerphi>eulerphi, do not use this extra table.

The present PARI version \vers{} allows up to 100 user-specified primes to be appended to the table. This limit may be changed by altering NUMPRTBELT in file init.c. To remove primes from the list use removeprimes.

X<addprimes>The library syntax is addprimes(x).


X<bestappr>bestappr<CODE>(x,k)</CODE>

if x\in<STRONG><EM>R</EM></STRONG>, finds the best rational approximation to x with denominator at most equal to k using continued fractions.

X<bestappr>The library syntax is bestappr(x,k).


X<bezout>bezout<CODE>(x,y)</CODE>

finds u and v minimal in a natural sense such that 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(x,y).

X<vecbezout>The library syntax is vecbezout(x,y) to get the vector, or X<gbezoutgbezout(x,y, &u, &v)> which gives as result the address of the created gcd, and puts the addresses of the corresponding created objects into u and v.


X<bezoutres>bezoutres<CODE>(x,y)</CODE>

as bezout, with the resultant of x and y replacing the gcd.

X<vecbezoutres>The library syntax is vecbezoutres(x,y) to get the vector, or X<subresextsubresext(x,y, &u, &v)> which gives as result the address of the created gcd, and puts the addresses of the corresponding created objects into u and v.


X<bigomega>bigomega<CODE>(x)</CODE>

number of prime divisors of x counted with multiplicity. x must be an integer.

X<bigomega>The library syntax is bigomega(x), the result is a long.


X<binomial>binomial<CODE>(x,y)</CODE>

X<binomial coefficient>binomial coefficient \binom x y. Here y must be an integer, but x can be any PARI object.

X<binome>The library syntax is binome(x,y), where y must be a long.


X<chinese>chinese<CODE>(x,y)</CODE>

if x and y are both integermods or both polmods, 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 recursively applied to each component of the vector or matrix. For polynomial arguments, it is applied to each coefficient. Finally <CODE>chinese</CODE>(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.

X<chinois>The library syntax is chinois(x,y).


X<content>content<CODE>(x)</CODE>

computes the gcd of all the coefficients of x, when this gcd makes sense. If x is a scalar, this simply returns x. If x is a polynomial (and by extension a power series), it gives the usual content of x. If x is a rational function, it gives the ratio of the contents of the numerator and the denominator. Finally, if x is a vector or a matrix, it gives the gcd of all the entries.

X<content>The library syntax is content(x).


X<contfrac>contfrac<CODE>(x,{b},{lmax})</CODE>

creates the row vector whose components are the partial quotients of the X<continued fraction>continued fraction expansion of x, the number of partial quotients being limited to lmax. If x is a real number, the expansion stops at the last significant partial quotient if lmax is omitted. x can also be a rational function or a power series.

If a vector b is supplied, the numerators will be equal to the coefficients of b. The length of the result is then equal to the length of b, unless a partial remainder is encountered which is equal to zero. 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.

X<contfrac0>The library syntax is contfrac0(x,b,lmax). Also available are X<gboundcfgboundcf(x,lmax)>, X<gcfgcf(x)>, or X<gcf2gcf2(b,x)>, where lmax is a C integer.


X<contfracpnqn>contfracpnqn<CODE>(x)</CODE>

when x is a vector or a one-row matrix, x is considered as the list of partial quotients [a_0,a_1,...,a_n] of a rational number, and the result is the 2 by 2 matrix [p_n,p_{n-1};q_n,q_{n-1}] in the standard notation of continued fractions, so p_n/q_n=a_0+1/(a_1+...+1/a_n)...). If x is a matrix with two rows [b_0,b_1,...,b_n] and [a_0,a_1,...,a_n], this is then considered as a generalized continued fraction and we have similarly p_n/q_n=1/b_0(a_0+b_1/(a_1+...+b_n/a_n)...). Note that in this case one usually has b_0=1.

X<pnqn>The library syntax is pnqn(x).


X<core>core<CODE>(n,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

if n is a non-zero integer written as n=df^2 with d squarefree, returns d. If <EM>flag</EM> is non-zero, returns the two-element row vector [d,f].

X<core0>The library syntax is core0(n,<EM>flag</EM>). Also available are X<corecore(n)> (= X<core>core(n,0)) and X<core2core2(n)> (= X<core>core(n,1)).


X<coredisc>coredisc<CODE>(n,{&lt;EM&gt;flag&lt;/EM&gt;})</CODE>

if n is a non-zero integer written as n=df^2 with d fundamental discriminant (including 1), returns d. If <EM>flag</EM> 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.

X<coredisc0>The library syntax is coredisc0(n,<EM>flag</EM>). Also available are X<coredisccoredisc(n)> (= X<coredisc>coredisc(n,0)) and X<coredisc2coredisc2(n)> (= X<coredisc>coredisc(n,1)).


X<dirdiv>dirdiv<CODE>(x,y)</CODE>

x and y being vectors of perhaps different lengths but with y[1]!= 0 considered as X<Dirichlet series>Dirichlet series, computes the quotient of x by y, again as a vector.

X<dirdiv>The library syntax is dirdiv(x,y).


X<direuler>direuler<CODE>(p=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

computes the X<Dirichlet series>Dirichlet series to b terms of the X<Euler product>Euler product of expression expr as p ranges through the primes from a to b. expr must be a polynomial or rational function in another variable than p (say X) and <CODE>expr</CODE>(X) is understood as the Dirichlet series (or more precisely the local factor) <CODE>expr</CODE>(p^{-s}).

X<direuler>The library syntax is direuler(entree *ep, GEN a, GEN b, char *expr) (see the section on sums and products for explanations of this).


X<dirmul>dirmul<CODE>(x,y)</CODE>

x and y being vectors of perhaps different lengths considered as X<Dirichlet series>Dirichlet series, computes the product of x by y, again as a vector.

X<dirmul>The library syntax is dirmul(x,y).


X<divisors>divisors<CODE>(x)</CODE>

creates a row vector whose components are the positive divisors of the integer x in increasing order. The factorization of x (as output by X<factor>factor) can be used instead.

X<divisors>The library syntax is divisors(x).


X<eulerphi>eulerphi<CODE>(x)</CODE>

Euler's <EM>phi</EM> (totient)X<Euler totient function> function of x. x must be of type integer.

X<phi>The library syntax is phi(x).


X<factor>factor<CODE>(x,{&lt;CODE&gt;lim&lt;/CODE&gt;=-1})</CODE>

general factorization function. If x is of type integer, rational, polynomial or rational function, the result is a two-column matrix, the first column being the irreducibles dividing x (prime numbers or polynomials), and the second the exponents. If x is a vector or a matrix, the factoring is done componentwise (hence the result is a vector or matrix of two-column matrices).

If x is of type integer or rational, an argument lim can be added, meaning that we look only for factors up to lim, or to primelimit, whichever is lowest (except when <CODE>lim</CODE>=0 where the effect is identical to setting <CODE>lim</CODE>=<CODE>primelimit</CODE>). Hence in this case, the remaining part is not necessarily prime. See X<factorint>factorint for more information about the algorithms used.

The polynomials or rational functions to be factored must have scalar coefficients. In particular PARI does not know how to factor multivariate polynomials.

Note that PARI tries to guess in a sensible way over which ring you want to factor. Note also that factorization of polynomials is done up to multiplication by a constant. In particular, the factors of rational polynomials will have integer coefficients, and the content of a polynomial or rational function is discarded and not included in the factorization. If you need to, you can always ask for the content explicitly:

\bprog ? factor(t^2 + 5/2*t + 1) %1 = [2*t + 1 1]

[t + 2 1]

? content(t^2 + 5/2*t + 1) %2 = 1/2 \eprog

   See also X<factornf>I<factornf>.

X<factor0>The library syntax is factor0(x,<CODE>lim</CODE>), where lim is a C integer. Also available are X<factorfactor(x)> (= X<factor0factor0(x,-1)>), X<smallfactsmallfact(x)> (= X<factor0factor0(x,0)>).


X<factorback>factorback<CODE>(f,{nf})</CODE>

f being any factorization, gives back the factored object. If a second argument <CODE>nf</CODE> is supplied, f is assumed to be a prime ideal factorization in the number field <CODE>nf</CODE>. The resulting ideal is given in HNFX<Hermite normal form> form.

X<factorback>The library syntax is factorback(f,<CODE>nf</CODE>), where an omitted <CODE>nf</CODE> is entered as NULL.


X<factorcantor>factorcantor<CODE>(x,p)</CODE>

factors the polynomial x modulo the prime p, using distinct degree plus X<Cantor-Zassenhaus>Cantor-ZassenhausX<Zassenhaus>. The coefficients of x must be operation-compatible with <STRONG><EM>Z</EM></STRONG>/p<STRONG><EM>Z</EM></STRONG>. 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 <CODE>factormod</CODE>(x,p,1). Note that the factormod algorithm is usually faster than factorcantor.

X<factcantor>The library syntax is factcantor(x,p).


X<factorff>factorff<CODE>(x,p,a)</CODE>

factors the polynomial x in the field <STRONG><EM>F</EM></STRONG>_q defined by the irreducible polynomial a over <STRONG><EM>F</EM></STRONG>_p. The coefficients of x must be operation-compatible with <STRONG><EM>Z</EM></STRONG>/p<STRONG><EM>Z</EM></STRONG>. The result is a two-column matrix, the first column being the irreducible polynomials dividing x, and the second the exponents. It is recommended to use for the variable of a (which will be used as variable of a polmod) a name distinct from the other variables used, so that a lift() of the result will be legible.

X<factmod9>The library syntax is factmod9(x,p,a).


X<factorial>factorial<CODE>(x)</CODE> or <A HREF="#item_x_">x!</A>

factorial of x. The expression x! gives a result which is an integer, while <CODE>fact</CODE>(x) gives a real number.

X<mpfact>The library syntax is mpfact(x) for x! and X<mpfactrmpfactr(x,prec)> for <CODE>fact</CODE>(x). x must be a long integer and not a PARI integer.


X<factorint>factorint<CODE>(n,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

factors the integer n using a combination of the X<Pollard Rho>Pollard Rho method (with modifications due to Brent), X<Lenstra>Lenstra's X< ECM>ECM (with modifications by Montgomery), and X< MPQS>MPQS (the latter adapted from the X< LiDIA>LiDIA code with the kind permission of the LiDIA maintainers), as well as a search for pure powers with exponents&lt;= 10. The output is a two-column matrix as for factor.

This gives direct access to the integer factoring engine called by most arithmetical functions. flag is optional; its binary digits mean 1: avoid MPQS, 2: skip first stage ECM (we may still fall back to it later), 4: avoid Rho, 8: don't run final ECM (as a result, a huge composite may be declared to be prime). Note that a (strong) probabilistic primality test is used; thus composites might (very rarely) not be detected.

The machinery underlying this function is still in a somewhat experimental state, but should be much faster on average than pure ECM as used by all PARI versions up to 2.0.8, at the expense of heavier memory use. You are invited to play with the flag settings and watch the internals at work by using GP's X< debuglevel>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.

X<factorint>The library syntax is factorint(n,<EM>flag</EM>).


X<factormod>factormod<CODE>(x,p,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

factors the polynomial x modulo the prime integer p, using X<Berlekamp>Berlekamp. The coefficients of x must be operation-compatible with <STRONG><EM>Z</EM></STRONG>/p<STRONG><EM>Z</EM></STRONG>. The result is a two-column matrix, the first column being the irreducible polynomials dividing x, and the second the exponents. If <EM>flag</EM> 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.

X<factormod>The library syntax is factormod(x,p,<EM>flag</EM>). Also available are X<factmodfactmod(x,p)> (which is equivalent to X<factormodfactormod(x,p,0)>) and X<simplefactmodsimplefactmod(x,p)> (= X<factormodfactormod(x,p,1)>).


X<fibonacci>fibonacci<CODE>(x)</CODE>

x^{th} Fibonacci number.

X<fibo>The library syntax is fibo(x). x must be a long.


X<gcd>gcd<CODE>(x,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

creates the greatest common divisor of x and y. x and y can be of quite general types, for instance both rational numbers. Vector/matrix types are also accepted, in which case the GCD is taken recursively on each component. Note that for these types, gcd is not commutative.

If <EM>flag</EM>=0, use X<Euclid>Euclid's algorithm.

If <EM>flag</EM>=1, use the modular gcd algorithm (x and y have to be polynomials, with integer coefficients).

If <EM>flag</EM>=2, use the X<subresultant algorithm>subresultant algorithm.

X<gcd0>The library syntax is gcd0(x,y,<EM>flag</EM>). Also available are X<ggcdggcd(x,y)>, X<modulargcdmodulargcd(x,y)>, and X<srgcdsrgcd(x,y)> corresponding to <EM>flag</EM>=0, 1 and 2 respectively.


X<hilbert>hilbert<CODE>(x,y,{p})</CODE>

X<Hilbert symbol>Hilbert symbol of x and y modulo p. If x and y are of type integer or fraction, an explicit third parameter p must be supplied, p=0 meaning the place at infinity. Otherwise, p needs not be given, and x and y can be of compatible types integer, fraction, real, integermod or p-adic.

X<hil>The library syntax is hil(x,y,p).


X<isfundamental>isfundamental<CODE>(x)</CODE>

true (1) if x is equal to 1 or to the discriminant of a quadratic field, false (0) otherwise.

X<gisfundamental>The library syntax is gisfundamental(x), but the simpler function X<isfundamentalisfundamental(x)> which returns a long should be used if x is known to be of type integer.


X<isprime>isprime<CODE>(x)</CODE>

true (1) if x is a strong pseudo-prime for 10 randomly chosen bases, false (0) otherwise.

X<gisprime>The library syntax is gisprime(x), but the simpler function X<isprimeisprime(x)> which returns a long should be used if x is known to be of type integer.


X<ispseudoprime>ispseudoprime<CODE>(x)</CODE>

true (1) if x is a strong pseudo-prime for a randomly chosen base, false (0) otherwise.

X<gispsp>The library syntax is gispsp(x), but the simpler function X<ispspispsp(x)> which returns a long should be used if x is known to be of type integer.


X<issquare>issquare<CODE>(x,{&amp;n})</CODE>

true (1) if x is square, false (0) if not. x can be of any type. If n is given and an exact square root had to be computed in the checking process, puts that square root in n. This is in particular the case when x is an integer or a polynomial. This is not the case for intmods (use quadratic reciprocity) or series (only check the leading coefficient).

X<gcarrecomplet>The library syntax is gcarrecomplet(x,&n). Also available is X<gcarreparfaitgcarreparfait(x)>.


X<issquarefree>issquarefree<CODE>(x)</CODE>

true (1) if x is squarefree, false (0) if not. Here x can be an integer or a polynomial.

X<gissquarefree>The library syntax is gissquarefree(x), but the simpler function X<issquarefreeissquarefree(x)> which returns a long should be used if x is known to be of type integer. This X<issquarefree>issquarefree is just the square of the M\``obiusX<moebius> function, and is computed as a multiplicative arithmetic function much like the latter.


X<kronecker>kronecker<CODE>(x,y)</CODE>

KroneckerX<Kronecker symbol>X<Legendre symbol> (i.e. generalized Legendre) symbol ((x)/(y)). x and y must be of type integer.

X<kronecker>The library syntax is kronecker(x,y), the result (0 or <EM>+-</EM> 1) is a long.


X<lcm>lcm<CODE>(x,y)</CODE>

least common multiple of x and y, i.e. such that lcm(x,y)*gcd(x,y)=abs(x*y).

X<glcm>The library syntax is glcm(x,y).


X<moebius>moebius<CODE>(x)</CODE>

M\``obius <EM>mu</EM>-function of x. x must be of type integer.

X<mu>The library syntax is mu(x), the result (0 or <EM>+-</EM> 1) is a long.


X<nextprime>nextprime<CODE>(x)</CODE>

finds the smallest prime greater than or equal to x. x can be of any real type. Note that if x is a prime, this function returns x and not the smallest prime strictly larger than x.

X<nextprime>The library syntax is nextprime(x).


X<numdiv>numdiv<CODE>(x)</CODE>

number of divisors of x. x must be of type integer, and the result is a long.

X<numbdiv>The library syntax is numbdiv(x).


X<omega>omega<CODE>(x)</CODE>

number of distinct prime divisors of x. x must be of type integer.

X<omega>The library syntax is omega(x), the result is a long.


X<precprime>precprime<CODE>(x)</CODE>

finds the largest prime less than or equal to x. x can be of any real type. Returns 0 if x&lt;=1. Note that if x is a prime, this function returns x and not the largest prime strictly smaller than x.

X<precprime>The library syntax is precprime(x).


X<prime>prime<CODE>(x)</CODE>

the x^{th} prime number, which must be among the precalculated primes.

X<prime>The library syntax is prime(x). x must be a long.


X<primes>primes<CODE>(x)</CODE>

creates a row vector whose components are the first x prime numbers, which must be among the precalculated primes.

X<primes>The library syntax is primes(x). x must be a long.


X<qfbclassno>qfbclassno<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

class number of the quadratic field of discriminant x. In the present version \vers, a simple algorithm is used for x&gt;0, so x should not be too large (say x<10^7) for the time to be reasonable. On the other hand, for x<0 one can reasonably compute classno(x) for |x|<10^{25}, since the method used is X<Shanks>Shanks' method which is in O(|x|^{1/4}). For larger values of |D|, see quadclassunit.

If <EM>flag</EM>=1, compute the class number using X<Euler product>Euler products and the functional equation. However, it is in O(|x|^{1/2}).

\misctitle{Important warning.} For D < 0, this function often gives incorrect results when the class group is non-cyclic, because the authors were too lazy to implement X< Shanks>Shanks' method completely. It is therefore strongly recommended to use either the version with <EM>flag</EM>=1, the function <CODE>qfhclassno</CODE>(-x) if x is known to be a fundamental discriminant, or the function quadclassunit.

X<qfbclassno0>The library syntax is qfbclassno0(x,<EM>flag</EM>). Also available are X<classnoclassno(x)> (= X<qfbclassnoqfbclassno(x)>), X<classno2classno2(x)> (= X<qfbclassnoqfbclassno(x,1)>), and finally there exists the function X<hclassnohclassno(x)> which computes the class number of an imaginary quadratic field by counting reduced forms, an O(|x|) algorithm. See also qfbhclassno.


X<qfbcompraw>qfbcompraw<CODE>(x,y)</CODE>

X<composition>composition of the binary quadratic forms x and y, without X<reduction>reduction of the result. This is useful e.g. to compute a generating element of an ideal.

X<compraw>The library syntax is compraw(x,y).


X<qfbhclassno>qfbhclassno<CODE>(x)</CODE>

X<Hurwitz class number>Hurwitz class number of x, where x is non-negative and congruent to 0 or 3 modulo 4. See also qfbclassno.

X<hclassno>The library syntax is hclassno(x).


X<qfbnucomp>qfbnucomp<CODE>(x,y,l)</CODE>

X<composition>composition of the primitive positive definite binary quadratic forms x and y using the NUCOMP and NUDUPL algorithms of X< Shanks>Shanks (\`a la Atkin). l is any positive constant, but for optimal speed, one should take l=|D|^{1/4}, where D is the common discriminant of x and y.

X<nucomp>The library syntax is nucomp(x,y,l). The auxiliary function X<nuduplnudupl(x,l)> should be used instead for speed when x=y.


X<qfbnupow>qfbnupow<CODE>(x,n)</CODE>

n-th power of the primitive positive definite binary quadratic form x using the NUCOMP and NUDUPL algorithms (see qfbnucomp).

X<nupow>The library syntax is nupow(x,n).


X<qfbpowraw>qfbpowraw<CODE>(x,n)</CODE>

n-th power of the binary quadratic form x, computed without doing any X<reduction>reduction (i.e. using qfbcompraw). Here n must be non-negative and n<2^{31}.

X<powraw>The library syntax is powraw(x,n) where n must be a long integer.


X<qfbprimeform>qfbprimeform<CODE>(x,p)</CODE>

prime binary quadratic form of discriminant x whose first coefficient is the prime number p. Returns an error if x is not a quadratic residue mod p. In the case where x&gt;0, the ``distance'' component of the form is set equal to zero according to the current precision.


X<qfbred>qfbred<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0},{D},{&lt;CODE&gt;isqrtD&lt;/CODE&gt;},{&lt;CODE&gt;sqrtD&lt;/CODE&gt;})</CODE>

reduces the binary quadratic form x. <EM>flag</EM> can be any of 0: default behaviour, uses X<Shanks>Shanks' distance function d, 1: uses d, but performs only a single X<reduction>reduction step, 2: does not compute the distance function d, or 3: does not use d, single reduction step.

D, isqrtD, sqrtD, if present, supply the values of the discriminant, \lfloor <EM>sqrt</EM> D\rfloor, and <PRE> F&lt;sqrt&gt; D </PRE> respectively (no checking is done of these facts). If D < 0 these values are useless, and all references to Shanks's distance are irrelevant.

X<qfbred0>The library syntax is qfbred0(x,<EM>flag</EM>,D,<CODE>isqrtD</CODE>,<CODE>sqrtD</CODE>). Use NULL to omit any of D, isqrtD, sqrtD.

   Also available are

X<redimagredimag(x)> (= X<qfbredqfbred(x)> where x is definite),

   and for indefinite forms:

X<redrealredreal(x)> (= X<qfbredqfbred(x)>),

X<rhorealrhoreal(x)> (= X<qfbredqfbred(x,1)>),

X<redrealnodredrealnod(x,sq)> (= X<qfbredqfbred(x,2,,isqrtD)>),

X<rhorealnodrhorealnod(x,sq)> (= X<qfbredqfbred(x,3,,isqrtD)>).

X<primeform>The library syntax is primeform(x,p,<CODE>prec</CODE>), where the third variable <CODE>prec</CODE> is a long, but is only taken into account when x&gt;0.


X<quadclassunit>quadclassunit<CODE>(D,{&lt;EM&gt;flag&lt;/EM&gt;=0},{&lt;CODE&gt;tech&lt;/CODE&gt;=[]})</CODE>

X<Buchmann-McCurley>Buchmann-McCurley's sub-exponential algorithm for computing the class group of a quadratic field of discriminant D. If D is not fundamental, the result is undefined, but usually correct (a warning is issued). The more general function X< bnrinit>bnrinit should be used to compute the class group of an order.

This function should be used instead of qfbclassno or quadregula when D < -10^{25}, D&gt;10^{10}, or when the structure is wanted.

If <EM>flag</EM> 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 \vers, this doesn't work at all : use the general function X< bnfnarrow>bnfnarrow.

tech is a row vector of the form [c_1,c_2], where c_1 and c_2 are positive real numbers which control the execution time and the stack size. To get maximum speed, set c_2=c. To get a rigorous result (under X< GRH>GRH) you must take c_2=6. Reasonable values for c are between 0.1 and 2.

The result of this function is a vector v with 4 components if D < 0, and 5 otherwise. The correspond respectively to

--- v[1] : the class number

--- v[2] : a vector giving the structure of the class group as a product of cyclic groups;

--- v[3] : a vector giving generators of those cyclic groups (as binary quadratic forms).

--- v[4] : (omitted if D < 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).

--- v[5] : a measure of the correctness of the result. If it is close to 1, the result is correct (under X< GRH>GRH). If it is close to a larger integer, this shows that the class number is off by a factor equal to this integer, and you must start again with a larger value for c_1 or a different random seed. In this case, a warning message is printed.

X<quadclassunit0>The library syntax is quadclassunit0(D,<EM>flag</EM>,tech). Also available are X<buchimagbuchimag(D,c_1,c_2)> and X<buchrealbuchreal (D,flag,c_1,c_2)>.


X<quaddisc>quaddisc<CODE>(x)</CODE>

discriminant of the quadratic field <STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> x), where x\in<STRONG><EM>Q</EM></STRONG>.

X<quaddisc>The library syntax is quaddisc(x).


X<quadhilbert>quadhilbert<CODE>(D,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

relative equation defining the X<Hilbert class field>Hilbert class field of the quadratic field of discriminant D. If <EM>flag</EM> is non-zero and D < 0, outputs [<CODE>form</CODE>,<CODE>root</CODE>(<CODE>form</CODE>)] (to be used for constructing subfields). Uses complex multiplication in the imaginary case and X<Stark units>Stark units in the real case.

X<quadhilbert>The library syntax is quadhilbert(D,<EM>flag</EM>,<CODE>prec</CODE>).


X<quadgen>quadgen<CODE>(x)</CODE>

creates the quadratic numberX<omega> <EM>omega</EM>=(a+ <EM>sqrt</EM> x)/2 where a=0 if x ~ 0 <EM>mod</EM> 4, a=1 if x ~ 1 <EM>mod</EM> 4, so that (1,<EM>omega</EM>) is an integral basis for the quadratic order of discriminant x. x must be an integer congruent to 0 or 1 modulo 4.

X<quadgen>The library syntax is quadgen(x).


X<quadpoly>quadpoly<CODE>(D,{v=x})</CODE>

creates the ``canonical'' quadratic polynomial (in the variable v) corresponding to the discriminant D, i.e. the minimal polynomial of <CODE>quadgen</CODE>(x). D must be an integer congruent to 0 or 1 modulo 4.

X<quadpoly0>The library syntax is quadpoly0(x,v).


X<quadray>quadray<CODE>(D,f,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

relative equation for the ray class field of conductor f for the quadratic field of discriminant D (which can also be a bnf). flag is only meaningful when D < 0. If it's an odd integer, outputs instead the vector of [<CODE>ideal</CODE>, \var{corresponding root}]. If <EM>flag</EM>=0 or 1, uses the <EM>sigma</EM> function, while if \fl&gt;1, uses the Weierstrass \wp function. Finally, flag can also be a two-component vector [<EM>lambda</EM>,<EM>flag</EM>], where flag is as above and <EM>lambda</EM> is the technical element of bnf necessary for Schertz's method using <EM>sigma</EM>. In that case, returns 0 if <EM>lambda</EM> is not suitable.

If D&gt;0, the function may fail with the following message \bprog ``Cannot find a suitable modulus in FindModulus'' \eprog See the comments in X< bnrstark>bnrstark about this problem.

X<quadray>The library syntax is quadray(D,f,<EM>flag</EM>).


X<quadregulator>quadregulator<CODE>(x)</CODE>

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.

X<regula>The library syntax is regula(x,<CODE>prec</CODE>).


X<quadunit>quadunit<CODE>(x)</CODE>

fundamental unitX<fundamental units> of the real quadratic field <STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> x) where x is the positive discriminant of the field. If x is not a fundamental discriminant, this probably gives the fundamental unit of the corresponding order. x must be of type integer, and the result is a quadratic number.

X<fundunit>The library syntax is fundunit(x).


X<removeprimes>removeprimes<CODE>({x=[ ]})</CODE>

removes the primes listed in x from the prime number table. x can also be a single integer. List the current extra primes if x is omitted.

X<removeprimes>The library syntax is removeprimes(x).


X<sigma>sigma<CODE>(x,{k=1})</CODE>

sum of the k^{th} powers of the positive divisors of x. x must be of type integer.

X<sumdiv>The library syntax is sumdiv(x) (= X<sigmasigma(x)>) or X<gsumdivkgsumdivk(x,k)> (= X<sigmasigma(x,k)>), where k is a C long integer.


X<sqrtint>sqrtint<CODE>(x)</CODE>

integer square root of x, which must be of PARI type integer. The result is non-negative and rounded towards zero. A negative x is allowed, and the result in that case is I*sqrtint(-x).

X<racine>The library syntax is racine(x).


X<znlog>znlog<CODE>(x,g)</CODE>

g must be a primitive root mod a prime p, and the result is the discrete log of x in the multiplicative group (<STRONG><EM>Z</EM></STRONG>/p<STRONG><EM>Z</EM></STRONG>)^*. This function using a simple-minded baby-step/giant-step approach and requires O( <EM>sqrt</EM> p) storage, hence it cannot be used for p greater than about 10^13.

X<znlog>The library syntax is znlog(x,g).


X<znorder>znorder<CODE>(x)</CODE>

x must be an integer mod n, and the result is the order of x in the multiplicative group (<STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG>)^*. Returns an error if x is not invertible.

X<order>The library syntax is order(x).


X<znprimroot>znprimroot<CODE>(x)</CODE>

returns a primitive root of x, where x is a prime power.

X<gener>The library syntax is gener(x).


X<znstar>znstar<CODE>(n)</CODE>

gives the structure of the multiplicative group (<STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG>)^* as a 3-component row vector v, where v[1]=<EM>phi</EM>(n) is the order of that group, v[2] is a k-component row-vector d of integers d[i] such that d[i]&gt;1 and d[i] | d[i-1] for i &gt;= 2 and (<STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG>)^* ~ <EM>prod</EM>_{i=1}^k(<STRONG><EM>Z</EM></STRONG>/d[i]<STRONG><EM>Z</EM></STRONG>), and v[3] is a k-component row vector giving generators of the image of the cyclic groups <STRONG><EM>Z</EM></STRONG>/d[i]<STRONG><EM>Z</EM></STRONG>.

X<znstar>The library syntax is znstar(n).


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 X< Tate>Tate's notations. The functions assume that the curve is given by a general Weierstrass modelX<Weierstrass equation> <PRE> y^2+a_1xy+a_3y=x^3+a_2x^2+a_4x+a_6, </PRE> where a priori the a_i 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 X< ellinit>ellinit (see there), which usually gives a 19 component vector (which we will call a long vector in this section). If a specific flag is added, a vector with only 13 component will be output (which we will call a medium vector). A medium vector just gives the first 13 components of the long vector corresponding to the same curve, but is of course faster to compute. The following X< member functions>member functions are available to deal with the output of ellinit: \settabs\+xxxxxxxxxxxxxxxxxx&: &\cr

\+ a1--a6, b2--b8, c4--c6 &: & coefficients of the elliptic curve.\cr

\+ X<area>area &: & volume of the complex lattice defining E.\cr

\+ X<disc>disc &: & discriminant of the curve.\cr

\+ X<j>j &: & j-invariant of the curve.\cr

\+ X<omega>omega&: & [<EM>omega</EM>_1,<EM>omega</EM>_2], periods forming a basis of the complex lattice defining E (<EM>omega</EM>_1 is the\cr

\+ & & real period, and <EM>omega</EM>_2/<EM>omega</EM>_1 belongs to Poincar\'e's half-plane).\cr

\+ X<eta>eta &: & quasi-periods [<EM>eta</EM>_1, <EM>eta</EM>_2], such that <EM>eta</EM>_1<EM>omega</EM>_2-<EM>eta</EM>_2<EM>omega</EM>_1=i<EM>pi</EM>.\cr

\+ X<roots>roots&: & roots of the associated Weierstrass equation.\cr

\+ X<tate>tate &: & [u^2,u,v] in the notation of Tate.\cr

\+ X<w>w &: & Mestre's w (this is technical).\cr

Their use is best described by an example: assume that E was output by ellinit, then typing <A HREF="#item_E">E</A>.disc will retrieve the curve's discriminant. The member functions area, eta and omega are only available for curves over Q. Conversely, tate and w are only available for curves defined over <STRONG><EM>Q</EM></STRONG>_p.

Some functions, in particular those relative to height computations (see ellheight) require also that the curve be in minimal Weierstrass form. This is achieved by the function ellglobalred.

All functions related to elliptic curves share the prefix ell, and the precise curve we are interested in is always the first argument, in either one of the three formats discussed above, unless otherwise specified. For instance, in functions which do not use the extra information given by long vectors, the curve can be given either as a five-component vector, or by one of the longer vectors computed by ellinit.


X<elladd>elladd<CODE>(E,z1,z2)</CODE>

sum of the points z1 and z2 on the elliptic curve corresponding to the vector E.

X<addell>The library syntax is addell(E,z1,z2).


X<ellak>ellak<CODE>(E,n)</CODE>

computes the coefficient a_n of the L-function of the elliptic curve E, i.e. in principle coefficients of a newform of weight 2 assuming X<Taniyama-Weil>Taniyama-Weil. E must be a medium or long vector of the type given by ellinit. For this function to work for every n and not just those prime to the conductor, E must be a minimal Weierstrass equation. If this is not the case, use the function ellglobalred first before using ellak.

X<akell>The library syntax is akell(E,n).


X<ellan>ellan<CODE>(E,n)</CODE>

computes the vector of the first n a_k corresponding to the elliptic curve E. All comments in ellak description remain valid.

X<anell>The library syntax is anell(E,n), where n is a C integer.


X<ellap>ellap<CODE>(E,p,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

computes the a_p corresponding to the elliptic curve E and the prime number p. These are defined by the equation #E(<STRONG><EM>F</EM></STRONG>_p)=p+1-a_p, where #E(<STRONG><EM>F</EM></STRONG>_p) stands for the number of points of the curve E over the finite field <STRONG><EM>F</EM></STRONG>_p. When <EM>flag</EM> is 0, this uses the baby-step giant-step method and a trick due to Mestre.

If <EM>flag</EM> is 1, computes the a_p as a sum of Legendre symbols. This is slower than the previous method as soon as p is greater than 100, say.

No checking is done that p is indeed prime. E must be a medium or long vector of the type given by ellinit.

X<ellap0>The library syntax is ellap0(E,p,<EM>flag</EM>). Also available are X<apellapell(E,p)>, corresponding to <EM>flag</EM>=0, and X<apell2apell2(E,p)> (<EM>flag</EM>=1).


X<ellbil>ellbil<CODE>(E,z1,z2)</CODE>

if z1 and z2 are points on the elliptic curve E, this function computes the value of the canonical bilinear form on z1, z2: <PRE> C&lt;ellheight&gt;(E,z1C&lt;+&gt;z2) - C&lt;ellheight&gt;(E,z1) - C&lt;ellheight&gt;(E,z2) </PRE> where + denotes of course addition on E. In addition, z1 or z2 (but not both) can be vectors or matrices. Note that this is equal to twice some normalizations.

X<bilhell>The library syntax is bilhell(E,z1,z2,<CODE>prec</CODE>).


X<ellchangecurve>ellchangecurve<CODE>(E,v)</CODE>

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^2x'+r, y=u^3y'+su^2x'+t. The vector E must be a medium or long vector of the type given by ellinit.

X<coordch>The library syntax is coordch(E,v).


X<ellchangepoint>ellchangepoint<CODE>(x,v)</CODE>

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=u^2x'+r, y=u^3y'+su^2x'+t (see also ellchangecurve).

X<pointch>The library syntax is pointch(x,v).


X<elleisnum>elleisnum<CODE>(E,k,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

E being an elliptic curve as output by ellinit (or, alternatively, given by a 2-component vector [<EM>omega</EM>_1,<EM>omega</EM>_2]), and k being an even positive integer, computes the numerical value of the Eisenstein series of weight k at E. When flag is non-zero and k=4 or 6, returns g_2 or g_3 with the correct normalization.

X<elleisnum>The library syntax is elleisnum(E,k,<EM>flag</EM>).


X<elleta>elleta<CODE>(om)</CODE>

returns the two-component row vector [<EM>eta</EM>_1,<EM>eta</EM>_2] of quasi-periods associated to <CODE>om</CODE> = [<EM>omega</EM>_1, <EM>omega</EM>_2]

X<elleta>The library syntax is elleta(om, <CODE>prec</CODE>)


X<ellglobalred>ellglobalred<CODE>(E)</CODE>

calculates the arithmetic conductor, the global minimal model of E and the global X<Tamagawa number>Tamagawa number c. Here E is an elliptic curve given by a medium or long vector of the type given by ellinit, and is supposed to have all its coefficients a_i in Q. The result is a 3 component vector [N,v,c]. N is the arithmetic conductor of the curve, v is itself a vector [u,r,s,t] with rational components. It gives a coordinate change for E over Q such that the resulting model has integral coefficients, is everywhere minimal, a_1 is 0 or 1, a_2 is 0, 1 or -1 and a_3 is 0 or 1. Such a model is unique, and the vector v is unique if we specify that u is positive. To get the new model, simply type ellchangecurve(E,v). Finally c is the product of the local Tamagawa numbers c_p, a quantity which enters in the X<Birch and Swinnerton-Dyer conjecture>Birch and Swinnerton-Dyer conjecture.

X<globalreduction>The library syntax is globalreduction(E).


X<ellheight>ellheight<CODE>(E,z,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

global X<N\'eron-Tate height>N\'eron-Tate height of the point z on the elliptic curve E. The vector E must be a long vector of the type given by ellinit, with <EM>flag</EM>=1. If <EM>flag</EM>=0, this computation is done using sigma and theta-functions and a trick due to J. Silverman. If <EM>flag</EM>=1, use Tate's 4^n algorithm, which is much slower.

X<ellheight0>The library syntax is ellheight0(E,z,<EM>flag</EM>,<CODE>prec</CODE>). The Archimedean contribution alone is given by the library function X<hellhell(E,z,prec)>. Also available are X<ghellghell(E,z,prec)> (<EM>flag</EM>=0) and X<ghell2ghell2(E,z,prec)> (<EM>flag</EM>=1).


X<ellheightmatrix>ellheightmatrix<CODE>(E,x)</CODE>

x being a vector of points, this function outputs the Gram matrix of x with respect to the N\'eron-Tate height, in other words, the (i,j) component of the matrix is equal to ellbil(<A HREF="#item_E">E</A>,x[<CODE>i</CODE>],x[<CODE>j</CODE>]). 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 X<Mordell-Weil group>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.

X<mathell>The library syntax is mathell(E,x,<CODE>prec</CODE>).


X<ellinit>ellinit<CODE>(E,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

computes some fixed data concerning the elliptic curve given by the five-component vector E, which will be essential for most further computations on the curve. The result is a 19-component vector E (called a long vector in this section), shortened to 13 components (medium vector) if <EM>flag</EM>=1. Both contain the following information in the first 13 components:

<PRE> a_1,a_2,a_3,a_4,a_6,b_2,b_4,b_6,b_8,c_4,c_6,F&lt;Delta&gt;,j. </PRE>

In particular, the discriminant is E[12] (or <A HREF="#item_E">E</A>.disc), and the j-invariant is E[13] (or <A HREF="#item_E">E</A>.j).

The other six components are only present if <EM>flag</EM> is 0 (or omitted!). Their content depends on whether the curve is defined over R or not:

--- When E is defined over R, E[14] (<A HREF="#item_E">E</A>.roots) is a vector whose three components contain the roots of the associated Weierstrass equation. If the roots are all real, then they are ordered by decreasing value. If only one is real, it is the first component of E[14].

E[15] (<A HREF="#item_E">E</A>.omega[1]) is the real period of E (integral of dx/(2y+a_1x+a_3) over the connected component of the identity element of the real points of the curve), and E[16] (<A HREF="#item_E">E</A>.omega[2]) is a complex period. In other words, <EM>omega</EM>_1=E[15] and <EM>omega</EM>_2=E[16] form a basis of the complex lattice defining E (<A HREF="#item_E">E</A>.omega), with <EM>tau</EM>=(<EM>omega</EM>_2)/(<EM>omega</EM>_1) having positive imaginary part.

E[17] and E[18] are the corresponding values <EM>eta</EM>_1 and <EM>eta</EM>_2 such that <EM>eta</EM>_1<EM>omega</EM>_2-<EM>eta</EM>_2<EM>omega</EM>_1=i<EM>pi</EM>, and both can be retrieved by typing <A HREF="#item_E">E</A>.eta (as a row vector whose components are the <EM>eta</EM>_i).

Finally, E[19] (<A HREF="#item_E">E</A>.area) is the volume of the complex lattice defining E.

--- When E is defined over <STRONG><EM>Q</EM></STRONG>_p, the p-adic valuation of j must be negative. Then E[14] (<A HREF="#item_E">E</A>.roots) is the vector with a single component equal to the p-adic root of the associated Weierstrass equation corresponding to -1 under the Tate parametrization.

E[15] is equal to the square of the u-value, in the notation of Tate.

E[16] is the u-value itself, if it belongs to <STRONG><EM>Q</EM></STRONG>_p, otherwise zero.

E[17] is the value of Tate's q for the curve E.

<A HREF="#item_E">E</A>.tate will yield the three-component vector [u^2,u,q].

E[18] (<A HREF="#item_E">E</A>.w) is the value of Mestre's w (this is technical), and E[19] is arbitrarily set equal to zero.

For all other base fields or rings, the last six components are arbitrarily set equal to zero (see also the description of member functions related to elliptic curves at the beginning of this section).

X<ellinit0>The library syntax is ellinit0(E,<EM>flag</EM>,<CODE>prec</CODE>). Also available are X<initellinitell (E,prec)> (<EM>flag</EM>=0) and X<smallinitellsmallinitell (E,prec)> (<EM>flag</EM>=1).


X<ellisoncurve>ellisoncurve<CODE>(E,z)</CODE>

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.

X<oncurve>The library syntax is oncurve(E,z), and the result is a long.


X<ellj>ellj<CODE>(x)</CODE>

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.

X<jell>The library syntax is jell(x,<CODE>prec</CODE>).


X<elllocalred>elllocalred<CODE>(E,p)</CODE>

calculates the X<Kodaira>Kodaira type of the local fiber of the elliptic curve E at the prime p. E must be given by a medium or long vector of the type given by ellinit, and is assumed to have all its coefficients a_i 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 I_0), 2, 3 and 4 mean types II, III and IV respectively, 4+<EM>nu</EM> with <EM>nu</EM>&gt;0 means type I_<EM>nu</EM>; finally the opposite values -1, -2, etc. refer to the starred types I_0^*, 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 X<Tamagawa number>Tamagawa number c_p.

X<localreduction>The library syntax is localreduction(E,p).


X<elllseries>elllseries<CODE>(E,s,{A=1})</CODE>

E being a medium or long vector given by ellinit, this computes the value of the L-series of E at s. It is assumed that E is a minimal model over Z and that the curve is a modular elliptic curve. The optional parameter A is a cutoff point for the integral, which must be chosen close to 1 for best speed. The result must be independent of A, so this allows some internal checking of the function.

Note that if the conductor of the curve is large, say greater than 10^{12}, this function will take an unreasonable amount of time since it uses an O(N^{1/2}) algorithm.

X<lseriesell>The library syntax is lseriesell(E,s,A,<CODE>prec</CODE>) where <CODE>prec</CODE> is a long and an omitted A is coded as NULL.


X<ellorder>ellorder<CODE>(E,z)</CODE>

gives the order of the point z on the elliptic curve E if it is a torsion point, zero otherwise. In the present version \vers{}, this is implemented only for elliptic curves defined over Q.

X<orderell>The library syntax is orderell(E,z).


X<ellordinate>ellordinate<CODE>(E,x)</CODE>

gives a 0, 1 or 2-component vector containing the y-coordinates of the points of the curve E having x as x-coordinate.

X<ordell>The library syntax is ordell(E,x).


X<ellpointtoz>ellpointtoz<CODE>(E,z)</CODE>

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, \wp(t)=z[1],\wp'(t)=z[2]. In other words, this is the inverse function of ellztopoint.

If E has coefficients in <STRONG><EM>Q</EM></STRONG>_p, then either Tate's u is in <STRONG><EM>Q</EM></STRONG>_p, 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 a long vector output by ellinit.

X<zell>The library syntax is zell(E,z,<CODE>prec</CODE>).


X<ellpow>ellpow<CODE>(E,z,n)</CODE>

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).

X<powell>The library syntax is powell(E,z,n).


X<ellrootno>ellrootno<CODE>(E,{p=1})</CODE>

E being a medium or long vector given by ellinit, this computes the local (if p!= 1) or global (if p=1) root number of the L-series of the elliptic curve E. Note that the global root number is the sign of the functional equation and conjecturally is the parity of the rank of the X< Mordell-Weil group>Mordell-Weil group. The equation for E must have coefficients in Q but need not be minimal.

X<ellrootno>The library syntax is ellrootno(E,p) and the result (equal to <EM>+-</EM>1) is a long.


X<ellsigma>ellsigma<CODE>(E,z,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

value of the Weierstrass <EM>sigma</EM> function of the lattice associated to E as given by ellinit (alternatively, E can be given as a lattice [<EM>omega</EM>_1,<EM>omega</EM>_2]).

If <EM>flag</EM>=1, computes an (arbitrary) determination of <PRE> F&lt;log&gt; (F&lt;sigma&gt;(z)) </PRE> .

If <EM>flag</EM>=2,3, same using the product expansion instead of theta series. X<ellsigma>The library syntax is ellsigma(E,z,<EM>flag</EM>)


X<ellsub>ellsub<CODE>(E,z1,z2)</CODE>

difference of the points z1 and z2 on the elliptic curve corresponding to the vector E.

X<subell>The library syntax is subell(E,z1,z2).


X<elltaniyama>elltaniyama<CODE>(E)</CODE>

computes the modular parametrization of the elliptic curve E, where E is given in the (long or medium) format output by ellinit, in the form of a two-component vector [u,v] of power series, given to the current default series precision. This vector is characterized by the following two properties. First the point (x,y)=(u,v) satisfies the equation of the elliptic curve. Second, the differential du/(2v+a_1u+a_3) is equal to f(z)dz, a differential form on H/<EM>Gamma</EM>_0(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 <PRE> F&lt;exp&gt; (2iF&lt;pi&gt; z) </PRE> . It is assumed that the curve is a strong X<Weil curve>Weil curve, and the Manin constant is equal to 1. The equation of the curve E must be minimal (use ellglobalred to get a minimal equation).

X<taniyama>The library syntax is taniyama(E), and the precision of the result is determined by the global variable precdl.


X<elltors>elltors<CODE>(E,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

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. E must be a long vector as output by ellinit.

\bprog ? E = ellinit([0,0,0,-1,0]); ? elltors(E) %1 = [4, [2, 2], [[0, 0], [1, 0]]] \eprog Here, the torsion subgroup is isomorphic to <STRONG><EM>Z</EM></STRONG>/2<STRONG><EM>Z</EM></STRONG> \times <STRONG><EM>Z</EM></STRONG>/2<STRONG><EM>Z</EM></STRONG>, with generators [0,0] and [1,0].

If <EM>flag</EM> = 0, use Doud's algorithm : bound torsion by computing #E(<STRONG><EM>F</EM></STRONG>_p) for small primes of good reduction, then look for torsion points using Weierstrass parametrization (and Mazur's classification).

If <EM>flag</EM> = 1, use Lutz--Nagell (much slower), E is allowed to be a medium vector.

X<elltors0>The library syntax is elltors0(E,flag).


X<ellwp>ellwp<CODE>(E,{z=x},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

Computes the value at z of the Weierstrass \wp function attached to the elliptic curve E as given by ellinit (alternatively, E can be given as a lattice [<EM>omega</EM>_1,<EM>omega</EM>_2]).

If z is omitted or is a simple variable, computes the power series expansion in z (starting z^{-2}+O(z^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 \wp(z), 1: compute [\wp(z),\wp'(z)].

X<ellwp0>The library syntax is ellwp0(E,z,<EM>flag</EM>,<CODE>prec</CODE>,<CODE>precdl</CODE>). Also available is X<weipell>weipell(E,<CODE>precdl</CODE>) for the power series (in x=<CODE>polx[0]</CODE>).


X<ellzeta>ellzeta<CODE>(E,z)</CODE>

value of the Weierstrass <EM>zeta</EM> function of the lattice associated to E as given by ellinit (alternatively, E can be given as a lattice [<EM>omega</EM>_1,<EM>omega</EM>_2]).

X<ellzeta>The library syntax is ellzeta(E,z).


X<ellztopoint>ellztopoint<CODE>(E,z)</CODE>

E being a long vector, computes the coordinates [x,y] on the curve E corresponding to the complex number z. Hence this is the inverse function of ellpointtoz. In other words, if the curve is put in Weierstrass form, [x,y] represents the X<Weierstrass \wp-function>Weierstrass \wp-function and its derivative. If z is in the lattice defining E over C, the result is the point at infinity [0].

X<pointell>The library syntax is pointell(E,z,<CODE>prec</CODE>).


Functions related to general number fields

In this section can be found functions which are used almost exclusively for working in general number fields. Other less specific functions can be found in the next section on polynomials. Functions related to quadratic number fields can be found in the section Label se:arithmetic (Arithmetic functions).

   We shall use the following conventions:

--- X<nfnf> denotes a number field, i.e. a 9-component vector in the format output by X< nfinit>nfinit. This contains the basic arithmetic data associated to the number field: signature, maximal order, discriminant, etc.

--- X<bnfbnf> denotes a big number field, i.e. a 10-component vector in the format output by X< bnfinit>bnfinit. This contains <CODE>nf</CODE> and the deeper invariants of the field: units, class groups, as well as a lot of technical data necessary for some complex fonctions like bnfisprincipal.

--- X<bnrbnr> denotes a big ``ray number field'', i.e. some data structure output by bnrinit, even more complicated than <CODE>bnf</CODE>, corresponding to the ray class group structure of the field, for some modulus.

--- X<rnfrnf> denotes a relative number field (see below).

--- <EM>X<ideal</EM>ideal> can mean any of the following:

     -- a B<I<Z>>-basis, in X<Hermite normal form>Hermite normal form
(HNF) or not. In this case C<x> is a square matrix.

     -- an I<X<idele>idele>, i.e. a 2-component vector, the first
being an ideal given as a B<I<Z>>--basis, the second being a C<r_1+r_2>-component
row vector giving the complex logarithmic Archimedean information.

     -- a C<B<I<Z>>_K>-generating system for an ideal.

     -- a I<column> vector C<x> expressing an element of the number field
on the integral basis, in which case the ideal is treated as being the
principal idele (or ideal) generated by C<x>.

     -- a prime ideal, i.e. a 5-component vector in the format output by
C<idealprimedec>.

     -- a polmod C<x>, i.e. an algebraic integer, in which case the ideal
is treated as being the principal idele generated by C<x>.

     -- an integer or a rational number, also treated as a principal idele.

--- a {\itX<character>character} on the Abelian group \bigoplus (<STRONG><EM>Z</EM></STRONG>/N_i<STRONG><EM>Z</EM></STRONG>) g_i is given by a row vector <EM>chi</EM> = [a_1,...,a_n] such that <EM>chi</EM>(<EM>prod</EM> g_i^{n_i}) = exp(2i<EM>pi</EM><EM>sum</EM> a_i n_i / N_i).

\misctitle{Warnings:}

1) An element in <CODE>nf</CODE> can be expressed either as a polmod or as a vector of components on the integral basis <CODE>nf</CODE>.zk. It is absolutely essential that all such vectors be column vectors.

2) When giving an ideal by a <STRONG><EM>Z</EM></STRONG>_K generating system to a function expecting an ideal, it must be ensured that the function understands that it is a <STRONG><EM>Z</EM></STRONG>_K-generating system and not a Z-generating system. When the number of generators is strictly less than the degree of the field, there is no ambiguity and the program assumes that one is giving a <STRONG><EM>Z</EM></STRONG>_K-generating set. When the number of generators is greater than or equal to the degree of the field, however, the program assumes on the contrary that you are giving a Z-generating set. If this is not the case, you must absolutely change it into a Z-generating set, the simplest manner being to use idealhnf(<CODE>nf</CODE>,<A HREF="#item_x">x</A>).

Concerning relative extensions, some additional definitions are necessary.

--- A {\itX<relative matrix>relative matrix} will be a matrix whose entries are elements of a (given) number field <CODE>nf</CODE>, always expressed as column vectors on the integral basis <CODE>nf</CODE>.zk. Hence it is a matrix of vectors.

--- An {\itX<ideal list>ideal list} will be a row vector of (fractional) ideals of the number field <CODE>nf</CODE>.

--- A {\itX<pseudo-matrix>pseudo-matrix} will be a pair (A,I) where A is a relative matrix and I an ideal list whose length is the same as the number of columns of A. This pair will be represented by a 2-component row vector.

--- The {\itX<module>module} generated by a pseudo-matrix (A,I) is the sum <EM>sum</EM>_i{<STRONG><EM>a</EM></STRONG>}_jA_j where the {<STRONG><EM>a</EM></STRONG>}_j are the ideals of I and A_j is the j-th column of A.

--- A pseudo-matrix (A,I) is a {\itX<pseudo-basis>pseudo-basis} of the module it generates if A is a square matrix with non-zero determinant and all the ideals of I are non-zero. We say that it is in Hermite Normal FormX<Hermite normal form> (HNF) if it is upper triangular and all the elements of the diagonal are equal to 1.

--- The determinant of a pseudo-basis (A,I) is the ideal equal to the product of the determinant of A by all the ideals of I. The determinant of a pseudo-matrix is the determinant of any pseudo-basis of the module it generates.

Finally, when defining a relative extension, the base field should be defined by a variable having a lower priority (i.e. a higher number) than the variable defining the extension. For example, under GP you can use the variable name y (or t) to define the base field, and the variable name x to define the relative extension.

Now a last set of definitions concerning the way big ray number fields (or bnr) are input, using class field theory. These are defined by a triple a1, a2, a3, where the defining set [a1,a2,a3] can have any of the following forms: [<CODE>bnr</CODE>], [<CODE>bnr</CODE>,<CODE>subgroup</CODE>], [<CODE>bnf</CODE>,<CODE>module</CODE>], [<CODE>bnf</CODE>,<CODE>module</CODE>,<CODE>subgroup</CODE>], where:

--- <CODE>bnf</CODE> is as output by bnfclassunit or bnfinit, where units are mandatory unless the ideal is trivial; bnr by bnrclass (with \fl&gt;0) or bnrinit. This is the ground field.

--- module is either an ideal in any form (see above) or a two-component row vector containing an ideal and an r_1-component row vector of flags indicating which real Archimedean embeddings to take in the module.

--- subgroup is the HNF matrix of a subgroup of the ray class group of the ground field for the modulus module. This is input as a square matrix expressing generators of a subgroup of the ray class group <CODE>bnr</CODE>.clgp on the given generators.

The corresponding bnr is then the subfield of the ray class field of the ground field for the given modulus, associated to the given subgroup.

All the functions which are specific to relative extensions, number fields, big number fields, big number rays, share the prefix rnf, nf, bnf, bnr respectively. They are meant to 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 <CODE>nf</CODE>, to use a <CODE>bnf</CODE> instead (which contains much more information). The program will make the effort of converting to what it needs. On the other hand, if the program requires a big number field, the program will not launch bnfinit for you, which can be a costly operation. Instead, it will give you a specific error message.

The data types corresponding to the structures described above are rather complicated. Thus, as we already have seen it with elliptic curves, GP provides you with some ``member functions'' to retrieve the data you need from these structures (once they have been initialized of course). The relevant types of number fields are indicated between parentheses:

X<member functions> \settabs\+xxxxxxx&(bnr,x&bnf,x&nf\hskip2pt&)x&: &\cr

\+X<bnf>bnf &(bnr,& bnf&&)&: & big number field.\cr

\+X<clgp>clgp &(bnr,& bnf&&)&: & classgroup. This one admits the following three subclasses:\cr

\+ X<cyc>cyc &&&&&: & cyclic decomposition (SNF)X<Smith normal form>.\cr

\+ genX<gen (member function)> &&&&&: & generators.\cr

\+ X<no>no &&&&&: & number of elements.\cr

\+X<diff>diff &(bnr,& bnf,& nf&)&: & the different ideal.\cr

\+X<codiff>codiff&(bnr,& bnf,& nf&)&: & the codifferent (inverse of the different in the ideal group).\cr

\+X<disc>disc &(bnr,& bnf,& nf&)&: & discriminant.\cr

\+X<fu>fu &(bnr,& bnf,& nf&)&: & X<fundamental units>fundamental units.\cr

\+X<futu>futu &(bnr,& bnf&&)&: & [u,w], u is a vector of fundamental units, w generates the torsion.\cr

\+X<nf>nf &(bnr,& bnf,& nf&)&: & number field.\cr

\+X<reg>reg &(bnr,& bnf,&&)&: & regulator.\cr

\+X<roots>roots&(bnr,& bnf,& nf&)&: & roots of the polnomial generating the field.\cr

\+X<sign>sign &(bnr,& bnf,& nf&)&: & [r_1,r_2] the signature of the field. This means that the field has r_1 real \cr \+ &&&&&& embeddings, 2r_2 complex ones.\cr

\+X<t2>t2 &(bnr,& bnf,& nf&)&: & the T2 matrix (see nfinit).\cr

\+X<tu>tu &(bnr,& bnf,&&)&: & a generator for the torsion units.\cr

\+X<tufu>tufu &(bnr,& bnf,&&)&: & as futu, but outputs [w,u].\cr

\+X<zk>zk &(bnr,& bnf,& nf&)&: & integral basis, i.e. a Z-basis of the maximal order.\cr

\+X<zkst>zkst &(bnr& & &)&: & structure of (<STRONG><EM>Z</EM></STRONG>_K/m)^* (can be extracted also from an idealstar).\cr

For instance, assume that <CODE>bnf</CODE> = <CODE>bnfinit</CODE>(<CODE>pol</CODE>), for some polynomial. Then <CODE>bnf</CODE>.clgp retrieves the class group, and <CODE>bnf</CODE>.clgp.no the class number. If we had set <CODE>bnf</CODE> = <CODE>nfinit</CODE>(<CODE>pol</CODE>), both would have output an error message. All these functions are completely recursive, thus for instance <CODE>bnr</CODE>.bnf.nf.zk will yield the maximal order of bnr (which you could get directly with a simple <CODE>bnr</CODE>.zk of course).

\medskip The following functions, starting with buch in library mode, and with bnf under GP, are implementations of the sub-exponential algorithms for finding class and unit groups under X<GRH>GRH, due to Hafner-McCurley, X<Buchmann>Buchmann and Cohen-Diaz-Olivier.

The general call to the functions concerning class groups of general number fields (i.e. excluding quadclassunit) involves a polynomial P and a technical vector <CODE>tech</CODE> = [c,c2,<CODE>nrel</CODE>,<CODE>borne</CODE>,<CODE>nrpid</CODE>,<CODE>minsfb</CODE>], where the parameters are to be understood as follows:

P is the defining polynomial for the number field, which must be in <STRONG><EM>Z</EM></STRONG>[X], irreducible and, preferably, monic. In fact, if you supply a non-monic polynomial at this point, GP will issue a warning, then transform your polynomial so that it becomes monic. Instead of the normal result, say res, you then get a vector [res,Mod(a,Q)], where Mod(a,Q)=Mod(X,P) gives the change of variables.

The numbers c and c2 are positive real numbers which control the execution time and the stack size. To get maximum speed, set c2=c. To get a rigorous result (under X< GRH>GRH) you must take c2=12 (or c2=6 in the quadratic case, but then you should use the much faster function quadclassunit). Reasonable values for c are between 0.1 and 2. (The defaults are c=c2=0.3).

<CODE>nrel</CODE> is the number of initial extra relations requested in computing the relation matrix. Reasonable values are between 5 and 20. (The default is 5).

<CODE>borne</CODE> is a multiplicative coefficient of the Minkowski bound which controls the search for small norm relations. If this parameter is set equal to 0, the program does not search for small norm relations. Otherwise reasonable values are between 0.5 and 2.0. (The default is 1.0).

<CODE>nrpid</CODE> is the maximal number of small norm relations associated to each ideal in the factor base. Irrelevant when <CODE>borne</CODE>=0. Otherwise, reasonable values are between 4 and 20. (The default is 4).

<CODE>minsfb</CODE> is the minimal number of elements in the ``sub-factorbase''. If the program does not seem to succeed in finding a full rank matrix (which you can see in GP by typing \g 2), increase this number. Reasonable values are between 2 and 5. (The default is 3).

\misctitle{Remarks.}

Apart from the polynomial P, you don't need to supply any of the technical parameters (under the library you still need to send at least an empty vector, cgetg(1,t_VEC)). However, should you choose to set some of them, they must be given in the requested order. For example, if you want to specify a given value of nrel, you must give some values as well for c and c2, and provide a vector [c,c2,nrel].

Note also that you can use an <CODE>nf</CODE> instead of P, which avoids recomputing the integral basis and analogous quantities.


X<bnfcertify>bnfcertify<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;)</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit or bnfclassunit, checks whether the result is correct, i.e. whether it is possible to remove the assumption of the Generalized Riemann HypothesisX< GRH>. If it is correct, the answer is 1. If not, the program may output some error message, but more probably will loop indefinitely. In no occasion can the program give a wrong answer (barring bugs of course): if the program answers 1, the answer is certified.

X<certifybuchall>The library syntax is certifybuchall(<CODE>bnf</CODE>), and the result is a C long.


X<bnfclassunit>bnfclassunit<CODE>(P,{&lt;EM&gt;flag&lt;/EM&gt;=0},{&lt;CODE&gt;tech&lt;/CODE&gt;=[ ]})</CODE>

X<Buchmann>Buchmann's sub-exponential algorithm for computing the class group, the regulator and a system of X< fundamental units>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 10 components (it is not a <CODE>bnf</CODE>, you need bnfinit for that), which for ease of presentation is in fact output as a one column matrix. First we describe the default behaviour (<EM>flag</EM>=0):

v[1] is equal to the polynomial P. Note that for optimum performance, P should have gone through polred or <CODE>nfinit</CODE>(x,2).

v[2] is the 2-component vector [r1,r2], where r1 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] (<CODE>v</CODE>.clgp) is a 3-component vector containing the class number (<CODE>v</CODE>.clgp.no), the structure of the class group as a product of cyclic groups of order n_i (<CODE>v</CODE>.clgp.cyc), and the corresponding generators of the class group of respective orders n_i (<CODE>v</CODE>.clgp.gen).

v[6] (<CODE>v</CODE>.reg) is the regulator computed to an accuracy which is the maximum of an internally determined accuracy and of the default.

v[7] is a measure of the correctness of the result. If it is close to 1, the results are correct (under X< GRH>GRH). If it is close to a larger integer, this shows that the product of the class number by the regulator is off by a factor equal to this integer, and you must start again with a larger value for c or a different random seed, i.e. use the function setrand. (Since the computation involves a random process, starting again with exactly the same parameters may give the correct result.) In this case a warning message is printed.

v[8] (<CODE>v</CODE>.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] (<CODE>v</CODE>.fu) is a system of fundamental units also expressed as polynomials.

v[10] gives a measure of the correctness of the computations of the fundamental units (not of the regulator), expressed as a number of bits. If this number is greater than 20, say, everything is OK. If v[10]&lt;=0, then we have lost all accuracy in computing the units (usually an error message will be printed and the units not given). In the intermediate cases, one must proceed with caution (for example by increasing the current precision).

If <EM>flag</EM>=1, and the precision happens to be insufficient for obtaining the fundamental units exactly, the internal precision is doubled and the computation redone, until the exact results are obtained. The user should be warned that this can take a very long time when the coefficients of the fundamental units on the integral basis are very large, for example in the case of large real quadratic fields. In that case, there are alternate methods for representing algebraic numbers which are not implemented in PARI.

If <EM>flag</EM>=2, the fundamental units and roots of unity are not computed. Hence the result has only 7 components, the first seven ones.

<CODE>tech</CODE> is a technical vector (empty by default) containing c, c2, nrel, borne, nbpid, minsfb, in this order (see the beginning of the section or the keyword bnf). You can supply any number of these provided you give an actual value to each of them (the ``empty arg'' trick won't work here). Careful use of these parameters may speed up your computations considerably.

X<bnfclassunit0>The library syntax is bnfclassunit0(P,<EM>flag</EM>,<CODE>tech</CODE>,<CODE>prec</CODE>).


X<bnfclgp>bnfclgp<CODE>(P,{&lt;CODE&gt;tech&lt;/CODE&gt;=[ ]})</CODE>

as bnfclassunit, but only outputs v[5], i.e. the class group.

X<bnfclassgrouponly>The library syntax is bnfclassgrouponly(P,<CODE>tech</CODE>,<CODE>prec</CODE>), where tech is as described under bnfclassunit.


X<bnfdecodemodule>bnfdecodemodule<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,m)</CODE>

if m is a module as output in the first component of an extension given by bnrdisclist, outputs the true module.

X<decodemodule>The library syntax is decodemodule(<CODE>nf</CODE>,m).


bnf{}init

(P,{<EM>flag</EM>=0},{<CODE>tech</CODE>=[ ]}): essentially identical to bnfclassunit except that the output contains a lot of technical data, and should not be printed out explicitly in general. The result of bnfinit is used in programs such as bnfisprincipal, bnfisunit or bnfnarrow. The result is a 10-component vector <CODE>bnf</CODE>.

   C<---> The first 6 and last 2 components are technical and in
principle are not used by the casual user. However, for the sake of
completeness, their description is as follows. We use the notations explained
in the book by H. Cohen, I<A Course in Computational Algebraic Number
Theory>, Graduate Texts in Maths C<138>, Springer-Verlag, 1993, Section
6.5, and subsection 6.5.5 in particular.

<CODE>bnf</CODE>[1] contains the matrix W (mit in the source code), i.e. the matrix in Hermite normal form giving relations for the class group on prime ideal generators (<STRONG>p</STRONG>_i)_{1&lt;= i&lt;= r}.

<CODE>bnf</CODE>[2] contains the matrix B (matalpha), i.e. the matrix containing the expressions of the prime ideal factorbase in terms of the <STRONG>p</STRONG>_i. It is an r\times c matrix.

<CODE>bnf</CODE>[3] contains the complex logarithmic embeddings of the system of fundamental units which has been found. It is an (r_1+r_2)\times(r_1+r_2-1) matrix.

<CODE>bnf</CODE>[4] contains the matrix M''_C of Archimedean components of the relations of the matrix M'', except that the first r_1+r_2-1 columns are suppressed since they are already in <CODE>bnf</CODE>[3].

<CODE>bnf</CODE>[5] contains the prime factor base, i.e. the list of k prime ideals used in finding the relations.

<CODE>bnf</CODE>[6] contains the permutation of the prime factor base which was necessary to reduce the relation matrix to the form explained in subsection 6.5.5 of GTM 138 (i.e. with a big c\times c identity matrix on the lower right). Note that in the above mentioned book, the need to permute the rows of the relation matrices which occur was not emphasized.

<CODE>bnf</CODE>[9] is a 3-element row vector obtained as follows. Let b=u_1^{-1}<CODE>bnf</CODE>[1]u_2 obtained by applying the X<Smith normal form>Smith normal form algorithm to the matrix <CODE>bnf</CODE>[1] (i.e. mit). Then <CODE>bnf</CODE>[9]=[u_1,u_2,b]. Note that the final class group generators given by bnfinit or bnfclassunit are obtained by X<LLL>LLL-reducing the generators whose list is b.

Finally, <CODE>bnf</CODE>[10] is unused and set equal to 0, but it is essential that this component be present, because PARI distinguishes a number field nf from a big number field bnf by the number of its components.

\noindent--- The less technical components are as follows:

<CODE>bnf</CODE>[7] or <CODE>bnf</CODE>.nf is equal to the number field data <CODE>nf</CODE> as would be given by nfinit.

<CODE>bnf</CODE>[8] is a vector containing the last 6 components of bnfclassunit[,1], i.e. the classgroup <CODE>bnf</CODE>.clgp, the regulator <CODE>bnf</CODE>.reg, the general ``check'' number which should be close to 1, the number of roots of unity and a generator <CODE>bnf</CODE>.tu, the fundamental units <CODE>bnf</CODE>.fu, and finally the check on their computation. If the precision becomes insufficient, GP outputs a warning ( fundamental units too large, not given) and does not strive to compute the units by default (<EM>flag</EM>=0).

When <EM>flag</EM>=1, GP insists on finding the fundamental units exactly, the internal precision being doubled and the computation redone, until the exact results are obtained. The user should be warned that this can take a very long time when the coefficients of the fundamental units on the integral basis are very large.

When <EM>flag</EM>=2, on the contrary, it is initially agreed that GP will not compute units.

When <EM>flag</EM>=3, computes a very small version of bnfinit, a ``small big number field'' (or sbnf for short) which contains enough information to recover the full <CODE>bnf</CODE> 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. The output is a 12 component vector v, as follows. Let <CODE>bnf</CODE> be the result of a full bnfinit, complete with units. Then v[1] is the polynomial P, v[2] is the number of real embeddings r_1, 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 <CODE>mit</CODE>=<CODE>bnf</CODE>[1], v[8] is the matrix <CODE>matalpha</CODE>=<CODE>bnf</CODE>[2], v[9] is the prime ideal factor base <CODE>bnf</CODE>[5] coded in a compact way, and ordered according to the permutation <CODE>bnf</CODE>[6], v[10] is the 2-component vector giving the number of roots of unity and a generator, expressed on the integral basis, v[11] is the list of fundamental units, expressed on the integral basis, v[12] is a vector containing the algebraic numbers alpha corresponding to the columns of the matrix matalpha, expressed on the integral basis.

Note that all the components are exact (integral or rational), except for the roots in v[5]. In practice, this is the only component which a user is allowed to modify, by recomputing the roots to a higher accuracy if desired. Note also that the member functions will not work on sbnf, you have to use bnfmake explicitly first.

\sidx{bnf{}init0}The library syntax is bnf{}init0(P,<EM>flag</EM>,<CODE>tech</CODE>,<CODE>prec</CODE>).


bnf{}isintnorm

(<CODE>bnf</CODE>,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 <CODE>bnf</CODE>. If <CODE>bnf</CODE> has not been certified, the correctness of the result depends on the validity of X<GRH>GRH.

\sidx{bnf{}isintnorm}The library syntax is bnf{}isintnorm(<CODE>bnf</CODE>,x).


bnf{}isnorm

(<CODE>bnf</CODE>,x,{<EM>flag</EM>=1}): tries to tell whether the rational number x is the norm of some element y in <CODE>bnf</CODE>. Returns a vector [a,b] where x=Norm(a)*b. Looks for a solution which is an S-unit, with S a certain set of prime ideals containing (among others) all primes dividing x. If <CODE>bnf</CODE> is known to be X<Galois>Galois, set <EM>flag</EM>=0 (in this case, x is a norm iff b=1). If <EM>flag</EM> is non zero the program adds to S the following prime ideals, depending on the sign of <EM>flag</EM>. If \fl&gt;0, the ideals of norm less than <EM>flag</EM>. And if <EM>flag</EM><0 the ideals dividing <EM>flag</EM>.

If you are willing to assume X< GRH>GRH, the answer is guaranteed (i.e. x is a norm iff b=1), if S contains all primes less than 12 <EM>log</EM> (<CODE>disc</CODE>(<CODE>Bnf</CODE>))^2, where <CODE>Bnf</CODE> is the Galois closure of <CODE>bnf</CODE>.

\sidx{bnf{}isnorm}The library syntax is bnf{}isnorm(<CODE>bnf</CODE>,x,<EM>flag</EM>,<CODE>prec</CODE>), where <EM>flag</EM> and <CODE>prec</CODE> are longs.


bnf{}issunit

(<CODE>bnf</CODE>,<CODE>sfu</CODE>,x): <CODE>bnf</CODE> 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.

\sidx{bnf{}issunit}The library syntax is bnf{}issunit(<CODE>bnf</CODE>,<CODE>sfu</CODE>,x).


bnf{}isprincipal

(<CODE>bnf</CODE>,x,{<EM>flag</EM>=1}): <CODE>bnf</CODE> 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 [v_1,v_2,check], where

v_1 is the vector of components c_i of the class of the ideal x in the class group, expressed on the generators g_i given by bnfinit (specifically <CODE>bnf</CODE>.clgp.gen which is the same as <CODE>bnf</CODE>[8][1][3]). The c_i are chosen so that 0&lt;= c_i<n_i where n_i is the order of g_i (the vector of n_i being <CODE>bnf</CODE>.clgp.cyc, that is <CODE>bnf</CODE>[8][1][2]).

v_2 gives on the integral basis the components of <EM>alpha</EM> such that x=<EM>alpha</EM><EM>prod</EM>_ig_i^{c_i}. In particular, x is principal if and only if v_1 is equal to the zero vector, and if this the case x=<EM>alpha</EM><STRONG><EM>Z</EM></STRONG>_K where <EM>alpha</EM> is given by v_2. Note that if <EM>alpha</EM> is too large to be given, a warning message will be printed and v_2 will be set equal to the empty vector.

Finally the third component check is analogous to the last component of bnfclassunit: it gives a check on the accuracy of the result, in bits. check should be at least 10, and preferably much more. In any case, the result is checked for correctness.

If <EM>flag</EM>=0, outputs only v_1, which is much easier to compute.

If <EM>flag</EM>=2, does as if <EM>flag</EM> were 0, but doubles the precision until a result is obtained.

If <EM>flag</EM>=3, as in the default behaviour (<EM>flag</EM>=1), but doubles the precision until a result is obtained.

The user is warned that these two last setting may induce very lengthy computations.

X<isprincipalall>The library syntax is isprincipalall(<CODE>bnf</CODE>,x,<EM>flag</EM>).


bnf{}isunit

(<CODE>bnf</CODE>,x): <CODE>bnf</CODE> being the number field data output by bnfinit and x 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 u_1,...,u_r are the fundamental units, and <EM>zeta</EM> is the generator of the group of roots of unity (found by bnfclassunit or bnfinit), the output is a vector [x_1,...,x_r,x_{r+1}] such that x=u_1^{x_1}... u_r^{x_r} . <EM>zeta</EM>^{x_{r+1}}. The x_i are integers for i&lt;= r and is an integer modulo the order of <EM>zeta</EM> for i=r+1.

X<isunit>The library syntax is isunit(<CODE>bnf</CODE>,x).


X<bnfmake>bnfmake<CODE>(&lt;CODE&gt;sbnf&lt;/CODE&gt;)</CODE>

sbnf being a ``small <CODE>bnf</CODE>'' as output by bnfinit(x,3), computes the complete bnfinit information. The result is not identical to what bnfinit would yield, but is functionally identical. The execution time is very small compared to a complete bnfinit. Note that if the default precision in GP (or <CODE>prec</CODE> in library mode) is greater than the precision of the roots <CODE>sbnf</CODE>[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.

X<makebigbnf>The library syntax is makebigbnf(<CODE>sbnf</CODE>,<CODE>prec</CODE>), where <CODE>prec</CODE> is a C long integer.


X<bnfnarrow>bnfnarrow<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;)</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit, computes the narrow class group of <CODE>bnf</CODE>. The output is a 3-component row vector v analogous to the corresponding class group component <CODE>bnf</CODE>.clgp (<CODE>bnf</CODE>[8][1]): the first component is the narrow class number <CODE>v</CODE>.no, the second component is a vector containing the SNFX<Smith normal form> cyclic components <CODE>v</CODE>.cyc of the narrow class group, and the third is a vector giving the generators of the corresponding <CODE>v</CODE>.gen cyclic groups. Note that this function is a special case of bnrclass.

X<buchnarrow>The library syntax is buchnarrow(<CODE>bnf</CODE>).


X<bnfsignunit>bnfsignunit<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;)</CODE>

<CODE>bnf</CODE> being a big number field output by bnfinit, this computes an r_1\times(r_1+r_2-1) matrix having <EM>+-</EM>1 components, giving the signs of the real embeddings of the fundamental units.

X<signunits>The library syntax is signunits(<CODE>bnf</CODE>).


X<bnfreg>bnfreg<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;)</CODE>

<CODE>bnf</CODE> being a big number field output by bnfinit, computes its regulator.

X<regulator>The library syntax is regulator(<CODE>bnf</CODE>,<CODE>tech</CODE>,<CODE>prec</CODE>), where tech is as in bnfclassunit.


X<bnfsunit>bnfsunit<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,S)</CODE>

computes the fundamental S-units of the number field <CODE>bnf</CODE> (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 the coordinates of v[1] on the ideals S, ordered as they were input. This is a matrix in Hermite normal form.

v[3] gives the (complex) logarithmic embeddings of the generators in v[1].

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.

X<bnfsunit>The library syntax is bnfsunit(<CODE>bnf</CODE>,S,<CODE>prec</CODE>).


X<bnfunit>bnfunit<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;)</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit, outputs a two-component row vector giving in the first component the vector of fundamental units of the number field, and in the second component the number of bit of accuracy which remained in the computation (which is always correct, otherwise an error message is printed). This function is mainly for people who used the wrong flag in bnfinit and would like to skip part of a lengthy bnfinit computation.

X<buchfu>The library syntax is buchfu(<CODE>bnf</CODE>).


X<bnrL1>bnrL1<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

bnr being the number field data which is output by bnrinit(,,1), returns for each X<character>character <EM>chi</EM> of the corresponding ray class group, the value at s = 1 (or s = 0) of the abelian L-functions associated to <EM>chi</EM>. For the value at s = 0, the function returns in fact for each character <EM>chi</EM> a vector [r_<EM>chi</EM> , c_<EM>chi</EM>] where r_<EM>chi</EM> is the order of L(s, <EM>chi</EM>) at s = 0 and c_<EM>chi</EM> the first non-zero term in the expansion of L(s, <EM>chi</EM>) at s = 0; in other words

L(s, <EM>chi</EM>) = c_<EM>chi</EM> . s^{r_<EM>chi</EM>} + O(s^{r_<EM>chi</EM> + 1})

   near C<0>. I<flag> is optional, default value is 0; its binary digits
mean 1: compute at C<s = 1> if set to 1 or C<s = 0> if set to 0, 2: compute
the primitive C<L>-functions associated to C<F<chi>> if set to 0 or the
C<L>-function with Euler factors at prime ideals dividing the modulus of
C<bnr> removed if set to 1 (this is the so-called C<L_S(s, F<chi>)>
function where C<S> is the set of infinite places of the number field
together with the finite prime ideals dividing the modulus of C<bnr>,
see the example below), 3: returns also the character.

Example:

\bprog bnf = bnfinit(x^ 2-229); bnr = bnrinit(bnf,1,1); bnrL1(bnr) \eprog returns the order and the first non-zero term of the abelian L-functions L(s, <EM>chi</EM>) at s = 0 where <EM>chi</EM> runs through the characters of the class group of <STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> 229). Then \bprog bnr2 = bnrinit(bnf,2,1); bnrL1(bnr2,2) \eprog returns the order and the first non-zero terms of the abelian L-functions L_S(s, <EM>chi</EM>) at s = 0 where <EM>chi</EM> runs through the characters of the class group of <STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> 229) and S is the set of infinite places of <STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> 229) together with the finite prime 2 (note that the ray class group modulo 2 is in fact the class group, so bnrL1(bnr2) returns exactly the same answer as bnrL1(bnr)!).

X<bnrL1>The library syntax is bnrL1(<CODE>bnr</CODE>,<EM>flag</EM>,<CODE>prec</CODE>)


X<bnrclass>bnrclass<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,&lt;CODE&gt;ideal&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit (the units are mandatory unless the ideal is trivial), and ideal being either an ideal in any form or a two-component row vector containing an ideal and an r_1-component row vector of flags indicating which real Archimedean embeddings to take in the module, computes the ray class group of the number field for the module ideal, as a 3-component vector as all other finite Abelian groups (cardinality, vector of cyclic components, corresponding generators).

If <EM>flag</EM>=2, the output is different. It is a 6-component vector w. w[1] is <CODE>bnf</CODE>. w[2] is the result of applying <CODE>idealstar</CODE>(<CODE>bnf</CODE>,I,2). w[3], w[4] and w[6] are technical components used only by the function bnrisprincipal. w[5] is the structure of the ray class group as would have been output with <EM>flag</EM>=0.

If <EM>flag</EM>=1, as above, except that the generators of the ray class group are not computed, which saves time.

X<bnrclass0>The library syntax is bnrclass0(<CODE>bnf</CODE>,<CODE>ideal</CODE>,<EM>flag</EM>,<CODE>prec</CODE>).


X<bnrclassno>bnrclassno<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,I)</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit (units are mandatory unless the ideal is trivial), and I being either an ideal in any form or a two-component row vector containing an ideal and an r_1-component row vector of flags indicating which real Archimedean embeddings to take in the modulus, computes the ray class number of the number field for the modulus I. This is faster than bnrclass and should be used if only the ray class number is desired.

X<rayclassno>The library syntax is rayclassno(<CODE>bnf</CODE>,I).


X<bnrclassnolist>bnrclassnolist<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;)</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit (units are mandatory unless the ideal is trivial), and list being a list of modules as output by ideallist of ideallistarch, outputs the list of the class numbers of the corresponding ray class groups.

X<rayclassnolist>The library syntax is rayclassnolist(<CODE>bnf</CODE>,<A HREF="#item_list">list</A>).


X<bnrconductor>bnrconductor<CODE>(a_1,{a_2},{a_3}, {&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

conductor of the subfield of a ray class field as defined by [a_1,a_2,a_3] (see bnr at the beginning of this section).

X<bnrconductor>The library syntax is bnrconductor(a_1,a_2,a_3,<EM>flag</EM>,<CODE>prec</CODE>), where an omitted argument among the a_i is input as gzero, and <EM>flag</EM> is a C long.


X<bnrconductorofchar>bnrconductorofchar<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,&lt;CODE&gt;chi&lt;/CODE&gt;)</CODE>

bnr being a big ray number field as output by bnrclass, and chi being a row vector representing a X<character>character as expressed on the generators of the ray class group, gives the conductor of this character as a modulus.

X<bnrconductorofchar>The library syntax is bnrconductorofchar(<CODE>bnr</CODE>,<CODE>chi</CODE>,<CODE>prec</CODE>) where <CODE>prec</CODE> is a long.


X<bnrdisc>bnrdisc<CODE>(a1,{a2},{a3},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

a1, a2, a3 defining a big ray number field L over a groud field K (see bnr at the beginning of this section for the meaning of a1, a2, a3), outputs a 3-component row vector [N,R_1,D], where N is the (absolute) degree of L, R_1 the number of real places of L, and D the discriminant of L/<STRONG><EM>Q</EM></STRONG>, including sign (if <EM>flag</EM>=0).

If <EM>flag</EM>=1, as above but outputs relative data. N is now the degree of L/K, R_1 is the number of real places of K unramified in L (so that the number of real places of L is equal to R_1 times the relative degree N), and D is the relative discriminant ideal of L/K.

If <EM>flag</EM>=2, does as in case 0, except that if the modulus is not the exact conductor corresponding to the L, no data is computed and the result is 0 (gzero).

If <EM>flag</EM>=3, as case 2, outputting relative data.

X<bnrdisc0>The library syntax is bnrdisc0(a1,a2,a3,<EM>flag</EM>,<CODE>prec</CODE>).


X<bnrdisclist>bnrdisclist<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,&lt;CODE&gt;bound&lt;/CODE&gt;,{&lt;CODE&gt;arch&lt;/CODE&gt;},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit (the units are mandatory), computes a list of discriminants of Abelian extensions of the number field by increasing modulus norm up to bound bound, where the ramified Archimedean places are given by arch (unramified at infinity if arch is void or omitted). If flag is non-zero, give arch all the possible values. (See bnr at the beginning of this section for the meaning of a1, a2, a3.)

The alternative syntax <CODE>bnrdisclist</CODE>(<CODE>bnf</CODE>,<A HREF="#item_list">list</A>) is supported, where list is as output by ideallist or ideallistarch (with units).

The output format is as follows. The output v is a row vector of row vectors, allowing the bound to be greater than 2^{16} for 32-bit machines, and v[i][j] is understood to be in fact V[2^{15}(i-1)+j] of a unique big vector V (note that 2^{15} is hardwired and can be increased in the source code only on 64-bit machines and higher).

Such a component V[k] is itself a vector W (maybe of length 0) whose components correspond to each possible ideal of norm k. Each component W[i] corresponds to an Abelian extension L of <CODE>bnf</CODE> whose modulus is an ideal of norm k and no Archimedean components (hence the extension is unramified at infinity). The extension W[i] is represented by a 4-component row vector [m,d,r,D] with the following meaning. m is the prime ideal factorization of the modulus, d=[L:<STRONG><EM>Q</EM></STRONG>] is the absolute degree of L, r is the number of real places of L, and D is the factorization of the absolute discriminant. Each prime ideal pr=[p,<EM>alpha</EM>,e,f,<EM>beta</EM>] in the prime factorization m is coded as p . n^2+(f-1) . n+(j-1), where n is the degree of the base field and j is such that

pr=idealprimedec(<CODE>nf</CODE>,p)[j].

m can be decoded using bnfdecodemodule.

X<bnrdisclist0>The library syntax is bnrdisclist0(a1,a2,a3,<CODE>bound</CODE>,<CODE>arch</CODE>,<EM>flag</EM>).


X<bnrinit>bnrinit<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,&lt;CODE&gt;ideal&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

<CODE>bnf</CODE> is as output by bnfinit, ideal is a valid ideal (or a module), initializes data linked to the ray class group structure corresponding to this module. This is the same as <CODE>bnrclass</CODE>(<CODE>bnf</CODE>,<CODE>ideal</CODE>,<EM>flag</EM>+1).

X<bnrinit0>The library syntax is bnrinit0(<CODE>bnf</CODE>,<CODE>ideal</CODE>,<EM>flag</EM>,<CODE>prec</CODE>).


X<bnrisconductor>bnrisconductor<CODE>(a1,{a2},{a3})</CODE>

a1, a2, a3 represent an extension of the base field, given by class field theory for some modulus encoded in the parameters. Outputs 1 if this modulus is the conductor, and 0 otherwise. This is slightly faster than bnrconductor.

X<bnrisconductor>The library syntax is bnrisconductor(a1,a2,a3) and the result is a long.


X<bnrisprincipal>bnrisprincipal<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,x,{&lt;EM&gt;flag&lt;/EM&gt;=1})</CODE>

bnr being the number field data which is output by bnrinit and x 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 3-component vector v where v[1] is the vector of components of x on the ray class group generators, v[2] gives on the integral basis an element <EM>alpha</EM> such that x=<EM>alpha</EM><EM>prod</EM>_ig_i^{x_i}. Finally v[3] indicates the number of bits of accuracy left in the result. In any case the result is checked for correctness, but v[3] is included to see if it is necessary to increase the accuracy in other computations.

If <EM>flag</EM>=0, outputs only v_1.

The settings <EM>flag</EM>=2 or 3 are not available in this case.

X<isprincipalrayall>The library syntax is isprincipalrayall(<CODE>bnr</CODE>,x,<EM>flag</EM>).


X<bnrrootnumber>bnrrootnumber<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,&lt;CODE&gt;chi&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

if <EM>chi</EM>=<CODE>chi</CODE> is a (not necessarily primitive) X<character>character over bnr, let L(s,<EM>chi</EM>) = <EM>sum</EM>_{id} <EM>chi</EM>(id) N(id)^{-s} be the associated X<Artin L-function>Artin L-function. Returns the so-called X<Artin root number>Artin root number, i.e. the complex number W(<EM>chi</EM>) of modulus 1 such that

<EM>Lambda</EM>(1-s,<EM>chi</EM>) = W(<EM>chi</EM>) <EM>Lambda</EM>(s,\overline{<EM>chi</EM>})

   where C<F<Lambda>(s,F<chi>) = A(F<chi>)^{s/2}F<gamma>_F<chi>(s) L(s,F<chi>)> is
the enlarged L-function associated to C<L>.

The generators of the ray class group are needed, and you can set <EM>flag</EM>=1 if the character is known to be primitive. Example:

\bprog bnf = bnfinit(x^ 2-145); bnr = bnrinit(bnf,7,1); bnrrootnumber(bnr, [5]) \eprog returns the root number of the character <EM>chi</EM> of Cl_7(<STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> 145)) such that <EM>chi</EM>(g) = <EM>zeta</EM>^5, where g is the generator of the ray-class field and <EM>zeta</EM> = e^{2i<EM>pi</EM>/N} where N is the order of g (N=12 as bnr.cyc readily tells us).

X<bnrrootnumber>The library syntax is bnrrootnumber(<CODE>bnf</CODE>,<CODE>chi</CODE>,<EM>flag</EM>)


bnrstark<CODE>{(&lt;CODE&gt;bnr&lt;/CODE&gt;,&lt;CODE&gt;subgroup&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})}</CODE>

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 using X<Stark units>Stark units (set <CODE>subgroup</CODE>=0 if you want the whole ray class group). The main variable of bnr must not be x, and the ground field and the class field must be totally real and not isomorphic to Q. flag is optional and may be set to 0 to obtain a reduced relative polynomial, 1 to be satisfied with any relative polynomial, 2 to obtain an absolute polynomial and 3 to obtain the irreducible relative polynomial of the Stark unit, 0 being default. Example:

\bprog bnf = bnfinit(y^ 2-3); bnr = bnrinit(bnf,5,1); bnrstark(bnr,0) \eprog returns the ray class field of <STRONG><EM>Q</EM></STRONG>( <EM>sqrt</EM> 3) modulo 5.

\misctitle{Remark.} The function may fail, returning the error message

"Cannot find a suitable modulus in FindModule".

In this case, the corresponding congruence group is a product of cyclic groups and, for the time being, the class field has to be obtained by splitting this group into its cyclic components.

X<bnrstark>The library syntax is bnrstark(<CODE>bnr</CODE>,<CODE>subgroup</CODE>,<EM>flag</EM>).


X<dirzetak>dirzetak<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,b)</CODE>

gives as a vector the first b coefficients of the X<Dedekind>Dedekind zeta function of the number field <CODE>nf</CODE> considered as a X<Dirichlet series>Dirichlet series.

X<dirzetak>The library syntax is dirzetak(<CODE>nf</CODE>,b).


X<factornf>factornf<CODE>(x,t)</CODE>

factorization of the univariate polynomial x over the number field defined by the (univariate) polynomial t. x may have coefficients in Q or in the number field. The main variable of t must be of lower priority than that of x (in other words the variable number of t must be greater than that of x). However if the coefficients of the number field occur explicitly (as polmods) as coefficients of x, the variable of these polmods must be the same as the main variable of t. For example factornf(x^ 2 + Mod(y,y^ 2+1), y^ 2+1) and factornf(x^ 2+1, y^ 2+1) are legal but factornf(x^ 2 + Mod(z,z^ 2+1), y^ 2+1) is not.

X<polfnf>The library syntax is polfnf(x,t).


X<ffinit>ffinit<CODE>(p,n,{v=x})</CODE>

computes a monic polynomial of degree n which is irreducible over <STRONG><EM>F</EM></STRONG>_p. For instance if P = ffinit(3,2,y), you can represent elements in <STRONG><EM>F</EM></STRONG>_{3^2} as polmods modulo P. This function is rather crude and expects p to be relatively small (p < 2^31).

X<ffinit>The library syntax is ffinit(p,n,v), where v is a variable number.


X<idealadd>idealadd<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

sum of the two ideals x and y in the number field <CODE>nf</CODE>. When x and y are given by Z-bases, this does not depend on <CODE>nf</CODE> and can be used to compute the sum of any two Z-modules. The result is given in HNF.

X<idealadd>The library syntax is idealadd(<CODE>nf</CODE>,x,y).


X<idealaddtoone>idealaddtoone<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,{y})</CODE>

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\in x, b\in y and a+b=1.

The alternative syntax <CODE>idealaddtoone</CODE>(<CODE>nf</CODE>,v), is supported, where v is a k-component vector of ideals (given in any form) which sum to <STRONG><EM>Z</EM></STRONG>_K. This outputs a k-component vector e such that e[i]\in x[i] for 1&lt;= i&lt;= k and <EM>sum</EM>_{1&lt;= i&lt;= k}e[i]=1.

X<idealaddtoone0>The library syntax is idealaddtoone0(<CODE>nf</CODE>,x,y), where an omitted y is coded as NULL.


X<idealappr>idealappr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

if x is a fractional ideal (given in any form), gives an element <EM>alpha</EM> in <CODE>nf</CODE> such that for all prime ideals <STRONG>p</STRONG> such that the valuation of x at <STRONG>p</STRONG> is non-zero, we have v_{<STRONG>p</STRONG>}(<EM>alpha</EM>)=v_{<STRONG>p</STRONG>}(x), and. v_{<STRONG>p</STRONG>}(<EM>alpha</EM>)&gt;=0 for all other {<STRONG>p</STRONG>}.

If <EM>flag</EM> 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 <EM>alpha</EM> such that for all prime ideals <STRONG>p</STRONG> occurring in x, v_{<STRONG>p</STRONG>}(<EM>alpha</EM>) is equal to the exponent of <STRONG>p</STRONG> in x, and for all other prime ideals, v_{<STRONG>p</STRONG>}(<EM>alpha</EM>)&gt;=0. This generalizes <CODE>idealappr</CODE>(<CODE>nf</CODE>,x,0) since zero exponents are allowed. Note that the algorithm used is slightly different, so that idealapp(<CODE>nf</CODE>,idealfactor(<CODE>nf</CODE>,x)) may not be the same as idealappr(<CODE>nf</CODE>,x,1).

X<idealappr0>The library syntax is idealappr0(<CODE>nf</CODE>,x,<EM>flag</EM>).


X<idealchinese>idealchinese<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

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 <CODE>nf</CODE> indexed by the ideals in x, computes an element b such that

v_<STRONG>p</STRONG>(b - y_<STRONG>p</STRONG>) &gt;= v_<STRONG>p</STRONG>(x) for all prime ideals in x and v_<STRONG>p</STRONG>(b)&gt;= 0 for all other <STRONG>p</STRONG>.

X<idealchinese>The library syntax is idealchinese(<CODE>nf</CODE>,x,y).


X<idealcoprime>idealcoprime<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

given two integral ideals x and y in the number field <CODE>nf</CODE>, finds a <EM>beta</EM> in the field, expressed on the integral basis <CODE>nf</CODE>[7], such that <EM>beta</EM> . y is an integral ideal coprime to x.

X<idealcoprime>The library syntax is idealcoprime(<CODE>nf</CODE>,x).


X<idealdiv>idealdiv<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

quotient x . y^{-1} of the two ideals x and y in the number field <CODE>nf</CODE>. The result is given in HNF.

If <EM>flag</EM> is non-zero, the quotient x . y^{-1} 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.

X<idealdiv0>The library syntax is idealdiv0(<CODE>nf</CODE>,x,y,<EM>flag</EM>). Also available are X<idealdividealdiv(nf,x,y)> (<EM>flag</EM>=0) and X<idealdivexactidealdivexact(nf,x,y)> (<EM>flag</EM>=1).


X<idealfactor>idealfactor<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

factors into prime ideal powers the ideal x in the number field <CODE>nf</CODE>. 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.

X<idealfactor>The library syntax is idealfactor(<CODE>nf</CODE>,x).


X<idealhnf>idealhnf<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,a,{b})</CODE>

gives the X<Hermite normal form>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 <STRONG><EM>Z</EM></STRONG>_K-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 a<STRONG><EM>Z</EM></STRONG>_K+b<STRONG><EM>Z</EM></STRONG>_K, where a and b are elements of K given either as vectors on the integral basis <CODE>nf</CODE>[7] or as algebraic numbers.

X<idealhnf0>The library syntax is idealhnf0(<CODE>nf</CODE>,a,b) where an omitted b is coded as NULL. Also available is X<idealhermiteidealhermite(nf,a)> (b omitted).


X<idealintersect>idealintersect<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

intersection of the two ideals x and y in the number field <CODE>nf</CODE>. When x and y are given by Z-bases, this does not depend on <CODE>nf</CODE> and can be used to compute the intersection of any two Z-modules. The result is given in HNF.

X<idealintersect>The library syntax is idealintersect(<CODE>nf</CODE>,x,y).


X<idealinv>idealinv<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

inverse of the ideal x in the number field <CODE>nf</CODE>. 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.

If <EM>flag</EM>=1, uses the different. This is usually slower.

X<idealinv0>The library syntax is idealinv0(<CODE>nf</CODE>,x,<EM>flag</EM>). Also available is X<idealinvidealinv(nf,x)> (<EM>flag</EM>=0).


X<ideallist>ideallist<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;bound&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=4})</CODE>

computes the list of all ideals of norm less or equal to bound in the number field nf. The result is a row vector with exactly bound components. Each component is itself a row vector containing the information about ideals of a given norm, in no specific order. This information can be either the HNF of the ideal or the idealstar with possibly some additional information.

If <EM>flag</EM> is present, its binary digits are toggles meaning

     1: give also the generators in the C<idealstar>.

     2: output C<[L,U]>, where C<L> is as before and C<U> is a vector of
C<zinternallogs> of the units.

     4: give only the ideals and not the C<idealstar> or the C<ideallog>
of the units.

X<ideallist0>The library syntax is ideallist0(<CODE>nf</CODE>,<CODE>bound</CODE>,<EM>flag</EM>), where bound must be a C long integer. Also available is X<ideallistideallist(nf,bound)>, corresponding to the case <EM>flag</EM>=0.


X<ideallistarch>ideallistarch<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;,{&lt;CODE&gt;arch&lt;/CODE&gt;=[ ]},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

vector of vectors of all idealstarinit (see idealstar) of all modules in list, with Archimedean part arch added (void if omitted). <EM>flag</EM> is optional; its binary digits are toggles meaning: 1: give generators as well, 2: list format is [L,U] (see ideallist).

X<ideallistarch0>The library syntax is ideallistarch0(<CODE>nf</CODE>,<A HREF="#item_list">list</A>,<CODE>arch</CODE>,<EM>flag</EM>), where an omitted arch is coded as NULL.


X<ideallog>ideallog<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;bid&lt;/CODE&gt;)</CODE>

<CODE>nf</CODE> being a number field, bid being a ``big ideal'' as output by idealstar and x being a non-necessarily integral element of nf which must have valuation equal to 0 at all prime ideals dividing I=<CODE>bid</CODE>[1], computes the ``discrete logarithm'' of x on the generators given in <CODE>bid</CODE>[2]. In other words, if g_i are these generators, of orders d_i respectively, the result is a column vector of integers (x_i) such that 0&lt;= x_i<d_i and x ~ <EM>prod</EM>_ig_i^{x_i}\pmod{ ^*I} . Note that when I is a module, this implies also sign conditions on the embeddings.

X<zideallog>The library syntax is zideallog(<CODE>nf</CODE>,x,<CODE>bid</CODE>).


X<idealmin>idealmin<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;vdir&lt;/CODE&gt;)</CODE>

computes a minimum of the ideal x in the direction vdir in the number field nf.

X<minideal>The library syntax is minideal(<CODE>nf</CODE>,x,<CODE>vdir</CODE>,<CODE>prec</CODE>).


X<idealmul>idealmul<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

ideal multiplication of the ideals x and y in the number field nf. The result is a generating set for the ideal product with at most n elements, and is in Hermite normal form if either x or y is in HNF or is a prime ideal as output by idealprimedec, and this is given together with the sum of the Archimedean information in x and y if both are given.

If <EM>flag</EM> is non-zero, reduce the result using idealred.

X<idealmul>The library syntax is idealmul(<CODE>nf</CODE>,x,y) (<EM>flag</EM>=0) or X<idealmulredidealmulred(nf,x,y,prec)> (<EM>flag</EM>!=0), where as usual, <CODE>prec</CODE> is a C long integer representing the precision.


X<idealnorm>idealnorm<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

computes the norm of the ideal x in the number field <CODE>nf</CODE>.

X<idealnorm>The library syntax is idealnorm(<CODE>nf</CODE>, x).


X<idealpow>idealpow<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,k,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

computes the k-th power of the ideal x in the number field <CODE>nf</CODE>. 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 <EM>flag</EM> is non-zero, reduce the result using idealred. Note however that this is NOT the same as as <CODE>idealpow</CODE>(<CODE>nf</CODE>,x,k) followed by reduction, since the reduction is performed throughout the powering process.

The library syntax corresponding to <EM>flag</EM>=0 is X<idealpowidealpow(nf,x,k)>. If k is a long, you can use X<idealpowsidealpows(nf,x,k)>. Corresponding to <EM>flag</EM>=1 is X<idealpowredidealpowred(nf,vp,k,prec)>, where <CODE>prec</CODE> is a long.


X<idealprimedec>idealprimedec<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,p)</CODE>

computes the prime ideal decomposition of the prime number p in the number field <CODE>nf</CODE>. p must be a (positive) prime number. Note that the fact that p is prime is not checked, so if a non-prime number p is given it may lead to unpredictable results.

The result is a vector of 5-component vectors, each representing one of the prime ideals above p in the number field <CODE>nf</CODE>. The representation vp=[p,a,e,f,b] of a prime ideal means the following. The prime ideal is equal to p<STRONG><EM>Z</EM></STRONG>_K+<EM>alpha</EM><STRONG><EM>Z</EM></STRONG>_K where <STRONG><EM>Z</EM></STRONG>_K is the ring of integers of the field and <EM>alpha</EM>=<EM>sum</EM>_i a_i<EM>omega</EM>_i where the <EM>omega</EM>_i form the integral basis <CODE>nf</CODE>.zk, e is the ramification index, f is the residual index, and b is an n-component column vector representing a <EM>beta</EM>\in<STRONG><EM>Z</EM></STRONG>_K such that vp^{-1}=<STRONG><EM>Z</EM></STRONG>_K+<EM>beta</EM>/p<STRONG><EM>Z</EM></STRONG>_K which will be useful for computing valuations, but which the user can ignore. The number <EM>alpha</EM> is guaranteed to have a valuation equal to 1 at the prime ideal (this is automatic if e&gt;1).

X<idealprimedec>The library syntax is idealprimedec(<CODE>nf</CODE>,p).


X<idealprincipal>idealprincipal<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

creates the principal ideal generated by the algebraic number x (which must be of type integer, rational or polmod) in the number field <CODE>nf</CODE>. The result is a one-column matrix.

X<principalideal>The library syntax is principalideal(<CODE>nf</CODE>,x).


X<idealred>idealred<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,{&lt;CODE&gt;vdir&lt;/CODE&gt;=0})</CODE>

X< LLL>LLL reduction of the ideal x in the number field nf, along the direction vdir. Here vdir must be either an r1+r2-component vector (r1 and r2 number of real and complex places of nf as usual), or the PARI zero, in which case vdir is assumed to be equal to the vector having only components equal to 1. The notion of reduction along a direction is technical and cannot be explained here. Note that this is not the same as the LLL reduction of the lattice x since ideal operations are involved. The result is the X<Hermite normal form>Hermite normal form of the LLL-reduced ideal, which is usually, but not always, a reduced ideal. x may also be a 2-component vector, the first being as above, and the second containing a matrix of Archimedean information. In that case, this matrix is suitably updated.

X<ideallllred>The library syntax is ideallllred(<CODE>nf</CODE>,x,<CODE>vdir</CODE>,<CODE>prec</CODE>).


X<idealstar>idealstar<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,I,{&lt;EM&gt;flag&lt;/EM&gt;=1})</CODE>

nf being a number field, and I either and ideal in any form, or a row vector whose first component is an ideal and whose second component is a row vector of r_1 0 or 1, outputs necessary data for computing in the group (<STRONG><EM>Z</EM></STRONG>_K/I)^*.

If <EM>flag</EM>=2, the result is a 5-component vector w. w[1] is the ideal or module I itself. w[2] is the structure of the group. The other components are difficult to describe and are used only in conjunction with the function ideallog.

If <EM>flag</EM>=1 (default), as <EM>flag</EM>=2, but do not compute explicit generators for the cyclic components, which saves time.

If <EM>flag</EM>=0, computes the structure of (<STRONG><EM>Z</EM></STRONG>_K/I)^* as a 3-component vector v. v[1] is the order, v[2] is the vector of SNFX<Smith normal form> cyclic components and v[3] the corresponding generators. When the row vector is explicitly included, the non-zero elements of this vector are considered as real embeddings of nf in the order given by polroots, i.e. in nf[6] (<CODE>nf</CODE>.roots), and then I is a module with components at infinity.

To solve discrete logarithms (using ideallog), you have to choose <EM>flag</EM>=2.

X<idealstar0>The library syntax is idealstar0(<CODE>nf</CODE>,I,<EM>flag</EM>).


X<idealtwoelt>idealtwoelt<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,{a})</CODE>

computes a two-element representation of the ideal x in the number field <CODE>nf</CODE>, 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,<EM>alpha</EM>] with two components such that x=a<STRONG><EM>Z</EM></STRONG>_K+<EM>alpha</EM><STRONG><EM>Z</EM></STRONG>_K and a\in<STRONG><EM>Z</EM></STRONG>, 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 x\cap<STRONG><EM>Z</EM></STRONG>.

Note that when an explicit a is given, we use an asymptotically faster method, however in practice it is usually slower.

X<ideal_two_elt0>The library syntax is ideal_two_elt0(<CODE>nf</CODE>,x,a), where an omitted a is entered as NULL.


X<idealval>idealval<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;vp&lt;/CODE&gt;)</CODE>

gives the valuation of the ideal x at the prime ideal vp in the number field <CODE>nf</CODE>, where vp must be a 5-component vector as given by idealprimedec.

X<idealval>The library syntax is idealval(<CODE>nf</CODE>,x,<CODE>vp</CODE>), and the result is a long integer.


X<ideleprincipal>ideleprincipal<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

creates the principal idele generated by the algebraic number x (which must be of type integer, rational or polmod) in the number field <CODE>nf</CODE>. 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_1+r_2 components giving the complex logarithmic embedding of x.

X<principalidele>The library syntax is principalidele(<CODE>nf</CODE>,x).


X<matalgtobasis>matalgtobasis<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

<CODE>nf</CODE> being a number field in nfinit format, and x a matrix whose coefficients are expressed as polmods in <CODE>nf</CODE>, transforms this matrix into a matrix whose coefficients are expressed on the integral basis of <CODE>nf</CODE>. This is the same as applying nfalgtobasis to each entry, but it would be dangerous to use the same name.

X<matalgtobasis>The library syntax is matalgtobasis(<CODE>nf</CODE>,x).


X<matbasistoalg>matbasistoalg<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

<CODE>nf</CODE> being a number field in nfinit format, and x a matrix whose coefficients are expressed as column vectors on the integral basis of <CODE>nf</CODE>, transforms this matrix into a matrix whose coefficients are algebraic numbers expressed as polmods. This is the same as applying nfbasistoalg to each entry, but it would be dangerous to use the same name.

X<matbasistoalg>The library syntax is matbasistoalg(<CODE>nf</CODE>,x).


X<modreverse>modreverse<CODE>(a)</CODE>

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 <EM>theta</EM> is a root of T then <EM>theta</EM>=B(<EM>alpha</EM>) for a certain root <EM>alpha</EM> of Q.

This is very useful when one changes the generating element in algebraic extensions.

X<polmodrecip>The library syntax is polmodrecip(x).


X<newtonpoly>newtonpoly<CODE>(x,p)</CODE>

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 (2^{31}-1 (resp. 2^{63}-1) on 32-bit (resp. 64-bit) machines), see Label se:valuation.

X<newtonpoly>The library syntax is newtonpoly(x,p).


X<nfalgtobasis>nfalgtobasis<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

this is the inverse function of nfbasistoalg. Given an object x whose entries are expressed as algebraic numbers in the number field <CODE>nf</CODE>, transforms it so that the entries are expressed as a column vector on the integral basis <CODE>nf</CODE>.zk.

X<algtobasis>The library syntax is algtobasis(<CODE>nf</CODE>,x).


X<nfbasis>nfbasis<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0},{p})</CODE>

X<integral basis>integral basis of the number field defined by the irreducible, preferably monic, polynomial x, using the X<round 4>round 4 algorithm by default. (This program is the translation into C by Pascal Letard of a program written by David X< Ford>Ford in Maple.) The binary digits of <EM>flag</EM> have the following meaning:

1: assume that no square of a prime greater than the default primelimit divides the discriminant of x, i.e. that the index of x has only small prime divisors.

2: use X<round 2>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 X<Ford>Ford in Algeb.)

Thus for instance, if <EM>flag</EM>=3, this uses the round 2 algorithm and outputs an order which will be maximal at all the small primes.

If p is present, we assume (without checking!) that it is the two-column matrix of the factorization 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.

X<nfbasis0>The library syntax is nfbasis0(x,<EM>flag</EM>,p). An extended version is X<nfbasisnfbasis(x,&d,flag,p)>, where d will receive the discriminant of the number field (not of the polynomial x), and an omitted p should be input as gzero. Also available are X<basebase(x,&d)> (<EM>flag</EM>=0), X<base2base2(x,&d)> (<EM>flag</EM>=2) and X<factoredbasefactoredbase(x,p,&d)>.


X<nfbasistoalg>nfbasistoalg<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

this is the inverse function of nfalgtobasis. Given an object x whose entries are expressed on the integral basis <CODE>nf</CODE>.zk, transforms it into an object whose entries are algebraic numbers (i.e. polmods).

X<basistoalg>The library syntax is basistoalg(<CODE>nf</CODE>,x).


X<nfdetint>nfdetint<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

given a pseudo-matrix x, computes a non-zero ideal contained in (i.e. multiple of) the determinant of x. This is particularly useful in conjunction with nfhnfmod.

X<nfdetint>The library syntax is nfdetint(<CODE>nf</CODE>,x).


X<nfdisc>nfdisc<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0},{p})</CODE>

X<field discriminant>field discriminant of the number field defined by the integral, preferably monic, irreducible polynomial x. <EM>flag</EM> and p are exactly as in nfbasis. That is, p provides the matrix of a partial factorization of the discriminant of x, and binary digits of <EM>flag</EM> 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 X<round 4>round 4. This should be slower except maybe for polynomials of small degree and coefficients.

X<nfdiscf0>The library syntax is nfdiscf0(x,<EM>flag</EM>,p) where, to omit p, you should input gzero. You can also use X<discfdiscf(x)> (<EM>flag</EM>=0).


X<nfeltdiv>nfeltdiv<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

given two elements x and y in nf, computes their quotient x/y in the number field <CODE>nf</CODE>.

X<element_div>The library syntax is element_div(<CODE>nf</CODE>,x,y).


X<nfeltdiveuc>nfeltdiveuc<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

given two elements x and y in nf, computes an algebraic integer q in the number field <CODE>nf</CODE> such that the components of x-qy are reasonably small. In fact, this is functionally identical to round(nfeltdiv(<CODE>nf</CODE>,x,y)).

X<nfdiveuc>The library syntax is nfdiveuc(<CODE>nf</CODE>,x,y).


X<nfeltdivmodpr>nfeltdivmodpr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

given two elements x and y in nf and pr a prime ideal in modpr format (see X<nfmodprinit>nfmodprinit), computes their quotient x / y modulo the prime ideal pr.

X<element_divmodpr>The library syntax is element_divmodpr(<CODE>nf</CODE>,x,y,<CODE>pr</CODE>).


X<nfeltdivrem>nfeltdivrem<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

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 <CODE>nf</CODE>, and the components of r are reasonably small.

X<nfdivres>The library syntax is nfdivres(<CODE>nf</CODE>,x,y).


X<nfeltmod>nfeltmod<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

given two elements x and y in nf, computes an element r of <CODE>nf</CODE> of the form r=x-qy with q and algebraic integer, and such that r is small. This is functionally identical to <CODE>x - nfeltmul(&lt;CODE&gt;nf&lt;/CODE&gt;,round(nfeltdiv(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)),y)</CODE>.

X<nfmod>The library syntax is nfmod(<CODE>nf</CODE>,x,y).


X<nfeltmul>nfeltmul<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y)</CODE>

given two elements x and y in nf, computes their product x*y in the number field <CODE>nf</CODE>.

X<element_mul>The library syntax is element_mul(<CODE>nf</CODE>,x,y).


X<nfeltmulmodpr>nfeltmulmodpr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,y,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

given two elements x and y in nf and pr a prime ideal in modpr format (see X<nfmodprinit>nfmodprinit), computes their product x*y modulo the prime ideal pr.

X<element_mulmodpr>The library syntax is element_mulmodpr(<CODE>nf</CODE>,x,y,<CODE>pr</CODE>).


X<nfeltpow>nfeltpow<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,k)</CODE>

given an element x in nf, and a positive or negative integer k, computes x^k in the number field <CODE>nf</CODE>.

X<element_pow>The library syntax is element_pow(<CODE>nf</CODE>,x,k).


X<nfeltpowmodpr>nfeltpowmodpr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,k,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

given an element x in nf, an integer k and a prime ideal pr in modpr format (see X<nfmodprinit>nfmodprinit), computes x^k modulo the prime ideal pr.

X<element_powmodpr>The library syntax is element_powmodpr(<CODE>nf</CODE>,x,k,<CODE>pr</CODE>).


X<nfeltreduce>nfeltreduce<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;ideal&lt;/CODE&gt;)</CODE>

given an ideal in Hermite normal form and an element x of the number field <CODE>nf</CODE>, finds an element r in <CODE>nf</CODE> such that x-r belongs to the ideal and r is small.

X<element_reduce>The library syntax is element_reduce(<CODE>nf</CODE>,x,<CODE>ideal</CODE>).


X<nfeltreducemodpr>nfeltreducemodpr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

given an element x of the number field <CODE>nf</CODE> and a prime ideal pr in modpr format compute a canonical representative for the class of x modulo pr.

X<nfreducemodpr2>The library syntax is nfreducemodpr2(<CODE>nf</CODE>,x,<CODE>pr</CODE>).


X<nfeltval>nfeltval<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

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(<CODE>nf</CODE>,x,<CODE>pr</CODE>) (since x would then be converted to a principal ideal), but it would be less efficient.

X<element_val>The library syntax is element_val(<CODE>nf</CODE>,x,<CODE>pr</CODE>), and the result is a long.


nf{}factor

(<CODE>nf</CODE>,x): factorization of the univariate polynomial x over the number field <CODE>nf</CODE> given by nfinit. x has coefficients in <CODE>nf</CODE> (i.e. either scalar, polmod, polynomial or column vector). The main variable of <CODE>nf</CODE> must be of lower priority than that of x (in other words, the variable number of <CODE>nf</CODE> must be greater than that of x). However if the polynomial defining the number field occurs explicitly in the coefficients of x (as modulus of a t_POLMOD), its main variable must be the same as the main variable of x. For example, if <CODE>nf</CODE>={<CODE>nfinit(y^ 2+1)</CODE>} then {nffactor(<CODE>nf</CODE>,x^ 2+Mod(y,y^ 2+1))} and {nffactor(<CODE>nf</CODE>,x^ 2+1)} are both legal but {nffactor(<CODE>nf</CODE>,x^ 2+Mod(z,z^ 2+1))} is not.

\sidx{nf{}factor}The library syntax is nf{}factor(<CODE>nf</CODE>,x).


nf{}factormod

(<CODE>nf</CODE>,x,<CODE>pr</CODE>): factorization of the univariate polynomial x modulo the prime ideal pr in the number field <CODE>nf</CODE>. x can have coefficients in the number field (scalar, polmod, polynomial, column vector) or modulo the prime ideal (integermod modulo the rational prime under pr, polmod or polynomial with integermod coefficients, column vector of integermod). The prime ideal pr must be in the format output by idealprimedec. The main variable of <CODE>nf</CODE> must be of lower priority than that of x (in other words the variable number of <CODE>nf</CODE> must be greater than that of x). However if the coefficients of the number field occur explicitly (as polmods) as coefficients of x, the variable of these polmods must be the same as the main variable of t (see nffactor).

\sidx{nf{}factormod}The library syntax is nf{}factormod(<CODE>nf</CODE>,x,<CODE>pr</CODE>).


X<nfgaloisapply>nfgaloisapply<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;aut&lt;/CODE&gt;,x)</CODE>

<CODE>nf</CODE> being a number field as output by nfinit, and aut being a X<Galois>Galois automorphism of <CODE>nf</CODE> 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 given by <STRONG><EM>Z</EM></STRONG>_K-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.

X<galoisapply>The library syntax is galoisapply(<CODE>nf</CODE>,<CODE>aut</CODE>,x).


X<nfgaloisconj>nfgaloisconj<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0},{d})</CODE>

<CODE>nf</CODE> being a number field as output by nfinit, computes the conjugates of a root r of the non-constant polynomial x=<CODE>nf</CODE>[1] expressed as polynomials in r. This can be used even if the number field <CODE>nf</CODE> is not X<Galois>Galois since some conjugates may lie in the field. As a note to old-timers of PARI, starting with version 2.0.14 this function works much better than in earlier versions.

If <EM>flag</EM>=2, as <EM>flag</EM>=0, but using complex approximations to the roots and an integral X<LLL>LLL. The result is not guaranteed to be complete: some conjugates may be missing (especially so if the corresponding polynomial has a huge denominator). In that case, increasing the default precision may help.

If <EM>flag</EM>=3, as <EM>flag</EM>=2, but nf is allowed to be a polynomial.

If <EM>flag</EM>=4, checks whether the Galois group is weakly super solvable, that is contains a super solvable normal subgroup H such that G=H or G/H = A_4. (In particular, G abelian is accepted !) If not, returns 0. If it is, computes the conjugates using a generalisation of Kl\``uners's algorithm due to Allombert (result is guaranteed, nf can be a polynomial). If present, d is assumed to be a multiple of the index of the power basis in the maximal order (used if nf is a polynomial). This method is much faster than the default when it can be applied.

In practice, most groups of small order are weakly super solvable, the exceptions having order 24(1 exception), 36(1), 48(6), 56(1), 60(1), 72(8), 75(1), 80(1), 96(25) and &gt;= 100. Hence <EM>flag</EM> = 4 permits to quickly check whether a polynomial is Galois or not.

X<galoisconj0>The library syntax is galoisconj0(<CODE>nf</CODE>,<EM>flag</EM>,d,<CODE>prec</CODE>).


X<nfhilbert>nfhilbert<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,a,b,{&lt;CODE&gt;pr&lt;/CODE&gt;})</CODE>

if pr is omitted, compute the global X<Hilbert symbol>Hilbert symbol (a,b) in <CODE>nf</CODE>, that is 1 if x^2 - a y^2 - b z^2 has a non trivial solution (x,y,z) in <CODE>nf</CODE>, and -1 otherwise. Otherwise compute the local symbol modulo the prime ideal pr (as output by idealprimedec).

X<nfhilbert>The library syntax is nfhilbert(<CODE>nf</CODE>,a,b,<CODE>pr</CODE>), where an omitted pr is coded as NULL.


X<nfhnf>nfhnf<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

given a pseudo-matrix (A,I), finds a pseudo-basis in X<Hermite normal form>Hermite normal form of the module it generates.

X<nfhermite>The library syntax is nfhermite(<CODE>nf</CODE>,x).


X<nfhnfmod>nfhnfmod<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x,&lt;CODE&gt;detx&lt;/CODE&gt;)</CODE>

given a pseudo-matrix (A,I) and an ideal detx which is contained in (read integral multiple of) the determinant of (A,I), finds a pseudo-basis in X<Hermite normal form>Hermite normal form of the module generated by (A,I). This avoids coefficient explosion. detx can be computed using the function nfdetint.

X<nfhermitemod>The library syntax is nfhermitemod(<CODE>nf</CODE>,x,<CODE>detx</CODE>).


nf{}init

(<CODE>pol</CODE>,{<EM>flag</EM>=0}): pol being a non-constant, preferably monic, irreducible polynomial in <STRONG><EM>Z</EM></STRONG>[X], computes a 9-component vector nf useful in working in the number field K defined by pol.

<CODE>nf</CODE>[1] contains the polynomial pol (<CODE>nf</CODE>.pol).

<CODE>nf</CODE>[2] contains [r1,r2] (<CODE>nf</CODE>.sign), the number of real and complex places of K.

<CODE>nf</CODE>[3] contains the discriminant d(K) (<CODE>nf</CODE>.disc) of the number field K.

<CODE>nf</CODE>[4] contains the index of <CODE>nf</CODE>[1], i.e. [<STRONG><EM>Z</EM></STRONG>_K:<STRONG><EM>Z</EM></STRONG>[<EM>theta</EM>]], where <EM>theta</EM> is any root of <CODE>nf</CODE>[1].

<CODE>nf</CODE>[5] is a vector containing 7 matrices M, MC, T2, T, MD, TI, MDI useful for certain computations in the number field K.

\quad--- M is the (r1+r2)\times n matrix whose columns represent the numerical values of the conjugates of the elements of the integral basis.

\quad--- MC is essentially the conjugate of the transpose of M, except that the last r2 columns are also multiplied by 2.

\quad--- T2 is an n\times n matrix equal to the real part of the product MC . M (which is a real positive definite symmetric matrix), the so-called T_2-matrix (<CODE>nf</CODE>.t2).

\quad--- T is the n\times n matrix whose coefficients are Tr(<EM>omega</EM>_i<EM>omega</EM>_j) where the <EM>omega</EM>_i are the elements of the integral basis. Note that T=\overline{MC} . M and in particular that T=T_2 if the field is totally real (in practice T_2 will have real approximate entries and T will have integer entries). Note also that <PRE> F&lt;det&gt; (T) </PRE> is equal to the discriminant of the field K.

\quad--- The columns of MD (<CODE>nf</CODE>.diff) express a Z-basis of the different of K on the integral basis.

\quad--- TI is equal to d(K)T^{-1}, which has integral coefficients.

\quad--- Finally, MDI has the form [x,y,n], where (x,y) expresses a <STRONG><EM>Z</EM></STRONG>_K-basis of d(K) times the codifferent ideal (<CODE>nf</CODE>.disc<CODE>*</CODE><CODE>nf</CODE>.codiff, which is an integral ideal) and n is its norm (this ideal is used in X<idealinv>idealinv).

<CODE>nf</CODE>[6] is the vector containing the r1+r2 roots (<CODE>nf</CODE>.roots) of <CODE>nf</CODE>[1] corresponding to the r1+r2 embeddings of the number field into C (the first r1 components are real, the next r2 have positive imaginary part).

<CODE>nf</CODE>[7] is an integral basis in Hermite normal form for <STRONG><EM>Z</EM></STRONG>_K (<CODE>nf</CODE>.zk) expressed on the powers of <EM>theta</EM>.

<CODE>nf</CODE>[8] is the n\times n integral matrix expressing the power basis in terms of the integral basis, and finally

<CODE>nf</CODE>[9] is the n\times n^2 matrix giving the multiplication table of the integral basis.

If a non monic polynomial is input, nfinit will transform it into a monic one, then reduce it (see <EM>flag</EM>=3). It is allowed, though not very useful given the existence of X<nfnewprec>nfnewprec, to input a nf or a bnf instead of a polynomial.

The special input format [x,B] is also accepted where x is a polynomial as above and B is the integer basis, as computed by X<nfbasis>nfbasis. This can be useful since nfinit uses the round 4 algorithm by default, which can be very slow in pathological cases where round 2 (nfbasis(x,2)) would succeed very quickly.

If <EM>flag</EM>=1: does not compute the different, replace it by a dummy 0.

If <EM>flag</EM>=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 <EM>flag</EM>=3, does a polred as in case 2, but outputs [<CODE>nf</CODE>,<CODE>Mod</CODE>(a,P)], where <CODE>nf</CODE> is as before and <CODE>Mod</CODE>(a,P)=<CODE>Mod</CODE>(x,<CODE>pol</CODE>) 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 <EM>flag</EM>=4, as 2 but uses a partial polred.

If <EM>flag</EM>=5, as 3 using a partial polred.

\sidx{nf{}init0}The library syntax is nf{}init0(x,<EM>flag</EM>,<CODE>prec</CODE>).


nf{}isideal

(<CODE>nf</CODE>,x): returns 1 if x is an ideal in the number field <CODE>nf</CODE>, 0 otherwise.

X<isideal>The library syntax is isideal(x).


nf{}isincl

(x,y): tests whether the number field K defined by the polynomial x is conjugate to a subfield of the field L defined by y (where x and y must be in <STRONG><EM>Q</EM></STRONG>[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 | x\circ a.

If y is a number field (nf), a much faster algorithm is used (factoring x over y using X<nffactor>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.

\sidx{nf{}isincl}The library syntax is nf{}isincl(x,y,<EM>flag</EM>).


nf{}isisom

(x,y): as X<nfisincl>nfisincl, but tests for isomorphism. If either x or y is a number field, a much faster algorithm will be used.

\sidx{nf{}isisom}The library syntax is nf{}isisom(x,y,<EM>flag</EM>).


X<nfnewprec>nfnewprec<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;)</CODE>

transforms the number field <CODE>nf</CODE> into the corresponding data using current (usually larger) precision. This function works as expected if <CODE>nf</CODE> is in fact a <CODE>bnf</CODE> (update <CODE>bnf</CODE> to current precision) but may be quite slow (many generators of principal ideals have to be computed).

X<nfnewprec>The library syntax is nfnewprec(<CODE>nf</CODE>,<CODE>prec</CODE>).


X<nfkermodpr>nfkermodpr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,a,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

kernel of the matrix a in <STRONG><EM>Z</EM></STRONG>_K/<CODE>pr</CODE>, where pr is in modpr format (see nfmodprinit).

X<nfkermodpr>The library syntax is nfkermodpr(<CODE>nf</CODE>,a,<CODE>pr</CODE>).


X<nfmodprinit>nfmodprinit<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

transforms the prime ideal pr into X<modpr>modpr format necessary for all operations modulo pr in the number field nf. Returns a two-component vector [P,a], where P is the X<Hermite normal form>Hermite normal form of pr, and a is an integral element congruent to 1 modulo pr, and congruent to 0 modulo p / pr^e. Here p = <STRONG><EM>Z</EM></STRONG> \cap <CODE>pr</CODE> and e is the absolute ramification index.X<Label se:nfmodprinit>

X<nfmodprinit>The library syntax is nfmodprinit(<CODE>nf</CODE>,<CODE>pr</CODE>).


X<nfsubfields>nfsubfields<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,{d=0})</CODE>

finds all subfields of degree d of the number field <CODE>nf</CODE> (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 <CODE>nf</CODE>. This is a crude implementation by M. Olivier of an algorithm due to J. Kl\``uners.

X<subfields>The library syntax is subfields(<CODE>nf</CODE>,d).


X<nfroots>nfroots<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

roots of the polynomial x in the number field <CODE>nf</CODE> given by nfinit without multiplicity. x has coefficients in the number field (scalar, polmod, polynomial, column vector). The main variable of <CODE>nf</CODE> must be of lower priority than that of x (in other words the variable number of <CODE>nf</CODE> must be greater than that of x). However if the coefficients of the number field occur explicitly (as polmods) as coefficients of x, the variable of these polmods must be the same as the main variable of t (see nffactor).

X<nfroots>The library syntax is nfroots(<CODE>nf</CODE>,x).


X<nfrootsof1>nfrootsof1<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;)</CODE>

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 <CODE>nf</CODE>. 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 <CODE>nf</CODE>.zk.

X<rootsof1>The library syntax is rootsof1(<CODE>nf</CODE>).


X<nfsnf>nfsnf<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

given a torsion module x as a 3-component row vector [A,I,J] where A is a square invertible n\times n matrix, I and J are two ideal lists, outputs an ideal list d_1,...,d_n which is the X<Smith normal form>Smith normal form of x. In other words, x is isomorphic to <STRONG><EM>Z</EM></STRONG>_K/d_1\oplus...\oplus<STRONG><EM>Z</EM></STRONG>_K/d_n and d_i divides d_{i-1} for i&gt;=2. The link between x and [A,I,J] is as follows: if e_i is the canonical basis of K^n, I=[b_1,...,b_n] and J=[a_1,...,a_n], then x is isomorphic to <PRE> (b_1e_1\oplus...\oplus b_ne_n) / (a_1A_1\oplus...\oplus a_nA_n) , </PRE> where the A_j are the columns of the matrix A. Note that every finitely generated torsion module can be given in this way, and even with b_i=Z_K for all i.

X<nfsmith>The library syntax is nfsmith(<CODE>nf</CODE>,x).


X<nfsolvemodpr>nfsolvemodpr<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,a,b,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

solution of a . x = b in <STRONG><EM>Z</EM></STRONG>_K/<CODE>pr</CODE>, where a is a matrix and b a column vector, and where pr is in modpr format (see nfmodprinit).

X<nfsolvemodpr>The library syntax is nfsolvemodpr(<CODE>nf</CODE>,a,b,<CODE>pr</CODE>).


X<polcompositum>polcompositum<CODE>(x,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

x and y being polynomials in <STRONG><EM>Z</EM></STRONG>[x] in the same variable, outputs a vector giving the list of all possible composita of the number fields defined by x and y, if x and y are irreducible, or of the corresponding \'etale algebras, if they are only squarefree. Returns an error if one of the polynomials is not squarefree.

If <EM>flag</EM>=1, outputs a vector of 4-component vectors [z,a,b,k], where z ranges through the list of all possible compositums as above, and a (resp. b) expresses the root of x (resp. y) as a polmod in a root of z, and k is a small integer k such that a+kb is the chosen root of z.

X<polcompositum0>The library syntax is polcompositum0(x,y,<EM>flag</EM>).


X<polgalois>polgalois<CODE>(x)</CODE>

X<Galois>Galois group of the non-constant polynomial x\in<STRONG><EM>Q</EM></STRONG>[X]. In the present version \vers, x must be irreducible and the degree of x must be less than or equal to 7. On certain versions for which the data file of Galois resolvents has been installed (available in the Unix distribution as a separate package), degrees 8, 9, 10 and 11 are also implemented.

The output is a 3-component vector [n,s,k] with the following meaning: n is the cardinality of the group, s is its signature (s=1 if the group is a subgroup of the alternating group A_n, s=-1 otherwise), and k is the number of the group corresponding to a given pair (n,s) (k=1 except in 2 cases). Specifically, the groups are coded as follows, using standard notations (see GTM 138, quoted at the beginning of this section):

In degree 1: S_1=[1,-1,1].

In degree 2: S_2=[2,-1,1].

In degree 3: A_3=C_3=[3,1,1], S_3=[6,-1,1].

In degree 4: C_4=[4,-1,1], V_4=[4,1,1], D_4=[8,-1,1], A_4=[12,1,1], S_4=[24,-1,1].

In degree 5: C_5=[5,1,1], D_5=[10,1,1], M_{20}=[20,-1,1], A_5=[60,1,1], S_5=[120,-1,1].

In degree 6: C_6=[6,-1,1], S_3=[6,-1,2], D_6=[12,-1,1], A_4=[12,1,1], G_{18}=[18,-1,1], S_4^-=[24,-1,1], A_4\times C_2=[24,-1,2], S_4^+=[24,1,1], G_{36}^-=[36,-1,1], G_{36}^+=[36,1,1], S_4\times C_2=[48,-1,1], A_5=PSL_2(5)=[60,1,1], G_{72}=[72,-1,1], S_5=PGL_2(5)=[120,-1,1], A_6=[360,1,1], S_6=[720,-1,1].

In degree 7: C_7=[7,1,1], D_7=[14,-1,1], M_{21}=[21,1,1], M_{42}=[42,-1,1], PSL_2(7)=PSL_3(2)=[168,1,1], A_7=[2520,1,1], S_7=[5040,-1,1].

The method used is that of resolvent polynomials.

X<galois>The library syntax is galois(x,<CODE>prec</CODE>).


X<polred>polred<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0},{p})</CODE>

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 X<nfinit>nfinit are also allowed here (e.g. non-monic polynomials, nf, bnf, [x,Z_K_basis]).

The following binary digits of <EM>flag</EM> are significant:

1: does a partial reduction only. This means that only a suborder of the maximal order may be used.

2: gives also elements. The result is a two-column matrix, the first column giving the elements defining these subfields, the second giving the corresponding minimal polynomials.

If p is given, it is assumed that it is the two-column matrix of the factorization of the discriminant of the polynomial x.

X<polred0>The library syntax is polred0(x,<EM>flag</EM>,p,<CODE>prec</CODE>), where an omitted p is coded by gzero. Also available are X<polredpolred(x,prec)> and X<factoredpolredfactoredpolred(x,p,prec)>, both corresponding to <EM>flag</EM>=0.


X<polredabs>polredabs<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

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 T_2-norm) is minimal. All x accepted by X<nfinit>nfinit are also allowed here (e.g. non-monic polynomials, nf, bnf, [x,Z_K_basis]).

The binary digits of <EM>flag</EM> 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_2 norm (of the two polynomials P(x) and P(-x), only one is given).

X<polredabs0>The library syntax is polredabs0(x,<EM>flag</EM>,<CODE>prec</CODE>).


X<polredord>polredord<CODE>(x)</CODE>

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)^n, where n is the degree), and another always defines the same order as x if x is irreducible.

X<ordred>The library syntax is ordred(x).


X<poltschirnhaus>poltschirnhaus<CODE>(x)</CODE>

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 \'etale algebra defined by x. This is for instance useful when computing resolvents, hence is used by the polgalois function.

X<tschirnhaus>The library syntax is tschirnhaus(x).


X<rnfalgtobasis>rnfalgtobasis<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x)</CODE>

<CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an element of L expressed as a polynomial or polmod with polmod coefficients, expresses x on the relative integral basis.

X<rnfalgtobasis>The library syntax is rnfalgtobasis(<CODE>rnf</CODE>,x).


X<rnfbasis>rnfbasis<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,x)</CODE>

given a big number field <CODE>bnf</CODE> as output by bnfinit, and either a polynomial x with coefficients in <CODE>bnf</CODE> defining a relative extension L of <CODE>bnf</CODE>, or a pseudo-basis x of such an extension, gives either a true <CODE>bnf</CODE>-basis of L if it exists, or an n+1-element generating set of L if not, where n is the rank of L over <CODE>bnf</CODE>.

X<rnfbasis>The library syntax is rnfbasis(<CODE>bnf</CODE>,x).


X<rnfbasistoalg>rnfbasistoalg<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x)</CODE>

<CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an element of L expressed on the relative integral basis, computes the representation of x as a polmod with polmods coefficients.

X<rnfbasistoalg>The library syntax is rnfbasistoalg(<CODE>rnf</CODE>,x).


X<rnfcharpoly>rnfcharpoly<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,T,a,{v=x})</CODE>

characteristic polynomial of a over <CODE>nf</CODE>, where a belongs to the algebra defined by T over <CODE>nf</CODE>, i.e. <CODE>nf</CODE>[X]/(T). Returns a polynomial in variable v (x by default).

X<rnfcharpoly>The library syntax is rnfcharpoly(<CODE>nf</CODE>,T,a,v), where v is a variable number.


X<rnfconductor>rnfconductor<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

<CODE>bnf</CODE> being a big number field as output by bnfinit, and pol a relative polynomial defining an X<Abelian extension>Abelian extension, computes the class field theory conductor of this Abelian extension. The result is a 3-component vector [<CODE>conductor</CODE>,<CODE>rayclgp</CODE>,<CODE>subgroup</CODE>], where conductor is the conductor of the extension given as a 2-component row vector [f_0,f_<EM>infty</EM>], 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.

X<rnfconductor>The library syntax is rnfconductor(<CODE>rnf</CODE>,<CODE>pol</CODE>,<CODE>prec</CODE>).


X<rnfdedekind>rnfdedekind<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;,&lt;CODE&gt;pr&lt;/CODE&gt;)</CODE>

given a number field <CODE>nf</CODE> as output by nfinit and a polynomial pol with coefficients in <CODE>nf</CODE> defining a relative extension L of <CODE>nf</CODE>, evaluates the relative X<Dedekind>Dedekind criterion over the order defined by a root of pol for the prime ideal pr and outputs a 3-component vector as the result. The first component is a flag equal to 1 if the enlarged order is pr-maximal and to 0 otherwise, the second component is a pseudo-basis of the enlarged order and the third component is the valuation at pr of the order discriminant.

X<rnfdedekind>The library syntax is rnfdedekind(<CODE>nf</CODE>,<CODE>pol</CODE>,<CODE>pr</CODE>).


X<rnfdet>rnfdet<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,M)</CODE>

given a pseudomatrix M over the maximal order of <CODE>nf</CODE>, computes its pseudodeterminant.

X<rnfdet>The library syntax is rnfdet(<CODE>nf</CODE>,M).


X<rnfdisc>rnfdisc<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

given a number field <CODE>nf</CODE> as output by nfinit and a polynomial pol with coefficients in <CODE>nf</CODE> defining a relative extension L of <CODE>nf</CODE>, computes the relative discriminant of L. 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 <CODE>nf</CODE>^*/{<CODE>nf</CODE>^*}^2. The main variable of <CODE>nf</CODE> must be of lower priority than that of pol.

Note: As usual, <CODE>nf</CODE> can be a <CODE>bnf</CODE> as output by nfinit.

X<rnfdiscf>The library syntax is rnfdiscf(<CODE>bnf</CODE>,<CODE>pol</CODE>).


X<rnfeltabstorel>rnfeltabstorel<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x)</CODE>

<CODE>rnf</CODE> 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 <CODE>rnf</CODE>[11][1], computes x as an element of the relative extension L/K as a polmod with polmod coefficients.

X<rnfelementabstorel>The library syntax is rnfelementabstorel(<CODE>rnf</CODE>,x).


X<rnfeltdown>rnfeltdown<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x)</CODE>

<CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an element of L expressed as a polynomial or polmod with polmod coefficients, computes x as an element of K as a polmod, assuming x is in K (otherwise an error will occur). If x is given on the relative integral basis, apply rnfbasistoalg first, otherwise PARI will believe you are dealing with a vector.

X<rnfelementdown>The library syntax is rnfelementdown(<CODE>rnf</CODE>,x).


X<rnfeltreltoabs>rnfeltreltoabs<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x)</CODE>

<CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an element of L expressed as a polynomial or polmod with polmod coefficients, computes x as an element of the absolute extension L/<STRONG><EM>Q</EM></STRONG> as a polynomial modulo the absolute equation <CODE>rnf</CODE>[11][1]. If x is given on the relative integral basis, apply rnfbasistoalg first, otherwise PARI will believe you are dealing with a vector.

X<rnfelementreltoabs>The library syntax is rnfelementreltoabs(<CODE>rnf</CODE>,x).


X<rnfeltup>rnfeltup<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x)</CODE>

<CODE>rnf</CODE> 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/<STRONG><EM>Q</EM></STRONG> as a polynomial modulo the absolute equation <CODE>rnf</CODE>[11][1]. Note that it is unnecessary to compute x as an element of the relative extension L/K (its expression would be identical to itself). If x is given on the integral basis of K, apply nfbasistoalg first, otherwise PARI will believe you are dealing with a vector.

X<rnfelementup>The library syntax is rnfelementup(<CODE>rnf</CODE>,x).


X<rnfequation>rnfequation<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

given a number field <CODE>nf</CODE> as output by nfinit (or simply a polynomial) and a polynomial pol with coefficients in <CODE>nf</CODE> defining a relative extension L of <CODE>nf</CODE>, computes the absolute equation of L over Q.

If <EM>flag</EM> is non-zero, outputs a 3-component row vector [z,a,k], where z is the absolute equation of L over Q, as in the default behaviour, a expresses as a polmod a root <EM>beta</EM> of pol in terms of a root <EM>theta</EM> of z, and k is a small integer such that <EM>theta</EM>=<EM>beta</EM>+k<EM>alpha</EM> where <EM>alpha</EM> is a root of the polynomial defining the base field <CODE>nf</CODE>.

The main variable of <CODE>nf</CODE> must be of lower priority than that of pol. Note that for efficiency, this does not check whether the relative equation is irreducible over <CODE>nf</CODE>, but only if it is squarefree. If it is reducible but squarefree, the result will be the absolute equation of the \'etale algebra defined by pol. If pol is not squarefree, an error message will be issued.

X<rnfequation0>The library syntax is rnfequation0(<CODE>nf</CODE>,<CODE>pol</CODE>,<EM>flag</EM>).


X<rnfhnfbasis>rnfhnfbasis<CODE>(&lt;CODE&gt;bnf&lt;/CODE&gt;,x)</CODE>

given a big number field <CODE>bnf</CODE> as output by bnfinit, and either a polynomial x with coefficients in <CODE>bnf</CODE> defining a relative extension L of <CODE>bnf</CODE>, or a pseudo-basis x of such an extension, gives either a true <CODE>bnf</CODE>-basis of L in upper triangular Hermite normal form, if it exists, zero otherwise.

X<rnfhermitebasis>The library syntax is rnfhermitebasis(<CODE>nf</CODE>,x).


rnf{}idealabstorel

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an ideal of the absolute extension L/<STRONG><EM>Q</EM></STRONG> given in HNFX<Hermite normal form> (if it is not, apply idealhnf first), computes the relative pseudomatrix in HNF giving the ideal x considered as an ideal of the relative extension L/K.

\sidx{rnf{}idealabstorel}The library syntax is rnf{}idealabstorel(<CODE>rnf</CODE>,x).


rnf{}idealdown

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an ideal of the absolute extension L/<STRONG><EM>Q</EM></STRONG> given in HNF (if it is not, apply idealhnf first), gives the ideal of K below x, i.e. the intersection of x with K. Note that, if x is given as a relative ideal (i.e. a pseudomatrix in HNF), then it is not necessary to use this function since the result is simply the first ideal of the ideal list of the pseudomatrix.

\sidx{rnf{}idealdown}The library syntax is rnf{}idealdown(<CODE>rnf</CODE>,x).


rnf{}idealhnf

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being a relative ideal (which can be, as in the absolute case, of many different types, including of course elements), computes as a 2-component row vector the relative Hermite normal form of x, the first component being the HNF matrix (with entries on the integral basis), and the second component the ideals.

\sidx{rnf{}idealhermite}The library syntax is rnf{}idealhermite(<CODE>rnf</CODE>,x).


X<rnfidealmul>rnfidealmul<CODE>(&lt;CODE&gt;rnf&lt;/CODE&gt;,x,y)</CODE>

<CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x and y being ideals of the relative extension L/K given by pseudo-matrices, outputs the ideal product, again as a relative ideal.

\sidx{rnf{}idealmul}The library syntax is rnf{}idealmul(<CODE>rnf</CODE>,x,y).


rnf{}idealnormabs

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x 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/<STRONG><EM>Q</EM></STRONG>. This is identical to idealnorm(rnfidealnormrel(<CODE>rnf</CODE>,x)), only faster.

\sidx{rnf{}idealnormabs}The library syntax is rnf{}idealnormabs(<CODE>rnf</CODE>,x).


rnf{}idealnormrel

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x 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.

\sidx{rnf{}idealnormrel}The library syntax is rnf{}idealnormrel(<CODE>rnf</CODE>,x).


rnf{}idealreltoabs

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being a relative ideal (which can be, as in the absolute case, of many different types, including of course elements), computes the HNF matrix of the ideal x considered as an ideal of the absolute extension L/<STRONG><EM>Q</EM></STRONG>.

\sidx{rnf{}idealreltoabs}The library syntax is rnf{}idealreltoabs(<CODE>rnf</CODE>,x).


rnf{}idealtwoelt

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an ideal of the relative extension L/K given by a pseudo-matrix, gives a vector of two generators of x over <STRONG><EM>Z</EM></STRONG>_L expressed as polmods with polmod coefficients.

\sidx{rnf{}idealtwoelement}The library syntax is rnf{}idealtwoelement(<CODE>rnf</CODE>,x).


rnf{}idealup

(<CODE>rnf</CODE>,x): <CODE>rnf</CODE> being a relative number field extension L/K as output by rnfinit and x being an ideal of K, gives the ideal x<STRONG><EM>Z</EM></STRONG>_L as an absolute ideal of L/<STRONG><EM>Q</EM></STRONG> (the relative ideal representation is trivial: the matrix is the identity matrix, and the ideal list starts with x, all the other ideals being <STRONG><EM>Z</EM></STRONG>_K).

\sidx{rnf{}idealup}The library syntax is rnf{}idealup(<CODE>rnf</CODE>,x).


rnf{}init

(<CODE>nf</CODE>,<CODE>pol</CODE>): <CODE>nf</CODE> being a number field in nfinit format considered as base field, and pol a polynomial defining a relative extension over <CODE>nf</CODE>, this computes all the necessary data to work in the relative extension. The main variable of pol must be of higher priority (i.e. lower number) than that of <CODE>nf</CODE>, and the coefficients of pol must be in <CODE>nf</CODE>.

The result is an 11-component row vector as follows (most of the components are technical), the numbering being very close to that of nfinit. In the following description, we let K be the base field defined by <CODE>nf</CODE>, m the degree of the base field, n the relative degree, L the large field (of relative degree n or absolute degree nm), r_1 and r_2 the number of real and complex places of K.

<CODE>rnf</CODE>[1] contains the relative polynomial pol.

<CODE>rnf</CODE>[2] is a row vector with r_1+r_2 entries, entry j being a 2-component row vector [r_{j,1},r_{j,2}] where r_{j,1} and r_{j,2} are the number of real and complex places of L above the j-th place of K so that r_{j,1}=0 and r_{j,2}=n if j is a complex place, while if j is a real place we have r_{j,1}+2r_{j,2}=n.

<CODE>rnf</CODE>[3] is a two-component row vector [\d(L/K),s] where \d(L/K) is the relative ideal discriminant of L/K and s is the discriminant of L/K viewed as an element of K^*/(K^*)^2, in other words it is the output of rnfdisc.

<CODE>rnf</CODE>[4] is the ideal index \f, i.e. such that d(pol)<STRONG><EM>Z</EM></STRONG>_K=\f^2\d(L/K).

<CODE>rnf</CODE>[5] is a vector vm with 7 entries useful for certain computations in the relative extension L/K. <CODE>vm</CODE>[1] is a vector of r_1+r_2 matrices, the j-th matrix being an (r_{1,j}+r_{2,j})\times n matrix M_j representing the numerical values of the conjugates of the j-th embedding of the elements of the integral basis, where r_{i,j} is as in <CODE>rnf</CODE>[2]. <CODE>vm</CODE>[2] is a vector of r_1+r_2 matrices, the j-th matrix MC_j being essentially the conjugate of the matrix M_j except that the last r_{2,j} columns are also multiplied by 2. <CODE>vm</CODE>[3] is a vector of r_1+r_2 matrices T2_j, where T2_j is an n\times n matrix equal to the real part of the product MC_j . M_j (which is a real positive definite matrix). <CODE>vm</CODE>[4] is the n\times n matrix T whose entries are the relative traces of <EM>omega</EM>_i<EM>omega</EM>_j expressed as polmods in <CODE>nf</CODE>, where the <EM>omega</EM>_i are the elements of the relative integral basis. Note that the j-th embedding of T is equal to \overline{MC_j} . M_j, and in particular will be equal to T2_j if r_{2,j}=0. Note also that the relative ideal discriminant of L/K is equal to <PRE> F&lt;det&gt; (T) </PRE> times the square of the product of the ideals in the relative pseudo-basis (in <CODE>rnf</CODE>[7][2]). The last 3 entries <CODE>vm</CODE>[5], <CODE>vm</CODE>[6] and <CODE>vm</CODE>[7] are linked to the different as in nfinit, but have not yet been implemented.

<CODE>rnf</CODE>[6] is a row vector with r_1+r_2 entries, the j-th entry being the row vector with r_{1,j}+r_{2,j} entries of the roots of the j-th embedding of the relative polynomial pol.

<CODE>rnf</CODE>[7] is a two-component row vector, where the first component is the relative integral pseudo basis expressed as polynomials (in the variable of pol) with polmod coefficients in <CODE>nf</CODE>, and the second component is the ideal list of the pseudobasis in HNF.

<CODE>rnf</CODE>[8] is the inverse matrix of the integral basis matrix, with coefficients polmods in <CODE>nf</CODE>.

<CODE>rnf</CODE>[9] may be the multiplication table of the integral basis, but is not implemented at present.

<CODE>rnf</CODE>[10] is <CODE>nf</CODE>.

<CODE>rnf</CODE>[11] is a vector vabs with 5 entries describing the absolute extension L/<STRONG><EM>Q</EM></STRONG>. <CODE>vabs</CODE>[1] is an absolute equation. <CODE>vabs</CODE>[2] expresses the generator <EM>alpha</EM> of the number field <CODE>nf</CODE> as a polynomial modulo the absolute equation <CODE>vabs</CODE>[1]. <CODE>vabs</CODE>[3] is a small integer k such that, if <EM>beta</EM> is an abstract root of pol and <EM>alpha</EM> the generator of <CODE>nf</CODE>, the generator whose root is vabs will be <EM>beta</EM> + k <EM>alpha</EM>. Note that one must be very careful if k!=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 <EM>beta</EM> + k <EM>alpha</EM>. Typically, the GP instruction would be

pol = subst(pol, x, x - k*Mod(y,<CODE>nf</CODE>.pol))

Finally, <CODE>vabs</CODE>[4] is the absolute integral basis of L expressed in HNF (hence as would be output by nfinit(vabs[1])), and <CODE>vabs</CODE>[5] the inverse matrix of the integral basis, allowing to go from polmod to integral basis representation.

\sidx{rnf{}initalg}The library syntax is rnf{}initalg(<CODE>nf</CODE>,<CODE>pol</CODE>,<CODE>prec</CODE>).


rnf{}isfree

(<CODE>bnf</CODE>,x): given a big number field <CODE>bnf</CODE> as output by bnfinit, and either a polynomial x with coefficients in <CODE>bnf</CODE> defining a relative extension L of <CODE>bnf</CODE>, or a pseudo-basis x of such an extension, returns true (1) if L/<CODE>bnf</CODE> is free, false (0) if not.

\sidx{rnf{}isfree}The library syntax is rnf{}isfree(<CODE>bnf</CODE>,x), and the result is a long.


rnf{}isnorm

(<CODE>bnf</CODE>,<CODE>ext</CODE>,<CODE>el</CODE>,{<EM>flag</EM>=1}): similar to bnfisnorm but in the relative case. This tries to decide whether the element el in bnf is the norm of some y in ext. <CODE>bnf</CODE> is as output by bnfinit.

<CODE>ext</CODE> is a relative extension which has to be a row vector whose components are:

<CODE>ext</CODE>[1]: a relative equation of the number field ext over bnf. As usual, the priority of the variable of the polynomial defining the ground field bnf (say y) must be lower than the main variable of <CODE>ext</CODE>[1], say x.

<CODE>ext</CODE>[2]: the generator y of the base field as a polynomial in x (as given by rnfequation with <EM>flag</EM> = 1).

<CODE>ext</CODE>[3]: is the bnfinit of the absolute extension <CODE>ext</CODE>/<STRONG><EM>Q</EM></STRONG>.

This returns a vector [a,b], where <CODE>el</CODE>=<CODE>Norm</CODE>(a)*b. It looks for a solution which is an S-integer, with S a list of places (of bnf) containing the ramified primes, the generators of the class group of ext, as well as those primes dividing el. If <CODE>ext</CODE>/<CODE>bnf</CODE> is known to be X<Galois>Galois, set <EM>flag</EM>=0 (here el is a norm iff b=1). If <EM>flag</EM> is non zero add to S all the places above the primes which: divide <EM>flag</EM> if <EM>flag</EM><0, or are less than <EM>flag</EM> if \fl&gt;0. The answer is guaranteed (i.e. el is a norm iff b=1) under X< GRH>GRH, if S contains all primes less than 12 <EM>log</EM> ^2|disc(<CODE>Ext</CODE>)|, where Ext is the normal closure of <CODE>ext</CODE> / <CODE>bnf</CODE>.

\sidx{rnf{}isnorm}The library syntax is rnf{}isnorm(<CODE>bnf</CODE>,ext,x,<EM>flag</EM>,<CODE>prec</CODE>).


X<rnfkummer>rnfkummer<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,&lt;CODE&gt;subgroup&lt;/CODE&gt;,{deg=0})</CODE>

bnr being as output by bnrinit, finds a relative equation for the class field corresponding to the module in bnr and the given congruence subgroup. If deg is positive, outputs the list of all relative equations of degree deg contained in the ray class field defined by bnr.

(THIS PROGRAM IS STILL IN DEVELOPMENT STAGE)

X<rnfkummer>The library syntax is rnfkummer(<CODE>bnr</CODE>,<CODE>subgroup</CODE>,<CODE>deg</CODE>,<CODE>prec</CODE>), where deg is a long.


rnf{}lllgram

(<CODE>nf</CODE>,<CODE>pol</CODE>,<CODE>order</CODE>): given a polynomial pol with coefficients in nf and an order order as output by rnfpseudobasis or similar, gives [[<CODE>neworder</CODE>],U], where neworder is a reduced order and U is the unimodular transformation matrix.

\sidx{rnf{}lllgram}The library syntax is rnf{}lllgram(<CODE>nf</CODE>,<CODE>pol</CODE>,<CODE>order</CODE>,<CODE>prec</CODE>).


X<rnfnormgroup>rnfnormgroup<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

bnr being a big ray class field as output by bnrinit and pol a relative polynomial defining an X<Abelian extension>Abelian extension, computes the norm group (alias Artin or Takagi group) corresponding to the Abelian extension of <CODE>bnf</CODE>=bnr[1] defined by pol, where the module corresponding to bnr is assumed to be a multiple of the conductor (i.e. polrel defines a subextension of bnr). The result is the HNF defining the norm group on the given generators of <CODE>bnr</CODE>[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.

X<rnfnormgroup>The library syntax is rnfnormgroup(<CODE>bnr</CODE>,<CODE>pol</CODE>).


X<rnfpolred>rnfpolred<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

relative version of polred. Given a monic polynomial pol with coefficients in <CODE>nf</CODE>, finds a list of relative polynomials defining some subfields, hopefully simpler and containing the original field.

X<rnfpolred>The library syntax is rnfpolred(<CODE>nf</CODE>,<CODE>pol</CODE>,<CODE>prec</CODE>).


X<rnfpolredabs>rnfpolredabs<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

relative version of polredabs. Given a monic polynomial pol with coefficients in <CODE>nf</CODE>, finds a simpler relative polynomial defining the same field. If <EM>flag</EM>=1, returns [P,a] where P is the default output and a is an element expressed on a root of P whose characteristic polynomial is pol, if <EM>flag</EM>=2, returns an absolute polynomial (same as

rnfequation(<CODE>nf</CODE>,rnfpolredabs(<CODE>nf</CODE>,<CODE>pol</CODE>))

   but faster).

\misctitle{Remark.} In the present implementation, although this is slower than rnfpolred, it is much more efficient, the difference being more dramatic than in the absolute case. This is because the implementation of rnfpolred is based on an incomplete reduction theory of lattices over number fields (i.e. the function rnflllgram) which deserves to be improved.

X<rnfpolredabs>The library syntax is rnfpolredabs(<CODE>nf</CODE>,<CODE>pol</CODE>,<EM>flag</EM>,<CODE>prec</CODE>).


X<rnfpseudobasis>rnfpseudobasis<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

given a number field <CODE>nf</CODE> as output by nfinit and a polynomial pol with coefficients in <CODE>nf</CODE> defining a relative extension L of <CODE>nf</CODE>, computes a pseudo-basis (A,I) and the relative discriminant of L. This is output as a four-element row vector [A,I,D,d], where D is the relative ideal discriminant and d is the relative discriminant considered as an element of <CODE>nf</CODE>^*/{<CODE>nf</CODE>^*}^2.

Note: As usual, <CODE>nf</CODE> can be a <CODE>bnf</CODE> as output by bnfinit.

X<rnfpseudobasis>The library syntax is rnfpseudobasis(<CODE>nf</CODE>,<CODE>pol</CODE>).


X<rnfsteinitz>rnfsteinitz<CODE>(&lt;CODE&gt;nf&lt;/CODE&gt;,x)</CODE>

given a number field <CODE>nf</CODE> as output by nfinit and either a polynomial x with coefficients in <CODE>nf</CODE> defining a relative extension L of <CODE>nf</CODE>, or a pseudo-basis x of such an extension as output for example by rnfpseudobasis, computes another pseudo-basis (A,I) (not in HNF in general) such that all the ideals of I except perhaps the last one are equal to the ring of integers of <CODE>nf</CODE>, and outputs the four-component row vector [A,I,D,d] as in rnfpseudobasis. The name of this function comes from the fact that the ideal class of the last ideal of I (which is well defined) is called the Steinitz class of the module <STRONG><EM>Z</EM></STRONG>_L.

Note: <CODE>nf</CODE> can be a <CODE>bnf</CODE> as output by bnfinit.

X<rnfsteinitz>The library syntax is rnfsteinitz(<CODE>nf</CODE>,x).


X<subgrouplist>subgrouplist<CODE>(&lt;CODE&gt;bnr&lt;/CODE&gt;,{&lt;CODE&gt;bound&lt;/CODE&gt;},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

bnr being as output by bnrinit or a list of cyclic components of a finite Abelian group G, outputs the list of subgroups of G (of index bounded by bound, if not omitted). Subgroups are given as HNFX<Hermite normal form> left divisors of the SNFX<Smith normal form> matrix corresponding to G. If <EM>flag</EM>=0 (default) and bnr is as output by bnrinit, gives only the subgroups whose modulus is the conductor.

X<subgrouplist0>The library syntax is subgrouplist0(<CODE>bnr</CODE>,<CODE>bound</CODE>,<EM>flag</EM>,<CODE>prec</CODE>), where bound, <EM>flag</EM> and <CODE>prec</CODE> are long integers.


X<zetak>zetak<CODE>(&lt;CODE&gt;znf&lt;/CODE&gt;,x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

znf being a number field initialized by zetakinit (not by nfinit), computes the value of the X<Dedekind>Dedekind zeta function of the number field at the complex number x. If <EM>flag</EM>=1 computes Dedekind <EM>Lambda</EM> function instead (i.e. the product of the Dedekind zeta function by its gamma and exponential factors).

The accuracy of the result depends in an essential way on the accuracy of both the zetakinit program and the current accuracy, but even so the result may be off by up to 5 or 10 decimal digits.

X<glambdak>The library syntax is glambdak(<CODE>znf</CODE>,x,<CODE>prec</CODE>) or X<gzetakgzetak(znf,x,prec)>.


X<zetakinit>zetakinit<CODE>(x)</CODE>

computes a number of initialization data concerning the number field defined by the polynomial x so as to be able to compute the X<Dedekind>Dedekind zeta and lambda functions (respectively <CODE>zetak</CODE>(x) and <CODE>zetak</CODE>(x,1)). This function calls in particular the bnfinit program. The result is a 9-component vector v whose components are very technical and cannot really be used by the user except through the zetak function. The only component which can be used if it has not been computed already is v[1][4] which is the result of the bnfinit call.

This function is very inefficient and needs to computes millions of coefficients of the corresponding Dirichlet series if the precision is big. Unless the discriminant is small it will not be able to handle more than 9 digits of relative precision (e.g zetakinit(x^ 8 - 2) needs 440MB of memory at default precision).

X<initzeta>The library syntax is initzeta(x).


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.


X<O>O<A HREF="#item__a">(a</A><CODE>^</CODE><CODE>b)</CODE>

p-adic (if a is an integer greater or equal to 2) or power series zero (in all other cases), with precision given by b.

X<ggrandocp>The library syntax is ggrandocp(a,b), where b is a long.


X<deriv>deriv<CODE>(x,{v})</CODE>

derivative of x with respect to the main variable if v is omitted, and with respect to v otherwise. x can be any type except polmod. The derivative of a scalar type is zero, and the derivative of a vector or matrix is done componentwise. One can use x' as a shortcut if the derivative is with respect to the main variable of x.

X<deriv>The library syntax is deriv(x,v), where v is a long, and an omitted v is coded as -1.


X<eval>eval<CODE>(x)</CODE>

replaces in x the formal variables by the values that have been assigned to them after the creation of x. This is mainly useful in GP, and not in library mode. Do not confuse this with substitution (see subst). Applying this function to a character string yields the output from the corresponding GP command, as if directly input from the keyboard (see Label se:strings).X<Label se:eval>

X<geval>The library syntax is geval(x). The more basic functions X<polevalpoleval(q,x)>, X<qfevalqfeval(q,x)>, and X<hqfevalhqfeval(q,x)> evaluate q at x, where q is respectively assumed to be a polynomial, a quadratic form (a symmetric matrix), or an Hermitian form (an Hermitian complex matrix).


X<factorpadic>factorpadic<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,p,r,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

p-adic factorization of the polynomial pol to precision r, the result being a two-column matrix as in factor. r must be strictly larger than the p-adic valuation of the discriminant of pol for the result to make any sense. The method used is X<Ford>Ford-Letard's implementation of the X<round 4>round 4 algorithm of X<Zassenhaus>Zassenhaus.

If <EM>flag</EM>=1, use an algorithm due to X<Buchmann>Buchmann and X<Lenstra>Lenstra, which is usually less efficient.

X<factorpadic4>The library syntax is factorpadic4(<CODE>pol</CODE>,p,r), where r is a long integer.


X<intformal>intformal<CODE>(x,{v})</CODE>

X<formal integration>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 x is a rational function, it is assumed that the base ring is an integral domain of characteristic zero.

X<integ>The library syntax is integ(x,v), where v is a long and an omitted v is coded as -1.


X<padicappr>padicappr<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,a)</CODE>

vector of p-adic roots of the polynomial pol congruent to the p-adic number a modulo p (or modulo 4 if p=2), and with the same p-adic precision as a. The number a can be an ordinary p-adic number (type t_PADIC, i.e. an element of <STRONG><EM>Q</EM></STRONG>_p) or can be an element of a finite extension of <STRONG><EM>Q</EM></STRONG>_p, in which case it is of type t_POLMOD, where at least one of the coefficients of the polmod is a p-adic number. In this case, the result is the vector of roots belonging to the same extension of <STRONG><EM>Q</EM></STRONG>_p as a.

X<apprgen9>The library syntax is apprgen9(<CODE>pol</CODE>,a), but if a is known to be simply a p-adic number (type t_PADIC), the syntax X<apprgenapprgen(pol,a)> can be used.


X<polcoeff>polcoeff<CODE>(x,s,{v})</CODE>

coefficient of degree s of the polynomial x, with respect to the main variable if v is omitted, with respect to v otherwise.

X<polcoeff0>The library syntax is polcoeff0(x,s,v), where v is a long and an omitted v is coded as -1. Also available is X<truecoeff>truecoeff(x,v).


X<poldegree>poldegree<CODE>(x,{v})</CODE>

degree of the polynomial x in the main variable if v is omitted, in the variable v otherwise. This is to be understood as follows. When x is a polynomial or a rational function, it gives the degree of x, the degree of 0 being -1 by convention. When x is a non-zero scalar, it gives 0, and when x is a zero scalar, it gives -1. Return an error otherwise.

X<poldegree>The library syntax is poldegree(x,v), where v and the result are longs (and an omitted v is coded as -1). Also available is X<degree>degree(x), which is equivalent to poldegree(<A HREF="#item_x">x</A>,-1).


X<polcyclo>polcyclo<CODE>(n,{v=x})</CODE>

n-th cyclotomic polynomial, in variable v (x by default). The integer n must be positive.

X<cyclo>The library syntax is cyclo(n,v), where n and v are long integers (v is a variable number, usually obtained through varn).


X<poldisc>poldisc<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,{v})</CODE>

discriminant of the polynomial pol in the main variable is v is omitted, in v otherwise. The algorithm used is the X<subresultant algorithm>subresultant algorithm.

X<poldisc0>The library syntax is poldisc0(x,v). Also available is X<discsr>discsr(x), equivalent to poldisc0(x,-1).


X<poldiscreduced>poldiscreduced<CODE>(f)</CODE>

reduced discriminant vector of the (integral, monic) polynomial f. This is the vector of elementary divisors of <STRONG><EM>Z</EM></STRONG>[<EM>alpha</EM>]/f'(<EM>alpha</EM>)<STRONG><EM>Z</EM></STRONG>[<EM>alpha</EM>], where <EM>alpha</EM> is a root of the polynomial f. The components of the result are all positive, and their product is equal to the absolute value of the discriminant of f.

X<reduceddiscsmith>The library syntax is reduceddiscsmith(x).


X<polinterpolate>polinterpolate<CODE>(xa,ya,{v=x},{&amp;e})</CODE>

given the data vectors xa and ya of the same length n (xa containing the x-coordinates, and ya the corresponding y-coordinates), this function finds the X<interpolating polynomial>interpolating polynomial passing through these points and evaluates it at v. If present, e will contain an error estimate on the returned value.

X<polint>The library syntax is polint(xa,ya,v,&e), where e will contain an error estimate on the returned value.


X<polisirreducible>polisirreducible<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

pol being a polynomial (univariate in the present version \vers), 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.

X<gisirreducible>The library syntax is gisirreducible(<CODE>pol</CODE>).


X<pollead>pollead<CODE>(x,{v})</CODE>

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.

X<pollead>The library syntax is pollead(x,v), where v is a long and an omitted v is coded as -1. Also available is X<leadingcoeff>leadingcoeff(x).


X<pollegendre>pollegendre<CODE>(n,{v=x})</CODE>

creates the n^{th} X<Legendre polynomial>Legendre polynomial, in variable v.

X<legendre>The library syntax is legendre(n), where x is a long.


X<polrecip>polrecip<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;)</CODE>

reciprocal polynomial of pol, i.e. the coefficients are in reverse order. pol must be a polynomial.

X<polrecip>The library syntax is polrecip(x).


X<polresultant>polresultant<CODE>(x,y,{v},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

resultant of the two polynomials x and y with exact entries, with respect to the main variables of x and y if v is omitted, with respect to the variable v otherwise. The algorithm used is the X<subresultant algorithm>subresultant algorithm by default.

If <EM>flag</EM>=1, uses the determinant of Sylvester's matrix instead (here x and y may have non-exact coefficients).

If <EM>flag</EM>=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.

X<polresultant0>The library syntax is polresultant0(x,y,v,<EM>flag</EM>), where v is a long and an omitted v is coded as -1. Also available are X<subressubres(x,y)> (<EM>flag</EM>=0) and X<resultant2resultant2(x,y)> (<EM>flag</EM>=1).


X<polroots>polroots<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

complex roots of the polynomial pol, given as a column vector where each root is repeated according to its multiplicity. The precision is given as for transcendental functions: under GP it is kept in the variable realprecision and is transparent to the user, but it must be explicitly given as a second argument in library mode.

The algorithm used is a modification of A. X<Sch\``onhage>Sch\''onhage's remarkable root-finding algorithm, due to and implemented by X. Gourdon. Barring bugs, it is guaranteed to converge and to give the roots to the required accuracy.

If <EM>flag</EM>=1, use a variant of the Newton-Raphson method, which is not guaranteed to converge, but is rather fast. If you get the messages ``too many iterations in roots'' or ``INTERNAL ERROR: incorrect result in roots'', use the default function (i.e. no flag or <EM>flag</EM>=0). This used to be the default root-finding function in PARI until version 1.39.06.

X<roots>The library syntax is roots(<CODE>pol</CODE>,<CODE>prec</CODE>) or X<rootsoldrootsold(pol,prec)>.


X<polrootsmod>polrootsmod<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,p,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

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<100, you may try setting <EM>flag</EM>=1, which uses a naive search. In this case, multiple roots are repeated with their order of multiplicity.

X<rootmod>The library syntax is rootmod(<CODE>pol</CODE>,p) (<EM>flag</EM>=0) or X<rootmod2rootmod2(pol,p)> (<EM>flag</EM>=1).


X<polrootspadic>polrootspadic<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,p,r)</CODE>

row vector of p-adic roots of the polynomial pol with p-adic precision equal to r. Multiple roots are not repeated. p is assumed to be a prime.

X<rootpadic>The library syntax is rootpadic(<CODE>pol</CODE>,p,r), where r is a long.


X<polsturm>polsturm<CODE>(&lt;CODE&gt;pol&lt;/CODE&gt;,{a},{b})</CODE>

number of real roots of the real polynomial pol in the interval ]a,b], using Sturm's algorithm. a (resp. b) is taken to be -<EM>infty</EM> (resp. +<EM>infty</EM>) if omitted.

X<sturmpart>The library syntax is sturmpart(<CODE>pol</CODE>,a,b). Use NULL to omit an argument. X<sturmsturm(pol)> is equivalent to <CODE>sturmpart</CODE>(<CODE>pol</CODE>,NULL,NULL). The result is a long.


X<polsubcyclo>polsubcyclo<CODE>(n,d,{v=x})</CODE>

gives a polynomial (in variable v) defining the sub-Abelian extension of degree d of the cyclotomic field <STRONG><EM>Q</EM></STRONG>(<EM>zeta</EM>_n), where d | <EM>phi</EM>(n). (<STRONG><EM>Z</EM></STRONG>/n<STRONG><EM>Z</EM></STRONG>)^* has to be cyclic (i.e. n=2, 4, p^k or 2p^k for an odd prime p).

X<subcyclo>The library syntax is subcyclo(n,d,v), where v is a variable number.


X<polsylvestermatrix>polsylvestermatrix<CODE>(x,y)</CODE>

forms the Sylvester matrix corresponding to the two polynomials 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.

X<sylvestermatrix>The library syntax is sylvestermatrix(x,y).


X<polsym>polsym<CODE>(x,n)</CODE>

creates the vector of the X<symmetric powers>symmetric powers of the roots of the polynomial x up to power n, using Newton's formula.

X<polsym>The library syntax is polsym(x).


X<poltchebi>poltchebi<CODE>(n,{v=x})</CODE>

creates the n^{th} X<Chebyshev>Chebyshev polynomial, in variable v.

X<tchebi>The library syntax is tchebi(n,v), where n and v are long integers (v is a variable number).


X<polzagier>polzagier<CODE>(n,m)</CODE>

creates Zagier's polynomial P_{n,m} used in the functions sumalt and sumpos (with <EM>flag</EM>=1). The exact definition can be found in a forthcoming paper. One must have m&lt;= n.

X<polzagreel>The library syntax is polzagreel(n,m,<CODE>prec</CODE>) if the result is only wanted as a polynomial with real coefficients to the precision <CODE>prec</CODE>, or X<polzagpolzag(n,m)> if the result is wanted exactly, where n and m are longs.


X<serconvol>serconvol<CODE>(x,y)</CODE>

convolution (or X<Hadamard product>Hadamard product) of the two power series x and y; in other words if x=<EM>sum</EM> a_k*X^k and y=<EM>sum</EM> b_k*X^k then <CODE>serconvol</CODE>(x,y)=<EM>sum</EM> a_k*b_k*X^k.

X<convol>The library syntax is convol(x,y).


X<serlaplace>serlaplace<CODE>(x)</CODE>

x must be a power series with only non-negative exponents. If x=<EM>sum</EM> (a_k/k!)*X^k then the result is <EM>sum</EM> a_k*X^k.

X<laplace>The library syntax is laplace(x).


X<serreverse>serreverse<CODE>(x)</CODE>

reverse power series (i.e. x^{-1}, not 1/x) of x. x must be a power series whose valuation is exactly equal to one.

X<recip>The library syntax is recip(x).


X<subst>subst<CODE>(x,y,z)</CODE>

replace the simple variable y by the argument z in the ``polynomial'' expression x. Every type is allowed for x, but if it is not a genuine polynomial (or power series, or rational function), the substitution will be done as if the scalar components were polynomials of degree one. In particular, beware that:

\bprog ? subst(1, x, [1,2; 3,4]) %1 = [1 0]

[0 1]

? subst(1, x, Mat([0,1])) *** forbidden substitution by a non square matrix \eprog

If x is a power series, z must be either a polynomial, a power series, or a rational function. y must be a simple variable name.

X<gsubst>The library syntax is gsubst(x,v,z), where v is the number of the variable y.


X<taylor>taylor<CODE>(x,y)</CODE>

Taylor expansion around 0 of x with respect toX<Label se:taylor> the simple variable y. x can be of any reasonable type, for example a rational function. The number of terms of the expansion is transparent to the user under GP, but must be given as a second argument in library mode.

X<tayl>The library syntax is tayl(x,y,n), where the long integer n is the desired number of terms in the expansion.


X<thue>thue<CODE>(&lt;CODE&gt;tnf&lt;/CODE&gt;,a,{&lt;CODE&gt;sol&lt;/CODE&gt;})</CODE>

solves the equation P(x,y)=a in integers x and y, where tnf was created with <CODE>thueinit</CODE>(P). sol, if present, contains the solutions of Norm(x)=a modulo units of positive norm in the number field defined by P (as computed by bnfisintnorm). If tnf was computed without assuming X< GRH>GRH (<EM>flag</EM>=1 in thueinit), the result is unconditional.

X<thue>The library syntax is thue(<CODE>tnf</CODE>,a,<CODE>sol</CODE>), where an omitted sol is coded as NULL.


X<thueinit>thueinit<CODE>(P,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

initializes the tnf corresponding to P. It is meant to be used in conjunction with X<thue>thue to solve Thue equations P(x,y) = a, where a is an integer. If <EM>flag</EM> is non-zero, certify the result unconditionnaly, Otherwise, assume X<GRH>GRH, this being much faster of course.

X<thueinit>The library syntax is thueinit(P,<EM>flag</EM>,<CODE>prec</CODE>).


Vectors, matrices, linear algebra and sets

X<Label se:linear_algebra>

Note that most linear algebra functions operating on subspaces defined by generating sets (such as X< mathnf>mathnf, X<qflll>qflll, etc.) take matrices as arguments. As usual, the generating vectors are taken to be the columns of the given matrix.


X<algdep>algdep<CODE>(x,k,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

X<algebraic dependence> x being real or complex, finds a polynomial of degree at most k having x as approximate root. The algorithm used is a variant of the X<LLL>LLL algorithm due to Hastad, Lagarias and Schnorr (STACS 1986). Note that the polynomial which is obtained is not necessarily the ``correct'' one (it's not even guaranteed to be irreducible!). One can check the closeness either by a polynomial evaluation or substitution, or by computing the roots of the polynomial given by algdep.

If <EM>flag</EM> is non-zero, use a standard LLL. <EM>flag</EM> then indicates a precision, which should be between 0.5 and 1.0 times the number of decimal digits to which x was computed.

X<algdep0>The library syntax is algdep0(x,k,<EM>flag</EM>,<CODE>prec</CODE>), where k and <EM>flag</EM> are longs. Also available is X<algdepalgdep(x,k,prec)> (<EM>flag</EM>=0).


X<charpoly>charpoly<CODE>(A,{v=x},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

X<characteristic polynomial>characteristic polynomial of A with respect to the variable v, i.e. determinant of v*I-A if A is a square matrix, determinant of the map ``multiplication by A'' if A is a scalar, in particular a polmod (e.g. charpoly(I,x)=x^2+1), error if A is of any other type. The value of <EM>flag</EM> is only significant for matrices.

If <EM>flag</EM>=0, the method used is essentially the same as for computing the adjoint matrix, i.e. computing the traces of the powers of A.

If <EM>flag</EM>=1, uses Lagrange interpolation which is almost always slower.

If <EM>flag</EM>=2, uses the Hessenberg form. This is faster than the default when the coefficients are integermod a prime or real numbers, but is usually slower in other base rings.

X<charpoly0>The library syntax is charpoly0(A,v,<EM>flag</EM>), where v is the variable number. Also available are the functions X<caractcaract(A,v)> (<EM>flag</EM>=1), X<carhesscarhess(A,v)> (<EM>flag</EM>=2), and X<caradjcaradj(A,v,pt)> where, in this last case, pt is a GEN* which, if not equal to NULL, will receive the address of the adjoint matrix of A (see matadjoint), so both can be obtained at once.


X<concat>concat<CODE>(x,{y})</CODE>

concatenation of x and y. If x or y is not a vector or matrix, it is considered as a one-dimensional vector. All types are allowed for x and y, but the sizes must be compatible. Note that matrices are concatenated horizontally, i.e. the number of rows stays the same. Using transpositions, it is easy to concatenate them vertically.

To concatenate vectors sideways (i.e. to obtain a two-row or two-column matrix), first transform the vector into a one-row or one-column matrix using the function X< Mat>Mat. 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 [ ]~.)

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.

\bprog ? concat([1,2], [3,4]) %1 = [1, 2, 3, 4] ? concat([1,2]~, [3,4]~) %2 = [1, 2, 3, 4]~ ? concat([1,2; 3,4], [5,6]~) %3 = [1, 2, 5]

[3, 4, 6]

? concat([%, [7,8]~, [1,2,3,4]]) %4 = [1 2 5 7]

[3 4 6 8]

[1 2 3 4] \eprog

X<concat>The library syntax is concat(x,y).


X<lindep>lindep<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

X<linear dependence>x being a vector with real or complex coefficients, finds a small integral linear combination among these coefficients.

If <EM>flag</EM>=0, uses a variant of the X<LLL>LLL algorithm due to Hastad, Lagarias and Schnorr (STACS 1986).

If \fl&gt;0, uses the LLL algorithm. <EM>flag</EM> is a parameter which should be between one half the number of decimal digits of precision and that number (see algdep).

If <EM>flag</EM><0, returns as soon as one relation has been found.

X<lindep0>The library syntax is lindep0(x,<EM>flag</EM>,<CODE>prec</CODE>). Also available is X<lindeplindep(x,prec)> (<EM>flag</EM>=0).


X<listcreate>listcreate<CODE>(n)</CODE>

creates an empty list of maximal length n.

This function is useless in library mode.


X<listinsert>listinsert<CODE>(&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;,x,n)</CODE>

inserts the object x at position n in list (which must be of type t_LIST). All the remaining elements of list (from position n+1 onwards) are shifted to the right. This and listput are the only commands which enable you to increase a list's effective length (as long as it remains under the maximal length specified at the time of the listcreate).

This function is useless in library mode.


X<listkill>listkill<CODE>(&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;)</CODE>

kill list. This deletes all elements from list and sets its effective length to 0. The maximal length is not affected.

This function is useless in library mode.


X<listput>listput<CODE>(&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;,x,{n})</CODE>

sets the n-th element of the list list (which must be of type t_LIST) equal to x. If n is omitted, or greater than the list current effective length, just appends x. This and listinsert are the only commands which enable you to increase a list's effective length (as long as it remains under the maximal length specified at the time of the listcreate).

If you want to put an element into an occupied cell, i.e. if you don't want to change the effective length, you can consider the list as a vector and use the usual list[n] = x construct.

This function is useless in library mode.


X<listsort>listsort<CODE>(&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

sorts list (which must be of type t_LIST) in place. If <EM>flag</EM> is non-zero, suppresses all repeated coefficients. This is much faster than the vecsort command since no copy has to be made.

This function is useless in library mode.


X<matadjoint>matadjoint<CODE>(x)</CODE>

X<adjoint matrix>adjoint matrix of x, i.e. the matrix y of cofactors of x, satisfying x*y= <EM>det</EM> (x)*Id. x must be a (non-necessarily invertible) square matrix.

X<adj>The library syntax is adj(x).


X<matcompanion>matcompanion<CODE>(x)</CODE>

the left companion matrix to the polynomial x.

X<assmat>The library syntax is assmat(x).


X<matdet>matdet<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

determinant of x. x must be a square matrix.

If <EM>flag</EM>=0, uses Gauss-Bareiss.

If <EM>flag</EM>=1, uses classical Gaussian elimination, which is better when the entries of the matrix are reals or integers for example, but usually much worse for more complicated entries like multivariate polynomials.

X<det>The library syntax is det(x) (<EM>flag</EM>=0) and X<det2det2(x)> (<EM>flag</EM>=1).


X<matdetint>matdetint<CODE>(x)</CODE>

x being an m\times n matrix with integer coefficients, this function computes a multiple of the determinant of the lattice generated by the columns of x if it is of rank m, and returns zero otherwise. This function can be useful in conjunction with the function mathnfmod which needs to know such a multiple. Other ways to obtain this determinant (assuming the rank is maximal) is matdet(qflll(x,4)[2]<CODE>*</CODE>x) or more simply matdet(mathnf(x)). Experiment to see which is faster for your applications.

X<detint>The library syntax is detint(x).


X<matdiagonal>matdiagonal<CODE>(x)</CODE>

x being a vector, creates the diagonal matrix whose diagonal entries are those of x.

X<diagonal>The library syntax is diagonal(x).


X<mateigen>mateigen<CODE>(x)</CODE>

gives the eigenvectors of x as columns of a matrix.

X<eigen>The library syntax is eigen(x).


X<mathess>mathess<CODE>(x)</CODE>

Hessenberg form of the square matrix x.

X<hess>The library syntax is hess(x).


X<mathilbert>mathilbert<CODE>(x)</CODE>

x being a long, creates the X<Hilbert matrix>Hilbert matrix of order x, i.e. the matrix whose coefficient (i,j) is 1/ (i+j-1).

X<mathilbert>The library syntax is mathilbert(x).


X<mathnf>mathnf<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

if x is a (not necessarily square) matrix of maximal rank, finds the upper triangular X<Hermite normal form>Hermite normal form of x. If the rank of x is equal to its number of rows, the result is a square matrix. In general, the columns of the result form a basis of the lattice spanned by the columns of x.

If <EM>flag</EM>=0, uses the naive algorithm.

If <EM>flag</EM>=1, uses Batut's algorithm. Outputs a two-component row vector [H,U], where H is the upper triangular Hermite normal form of x (i.e. the default result) and U is the unimodular transformation matrix such that xU=[0|H]. If the rank of x is equal to its number of rows, H is a square matrix. In general, the columns of H form a basis of the lattice spanned by the columns of x.

If <EM>flag</EM>=2, uses Havas's algorithm. Outputs [H,U,P], such that H and U are as before and P is a permutation of the rows such that P applied to xU gives H. This does not work very well in present version \vers.

If <EM>flag</EM>=3, uses Batut's algorithm, and outputs [H,U,P] as in the previous case.

If <EM>flag</EM>=4, as in case 1 above, but uses X<LLL>LLL reduction along the way.

X<mathnf0>The library syntax is mathnf0(x,<EM>flag</EM>). Also available are X<hnfhnf(x)> (<EM>flag</EM>=0) and X<hnfallhnfall(x)> (<EM>flag</EM>=1).


X<mathnfmod>mathnfmod<CODE>(x,d)</CODE>

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 X<Hermite normal form>Hermite normal form of x.

If the rank of x is equal to its number of rows, the result is a square matrix. In general, the columns of the result form a basis of the lattice spanned by the columns of x. This is much faster than mathnf when d is known.

X<hnfmod>The library syntax is hnfmod(x,d).


X<mathnfmodid>mathnfmodid<CODE>(x,d)</CODE>

outputs the (upper triangular) X<Hermite normal form>Hermite normal form of x concatenated with d times the identity matrix.

X<hnfmodid>The library syntax is hnfmodid(x,d).


X<matid>matid<CODE>(n)</CODE>

creates the n\times n identity matrix.

X<idmat>The library syntax is idmat(n) where n is a long.

Related functions are X<gscalmatgscalmat(x,n)>, which creates x times the identity matrix (x being a GEN and n a long), and X<gscalsmatgscalsmat(x,n)> which is the same when x is a long.


X<matimage>matimage<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

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 <EM>flag</EM>=0, use standard Gauss pivot. If <EM>flag</EM>=1, use matsupplement.

X<matimage0>The library syntax is matimage0(x,<EM>flag</EM>). Also available is X<imageimage(x)> (<EM>flag</EM>=0).


X<matimagecompl>matimagecompl<CODE>(x)</CODE>

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 x.

X<imagecompl>The library syntax is imagecompl(x).


X<matindexrank>matindexrank<CODE>(x)</CODE>

x being a matrix of rank r, gives two vectors y and z of length r giving a list of rows and columns respectively (starting from 1) such that the extracted matrix obtained from these two vectors using X<vecextractvecextract(x,y,z)> is invertible.

X<indexrank>The library syntax is indexrank(x).


X<matintersect>matintersect<CODE>(x,y)</CODE>

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 X<idealintersect>idealintersect, which does the same for free Z-modules.

X<intersect>The library syntax is intersect(x,y).


X<matinverseimage>matinverseimage<CODE>(x,y)</CODE>

gives a column vector belonging to the inverse image of the column vector y by the matrix x if one exists, the empty vector otherwise. To get the complete inverse image, it suffices to add to the result any element of the kernel of x obtained for example by matker.

X<inverseimage>The library syntax is inverseimage(x,y).


X<matisdiagonal>matisdiagonal<CODE>(x)</CODE>

returns true (1) if x is a diagonal matrix, false (0) if not.

X<isdiagonal>The library syntax is isdiagonal(x), and this returns a long integer.


X<matker>matker<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

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 <EM>flag</EM>=1.

   Note: The library functionX<ker_mod_p>
C<C<ker_mod_p>(x, p)>, where C<x> has integer entries and C<p> is prime,
which is equivalent to but many orders of magnitude faster than
C<matker(x*Mod(1,p))> and needs much less stack space. To use it under GP,
type C<install(ker_mod_p, GG)> first.

X<matker0>The library syntax is matker0(x,<EM>flag</EM>). Also available are X<kerker(x)> (<EM>flag</EM>=0), X<kerikeri(x)> (<EM>flag</EM>=1) and <CODE>ker_mod_p</CODE>(x,p).


X<matkerint>matkerint<CODE>(x,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

gives an X<LLL>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 <EM>flag</EM>=0, uses a modified integer LLL algorithm.

If <EM>flag</EM>=1, uses <CODE>matrixqz</CODE>(x,-2). If LLL reduction of the final result is not desired, you can save time using matrixqz(matker(x),-2) instead.

If <EM>flag</EM>=2, uses another modified LLL. In the present version \vers, only independent rows are allowed in this case.

X<matkerint0>The library syntax is matkerint0(x,<EM>flag</EM>). Also available is X<kerintkerint(x)> (<EM>flag</EM>=0).


X<matmuldiagonal>matmuldiagonal<CODE>(x,d)</CODE>

product of the matrix x by the diagonal matrix whose diagonal entries are those of the vector d. Equivalent to, but much faster than x*<CODE>matdiagonal</CODE>(d).

X<matmuldiagonal>The library syntax is matmuldiagonal(x,d).


X<matmultodiagonal>matmultodiagonal<CODE>(x,y)</CODE>

product of the matrices x and y knowing that the result is a diagonal matrix. Much faster than x*y in that case.

X<matmultodiagonal>The library syntax is matmultodiagonal(x,y).


X<matpascal>matpascal<CODE>(x,{q})</CODE>

creates as a matrix the lower triangular X<pascal triangle>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 q-binomial coefficients).

X<matqpascal>The library syntax is matqpascal(x,q), where x is a long and q=<CODE>NULL</CODE> is used to omit q. Also available is X<matpascal>matpascal{x}.


X<matrank>matrank<CODE>(x)</CODE>

rank of the matrix x.

X<rank>The library syntax is rank(x), and the result is a long.


X<matrixqz>matrixqz<CODE>(x,p)</CODE>

x being an m\times n matrix with m&gt;= n with rational or integer entries, this function has varying behaviour depending on the sign of p:

If p&gt;= 0, x is assumed to be of maximal rank. This function returns a matrix having only integral entries, having the same image as x, such that the GCD of all its n\times n subdeterminants is equal to 1 when p is equal to 0, or not divisible by p otherwise. Here p must be a prime number (when it is non-zero). However, if the function is used when p has no small prime factors, it will either work or give the message ``impossible inverse modulo'' and a non-trivial divisor of p.

If p=-1, this function returns a matrix whose columns form a basis of the lattice equal to <STRONG><EM>Z</EM></STRONG>^n intersected with the lattice generated by the columns of x.

If p=-2, returns a matrix whose columns form a basis of the lattice equal to <STRONG><EM>Z</EM></STRONG>^n intersected with the Q-vector space generated by the columns of x.

X<matrixqz0>The library syntax is matrixqz0(x,p).


X<matsize>matsize<CODE>(x)</CODE>

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).

X<matsize>The library syntax is matsize(x).


X<matsnf>matsnf<CODE>(X,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

if X is a (singular or non-singular) square matrix outputs the vector of elementary divisors of X (i.e. the diagonal of the X<Smith normal form>Smith normal form of X).

The binary digits of flag mean:

1 (complete output): if set, outputs [U,V,D], where U and V are two unimodular matrices such that U\times X \times V is the diagonal matrix D. Otherwise output only the diagonal of D.

2 (generic input): if set, allows polynomial entries. Otherwise, assume that X has integer coefficients.

4 (cleanup): if set, cleans up the output. This means that elementary divisors equal to 1 will be deleted, i.e. outputs a shortened vector D' instead of D. If complete output was required, returns [U',V',D'] so that U'XV' = D' holds. If this flag is set, X is allowed to be of the form D or [U,V,D] as would normally be output with the cleanup flag unset.

X<matsnf0>The library syntax is matsnf0(X,<EM>flag</EM>). Also available is X<smithsmith (X)> (<EM>flag</EM>=0).


X<matsolve>matsolve<CODE>(x,y)</CODE>

x being an invertible matrix and y a column vector, finds the solution u of x*u=y, using Gaussian elimination. This has the same effect as, but is a bit faster, than x^{-1}*y.

X<gauss>The library syntax is gauss(x,y).


X<matsolvemod>matsolvemod<CODE>(m,d,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

m being any integral matrix, d a vector of positive integer moduli, and y an integral column vector, gives a small integer solution to the system of congruences <EM>sum</EM>_i m_{i,j}x_j ~ y_i\pmod{d_i} if one exists, otherwise returns zero. Shorthand notation: y (resp. d) can be given as a single integer, in which case all the y_i (resp. d_i) above are taken to be equal to y (resp. d).

If <EM>flag</EM>=1, all solutions are returned in the form of a two-component row vector [x,u], where x is a small integer solution to the system of congruences and u is a matrix whose columns give a basis of the homogeneous system (so that all solutions can be obtained by adding x to any linear combination of columns of u). If no solution exists, returns zero.

X<matsolvemod0>The library syntax is matsolvemod0(m,d,y,<EM>flag</EM>). Also available are X<gaussmodulogaussmodulo(m,d,y)> (<EM>flag</EM>=0) and X<gaussmodulo2gaussmodulo2(m,d,y)> (<EM>flag</EM>=1).


X<matsupplement>matsupplement<CODE>(x)</CODE>

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.

X<suppl>The library syntax is suppl(x).


X<mattranspose>mattranspose<CODE>(x)</CODE> or <A HREF="#item_x_">x~</A>

transpose of x. This has an effect only on vectors and matrices.

X<gtrans>The library syntax is gtrans(x).


X<qfgaussred>qfgaussred<CODE>(q)</CODE>

X<decomposition into squares>decomposition into squares of the quadratic form represented by the symmetric matrix q. The result is a matrix whose diagonal entries are the coefficients of the squares, and the non-diagonal entries represent the bilinear forms. More precisely, if (a_{ij}) denotes the output, one has <PRE> q(x) = F&lt;sum&gt;_i a_{ii} (x_i + F&lt;sum&gt;_jE&lt;gt&gt;i a_{ij} x_j)^2 </PRE>

X<sqred>The library syntax is sqred(x).


X<qfjacobi>qfjacobi<CODE>(x)</CODE>

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.

X<jacobi>The library syntax is jacobi(x).


qf{}lll

(x,{<EM>flag</EM>=0}): X< LLL>LLL algorithm applied to the columns of the (not necessarily square) matrix x. The columns of x must however be of maximal rank (unless specified otherwise below). The result is a square transformation matrix T such that x . T is an LLL-reduced basis of the lattice generated by the column vectors of x.

If <EM>flag</EM>=0 (default), the computations are done with real numbers (i.e. not with rational numbers) hence are fast but as presently programmed (version \vers) are numerically unstable.

If <EM>flag</EM>=1, it is assumed that the corresponding Gram matrix is integral. The computation is done entirely with integers and the algorithm is both accurate and quite fast. In this case, x needs not be of maximal rank.

If <EM>flag</EM>=2, similar to case 1, except x should be an integer matrix whose columns are linearly independent. The lattice generated by the columns of x is first partially reduced before applying the LLL algorithm. [A basis is said to be partially reduced if |v_i <EM>+-</EM> v_j| &gt;= |v_i| for any two distinct basis vectors v_i, v_j.]

This can be significantly faster than <EM>flag</EM>=1 when one row is huge compared to the other rows.

If <EM>flag</EM>=3, all computations are done in rational numbers. This does not incur numerical instability, but is extremely slow. This function is essentially superseded by case 1, so will soon disappear.

If <EM>flag</EM>=4, x is assumed to have integral entries, but needs not be of maximal rank. The result is a two-component vector of matrices, the columns of the first matrix representing a basis of the integer kernel of x (not necessarily LLL-reduced) and the columns of the second matrix being an LLL-reduced Z-basis of the image of the matrix x.

If <EM>flag</EM>=5, case as case 4, but x may have polynomial coefficients.

If <EM>flag</EM>=7, uses an older version of case 0 above.

If <EM>flag</EM>=8, same as case 0, where x may have polynomial coefficients.

If <EM>flag</EM>=9, variation on case 1, using content.

\sidx{qf{}lll0}The library syntax is qf{}lll0(x,<EM>flag</EM>,<CODE>prec</CODE>). Also available are X<llllll(x,prec)> (<EM>flag</EM>=0), X<lllintlllint(x)> (<EM>flag</EM>=1), and X<lllkerimlllkerim(x)> (<EM>flag</EM>=4).


qf{}lllgram

(x,{<EM>flag</EM>=0}): same as qflll except that the matrix x which must now be a square symmetric real matrix is the Gram matrix of the lattice vectors, and not the coordinates of the vectors themselves. The result is again the transformation matrix T which gives (as columns) the coefficients with respect to the initial basis vectors. The flags have more or less the same meaning, but some are missing. In brief:

<EM>flag</EM>=0: numerically unstable in the present version \vers.

<EM>flag</EM>=1: x has integer entries, the computations are all done in integers.

<EM>flag</EM>=4: x has integer entries, gives the kernel and reduced image.

<EM>flag</EM>=5: same as 4 for generic x.

<EM>flag</EM>=7: an older version of case 0.

\sidx{qf{}lllgram0}The library syntax is qf{}lllgram0(x,<EM>flag</EM>,<CODE>prec</CODE>). Also available are X<lllgramlllgram(x,prec)> (<EM>flag</EM>=0), X<lllgramintlllgramint(x)> (<EM>flag</EM>=1), and X<lllgramkerimlllgramkerim(x)> (<EM>flag</EM>=4).


X<qfminim>qfminim<CODE>(x,b,m,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

x being a square and symmetric matrix representing a positive definite quadratic form, this function deals with the minimal vectors of x, depending on <EM>flag</EM>.

If <EM>flag</EM>=0 (default), seeks vectors of square norm less than or equal to b (for the norm defined by x), and at most 2m of these vectors. The result is a three-component vector, the first component being the number of vectors, the second being the maximum norm found, and the last vector is a matrix whose columns are the vectors found, only one being given for each pair <EM>+-</EM> v (at most m such pairs).

If <EM>flag</EM>=1, ignores m and returns the first vector whose norm is less than b.

In both these cases, x is assumed to have integral entries, and the function searches for the minimal non-zero vectors whenever b=0.

If <EM>flag</EM>=2, x can have non integral real entries, but b=0 is now meaningless (uses Fincke-Pohst algorithm).

X<minim>The library syntax is minim(x,b,m) (<EM>flag</EM>=0), X<minim2minim2(x,b,m)> (<EM>flag</EM>=1), or finally <CODE>fincke_pohst</CODE>(x,b,m,<CODE>prec</CODE>) (<EM>flag</EM>=2).X<fincke_pohst>


X<qfperfection>qfperfection<CODE>(x)</CODE>

x being a square and symmetric matrix with integer entries representing a positive definite quadratic form, outputs the perfection rank of the form. That is, gives the rank of the family of the s symmetric matrices v_iv_i^t, where s is half the number of minimal vectors and the v_i (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.

X<perf>The library syntax is perf(x).


X<qfsign>qfsign<CODE>(x)</CODE>

signature of the quadratic form represented by the symmetric matrix x. The result is a two-component vector.

X<signat>The library syntax is signat(x).


X<setintersect>setintersect<CODE>(x,y)</CODE>

intersection of the two sets x and y.

X<setintersect>The library syntax is setintersect(x,y).


X<setisset>setisset<CODE>(x)</CODE>

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.

X<setisset>The library syntax is setisset(x), and this returns a long.


X<setminus>setminus<CODE>(x,y)</CODE>

difference of the two sets x and y, i.e. set of elements of x which do not belong to y.

X<setminus>The library syntax is setminus(x,y).


X<setsearch>setsearch<CODE>(x,y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

searches if y belongs to the set x. If it does and <EM>flag</EM> is zero or omitted, returns the index j such that x[j]=y, otherwise returns 0. If <EM>flag</EM> is non-zero returns the index j where y should be inserted, and 0 if it already belongs to x (this is meant to be used in conjunction with listinsert).

This function works also if x is a sorted list (see listsort).

X<setsearch>The library syntax is setsearch(x,y,<EM>flag</EM>) which returns a long integer.


X<setunion>setunion<CODE>(x,y)</CODE>

union of the two sets x and y.

X<setunion>The library syntax is setunion(x,y).


X<trace>trace<CODE>(x)</CODE>

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.

X<gtrace>The library syntax is gtrace(x).


X<vecextract>vecextract<CODE>(x,y,{z})</CODE>

extraction of components of the vector or matrix x according to y. In case x is a matrix, its components are as usual the columns of x. The parameter y is a component specifier, which is either an integer, a string describing a range, or a vector.

If y is an integer, it is considered as a mask: the binary bits of y are read from right to left, but correspond to taking the components from left to right. For example, if y=13=(1101)_2 then the components 1,3 and 4 are extracted.

If y is a vector, which must have integer entries, these entries correspond to the component numbers to be extracted, in the order specified.

If y is a string, it can be

--- a single (non-zero) index giving a component number (a negative index means we start counting from the end).

--- a range of the form "<A HREF="#item_a">a</A>..<CODE>b</CODE>", 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 < 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, x must be a matrix. y is then the line specifier, and z the column specifier, where the component specifier is as explained above.

\bprog ? v = [a, b, c, d, e]; ? vecextract(v, 5) \\mask %1 = [a, c] ? vecextract(v, [4, 2, 1]) \\component list %2 = [d, b, a] ? vecextract(v, ``2..4'') \\interval %3 = [b, c, d] ? vecextract(v, ``-1..-3'') \\interval + reverse order %4 = [e, d, c] ? vecextract([1,2,3], ``^2'') \\complement %5 = [1, 3] ? vecextract(matid(3), ``2..'', ``..'') %6 = [0 1 0]

[0 0 1] \eprog

X<extract>The library syntax is extract(x,y) or X<matextractmatextract(x,y,z)>.


X<vecsort>vecsort<CODE>(x,{k},{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

sorts the vector x in ascending order, using the heapsort method. x must be a vector, and its components integers, reals, or fractions.

If k is present and is an integer, sorts according to the value of the k-th subcomponents of the components of x. k can also be a vector, in which case the sorting is done lexicographically according to the components listed in the vector k. For example, if k=[2,1,3], sorting will be done with respect to the second component, and when these are equal, with respect to the first, and when these are equal, with respect to the third.

   The binary digits of I<flag> mean:

--- 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).

--- 2: sorts x by ascending lexicographic order (as per the lex comparison function).

X<vecsort0>The library syntax is vecsort0(x,k,flag). To omit k, use NULL instead. You can also use the simpler functions

X<sortsort(x)> (= <CODE>vecsort0</CODE>(x,NULL,0)).

X<indexsortindexsort(x)> (= <CODE>vecsort0</CODE>(x,NULL,1)).

X<lexsortlexsort(x)> (= <CODE>vecsort0</CODE>(x,NULL,2)).

Also available are X<sindexsort>sindexsort and X<sindexlexsort>sindexlexsort which return a vector (type t_VEC) of C-long integers v, where v[1]... v[n] contain the indices. Note that the resulting v is not a valid PARI object, but is in general easier to use in C programs!


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. The last parameter can be any legal PARI expression, including of course expressions using loops. Since it is much easier to program directly the loops in library mode, these functions are mainly useful for GP programming. The use of these functions in library mode is a little tricky and its explanation will be mostly omitted, although the reader can try and figure it out by himself by checking the example given for the X< sum>sum function. In this section we only give the library syntax, with no semantic explanation.

The letter X will always denote any simple variable name, and represents the formal parameter used in the function.

\misctitle{(numerical) integration}:X<numerical integration> A number of Romberg-like integration methods are implemented (see intnum as opposed to intformal which we already described). The user should not require too much accuracy: 18 or 28 decimal digits is OK, but not much more. In addition, analytical cleanup of the integral must have been done: there must be no singularities in the interval or at the boundaries. In practice this can be 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.

Note that X<infinity>infinity can be represented with essentially no loss of accuracy by 1e4000. However beware of real underflow when dealing with rapidly decreasing functions. For example, if one wants to compute the <EM>int</EM>_0^<EM>infty</EM> e^{-x^2} dx to 28 decimal digits, then one should set infinity equal to 10 for example, and certainly not to 1e4000.

The integrand may have values belonging to a vector space over the real numbers; in particular, it can be complex-valued or vector-valued.

See also the discrete summation methods below (sharing the prefix sum).


X<intnum>intnum<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

numerical integration of expr (smooth in ]a,b[), with respect to X.

Set <EM>flag</EM>=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 <EM>flag</EM>=1, uses a general driver routine for doing numerical integration, making no particular assumption (slow).

<EM>flag</EM>=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=+<EM>infty</EM>, then it is preferable to have a as large as possible, at least a&gt;=1.

If <EM>flag</EM>=3, the function is allowed to be undefined (but continuous) at a or b, for example the function <PRE> F&lt;sin&gt; (x)/x </PRE> at x=0.

X<intnum0>The library syntax is intnum0(entree<CODE>&lt;PRE&gt; &lt;/PRE&gt; </CODE>*e,GEN a,GEN b,char<CODE>&lt;PRE&gt; &lt;/PRE&gt; </CODE>*expr,long <EM>flag</EM>,long prec).


X<matrix>matrix<CODE>(m,n,{X},{Y},{&lt;CODE&gt;expr&lt;/CODE&gt;=0})</CODE>

creation of the m\times 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.

X<matrice>The library syntax is matrice(GEN nlig,GEN ncol,entree *e1,entree *e2,char *expr).


X<prod>prod<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;,{x=1})</CODE>

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^k) 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

\bprog ? prod(i=1, 100, 1-X^ i); \\this has degree 5050 !!

time = 3,335 ms.

? prod(i=1, 100, 1-X^ i, 1+O(X^ 101))

time = 43 ms.

%2 = 1 - X - X^ 2 + X^ 5 + X^ 7 - X^ 12 - X^ 15 + X^ 22 + X^ 26 - X^ 35 - X^ 40 + X^ 51 + X^ 57 - X^ 70 - X^ 77 + X^ 92 + X^ 100 + O(X^ 101) \eprog

X<produit>The library syntax is produit(entree *ep, GEN a, GEN b, char *expr, GEN x).


X<prodeuler>prodeuler<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

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.X<Euler product>

X<prodeuler>The library syntax is prodeuler(entree *ep, GEN a, GEN b, char *expr, long prec).


X<prodinf>prodinf<CODE>(X=a,&lt;CODE&gt;expr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

X<infinite product>infinite product of expression expr, the formal parameter X starting at a. The evaluation stops when the relative error of the expression minus 1 is less than the default precision. The expressions must always evaluate to an element of C.

If <EM>flag</EM>=1, do the product of the (1+<CODE>expr</CODE>) instead.

X<prodinf>The library syntax is prodinf(entree *ep, GEN a, char *expr, long prec) (<EM>flag</EM>=0), or X<prodinf1>prodinf1 with the same arguments (<EM>flag</EM>=1).


X<solve>solve<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

find a real root of expression expr between a and b, under the condition <CODE>expr</CODE>(X=a)*<CODE>expr</CODE>(X=b)&lt;=0. This routine uses Brent's method. This can fail miserably if expr is not defined in the whole of [a,b] (try solve(x=1, 2, tan(x)).

X<zbrent>The library syntax is zbrent(entree *ep, GEN a, GEN b, char *expr, long prec).


X<sum>sum<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;,{x=0})</CODE>

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

\bprog ? sum(i=1, 5000, 1/i); \\rational number: denominator has 2166 digits.

time = 1,241 ms.

? sum(i=1, 5000, 1/i, 0.)

time = 158 ms.

%2 = 9.094508852984436967261245533 \eprog

X<somme>The library syntax is somme(entree *ep, GEN a, GEN b, char *expr, GEN x). This is to be used as follows: ep represents the dummy variable used in the expression expr \bprog /* compute a^ 2 + ... + b^ 2 */ { /* define the dummy variable ``i'' */ entree *ep = gp_variable(``i''); /* sum for a <= i <= b */ return somme(ep, a, b, ``i^2'', gzero); } \eprog


X<sumalt>sumalt<CODE>(X=a,&lt;CODE&gt;expr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

numerical summation of the series expr, which should be an X<alternating series>alternating series, the formal variable X starting at a.

If <EM>flag</EM>=0, use an algorithm of F. Villegas as modified by D. Zagier. This is much better than X<Euler>Euler-Van Wijngaarden's method which was used formerly. Beware that the stopping criterion is that the term gets small enough, hence terms which are equal to 0 will create problems and should be removed.

If <EM>flag</EM>=1, use a variant with slightly different polynomials. Sometimes faster.

Divergent alternating series can sometimes be summed by this method, as well as series which are not exactly alternating (see for example Label se:user_defined).

\misctitle{Important hint:} a significant speed gain can be obtained by writing the (-1)^X which may occur in the expression as (1. - X%2*2).

X<sumalt>The library syntax is sumalt(entree *ep, GEN a, char *expr, long <EM>flag</EM>, long prec).


X<sumdiv>sumdiv<CODE>(n,X,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

sum of expression expr over the positive divisors of n.

In the present version \vers, n is restricted to being less than 2^{31}.

X<divsum>The library syntax is divsum(entree *ep, GEN num, char *expr).


X<suminf>suminf<CODE>(X=a,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

X<infinite sum>infinite sum of expression expr, the formal parameter X starting at a. The evaluation stops when the relative error of the expression is less than the default precision. The expressions must always evaluate to a complex number.

X<suminf>The library syntax is suminf(entree *ep, GEN a, char *expr, long prec).


X<sumpos>sumpos<CODE>(X=a,&lt;CODE&gt;expr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

numerical summation of the series expr, which must be a series of terms having the same sign, the formal variable X starting at a. The algorithm used is Van Wijngaarden's trick for converting such a series into an alternating one, and is quite slow. Beware that the stopping criterion is that the term gets small enough, hence terms which are equal to 0 will create problems and should be removed.

If <EM>flag</EM>=1, use slightly different polynomials. Sometimes faster.

X<sumpos>The library syntax is sumpos(entree *ep, GEN a, char *expr, long <EM>flag</EM>, long prec).


X<vector>vector<CODE>(n,{X},{&lt;CODE&gt;expr&lt;/CODE&gt;=0})</CODE>

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.

X<vecteur>The library syntax is vecteur(GEN nmax, entree *ep, char *expr).


X<vectorv>vectorv<CODE>(n,X,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

as X<vector>vector, but returns a column vector (type t_COL).

X<vvecteur>The library syntax is vvecteur(GEN nmax, entree *ep, char *expr).


Plotting functions

Although plotting is not even a side purpose of PARI, a number of plotting functions are provided. Moreover, a lot of people felt like suggesting ideas or submitting huge patches for this section of the code. Among these, special thanks go to Klaus-Peter Nischke who suggested the recursive plotting and the forking/resizing stuff under X11, and Ilya Zakharevich who undertook a complete rewrite of the graphic code, so that most of it is now platform-independent and should be relatively easy to port or expand.

These graphic functions are either

--- high-level plotting functions (all the functions starting with ploth) in which the user has little to do but explain what type of plot he wants, and whose syntax is similar to the one used in the preceding section (with somewhat more complicated flags).

--- low-level plotting functions, where every drawing primitive (point, line, box, etc.) must be specified by the user. These low-level functions (called rectplot functions, sharing the prefix plot) work as follows. You have at your disposal 16 virtual windows which are filled independently, and can then be physically ORed on a single window at user-defined positions. These windows are numbered from 0 to 15, and must be initialized before being used by the function plotinit, which specifies the height and width of the virtual window (called a rectwindow in the sequel). At all times, a virtual cursor (initialized at [0,0]) is associated to the window, and its current value can be obtained using the function plotcursor.

A number of primitive graphic objects (called rect objects) can then be drawn in these windows, using a default color associated to that window (which can be changed under X11, using the plotcolor function, black otherwise) and only the part of the object which is inside the window will be drawn, with the exception of polygons and strings which are drawn entirely (but the virtual cursor can move outside of the window). The ones sharing the prefix plotr draw relatively to the current position of the virtual cursor, the others use absolute coordinates. Those having the prefix plotrecth put in the rectwindow a large batch of rect objects corresponding to the output of the related ploth function.

Finally, the actual physical drawing is done using the function plotdraw. Note that the windows are preserved so that further drawings using the same windows at different positions or different windows can be done without extra work. If you want to erase a window (and free the corresponding memory), use the function plotkill. It is not possible to partially erase a window. Erase it completely, initialize it again and then fill it with the graphic objects that you want to keep.

In addition to initializing the window, you may want to have a scaled window to avoid unnecessary conversions. For this, use the function plotscale below. As long as this function is not called, the scaling is simply the number of pixels, the origin being at the upper left and the y-coordinates going downwards.

Note that in the present version \vers{} all these plotting functions (both low and high level) have been written for the X11-window system (hence also for GUI's based on X11 such as Openwindows and Motif), and for Sunview/Suntools only, though very little code remains which is actually platform-dependent. A Macintosh, and an Atari/Gem port were provided for previous versions. These may be adapted in future releases.

Under X11/Suntools, the physical window (opened by plotdraw or any of the ploth* functions) is completely separated from GP (technically, a fork is done, and the non-graphical memory is immediately freed in the child process), which means you can go on working in the current GP session, without having to kill the window first. Under X11, this window can be closed, enlarged or reduced using the standard window manager functions. No zooming procedure is implemented though (yet).

--- Finally, note that 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 X<PostScript>PostScript output of the plots. This will not be absolutely identical with the screen output, but will be sufficiently close. Note that you can use PostScript output even if you do not have the plotting routines enabled. The PostScript output is written in a file whose name is derived from the X< psfile>psfile default (./pari.ps if you did not tamper with it). Each time a new PostScript output is asked for, the PostScript output is appended to that file. Hence the user must remove this file, or change the value of psfile, first if he does not want unnecessary drawings from preceding sessions to appear. On the other hand, in this manner as many plots as desired can be kept in a single file.

None of the graphic functions are available within the PARI library, you must be under GP to use them. The reason for that is that you really should not use PARI for heavy-duty graphical work, there are much better specialized alternatives around. This whole set of routines was only meant as a convenient, but simple-minded, visual aid. If you really insist on using these in your program (we warned you), the source (plot*.c) should be readable enough for you to achieve something.


X<plot>plot<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

crude (ASCII) plot of the function represented by expression expr from a to b.


X<plotbox>plotbox<CODE>(w,x2,y2)</CODE>

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 (x2,y2) are opposite corners. Only the part of the rectangle which is in w is drawn. The virtual cursor does not move.


X<plotclip>plotclip<CODE>(w)</CODE>

`clips' the content of rectwindow w, i.e remove all parts of the drawing that would not be visible on the screen. Together with X< plotcopy>plotcopy this function enables you to draw on a scratchpad before commiting the part you're interested in to the final picture.


X<plotcolor>plotcolor<CODE>(w,c)</CODE>

set default color to c in rectwindow w. In present version \vers, this is only implemented for X11 window system, and you only have the following palette to choose from:

1=black, 2=blue, 3=sienna, 4=red, 5=cornsilk, 6=grey, 7=gainsborough.

Note that it should be fairly easy for you to hardwire some more colors by tweaking the files rect.h and plotX.c. User-defined colormaps would be nice, and may be available in future versions.


X<plotcopy>plotcopy<CODE>(w1,w2,dx,dy)</CODE>

copy the contents of rectwindow w1 to rectwindow w2, with offset (dx,dy).


X<plotcursor>plotcursor<CODE>(w)</CODE>

give as a 2-component vector the current (scaled) position of the virtual cursor corresponding to the rectwindow w.


X<plotdraw>plotdraw<CODE>(list)</CODE>

physically draw the rectwindows given in list which must be a vector whose number of components is divisible by 3. If list=[w1,x1,y1,w2,x2,y2,...], the windows w1, w2, etc. are physically placed with their upper left corner at physical position (x1,y1), (x2,y2),... respectively, and are then drawn together. Overlapping regions will thus be drawn twice, and the windows are considered transparent. Then display the whole drawing in a special window on your screen.


X<plotfile>plotfile<CODE>(s)</CODE>

set the output file for plotting output. Special filename - redirects to the same place as PARI output.


X<ploth>ploth<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0},{n=0})</CODE>

high precision plot of the function y=f(x) 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 [<CODE>xmin</CODE>,<CODE>xmax</CODE>,<CODE>ymin</CODE>,<CODE>ymax</CODE>].

\misctitle{Important note}: Since this may involve a lot of function calls, it is advised to keep the current precision to a minimum (e.g. 9) before calling this function.

n specifies the number of reference point on the graph (0 means use the hardwired default values, that is: 1000 for general plot, 1500 for parametric plot, and 15 for recursive plot).

If no <EM>flag</EM> 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 [f_1(X),...,f_k(X)], and then all the curves y=f_i(X) will be drawn in the same window.

   The binary digits of C<I<flag>> mean:

--- 1: Xparametric plot>. Here expr must be a vector with an even number of components. Successive pairs are then understood as the parametric coordinates of a plane curve. Each of these are then drawn.

For instance:

ploth(X=0,2*Pi,[sin(X),cos(X)],1) will draw a circle.

ploth(X=0,2*Pi,[sin(X),cos(X)]) will draw two entwined sinusoidal curves.

ploth(X=0,2*Pi,[X,X,sin(X),cos(X)],1) will draw a circle and the line y=x.

--- 2: Xrecursive plot>. If this flag is set, only one curve can be drawn at time, i.e. expr must be either a two-component vector (for a single parametric curve, and the parametric flag has to be set), or a scalar function. The idea is to choose pairs of successive reference points, and if their middle point is not too far away from the segment joining them, draw this as a local approximation to the curve. Otherwise, add the middle point to the reference points. This is very fast, and usually more precise than usual plot. Compare the results of <CODE>ploth(X=-1,1,sin(1/X),2)</CODE> and\quad<CODE>ploth(X=-1,1,sin(1/X))</CODE> 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 \bprog ploth(x = -20, 20, sin(x), 2) \eprog to see why. Hence, it's usually a good idea to try and plot the same curve with slightly different parameters.

--- 8: do not print the x-axis.

--- 16: do not print the y-axis.

--- 32: do not print frame.

--- 64: only plot reference points, do not join them.


X<plothraw>plothraw<CODE>(&lt;CODE&gt;listx&lt;/CODE&gt;,&lt;CODE&gt;listy&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

given listx and listy two vectors of equal length, plots (in high precision) the points whose (x,y)-coordinates are given in listx and listy. Automatic positioning and scaling is done, but with the same scaling factor on x and y. If <EM>flag</EM> is non-zero, join points.


X<plothsizes>plothsizes<CODE>()</CODE>

return data corresponding to the output window in the form of a 6-component vector: window width and height, sizes for ticks in horizontal and vertical directions (this is intended for the gnuplot interface and is currently not significant), width and height of characters.


X<plotinit>plotinit<CODE>(w,x,y)</CODE>

initialize the rectwindow w to width x and height y, and position the virtual cursor at (0,0). This destroys any rect objects you may have already drawn in w.

The plotting device imposes an upper bound for x and y, for instance the number of pixels for screen output. These bounds are available through the X< plothsizes>plothsizes function. The following sequence initializes in a portable way (i.e independant of the output device) a window of maximal size, accessed through coordinates in the [0,1000] \times [0,1000] range :

\bprog s = plothsizes(); plotinit(0, s[1]-1, s[2]-1); plotscale(0, 0,1000, 0,1000); \eprog


X<plotkill>plotkill<CODE>(w)</CODE>

erase rectwindow w and free the corresponding memory. Note that if you want to use the rectwindow w again, you have to use initrect first to specify the new size. So it's better in this case to use initrect directly as this throws away any previous work in the given rectwindow.


X<plotlines>plotlines<CODE>(w,X,Y,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

draw on the rectwindow w the polygon such that the (x,y)-coordinates of the vertices are in the vectors of equal length X and Y. For simplicity, the whole polygon is drawn, not only the part of the polygon which is inside the rectwindow. If <EM>flag</EM> is non-zero, close the polygon. In any case, the virtual cursor does not move.

X and Y are allowed to be scalars (in this case, both have to). There, a single segment will be drawn, between the virtual cursor current position and the point (X,Y). And only the part thereof which actually lies within the boundary of w. Then move the virtual cursor to (X,Y), even if it is outside the window. If you want to draw a line from (x1,y1) to (x2,y2) where (x1,y1) is not necessarily the position of the virtual cursor, use plotmove(w,x1,y1) before using this function.


X<plotlinetype>plotlinetype<CODE>(w,&lt;A HREF=&quot;#item_type&quot;&gt;type&lt;/A&gt;)</CODE>

this is intended for the gnuplot interface and is currently not significant.


X<plotmove>plotmove<CODE>(w,x,y)</CODE>

move the virtual cursor of the rectwindow w to position (x,y).


X<plotpoints>plotpoints<CODE>(w,X,Y)</CODE>

draw on the rectwindow w the points whose (x,y)-coordinates are in the vectors of equal length X and Y and which are inside w. The virtual cursor does not move. This is basically the same function as plothraw, but either with no scaling factor or with a scale chosen using the function plotscale.

As was the case with the plotlines function, X and Y are allowed to be (simultaneously) scalar. In this case, draw the single point (X,Y) on the rectwindow w (if it is actually inside w), and in any case move the virtual cursor to position (x,y).


X<plotpointsize>plotpointsize<CODE>(w,size)</CODE>

changes the ``size'' of following points in rectwindow w. If w = -1, change it in all rectwindows. This only works in the gnuplot interface.


X<plotpointtype>plotpointtype<CODE>(w,&lt;A HREF=&quot;#item_type&quot;&gt;type&lt;/A&gt;)</CODE>

this is intended for the gnuplot interface and is currently not significant.


X<plotrbox>plotrbox<CODE>(w,dx,dy)</CODE>

draw in the rectwindow w the outline of the rectangle which is such that the points (x1,y1) and (x1+dx,y1+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.


X<plotrecth>plotrecth<CODE>(w,X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0},{n=0})</CODE>

writes to rectwindow w the curve output of ploth(w,X=a,b,<CODE>expr</CODE>,<EM>flag</EM>,n).


X<plotrecthraw>plotrecthraw<CODE>(w,&lt;A HREF=&quot;#item_data&quot;&gt;data&lt;/A&gt;,{&lt;EM&gt;flag&lt;/EM&gt;=0})</CODE>

plot graph(s) for data in rectwindow w. <EM>flag</EM> has the same significance here as in ploth, though recursive plot is no more significant.

data is a vector of vectors, each corresponding to a list a coordinates. If parametric plot is set, there must be an even number of vectors, each successive pair corresponding to a curve. Otherwise, the first one containe the x coordinates, and the other ones contain the y-coordinates of curves to plot.


X<plotrline>plotrline<CODE>(w,dx,dy)</CODE>

draw in the rectwindow w the part of the segment (x1,y1)-(x1+dx,y1+dy) which is inside w, where (x1,y1) is the current position of the virtual cursor, and move the virtual cursor to (x1+dx,y1+dy) (even if it is outside the window).


X<plotrmove>plotrmove<CODE>(w,dx,dy)</CODE>

move the virtual cursor of the rectwindow w to position (x1+dx,y1+dy), where (x1,y1) is the initial position of the cursor (i.e. to position (dx,dy) relative to the initial cursor).


X<plotrpoint>plotrpoint<CODE>(w,dx,dy)</CODE>

draw the point (x1+dx,y1+dy) on the rectwindow w (if it is inside w), where (x1,y1) is the current position of the cursor, and in any case move the virtual cursor to position (x1+dx,y1+dy).


X<plotscale>plotscale<CODE>(w,x1,x2,y1,y2)</CODE>

scale the local coordinates of the rectwindow w so that x goes from x1 to x2 and y goes from y1 to y2 (x2<x1 and y2<y1 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.


X<plotstring>plotstring<CODE>(w,x)</CODE>

draw on the rectwindow w the String x (see Section 2.4), at the current position of the cursor.


X<plotterm>plotterm<CODE>(&lt;A HREF=&quot;#item_type&quot;&gt;type&lt;/A&gt;)</CODE>

this is intended for the gnuplot interface and is currently not significant.


X<psdraw>psdraw<CODE>(&lt;A HREF=&quot;#item_list&quot;&gt;list&lt;/A&gt;)</CODE>

same as plotdraw, except that the output is a PostScript program appended to the psfile.


X<psploth>psploth<CODE>(X=a,b,&lt;CODE&gt;expr&lt;/CODE&gt;)</CODE>

same as ploth, except that the output is a PostScript program appended to the psfile.


X<psplothraw>psplothraw<CODE>(&lt;CODE&gt;listx&lt;/CODE&gt;,&lt;CODE&gt;listy&lt;/CODE&gt;)</CODE>

same as plothraw, except that the output is a PostScript program appended to the psfile.


Programming under GP

X<programming>X<Label se:programming>


Control statements.

A number of control statements are available under GP. They are simpler and have a syntax slightly different from their C counterparts, but are quite powerful enough to write any kind of program. Some of them are specific to GP, since they are made for number theorists. They are as follows. As usual, X will denote any simple variable name, and seq will always denote a sequence of expressions, including the empty sequence.

breakbreak({n=1})

interrupts execution of current seq, and immediately exits from the n innermost enclosing loops.

forfor(X=a,b,seq)

the formal variable X going from a to b, the seq is evaluated. Nothing is done if a&gt;b. a and b must be in R.

fordivfordiv(n,X,seq)

the formal variable X ranging through the positive divisors of n, the sequence seq is evaluated. n must be of type integer.

forprimeforprime(X=a,b,seq)

the formal variable X ranging over the prime numbers between a to b (including a and b if they are prime), the seq is evaluated. Nothing is done if a&gt;b. Note that a and b must be in R.

forstepforstep(X=a,b,s,seq)

the formal variable X going from a to b, in increments of s, the seq is evaluated. Nothing is done if s&gt;0 and a&gt;b or if s<0 and a<b. s must be in <STRONG><EM>R</EM></STRONG>^* or a vector of steps [s_1,...,s_n]. In the latter case, the successive steps are used in the order they appear in s.

\bprog ? forstep(x=5, 20, [2,4], print(x)) 5 7 11 13 17 19 \eprog

forsubgroupforsubgroup(H=G,{B},seq)

executes seq for each subgroup H of the abelian group G (given in SNFX<Smith normal form> form or as a vector of elementary divisors), whose index is bounded by bound. The subgroups are not ordered in any obvious way, unless G is a p-group in which case Birkhoff's algorithm produces them by decreasing index. A X< subgroup>subgroup is given as a matrix whose columns give its generators on the implicit generators of G. For example, the following prints all subgroups of index less than 2 in G = <STRONG><EM>Z</EM></STRONG>/2<STRONG><EM>Z</EM></STRONG> g_1 \times <STRONG><EM>Z</EM></STRONG>/2<STRONG><EM>Z</EM></STRONG> g_2 :

\bprog ? G = [2,2]; forsubgroup(H=G, 2, print(H)) [1; 1] [1; 2] [2; 1] [1, 0; 1, 1] \eprog The last one, for instance is generated by (g_1, g_1 + g_2). This routine is intended to treat huge groups, when X<subgrouplist>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 HNFX<Hermite normal form> form), one can for instance use \bprog ? G = matdiagonal([2,2]); forsubgroup(H=G, 2, print(mathnf(concat(G,H)))) [2, 1; 0, 1] [1, 0; 0, 2] [2, 0; 0, 1] [1, 0; 0, 1] \eprog Note that in this last representation, the index [G:H] is given by the determinant.

forvecforvec(X=v,seq,{flag=0})

v being an n-component vector (where n is arbitrary) of two-component vectors [a_i,b_i] for 1&lt;= i&lt;= n, the seq is evaluated with the formal variable X[1] going from a_1 to b_1,...,X[n] going from a_n to b_n. The formal variable with the highest index moves the fastest. If <EM>flag</EM>=1, generate only nondecreasing vectors X, and if <EM>flag</EM>=2, generate only strictly increasing vectors X.

ifif(a,{seq1},{seq2})

if a is non-zero, the expression sequence seq1 is evaluated, otherwise the expression seq2 is evaluated. Of course, seq1 or seq2 may be empty, so if (<A HREF="#item_a">a</A>,<CODE>seq</CODE>) evaluates seq if a is not equal to zero (you don't have to write the second comma), and does nothing otherwise, whereas if (<A HREF="#item_a">a</A>,,<CODE>seq</CODE>) evaluates seq if a is equal to zero, and does nothing otherwise. You could get the same result using the ! (not) operator: if (!<A HREF="#item_a">a</A>,<CODE>seq</CODE>).

Note that the boolean operators && and || are evaluated according to operator precedence as explained in Label se:operators, 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 \bprog if (reallydoit && longcomplicatedfunction(), ...) \eprog is a perfectly safe statement.

Recall that functions such as break and next operate on loops (such as for<CODE>xxx</CODE>, while, until). The if statement is not a loop (obviously!).

nextnext()

interrupts execution of current seq, and immediately starts another iteration of the innermost enclosing loop.

returnreturn({x=0})

returns from current subroutine, with result x.

untiluntil(a,seq)

evaluates expression sequence seq until a is not equal to 0 (i.e. until a is true). If a is initially not equal to 0, seq is evaluated once (more generally, the condition on a is tested after execution of the seq, not before as in while).

whilewhile(a,seq)

while a is non-zero evaluate the expression sequence seq. 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.

Specific functions used in GP programming.

X<Label se:gp_program>

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 Label se:strings): 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.

We need an additional notation for this chapter. An argument between braces, followed by a star, like {<CODE>str</CODE>}*, means that any number of such arguments (possibly none) can be given.

addhelpaddhelp(S,str)

X<Label se:addhelp> changes the help message for the symbol S. The string str is expanded on the spot and stored as the online help for S. If S is a function you have defined, its definition will still be printed before the message str. It is recommended that you document global variables and user functions in this way. Of course GP won't protest if you don't do it.

There's nothing to prevent you from modifying the help of built-in PARI functions (but if you do, we'd like to hear why you needed to do it!).

aliasalias(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.

allocatememallocatemem({x=0})

this is a very special operation which allows the user to change the stack size after initialization. x must be a non-negative integer. If x!=0, a new stack of size 16*\lceil x/16\rceil bytes will be allocated, all the PARI data on the old stack will be moved to the new one, and the old stack will be discarded. If x=0, the size of the new stack will be twice the size of the old one.

Although it is a function, this must be the last instruction in any GP sequence. The technical reason is that this routine usually moves the stack, so objects from the current sequence might not be correct anymore. Hence, to prevent such problems, this routine terminates by a longjmp (just as an error would) and not by a return.

X<allocatemoremem>The library syntax is allocatemoremem(x), where x is an unsigned long, and the return type is void. GP uses a variant which ends by a longjmp.

defaultdefault({key},{val},{flag})

sets the default corresponding to keyword key to value val. val is a string (which of course accepts numeric arguments without adverse effects, due to the expansion mechanism). See Label se:defaults for a list of available defaults, and Label se:meta for some shortcut alternatives. X<Label se:default>

If val is omitted, prints the current value of default key. If key is omitted, prints the current values of all the defaults. If <EM>flag</EM> is set, returns the result instead of printing it.

errorerror({str}*)

outputs its argument list (each of them interpreted as a string), then interrupts the running GP program, returning to the input prompt.

Example: error("n = ", n, " is not squarefree !").

Note that, due to the automatic concatenation of strings, you could in fact use only one argument, just by suppressing the commas.

externextern(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.

getheapgetheap()

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.

X<getheap>The library syntax is getheap().

getrandgetrand()

returns the current value of the random number seed. Useful mainly for debugging purposes.

X<getrand>The library syntax is getrand(), returns a C long.

getstackgetstack()

returns the current value of top<CODE>{}-{}</CODE>avma, i.e. the number of bytes used up to now on the stack. Should be equal to 0 in between commands. Useful mainly for debugging purposes.

X<getstack>The library syntax is getstack(), returns a C long.

gettimegettime()

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.

X<gettime>The library syntax is gettime(), returns a C long.

globalglobal({list of variables})

X<Label se:global> declares the corresponding variables to be global. From now on, you will be forbidden to use them as formal parameters for function definitions or as loop indexes. This is especially useful when patching together various scripts, possibly written with different naming conventions. For instance the following situation is dangerous:

\bprog p = 3 \\fix characteristic ... forprime(p = 2, N, ...) f(p) = ... \eprog since within the loop or within the function's body, the true global value of p will be hidden. If the statement global(p = 3) appears at the beginning of the script, then both expressions will trigger syntax errors.

Calling global without arguments prints the list of global variables in use. In particular, eval(global) will output the values of all local variables.

inputinput()

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 Label se:emacs) 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).

installinstall(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 \secref{se:gp.interface} for an explanation of those). If lib is omitted, uses libpari.so. If gpname is omitted, uses name.X<Label se:install>

This function is useful for adding custom functions to the GP interpreter. But it also gives you access to all (non static) functions defined in the PARI library. For instance, the function GEN addii(GEN x, GEN y) adds two PARI integers, and is not directly accessible under GP (it's eventually called by the + operator of course):

\bprog ? install(``addii'', ``GG'') ? addii(1, 2) %1 = 3 \eprog

\misctitle{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). This used to be the fate of statically linked gp on Linux and OSF1 up to and including version 2.0.3.

Hence, if you intend to use this function, please check first on some harmless example such as the one above that it works properly on your machine.

killkill(x)

X<Label se:kill> kills the present value of the variable, alias or user-defined function x (you can only kill your own functions). The corresponding identifier can now be used to name any GP object (variable or function). This is the only way to replace a variable by a function having the same name (or the other way round), as in the following example:

\bprog ? f = 1 %1 = 1 ? f(x) = 0 *** unused characters: f(x)=0 ^---- ? kill(f) ? f(x) = 0 ? f() %2 = 0 \eprog

When you kill a variable, all objects that used it become invalid. You can still display them, even though the killed variable will be printed in a funny way (following the same convention as used by the library function fetch_var, see Label se:vars). For example:

\bprog ? a^ 2 + 1 %1 = a^2 + 1 ? kill(a) ? %1 %2 = #<1>^2 + 1 \eprog

printprint({str}*)

outputs its (string) arguments in raw format, ending with a newline.

print1print1({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 !).

printpprintp({str}*)

outputs its (string) arguments in prettyprint (beautified) format, ending with a newline.

printp1printp1({str}*)

outputs its (string) arguments in prettyprint (beautified) format, without ending with a newline.

printtexprinttex({str}*)

outputs its (string) arguments in TeX format. This output can then be used in a TeX manuscript. The printing is done on the standard output. If you want to print it to a file you should use writetex (see there).

Another possibility is to enable the X<log>log default (see Label se:defaults). You could for instance do:X<logfile>

\bprog default(logfile, ``new.tex''); default(log, 1); printtex(result); \eprog (You can use the automatic string expansion/concatenation process to have dynamic file names if you wish).

quitquit()

exits GP.X<Label se:quit>

readread({str})

reads in the file whose name results from the expansion of the string str. If str is omitted, re-reads the last file that was fed into GP. The return value is the result of the last expression evaluated.X<Label se:read>

reorderreorder({x=[ ]})

x must be a vector. If x is the empty vector, this gives the vector whose components are the existing variables in increasing order (i.e. in decreasing importance). Killed variables (see kill) will be shown as 0. If x is non-empty, it must be a permutation of variable names, and this permutation gives a new order of importance of the variables, for output only. For example, if the existing order is [x,y,z], then after reorder([z,x]) the order of importance of the variables, with respect to output, will be [z,y,x]. The internal representation is unaffected. X<Label se:reorder>

setrandsetrand(n)

reseeds the random number generator to the value n. The initial seed is n=1.

X<setrand>The library syntax is setrand(n), where n is a long. Returns n.

systemsystem(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.

typetype(x,{t})

this is useful only under GP. If t is not present, returns the internal type number of the PARI object x. Otherwise, makes a copy of x and sets its type equal to type t, which can be either a number or, preferably since internal codes may eventually change, a symbolic name such as t_FRACN (you can skip the t_ part here, so that FRACN by itself would also be all right). Check out existing type names with the metacommand \t.X<Label se:gptype>

Type changes must be used with extreme caution, or disasters may occur (SIGSEGV or SIGBUS being one's best bet), but one instance where it can be useful is type(x,RFRACN) when x is a rational function (type t_RFRAC). In this case, the created object, as well as the objects created from it, will not be reduced automatically, making the operations much faster. In fact this function is the only way to create reducible rationals (type t_FRACN) or rational functions (type t_RFRACN) in GP.

There is no equivalent library syntax, since the internal functions typ and settyp are available. Note that settyp does not create a copy of x, contrary to most PARI functions. It just changes the type in place (and returns nothing). typ returns a C long integer. Note also the different spellings of the internal functions (set)typ and of the GP function type\footnote{*}{This is due to the fact that type is a reserved identifier for some C compilers.}.

whatnowwhatnow(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).X<Label se:whatnow>

writewrite(filename,{str*})

writes (appends) to filename the remaining arguments, and appends a newline (same output as print).X<Label se:write>

write1write1(filename,{str*})

writes (appends) to filename the remaining arguments without a trailing newline (same output as print1).

writetexwritetex(filename,{str*})

as write, in TeX format.X<Label se:writetex>