home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / libPARI.pod < prev    next >
Encoding:
Text File  |  2003-05-21  |  342.6 KB  |  8,046 lines

  1. =head1 NAME
  2.  
  3. libPARI - Functions and Operations Available in PARI and GP
  4.  
  5. =head1 DESCRIPTION
  6.  
  7. X<Label se:functions>
  8. The functions and operators available in PARI and in the GP/PARI calculator
  9. are numerous and everexpanding. Here is a description of the ones available
  10. in version B<2.2.0>. It should be noted that many of these functions accept
  11. quite different types as arguments, but others are more restricted. The list
  12. of acceptable types will be given for each function or class of functions.
  13. Except when stated otherwise, it is understood that a function or operation
  14. which should make natural sense is legal. In this chapter, we will describe
  15. the functions according to a rough classification. The general entry looks
  16. something like:
  17.  
  18. B<foo>C<(x,{I<flag> = 0})>: short description.
  19.  
  20. X<foo>The library syntax is B<foo>C<(x,I<flag>)>.
  21.  
  22. This means that the GP function C<foo> has one mandatory argument C<x>, and
  23. an optional one, C<I<flag>>, whose default value is 0 (the C<{}> should never be
  24. typed, it is just a convenient notation we will use throughout to denote
  25. optional arguments). That is, you can type C<foo(x,2)>, or C<foo(x)>,
  26. which is then understood to mean C<foo(x,0)>. As well, a comma or closing
  27. parenthesis, where an optional argument should have been, signals to GP it
  28. should use the default. Thus, the syntax C<foo(x,)> is also accepted as a
  29. synonym for our last expression. When a function has more than one optional
  30. argument, the argument list is filled with user supplied values, in order.
  31. And when none are left, the defaults are used instead. Thus, assuming that
  32. C<foo>'s prototype had been
  33.  
  34. S<  >C<
  35. B<foo>({x = 1},{y = 2},{z = 3}),
  36. >
  37.  
  38. typing in C<foo(6,4)> would give
  39. you C<foo(6,4,3)>. In the rare case when you want to set some far away
  40. flag, and leave the defaults in between as they stand, you can use the
  41. ``empty arg'' trick alluded to above: C<foo(6,,1)> would yield
  42. C<foo(6,2,1)>. By the way, C<foo()> by itself yields
  43. C<foo(1,2,3)> as was to be expected. In this rather special case of a
  44. function having no mandatory argument, you can even omit the C<()>: a
  45. standalone C<foo> would be enough (though we don't really recommend it for
  46. your scripts, for the sake of clarity). In defining GP syntax, we strove
  47. to put optional arguments at the end of the argument list (of course, since
  48. they would not make sense otherwise), and in order of decreasing usefulness
  49. so that, most of the time, you will be able to ignore them.
  50.  
  51. B<Binary Flags>.X<binary flag> For some of these optional
  52. flags, we adopted the customary binary notation as a compact way to
  53. represent many toggles with just one number. Letting C<(p_0,...,p_n)> be a
  54. list of switches (i.e.S< >of properties which can be assumed to take either
  55. the value C<0> orS< >C<1>), the number C<2^3 + 2^5 = 40> means that C<p_3> and C<p_5>
  56. have been set (that is, set to C<1>), and none of the others were (that is,
  57. they were set to 0). This will usually be announced as ``The binary digits
  58. of C<I<flag>> mean 1: C<p_0>, 2: C<p_1>, 4: C<p_2>'', and so on, using the
  59. available consecutive powers ofS< >C<2>.
  60.  
  61. B<Pointers>.X<pointer> If a parameter in the function
  62. prototype is prefixed with a & sign, as in 
  63.  
  64. B<foo>C<(x,&e)>
  65.  
  66. it means that, besides the normal return value, the variable named
  67. C<e> may be set as a side effect. When passing the argument, the & sign has
  68. to be typed in explicitly. As of version B<2.2.0>, this X<pointer>C<pointer> argument
  69. is optional for all documented functions, hence the & will always appear
  70. between brackets as in C<issquare>C<(x,{&e})>.
  71.  
  72. B<About library programming>. To finish with our generic
  73. simple-minded example, the I<library> function C<foo>, as defined
  74. above, is seen to have two mandatory arguments, C<x> and I<flag> (no PARI
  75. mathematical function has been implemented so as to accept a variable
  76. number of arguments). When not mentioned otherwise, the result and
  77. arguments of a function are assumed implicitly to be of type C<GEN>.
  78. Most other functions return an object of type C<long> integer in C (see
  79. ChapterS< >4). The variable or parameter names I<prec> and I<flag> always
  80. denote C<long> integers.
  81.  
  82. The X<entree>C<entree> type is used by the library to implement iterators (loops,
  83. sums, integrals, etc.) when a formal variable has to successively assume a
  84. number of values in a given set. When programming with the library, it is
  85. easier and much more efficient to code loops and the like directly. Hence
  86. this type is not documented, although it does appear in a few library
  87. function prototypes below. See L<Label se:sums> for more details.
  88.  
  89. =head1 Standard monadic or dyadic operators
  90.  
  91. =head2 +C</>-
  92.  
  93. The expressions C<+>C<x> and C<->C<x> refer
  94. to monadic operators (the first does nothing, the second negates C<x>).
  95.  
  96. X<gneg>The library syntax is B<gneg>C<(x)> for C<->C<x>.
  97.  
  98. =head2 +, C<->
  99.  
  100. The expression C<x> C<+> C<y> is the X<sum>sum and
  101. C<x> C<-> C<y> is the X<difference>difference of C<x> and C<y>. Among the prominent
  102. impossibilities are addition/subtraction between a scalar type and a vector
  103. or a matrix, between vector/matrices of incompatible sizes and between an
  104. integermod and a real number.
  105.  
  106. X<gadd>The library syntax is B<gadd>C<(x,y)> C<x> C<+> C<y>, C<X<gsub>B<gsub>(x,y)> for C<x> C<-> C<y>.
  107.  
  108. =head2 *
  109.  
  110. The expression C<x> C<*> C<y> is the X<product>product of C<x>
  111. and C<y>. Among the prominent impossibilities are multiplication between
  112. vector/matrices of incompatible sizes, between an integermod and a real
  113. number. Note that because of vector and matrix operations, C<*> is not
  114. necessarily commutative. Note also that since multiplication between two
  115. column or two row vectors is not allowed, to obtain the X<scalar product>scalar product
  116. of two vectors of the same length, you must multiply a line vector by a
  117. column vector, if necessary by transposing one of the vectors (using
  118. the operator C<~> or the function C<mattranspose>, see
  119. L<Label se:linear_algebra>).
  120.  
  121. If C<x> and C<y> are binary quadratic forms, compose them. See also
  122. C<qfbnucomp> and C<qfbnupow>.
  123.  
  124. X<gmul>The library syntax is B<gmul>C<(x,y)> for C<x> C<*> C<y>. Also available is
  125. C<X<gsqr>B<gsqr>(x)> for C<x> C<*> C<x> (faster of course!).
  126.  
  127. =head2 /
  128.  
  129. The expression C<x> C</> C<y> is the X<quotient>quotient of C<x>
  130. and C<y>. In addition to the impossibilities for multiplication, note that if
  131. the divisor is a matrix, it must be an invertible square matrix, and in that
  132. case the result is C<x*y^{-1}>. Furthermore note that the result is as exact
  133. as possible: in particular, division of two integers always gives a rational
  134. number (which may be an integer if the quotient is exact) and I<not> the
  135. Euclidean quotient (see C<x> C<\> C<y> for that), and similarly the
  136. quotient of two polynomials is a rational function in general. To obtain the
  137. approximate real value of the quotient of two integers, add C<0.> to the
  138. result; to obtain the approximate C<p>-adic value of the quotient of two
  139. integers, add C<O(p^k)> to the result; finally, to obtain the
  140. X<Taylor series>Taylor series expansion of the quotient of two polynomials, add
  141. C<O(X^k)> to the result or use the C<taylor> function
  142. (see L<Label se:taylor>). X<Label se:gdiv>
  143.  
  144. X<gdiv>The library syntax is B<gdiv>C<(x,y)> for C<x> C</> C<y>.
  145.  
  146. =head2 \
  147.  
  148. The expression C<x> C<\> C<y> is the
  149.  
  150. X<Euclidean quotient>Euclidean quotient of C<x> and C<y>. The types must be either both
  151. integer or both polynomials. The result is the Euclidean quotient. In the
  152. case of integer division, the quotient is such that the corresponding
  153. remainder is non-negative.
  154.  
  155. X<gdivent>The library syntax is B<gdivent>C<(x,y)> for C<x> C<\> C<y>.
  156.  
  157. =head2 \/
  158.  
  159. The expression C<x> C<\/> C<y> is the Euclidean
  160. quotient of C<x> and C<y>.  The types must be either both integer or both
  161. polynomials. The result is the rounded Euclidean quotient. In the case of
  162. integer division, the quotient is such that the corresponding remainder is
  163. smallest in absolute value and in case of a tie the quotient closest to
  164. C<+ oo > is chosen.
  165.  
  166. X<gdivround>The library syntax is B<gdivround>C<(x,y)> for C<x> C<\/> C<y>.
  167.  
  168. =head2 %
  169.  
  170. The expression C<x> C<%> C<y> is the
  171.  
  172. X<Euclidean remainder>Euclidean remainder of C<x> and C<y>. The modulus C<y> must be of type
  173. integer or polynomial. The result is the remainder, always non-negative in
  174. the case of integers. Allowed dividend types are scalar exact types when
  175. the modulus is an integer, and polynomials, polmods and rational functions
  176. when the modulus is a polynomial.
  177.  
  178. X<gmod>The library syntax is B<gmod>C<(x,y)> for C<x> C<%> C<y>.
  179.  
  180. =head2 X<divrem>divremC<(x,y)>
  181.  
  182. creates a column vector with two components,
  183. the first being the Euclidean quotient, the second the Euclidean remainder,
  184. of the division of C<x> by C<y>. This avoids the need to do two divisions if
  185. one needs both the quotient and the remainder. The arguments must be both
  186. integers or both polynomials; in the case of integers, the remainder is 
  187. non-negative.
  188.  
  189. X<gdiventres>The library syntax is B<gdiventres>C<(x,y)>.
  190.  
  191. =head2 ^
  192.  
  193. The expression C<x^n> is X<powering>powering.
  194. If the exponent is an integer, then exact operations are performed using
  195. binary (left-shift) powering techniques. In particular, in this case C<x>
  196. cannot be a vector or matrix unless it is a square matrix (and moreover
  197. invertible if the exponent is negative). If C<x> is a C<p>-adic number, its
  198. precision will increase if C<v_p(n) E<gt> 0>. PARI is able to rewrite the
  199. multiplication C<x * x> of two I<identical> objects as C<x^2>, or
  200. C<sqr(x)> (here, identical means the operands are two different labels
  201. referencing the same chunk of memory; no equality test is performed). This
  202. is no longer true when more than two arguments are involved.
  203.  
  204. If the exponent is not of type integer, this is treated as a transcendental
  205. function (see L<Label se:trans>), and in particular has the effect of
  206. componentwise powering on vector or matrices.
  207.  
  208. As an exception, if the exponent is a rational number C<p/q> and C<x> an
  209. integer modulo a prime, return a solution C<y> of C<y^q = x^p> if it
  210. exists. Currently, C<q> must not have large prime factors.
  211.  
  212. Beware that
  213.  
  214.   ? Mod(7,19)^(1/2)
  215.   %1 = Mod(11, 19)/*is any square root*/
  216.   ? sqrt(Mod(7,19))
  217.   %2 = Mod(8, 19)/*is the smallest square root*/
  218.   ? Mod(7,19)^(3/5)
  219.   %3 = Mod(1, 19)
  220.   ? %3^(5/3)
  221.   %4 = Mod(1, 19)/*Mod(7,19) is just another cubic root*/
  222.  
  223. X<gpow>The library syntax is B<gpow>C<(x,n,I<prec>)> for C<x^n>.
  224.  
  225. =head2 X<shift>shiftC<(x,n)> or C<x> C<E<lt>E<lt> > C<n> ( = C<x> C<E<gt>E<gt> > C<(-n)>)
  226.  
  227. shifts
  228. C<x> componentwise left by C<n> bits if C<n E<gt>= 0> and right by C<|n|> bits if
  229. C<n E<lt> 0>. A left shift by C<n> corresponds to multiplication by C<2^n>. A right
  230. shift of an integer C<x> by C<|n|> corresponds to a Euclidean division of
  231. C<x> by C<2^{|n|}> with a
  232. remainder of the same sign as C<x>, hence is not the same (in general) as
  233. C<x \ 2^n>.
  234.  
  235. X<gshift>The library syntax is B<gshift>C<(x,n)> where C<n> is a C<long>.
  236.  
  237. =head2 X<shiftmul>shiftmulC<(x,n)>
  238.  
  239. multiplies C<x> by C<2^n>. The difference with
  240. C<shift> is that when C<n E<lt> 0>, ordinary division takes place, hence for
  241. example if C<x> is an integer the result may be a fraction, while for
  242. C<shift> Euclidean division takes place when C<n E<lt> 0> hence if C<x> is an
  243. integer the result is still an integer.
  244.  
  245. X<gmul2n>The library syntax is B<gmul2n>C<(x,n)> where C<n> is a C<long>.
  246.  
  247. =head2 Comparison and boolean operators
  248.  
  249. X<boolean operators>
  250. The six standard X<comparison operators>comparison operators C<E<lt>= >, C<E<lt> >, C<E<gt>= >,
  251. C<E<gt> >, C< == >, C<! = > are available in GP, and in library mode under
  252. the names X<gle>B<gle>, X<glt>B<glt>, X<gge>B<gge>, X<ggt>B<ggt>, X<geq>B<geq>, X<gne>B<gne>
  253. respectively. The library syntax is C<I<co>(x,y)>, where I<co> is the
  254. comparison operator. The result is 1 (as a C<GEN>) if the comparison is
  255. true, 0 (as a C<GEN>) if it is false.
  256.  
  257. The standard boolean functions  C<||> (X<inclusive or>inclusive or), C<&&>
  258. (X<and>and)X<or> and C<!> (X<not>not) are also available, and the
  259. library syntax is C<X<gor>B<gor>(x,y)>, C<X<gand>B<gand>(x,y)> and C<X<gnot>B<gnot>(x)>
  260. respectively.
  261.  
  262. In library mode, it is in fact usually preferable to use the two basic
  263. functions which are C<X<gcmp>B<gcmp>(x,y)> which gives the sign (1, 0, or -1) of
  264. C<x-y>, where C<x> and C<y> must be in B<I<R>>, and C<X<gegal>B<gegal>(x,y)> which
  265. can be applied to any two PARI objects C<x> and C<y> and gives 1 (i.e.S< >true) if
  266. they are equal (but not necessarily identical), 0 (i.e.S< >false) otherwise.
  267. Particular cases of X<gegal>B<gegal> which should be used are C<X<gcmp0>B<gcmp0>(x)>
  268. (C<x == 0> ?), C<X<gcmp1>B<gcmp1>(x)> (C<x == 1> ?), and
  269. C<X<gcmp_1>B<gcmp_1>(x)> (C<x == -1> ?).
  270.  
  271. Note that C<X<gcmp0>B<gcmp0>(x)> tests whether C<x> is equal to zero, even if C<x> is
  272. not an exact object. To test whether C<x> is an exact object which is equal to
  273. zero, one must use C<X<isexactzero>B<isexactzero>>.
  274.  
  275. Also note that the C<gcmp> and C<gegal> functions return a C-integer,
  276. and I<not> a C<GEN> like C<gle> etc.
  277.  
  278. GP accepts the following synonyms for some of the above functions: since we
  279. thought it might easily lead to confusion, we don't use the customary C
  280. operators for bitwise C<and> or bitwise C<or> (use X<bitand>C<bitand> or
  281. X<bitor>C<bitor>), hence C<|> and C<&> are accepted asX<bitwise
  282. and>X<bitwise or> synonyms of C<||> and C<&&> respectively.
  283. Also, C<E<lt>  E<gt> > is accepted as a synonym for C<! = >. On the other hand,
  284. C< = > is definitely I<not> a synonym for C< == > since it is the
  285. assignment statement.
  286.  
  287. =head2 X<lex>lexC<(x,y)>
  288.  
  289. gives the result of a lexicographic comparison
  290. between C<x> and C<y>. This is to be interpreted in quite a wide sense. For
  291. example, the vector C<[1,3]> will be considered smaller than the longer
  292. vector C<[1,3,-1]> (but of course larger than C<[1,2,5]>),
  293. i.e.S< >C<lex([1,3], [1,3,-1])> will return C<-1>.
  294.  
  295. X<lexcmp>The library syntax is B<lexcmp>C<(x,y)>.
  296.  
  297. =head2 X<sign>signC<(x)>
  298.  
  299. X<sign>sign (C<0>, C<1> or C<-1>) of C<x>, which must be of
  300. type integer, real or fraction.
  301.  
  302. X<gsigne>The library syntax is B<gsigne>C<(x)>. The result is a C<long>.
  303.  
  304. =head2 X<max>maxC<(x,y)> and X<min>B<min>C<(x,y)>
  305.  
  306. creates the
  307. maximum and minimum of C<x> and C<y> when they can be compared.
  308.  
  309. X<gmax>The library syntax is B<gmax>C<(x,y)> and C<X<gmin>B<gmin>(x,y)>.
  310.  
  311. =head2 X<vecmax>vecmaxC<(x)>
  312.  
  313. if C<x> is a vector or a matrix, returns the maximum
  314. of the elements of C<x>, otherwise returns a copy of C<x>. Returns C<- oo >
  315. in the form of C<-(2^{31}-1)> (or C<-(2^{63}-1)> for 64-bit machines) if C<x> is
  316. empty.
  317.  
  318. X<vecmax>The library syntax is B<vecmax>C<(x)>.
  319.  
  320. =head2 X<vecmin>vecminC<(x)>
  321.  
  322. if C<x> is a vector or a matrix, returns the minimum
  323. of the elements of C<x>, otherwise returns a copy of C<x>. Returns C<+ oo >
  324. in the form of C<2^{31}-1> (or C<2^{63}-1> for 64-bit machines) if C<x> is empty.
  325.  
  326. X<vecmin>The library syntax is B<vecmin>C<(x)>.
  327.  
  328. =head1 Conversions and similar elementary functions or commands
  329.  
  330. X<Label se:conversion>
  331. Many of the conversion functions are rounding or truncating operations. In
  332. this case, if the argument is a rational function, the result is the
  333. Euclidean quotient of the numerator by the denominator, and if the argument
  334. is a vector or a matrix, the operation is done componentwise. This will not
  335. be restated for every function.
  336.  
  337. =head2 X<List>ListC<({x = []})>
  338.  
  339. transforms a (row or column) vector C<x>
  340. into a list. The only other way to create a C<t_LIST> is to use the
  341. function C<listcreate>.
  342.  
  343. This is useless in library mode.
  344.  
  345. =head2 X<Mat>MatC<({x = []})>
  346.  
  347. transforms the object C<x> into a matrix.
  348. If C<x> is not a vector or a matrix, this creates a C<1 x 1> matrix.
  349. If C<x> is a row (resp. column) vector, this creates a 1-row (resp.
  350. 1-column) matrix. If C<x> is already a matrix, a copy of C<x> is created.
  351.  
  352. This function can be useful in connection with the function C<concat>
  353. (see there).
  354.  
  355. X<gtomat>The library syntax is B<gtomat>C<(x)>.
  356.  
  357. =head2 X<Mod>ModC<(x,y,{I<flag> = 0})>
  358.  
  359. X<Label se:Mod> creates the PARI object
  360. C<(x mod y)>, i.e.S< >an integermod or a polmod. C<y> must be an integer or a
  361. polynomial. If C<y> is an integer, C<x> must be an integer, a rational
  362. number, or a C<p>-adic number compatible with the modulus C<y>. If C<y> is a
  363. polynomial, C<x> must be a scalar (which is not a polmod), a polynomial, a
  364. rational function, or a power series.
  365.  
  366. This function is not the same as C<x> C<%> C<y>, the result of which is an
  367. integer or a polynomial.
  368.  
  369. If C<I<flag>> is equal to C<1>, the modulus of the created result is put on the
  370. heap and not on the stack, and hence becomes a permanent copy which cannot be
  371. erased later by garbage collecting (see L<Label se:garbage>). Functions
  372. will operate faster on such objects and memory consumption will be lower.
  373. On the other hand, care should be taken to avoid creating too many such
  374. objects.
  375.  
  376. Under GP, the same effect can be obtained by assigning the object to a GP
  377. variable (the value of which is a permanent object for the duration of the
  378. relevant library function call, and is treated as such). This value is
  379. subject to garbage collection, since it will be deleted when the value
  380. changes. This is preferable and the above flag is only retained for
  381. compatibility reasons (it can still be useful in library mode).
  382.  
  383. X<Mod0>The library syntax is B<Mod0>C<(x,y,I<flag>)>. Also available are
  384.  
  385. C<B<*>> for C<I<flag> = 1>: C<X<gmodulo>B<gmodulo>(x,y)>.
  386.  
  387. C<B<*>> for C<I<flag> = 0>: C<X<gmodulcp>B<gmodulcp>(x,y)>.
  388.  
  389. =head2 X<Pol>PolC<(x,{v = x})>
  390.  
  391. transforms the object C<x> into a polynomial with
  392. main variable C<v>. If C<x> is a scalar, this gives a constant polynomial. If
  393. C<x> is a power series, the effect is identical to C<truncate> (see there),
  394. i.e.S< >it chops off the C<O(X^k)>. If C<x> is a vector, this function creates
  395. the polynomial whose coefficients are given in C<x>, with C<x[1]> being the
  396. leading coefficient (which can be zero).
  397.  
  398. Warning: this is I<not> a substitution function. It is intended to be
  399. quick and dirty. So if you try C<Pol(a,y)> on the polynomial C<a = x+y>,
  400. you will get C<y+y>, which is not a valid PARI object.
  401.  
  402. X<gtopoly>The library syntax is B<gtopoly>C<(x,v)>, where C<v> is a variable number.
  403.  
  404. =head2 X<Polrev>PolrevC<(x,{v = x})>
  405.  
  406. transform the object C<x> into a polynomial
  407. with main variable C<v>. If C<x> is a scalar, this gives a constant polynomial.
  408. If C<x> is a power series, the effect is identical to C<truncate> (see
  409. there), i.e.S< >it chops off the C<O(X^k)>. If C<x> is a vector, this function
  410. creates the polynomial whose coefficients are given in C<x>, with C<x[1]> being
  411. the constant term. Note that this is the reverse of C<Pol> if C<x> is a
  412. vector, otherwise it is identical to C<Pol>.
  413.  
  414. X<gtopolyrev>The library syntax is B<gtopolyrev>C<(x,v)>, where C<v> is a variable number.
  415.  
  416. =head2 X<Qfb>QfbC<(a,b,c,{D = 0.})>
  417.  
  418. creates the binary quadratic form
  419. C<ax^2+bxy+cy^2>. If C<b^2-4ac E<gt> 0>, initialize X<Shanks>Shanks' distance
  420. function to C<D>.
  421.  
  422. X<Qfb0>The library syntax is B<Qfb0>C<(a,b,c,D,I<prec>)>. Also available are
  423. C<X<qfi>B<qfi>(a,b,c)> (when C<b^2-4ac E<lt> 0>), and
  424. C<X<qfr>B<qfr>(a,b,c,d)> (when C<b^2-4ac E<gt> 0>).X<binary quadratic form>
  425.  
  426. =head2 X<Ser>SerC<(x,{v = x})>
  427.  
  428. transforms the object C<x> into a power series
  429. with main variable C<v> (C<x> by default). If C<x> is a scalar, this gives a
  430. constant power series with precision given by the default C<serieslength>
  431. (corresponding to the C global variable C<precdl>). If C<x> is a
  432. polynomial, the precision is the greatest of C<precdl> and the degree of
  433. the polynomial. If C<x> is a vector, the precision is similarly given, and the
  434. coefficients of the vector are understood to be the coefficients of the power
  435. series starting from the constant term (i.e.S< >the reverse of the function
  436. C<Pol>).
  437.  
  438. The warning given for C<Pol> applies here: this is not a substitution
  439. function.
  440.  
  441. X<gtoser>The library syntax is B<gtoser>C<(x,v)>, where C<v> is a variable number (i.e.S< >a C integer).
  442.  
  443. =head2 X<Set>SetC<({x = []})>
  444.  
  445. converts C<x> into a set, i.e.S< >into a row vector
  446. with strictly increasing entries. C<x> can be of any type, but is most useful
  447. when C<x> is already a vector. The components of C<x> are put in canonical form
  448. (type C<t_STR>) so as to be easily sorted. To recover an ordinary C<GEN>
  449. from such an element, you can apply X<eval>C<eval> to it.
  450.  
  451. X<gtoset>The library syntax is B<gtoset>C<(x)>.
  452.  
  453. =head2 X<Str>StrC<({x = ""},{I<flag> = 0})>
  454.  
  455. converts C<x> into a
  456. character string (type C<t_STR>, the empty string if C<x> is omitted). To
  457. recover an ordinary C<GEN> from a string, apply C<eval> to it. The
  458. arguments of C<Str> are evaluated in string context (see
  459. L<Label se:strings>). If I<flag> is set, treat C<x> as a filename and perform
  460. X<environment expansion>environment expansion on the string. This feature can be used to read 
  461. X<environment variable>environment variable values.
  462.  
  463.   ? i = 1; Str("x" i)
  464.   %1 = "x1"
  465.   ? eval(%)
  466.   %2 = x1;
  467.   ? Str("$HOME", 1)
  468.   %3 = "/home/pari"
  469.  
  470. X<strtoGENstr>The library syntax is B<strtoGENstr>C<(x,I<flag>)>. This function is mostly useless in library mode. Use
  471. the pair X<strtoGEN>C<strtoGEN>/X<GENtostr>C<GENtostr> to convert between C<char*> and
  472. C<GEN>.
  473.  
  474. =head2 X<Vec>VecC<({x = []})>
  475.  
  476. transforms the object C<x> into a row vector. The
  477. vector will be with one component only, except when C<x> is a vector/matrix or
  478. a quadratic form (in which case the resulting vector is simply the initial
  479. object considered as a row vector), but more importantly when C<x> is a
  480. polynomial or a power series. In the case of a polynomial, the coefficients
  481. of the vector start with the leading coefficient of the polynomial, while
  482. for power series only the significant coefficients are taken into account,
  483. but this time by increasing order of degree.
  484.  
  485. X<gtovec>The library syntax is B<gtovec>C<(x)>.
  486.  
  487. =head2 X<binary>binaryC<(x)>
  488.  
  489. outputs the vector of the binary digits of C<|x|>.
  490. Here C<x> can be an integer, a real number (in which case the result has two
  491. components, one for the integer part, one for the fractional part) or a
  492. vector/matrix.
  493.  
  494. X<binaire>The library syntax is B<binaire>C<(x)>.
  495.  
  496. =head2 X<bitand>bitandC<(x,y)>
  497.  
  498. bitwise X<and>C<and>X<bitwise and> of two
  499. integers C<x> and C<y>, that is the integer
  500.  
  501. S<  >C<F<sum> (x_iS< >andS< >y_i) 2^i>
  502.  
  503. Negative numbers behave as if modulo a huge power of C<2>.
  504.  
  505. X<gbitand>The library syntax is B<gbitand>C<(x,y)>.
  506.  
  507. =head2 X<bitneg>bitnegC<(x,{n = -1})>
  508.  
  509. X<bitwise negation>bitwise negation of an integer C<x>,
  510. truncated to C<n> bits, that is the integer 
  511.  
  512. S<  >C<F<sum>_{i = 0}^n not(x_i) 2^i>
  513.  
  514. The special case C<n = -1> means no truncation: an infinite sequence of
  515. leading C<1> is then represented as a negative number.
  516.  
  517. Negative numbers behave as if modulo a huge power of C<2>.
  518.  
  519. X<gbitneg>The library syntax is B<gbitneg>C<(x)>.
  520.  
  521. =head2 X<bitnegimply>bitnegimplyC<(x,y)>
  522.  
  523. bitwise negated imply of two integers C<x>
  524. and C<y> (or C<not> C<(x ==E<gt> y)>), that is the integer
  525.  
  526. S<  >C<F<sum> (x_iS< >and not(y_i)) 2^i>
  527.  
  528. Negative numbers behave as if modulo a huge power of C<2>.
  529.  
  530. X<gbitnegimply>The library syntax is B<gbitnegimply>C<(x,y)>.
  531.  
  532. =head2 X<bitor>bitorC<(x,y)>
  533.  
  534. bitwise (inclusive) X<or>C<or>X<bitwise
  535. inclusive or> of two integers C<x> and C<y>, that is the integer
  536.  
  537. S<  >C<F<sum> (x_iS< >orS< >y_i) 2^i>
  538.  
  539. Negative numbers behave as if modulo a huge power of C<2>.
  540.  
  541. X<gbitor>The library syntax is B<gbitor>C<(x,y)>.
  542.  
  543. =head2 X<bittest>bittestC<(x,n)>
  544.  
  545. outputs the C<n^{th}> bit of C<|x|> starting
  546. from the right (i.e.S< >the coefficient of C<2^n> in the binary expansion of C<x>).
  547. The result is 0 or 1. To extract several bits at once as a vector, pass a
  548. vector for C<n>.
  549.  
  550. X<bittest>The library syntax is B<bittest>C<(x,n)>, where C<n> and the result are C<long>s.
  551.  
  552. =head2 X<bitxor>bitxorC<(x,y)>
  553.  
  554. bitwise (exclusive) X<or>C<or>X<bitwise
  555. exclusive or> of two integers C<x> and C<y>, that is the integer
  556.  
  557. S<  >C<F<sum> (x_iS< >xorS< >y_i) 2^i>
  558.  
  559. Negative numbers behave as if modulo a huge power of C<2>.
  560.  
  561. X<gbitxor>The library syntax is B<gbitxor>C<(x,y)>.
  562.  
  563. =head2 X<ceil>ceilC<(x)>
  564.  
  565. ceiling of C<x>. When C<x> is in B<I<R>>,
  566. the result is the smallest integer greater than or equal to C<x>. Applied to a
  567. rational function, C<ceil(x)> returns the euclidian quotient of the
  568. numerator by the denominator.
  569.  
  570. X<gceil>The library syntax is B<gceil>C<(x)>.
  571.  
  572. =head2 X<centerlift>centerliftC<(x,{v})>
  573.  
  574. lifts an element C<x = a mod n> of C<B<I<Z>>/nB<I<Z>>>
  575. to C<a> in B<I<Z>>, and similarly lifts a polmod to a polynomial. This is the
  576. same as C<lift> except that in the particular case of elements of
  577. C<B<I<Z>>/nB<I<Z>>>, the lift C<y> is such that C<-n/2 E<lt> y E<lt>= n/2>. If C<x> is of type
  578. fraction, complex, quadratic, polynomial, power series, rational function,
  579. vector or matrix, the lift is done for each coefficient. Real and C<p>-adics
  580. are forbidden.
  581.  
  582. X<centerlift0>The library syntax is B<centerlift0>C<(x,v)>, where C<v> is a C<long> and an omitted C<v> is coded
  583. as C<-1>. Also available is X<centerlift>B<centerlift>C<(x)> = C<centerlift0(x,-1)>.
  584.  
  585. =head2 X<changevar>changevarC<(x,y)>
  586.  
  587. creates a copy of the object C<x> where its
  588. variables are modified according to the permutation specified by the vector
  589. C<y>. For example, assume that the variables have been introduced in the
  590. order C<x>, C<a>, C<b>, C<c>. Then, if C<y> is the vector
  591. C<[x,c,a,b]>, the variable C<a> will be replaced by C<c>, C<b> by
  592. C<a>, and C<c> by C<b>, C<x> being unchanged. Note that the
  593. permutation must be completely specified, e.g.S< >C<[c,a,b]> would not work,
  594. since this would replace C<x> by C<c>, and leave C<a> and C<b>
  595. unchanged (as well as C<c> which is the fourth variable of the initial
  596. list). In particular, the new variable names must be distinct.
  597.  
  598. X<changevar>The library syntax is B<changevar>C<(x,y)>.
  599.  
  600. =head2 components of a PARI object
  601.  
  602. There are essentially three ways to extract the X<components>components from a PARI
  603. object.
  604.  
  605. The first and most general, is the function C<X<component>B<component>(x,n)> which
  606. extracts the C<n^{th}>-component of C<x>. This is to be understood as
  607. follows: every PARI type has one or two initial X<code words>code words. The
  608. components are counted, starting at 1, after these code words. In particular
  609. if C<x> is a vector, this is indeed the C<n^{th}>-component of C<x>, if
  610. C<x> is a matrix, the C<n^{th}> column, if C<x> is a polynomial, the
  611. C<n^{th}> coefficient (i.e.S< >of degree C<n-1>), and for power series, the
  612. C<n^{th}> significant coefficient. The use of the function
  613. C<component> implies the knowledge of the structure of the different PARI
  614. types, which can be recalled by typing C<\t> under GP.
  615.  
  616. X<compo>The library syntax is B<compo>C<(x,n)>, where C<n> is a C<long>.
  617.  
  618. The two other methods are more natural but more restricted. The function
  619. C< B<polcoeff>(x,n)>X<polcoeff> gives the coefficient of degree C<n> of the polynomial
  620. or power series C<x>, with respect to the main variable of C<x> (to check
  621. variable ordering, or to change it, use the function X<reorder>C<reorder>, see
  622. L<Label se:reorder>). In particular if C<n> is less than the valuation of
  623. C<x> or in the case of a polynomial, greater than the degree, the result is
  624. zero (contrary to C<compo> which would send an error message). If C<x> is
  625. a power series and C<n> is greater than the largest significant degree, then
  626. an error message is issued.
  627.  
  628. For greater flexibility, vector or matrix types are also accepted for C<x>,
  629. and the meaning is then identical with that of C<compo>.
  630.  
  631. Finally note that a scalar type is considered by C<polcoeff> as a
  632. polynomial of degree zero.
  633.  
  634. X<truecoeff>The library syntax is B<truecoeff>C<(x,n)>.
  635.  
  636. The third method is specific to vectors or matrices under GP. If C<x> is a
  637. (row or column) vector, then X<x[n]>C<x[n]> represents the C<n^{th}>
  638. component of C<x>, i.e.S< >C<compo(x,n)>. It is more natural and shorter to
  639. write. If C<x> is a matrix, X<x[m,n]>C<x[m,n]> represents the coefficient of
  640. row C<m> and column C<n> of the matrix, X<x[m,]>C<x[m,]> represents
  641. the C<m^{th}> I<row> of C<x>, and X<x[,n]>C<x[,n]> represents
  642. the C<n^{th}> I<column> of C<x>.
  643.  
  644. Finally note that in library mode, the macros X<coeff>B<coeff> and X<mael>B<mael>
  645. are available to deal with the non-recursivity of the C<GEN> type from the
  646. compiler's point of view. See the discussion on typecasts in Chapter 4.
  647.  
  648. =head2 X<conj>conjC<(x)>
  649.  
  650. conjugate of C<x>. The meaning of this
  651. is clear, except that for real quadratic numbers, it means conjugation in the
  652. real quadratic field. This function has no effect on integers, reals,
  653. integermods, fractions or C<p>-adics. The only forbidden type is polmod
  654. (see C<conjvec> for this).
  655.  
  656. X<gconj>The library syntax is B<gconj>C<(x)>.
  657.  
  658. =head2 X<conjvec>conjvecC<(x)>
  659.  
  660. conjugate vector representation of C<x>. If C<x> is a
  661. polmod, equal to C<Mod>C<(a,q)>, this gives a vector of length
  662. C<degree(q)> containing the complex embeddings of the polmod if C<q> has
  663. integral or rational coefficients, and the conjugates of the polmod if C<q>
  664. has some integermod coefficients. The order is the same as that of the
  665. C<polroots> functions. If C<x> is an integer or a rational number, the
  666. result isS< >C<x>. If C<x> is a (row or column) vector, the result is a matrix
  667. whose columns are the conjugate vectors of the individual elements of C<x>.
  668.  
  669. X<conjvec>The library syntax is B<conjvec>C<(x,I<prec>)>.
  670.  
  671. =head2 X<denominator>denominatorC<(x)>
  672.  
  673. lowest denominator of C<x>. The meaning of this
  674. is clear when C<x> is a rational number or function. When C<x> is an integer
  675. or a polynomial, the result is equal to C<1>. When C<x> is a vector or a matrix,
  676. the lowest common denominator of the components of C<x> is computed. All other
  677. types are forbidden.
  678.  
  679. X<denom>The library syntax is B<denom>C<(x)>.
  680.  
  681. =head2 X<floor>floorC<(x)>
  682.  
  683. floor of C<x>. When C<x> is in B<I<R>>, the result is the
  684. largest integer smaller than or equal to C<x>. Applied to a rational function,
  685. C<floor(x)> returns the euclidian quotient of the numerator by the
  686. denominator.
  687.  
  688. X<gfloor>The library syntax is B<gfloor>C<(x)>.
  689.  
  690. =head2 X<frac>fracC<(x)>
  691.  
  692. fractional part of C<x>. Identical to
  693. C<x-floor(x)>. If C<x> is real, the result is in C<[0,1[>.
  694.  
  695. X<gfrac>The library syntax is B<gfrac>C<(x)>.
  696.  
  697. =head2 X<imag>imagC<(x)>
  698.  
  699. imaginary part of C<x>. When
  700. C<x> is a quadratic number, this is the coefficient of C<F<omega>> in
  701. the ``canonical'' integral basis C<(1,F<omega>)>.
  702.  
  703. X<gimag>The library syntax is B<gimag>C<(x)>.
  704.  
  705. =head2 X<length>lengthC<(x)>
  706.  
  707. number of non-code words in C<x> really used (i.e.S< >the
  708. effective length minus 2 for integers and polynomials). In particular,
  709. the degree of a polynomial is equal to its length minus 1. If C<x> has type
  710. C<t_STR>, output number of letters.
  711.  
  712. X<glength>The library syntax is B<glength>C<(x)> and the result is a C long.
  713.  
  714. =head2 X<lift>liftC<(x,{v})>
  715.  
  716. lifts an element C<x = a mod n> of C<B<I<Z>>/nB<I<Z>>> to
  717. C<a> in B<I<Z>>, and similarly lifts a polmod to a polynomial if C<v> is omitted.
  718. Otherwise, lifts only polmods with main variable C<v> (if C<v> does not occur
  719. in C<x>, lifts only intmods). If C<x> is of type fraction, complex, quadratic,
  720. polynomial, power series, rational function, vector or matrix, the lift is
  721. done for each coefficient. Forbidden types for C<x> are reals and C<p>-adics.
  722.  
  723. X<lift0>The library syntax is B<lift0>C<(x,v)>, where C<v> is a C<long> and an omitted C<v> is coded as
  724. C<-1>. Also available is X<lift>B<lift>C<(x)> = C<lift0(x,-1)>.
  725.  
  726. =head2 X<norm>normC<(x)>
  727.  
  728. algebraic norm of C<x>, i.e.S< >the product of C<x> with
  729. its conjugate (no square roots are taken), or conjugates for polmods. For
  730. vectors and matrices, the norm is taken componentwise and hence is not the
  731. C<L^2>-norm (see C<norml2>). Note that the norm of an element of
  732. B<I<R>> is its square, so as to be compatible with the complex norm.
  733.  
  734. X<gnorm>The library syntax is B<gnorm>C<(x)>.
  735.  
  736. =head2 X<norml2>norml2C<(x)>
  737.  
  738. square of the C<L^2>-norm of C<x>. C<x> must
  739. be a (row or column) vector.
  740.  
  741. X<gnorml2>The library syntax is B<gnorml2>C<(x)>.
  742.  
  743. =head2 X<numerator>numeratorC<(x)>
  744.  
  745. numerator of C<x>. When C<x> is a rational number
  746. or function, the meaning is clear. When C<x> is an integer or a polynomial,
  747. the result is C<x> itself. When C<x> is a vector or a matrix, then
  748. C<numerator(x)> is defined to be C<denominator(x)*x>. All other types
  749. are forbidden.
  750.  
  751. X<numer>The library syntax is B<numer>C<(x)>.
  752.  
  753. =head2 X<numtoperm>numtopermC<(n,k)>
  754.  
  755. generates the C<k>-th permutation (as a
  756. row vector of length C<n>) of the numbers C<1> to C<n>. The number C<k> is taken
  757. modulo C<n!>, i.e.S< >inverse function of X<permtonum>C<permtonum>.
  758.  
  759. X<permute>The library syntax is B<permute>C<(n,k)>, where C<n> is a C<long>.
  760.  
  761. =head2 X<padicprec>padicprecC<(x,p)>
  762.  
  763. absolute C<p>-adic precision of the object C<x>.
  764. This is the minimum precision of the components of C<x>. The result is
  765. C<VERYBIGINT> (C<2^{31}-1> for 32-bit machines or C<2^{63}-1> for 64-bit
  766. machines) if C<x> is an exact object.
  767.  
  768. X<padicprec>The library syntax is B<padicprec>C<(x,p)> and the result is a C<long>
  769. integer.
  770.  
  771. =head2 X<permtonum>permtonumC<(x)>
  772.  
  773. given a permutation C<x> on C<n> elements,
  774. gives the number C<k> such that C<x = numtoperm(n,k)>, i.e.S< >inverse
  775. function of X<numtoperm>C<numtoperm>.
  776.  
  777. X<permuteInv>The library syntax is B<permuteInv>C<(x)>.
  778.  
  779. =head2 X<precision>precisionC<(x,{n})>
  780.  
  781. gives the precision in decimal digits of the
  782. PARI object C<x>. If C<x> is an exact object, the largest single precision
  783. integer is returned. If C<n> is not omitted, creates a new object equal to C<x>
  784. with a new precision C<n>. This is to be understood as follows:
  785.  
  786. For exact types, no change. For C<x> a vector or a matrix, the operation
  787. is done componentwise.
  788.  
  789. For real C<x>, C<n> is the number of desired significant I<decimal> digits.
  790. If C<n> is smaller than the precision of C<x>, C<x> is truncated, otherwise C<x>
  791. is extended with zeros.
  792.  
  793. For C<x> a C<p>-adic or a power series, C<n> is the desired number of
  794. significant C<p>-adic or C<X>-adic digits, where C<X> is the main variable of
  795. C<x>.
  796.  
  797. Note that the function C<precision> never changes the type of the result.
  798. In particular it is not possible to use it to obtain a polynomial from a
  799. power series. For that, see C<truncate>.
  800.  
  801. X<precision0>The library syntax is B<precision0>C<(x,n)>, where C<n> is a C<long>. Also available are
  802. C<X<ggprecision>B<ggprecision>(x)> (result is a C<GEN>) and C<X<gprec>B<gprec>(x,n)>, where
  803. C<n> is a C<long>.
  804.  
  805. =head2 X<random>randomC<({N = 2^{31}})>
  806.  
  807. gives a random integer between 0 and
  808. C<N-1>. C<N> can be arbitrary large. This is an internal PARI function and does
  809. not depend on the system's random number generator. Note that the resulting
  810. integer is obtained by means of linear congruences and will not be well
  811. distributed in arithmetic progressions.
  812.  
  813. X<genrand>The library syntax is B<genrand>C<(N)>.
  814.  
  815. =head2 X<real>realC<(x)>
  816.  
  817. real part of C<x>. In the case where C<x> is a quadratic
  818. number, this is the coefficient of C<1> in the ``canonical'' integral basis
  819. C<(1,F<omega>)>.
  820.  
  821. X<greal>The library syntax is B<greal>C<(x)>.
  822.  
  823. =head2 X<round>roundC<(x,{&e})>
  824.  
  825. If C<x> is in B<I<R>>, rounds C<x> to the nearest
  826. integer and sets C<e> to the number of error bits, that is the binary exponent
  827. of the difference between the original and the rounded value (the
  828. ``fractional part''). If the exponent of C<x> is too large compared to its
  829. precision (i.e.S< >C<e E<gt> 0>), the result is undefined and an error occurs if C<e>
  830. was not given.
  831.  
  832. B<Important remark:> note that, contrary to the other truncation
  833. functions, this function operates on every coefficient at every level of a
  834. PARI object. For example
  835.  
  836. S<  >C<truncate((2.4*X^2-1.7)/(X)) = 2.4*X,>
  837.  
  838. whereas
  839.  
  840. S<  >C<round((2.4*X^2-1.7)/(X)) = (2*X^2-2)/(X).>
  841.  
  842. An important use of C<round> is to get exact results after a long
  843. approximate computation, when theory tells you that the coefficients
  844. must be integers.
  845.  
  846. X<grndtoi>The library syntax is B<grndtoi>C<(x,&e)>, where C<e> is a C<long> integer. Also available is 
  847. C<X<ground>B<ground>(x)>.
  848.  
  849. =head2 X<simplify>simplifyC<(x)>
  850.  
  851. this function tries to simplify the object C<x> as
  852. much as it can. The simplifications do not concern rational functions (which
  853. PARI automatically tries to simplify), but type changes. Specifically, a
  854. complex or quadratic number whose imaginary part is exactly equal to 0
  855. (i.e.S< >not a real zero) is converted to its real part, and a polynomial of
  856. degree zero is converted to its constant term. For all types, this of course
  857. occurs recursively. This function is useful in any case, but in particular
  858. before the use of arithmetic functions which expect integer arguments, and
  859. not for example a complex number of 0 imaginary part and integer real part
  860. (which is however printed as an integer).
  861.  
  862. X<simplify>The library syntax is B<simplify>C<(x)>.
  863.  
  864. =head2 X<sizebyte>sizebyteC<(x)>
  865.  
  866. outputs the total number of bytes occupied by the
  867. tree representing the PARI object C<x>.
  868.  
  869. X<taille2>The library syntax is B<taille2>C<(x)> which returns a C<long>. The
  870. function X<taille>B<taille> returns the number of I<words> instead.
  871.  
  872. =head2 X<sizedigit>sizedigitC<(x)>
  873.  
  874. outputs a quick bound for the number of decimal
  875. digits of (the components of) C<x>, off by at most C<1>. If you want the
  876. exact value, you can use C<length(Str(x))>, which is much slower.
  877.  
  878. X<sizedigit>The library syntax is B<sizedigit>C<(x)> which returns a C<long>.
  879.  
  880. =head2 X<truncate>truncateC<(x,{&e})>
  881.  
  882. truncates C<x> and sets C<e> to the number of
  883. error bits. When C<x> is in B<I<R>>, this means that the part after the decimal
  884. point is chopped away, C<e> is the binary exponent of the difference between
  885. the original and the truncated value (the ``fractional part''). If the
  886. exponent of C<x> is too large compared to its precision (i.e.S< >C<e E<gt> 0>), the
  887. result is undefined and an error occurs if C<e> was not given. The function
  888. applies componentwise on rational functions and vector / matrices; C<e> is
  889. then the maximal number of error bits.
  890.  
  891. Note a very special use of C<truncate>: when applied to a power series, it
  892. transforms it into a polynomial or a rational function with denominator
  893. a power of C<X>, by chopping away the C<O(X^k)>. Similarly, when applied to
  894. a C<p>-adic number, it transforms it into an integer or a rational number
  895. by chopping away the C<O(p^k)>.
  896.  
  897. X<gcvtoi>The library syntax is B<gcvtoi>C<(x,&e)>, where C<e> is a C<long> integer. Also available is
  898. X<gtrunc>B<gtrunc>C<(x)>.
  899.  
  900. =head2 X<valuation>valuationC<(x,p)>
  901.  
  902. X<Label se:valuation> computes the highest
  903. exponent of C<p> dividing C<x>. If C<p> is of type integer, C<x> must be an
  904. integer, an integermod whose modulus is divisible by C<p>, a fraction, a
  905. C<q>-adic number with C<q = p>, or a polynomial or power series in which case the
  906. valuation is the minimum of the valuation of the coefficients.
  907.  
  908. If C<p> is of type polynomial, C<x> must be of type polynomial or rational
  909. function, and also a power series if C<x> is a monomial. Finally, the
  910. valuation of a vector, complex or quadratic number is the minimum of the
  911. component valuations.
  912.  
  913. If C<x = 0>, the result is C<VERYBIGINT> (C<2^{31}-1> for 32-bit machines or
  914. C<2^{63}-1> for 64-bit machines) if C<x> is an exact object. If C<x> is a
  915. C<p>-adic numbers or power series, the result is the exponent of the zero.
  916. Any other type combinations gives an error.
  917.  
  918. X<ggval>The library syntax is B<ggval>C<(x,p)>, and the result is a C<long>.
  919.  
  920. =head2 X<variable>variableC<(x)>
  921.  
  922. gives the main variable of the object C<x>, and
  923. C<p> if C<x> is a C<p>-adic number. Gives an error if C<x> has no variable
  924. associated to it. Note that this function is useful only in GP, since in
  925. library mode the function C<gvar> is more appropriate.
  926.  
  927. X<gpolvar>The library syntax is B<gpolvar>C<(x)>. However, in library mode, this function should not be used.
  928. Instead, test whether C<x> is a C<p>-adic (type C<t_PADIC>), in which case C<p>
  929. is in C<x[2]>, or call the function C<B<gvar>(x)> which returns the variable
  930. I<number> of C<x> if it exists, C<BIGINT> otherwise.
  931.  
  932. =head1 Transcendental functions
  933.  
  934. X<Label se:trans>
  935. As a general rule, which of course in some cases may have exceptions,
  936. transcendental functions operate in the following way:
  937.  
  938. C<B<*>> If the argument is either an integer, a real, a rational, a complex
  939. or a quadratic number, it is, if necessary, first converted to a real (or
  940. complex) number using the current X<precision>precision held in the default
  941. C<realprecision>. Note that only exact arguments are converted, while
  942. inexact arguments such as reals are not.
  943.  
  944. Under GP this is transparent to the user, but when programming in library
  945. mode, care must be taken to supply a meaningful parameter I<prec> as the
  946. last argument of the function if the first argument is an exact object.
  947. This parameter is ignored if the argument is inexact.
  948.  
  949. Note that in library mode the precision argument I<prec> is a word
  950. count including codewords, i.e.S< >represents the length in words of a real
  951. number, while under GP the precision (which is changed by the metacommand
  952. C<\p> or using C<default(realprecision,...)>) is the number of significant
  953. decimal digits.
  954.  
  955. Note that some accuracies attainable on 32-bit machines cannot be attained
  956. on 64-bit machines for parity reasons. For example the default GP accuracy
  957. is 28 decimal digits on 32-bit machines, corresponding to I<prec> having
  958. the value 5, but this cannot be attained on 64-bit machines.
  959.  
  960. After possible conversion, the function is computed. Note that even if the
  961. argument is real, the result may be complex (e.g.S< >C<acos(2.0)> or
  962. C<acosh(0.0)>). Note also that the principal branch is always chosen.
  963.  
  964. C<B<*>> If the argument is an integermod or a C<p>-adic, at present only a
  965. few functions like C<sqrt> (square root), C<sqr> (square), C<log>,
  966. C<exp>, powering, C<teichmuller> (TeichmE<uuml>ller character) and
  967. C<agm> (arithmetic-geometric mean) are implemented.
  968.  
  969. Note that in the case of a C<2>-adic number, C<sqr(x)> may not be
  970. identical to C<x*x>: for example if C<x = 1+O(2^5)> and C<y = 1+O(2^5)> then
  971. C<x*y = 1+O(2^5)> while C<sqr(x) = 1+O(2^6)>. Here, C<x * x> yields the
  972. same result as C<sqr(x)> since the two operands are known to be I<
  973. identical>. The same statement holds true for C<p>-adics raised to the power
  974. C<n>, where C<v_p(n) E<gt> 0>.
  975.  
  976. B<Remark:> note that if we wanted to be strictly consistent with
  977. the PARI philosophy, we should have C<x*y = (4 mod 8)> and C<sqr(x) = 
  978. (4 mod 32)> when both C<x> and C<y> are congruent to C<2> modulo C<4>.
  979. However, since integermod is an exact object, PARI assumes that the modulus
  980. must not change, and the result is hence C<(0 mod 4)> in both cases. On
  981. the other hand, C<p>-adics are not exact objects, hence are treated
  982. differently.
  983.  
  984. C<B<*>> If the argument is a polynomial, power series or rational function,
  985. it is, if necessary, first converted to a power series using the current
  986. precision held in the variable X<precdl>C<precdl>. Under GP this again is
  987. transparent to the user. When programming in library mode, however, the
  988. global variable C<precdl> must be set before calling the function if the
  989. argument has an exact type (i.e.S< >not a power series). Here C<precdl> is
  990. not an argument of the function, but a global variable.
  991.  
  992. Then the Taylor series expansion of the function around C<X = 0> (where C<X> is
  993. the main variable) is computed to a number of terms depending on the number
  994. of terms of the argument and the function being computed.
  995.  
  996. C<B<*>> If the argument is a vector or a matrix, the result is the
  997. componentwise evaluation of the function. In particular, transcendental
  998. functions on square matrices, which are not implemented in the present
  999. version B<2.2.0> (see AppendixS< >B however), will have a slightly different name
  1000. if they are implemented some day.
  1001.  
  1002. =head2 ^
  1003.  
  1004. If C<y> is not of type integer, C<x^y> has the same
  1005. effect as C<exp(y*ln(x))>. It can be applied to C<p>-adic numbers as
  1006. well as to the more usual types.X<powering>
  1007.  
  1008. X<gpow>The library syntax is B<gpow>C<(x,y,I<prec>)>.
  1009.  
  1010. =head2 Euler
  1011.  
  1012. Euler's constant C<0.57721...>. Note that C<Euler>
  1013. is one of the few special reserved names which cannot be used for variables
  1014. (the others are C<I> and C<Pi>, as well as all function names).
  1015. X<Label se:euler>
  1016.  
  1017. X<mpeuler>The library syntax is B<mpeuler>C<(I<prec>)> where C<I<prec>> I<must> be given. Note that
  1018. this creates C<F<gamma>> on the PARI stack, but a copy is also created on the
  1019. heap for quicker computations next time the function is called.
  1020.  
  1021. =head2 I
  1022.  
  1023. the complex number C< F<sqrt> {-1}>.
  1024.  
  1025. The library syntax is the global variable C<gi> (of type C<GEN>).
  1026.  
  1027. =head2 Pi
  1028.  
  1029. the constant C<F<Pi>> (C<3.14159...>).X<Label se:pi>
  1030.  
  1031. X<mppi>The library syntax is B<mppi>C<(I<prec>)> where C<I<prec>> I<must> be given. Note that this
  1032. creates C<F<Pi>> on the PARI stack, but a copy is also created on the heap for
  1033. quicker computations next time the function is called.
  1034.  
  1035. =head2 X<abs>absC<(x)>
  1036.  
  1037. absolute value of C<x> (modulus if C<x> is complex).
  1038. Power series and rational functions are not allowed. Contrary to most
  1039. transcendental functions, an exact argument is I<not> converted to a real
  1040. number before applying C<abs> and an exact result is returned if possible.
  1041.  
  1042.   ? abs(-1)
  1043.   %1 = 1
  1044.   ? abs(3/7 + 4/7*I)
  1045.   %2 = 5/7
  1046.   ? abs(1 + I)
  1047.   %3 = 1.414213562373095048801688724
  1048.  
  1049. If C<x> is a polynomial, returns C<-x> if the leading coefficient is
  1050. real and negative else returns C<x>. For a power series, the constant
  1051. coefficient is considered instead.
  1052.  
  1053. X<gabs>The library syntax is B<gabs>C<(x,I<prec>)>.
  1054.  
  1055. =head2 X<acos>acosC<(x)>
  1056.  
  1057. principal branch of C<cos^{-1}(x)>,
  1058. i.e.S< >such that C<Re(acos(x)) belongs to [0,F<Pi>]>. If
  1059. C<x belongs to B<I<R>>> and C<|x| E<gt> 1>, then C<acos(x)> is complex.
  1060.  
  1061. X<gacos>The library syntax is B<gacos>C<(x,I<prec>)>.
  1062.  
  1063. =head2 X<acosh>acoshC<(x)>
  1064.  
  1065. principal branch of C<cosh^{-1}(x)>,
  1066. i.e.S< >such that C<Im(acosh(x)) belongs to [0,F<Pi>]>. If
  1067. C<x belongs to B<I<R>>> and C<x E<lt> 1>, then C<acosh(x)> is complex.
  1068.  
  1069. X<gach>The library syntax is B<gach>C<(x,I<prec>)>.
  1070.  
  1071. =head2 X<agm>agmC<(x,y)>
  1072.  
  1073. arithmetic-geometric mean of C<x> and C<y>. In the
  1074. case of complex or negative numbers, the principal square root is always
  1075. chosen. C<p>-adic or power series arguments are also allowed. Note that
  1076. a C<p>-adic agm exists only if C<x/y> is congruent to 1 modulo C<p> (modulo
  1077. 16 for C<p = 2>). C<x> and C<y> cannot both be vectors or matrices.
  1078.  
  1079. X<agm>The library syntax is B<agm>C<(x,y,I<prec>)>.
  1080.  
  1081. =head2 X<arg>argC<(x)>
  1082.  
  1083. argument of the complex number C<x>, such that
  1084. C<-F<Pi> E<lt> arg(x) E<lt>= F<Pi>>.
  1085.  
  1086. X<garg>The library syntax is B<garg>C<(x,I<prec>)>.
  1087.  
  1088. =head2 X<asin>asinC<(x)>
  1089.  
  1090. principal branch of C<sin^{-1}(x)>, i.e.S< >such
  1091. that C<Re(asin(x)) belongs to [-F<Pi>/2,F<Pi>/2]>. If C<x belongs to B<I<R>>> and C<|x| E<gt> 1> then
  1092. C<asin(x)> is complex.
  1093.  
  1094. X<gasin>The library syntax is B<gasin>C<(x,I<prec>)>.
  1095.  
  1096. =head2 X<asinh>asinhC<(x)>
  1097.  
  1098. principal branch of C<sinh^{-1}(x)>, i.e.S< >such
  1099. that C<Im(asinh(x)) belongs to [-F<Pi>/2,F<Pi>/2]>.
  1100.  
  1101. X<gash>The library syntax is B<gash>C<(x,I<prec>)>.
  1102.  
  1103. =head2 X<atan>atanC<(x)>
  1104.  
  1105. principal branch of C<tan^{-1}(x)>, i.e.S< >such
  1106. that C<Re(atan(x)) belongs to  ]-F<Pi>/2,F<Pi>/2[>.
  1107.  
  1108. X<gatan>The library syntax is B<gatan>C<(x,I<prec>)>.
  1109.  
  1110. =head2 X<atanh>atanhC<(x)>
  1111.  
  1112. principal branch of C<tanh^{-1}(x)>, i.e.S< >such
  1113. that C<Im(atanh(x)) belongs to  ]-F<Pi>/2,F<Pi>/2]>. If C<x belongs to B<I<R>>> and C<|x| E<gt> 1> then
  1114. C<atanh(x)> is complex.
  1115.  
  1116. X<gath>The library syntax is B<gath>C<(x,I<prec>)>.
  1117.  
  1118. =head2 X<bernfrac>bernfracC<(x)>
  1119.  
  1120. Bernoulli numberX<Bernoulli numbers> C<B_x>,
  1121. where C<B_0 = 1>, C<B_1 = -1/2>, C<B_2 = 1/6>,..., expressed as a rational number.
  1122. The argument C<x> should be of type integer.
  1123.  
  1124. X<bernfrac>The library syntax is B<bernfrac>C<(x)>.
  1125.  
  1126. =head2 X<bernreal>bernrealC<(x)>
  1127.  
  1128. Bernoulli numberX<Bernoulli numbers>
  1129. C<B_x>, as C<bernfrac>, but C<B_x> is returned as a real number
  1130. (with the current precision).
  1131.  
  1132. X<bernreal>The library syntax is B<bernreal>C<(x,I<prec>)>.
  1133.  
  1134. =head2 X<bernvec>bernvecC<(x)>
  1135.  
  1136. creates a vector containing, as rational numbers,
  1137. the X<Bernoulli numbers>Bernoulli numbers C<B_0>, C<B_2>,..., C<B_{2x}>. These Bernoulli
  1138. numbers can then be used as follows. Assume that this vector has been put
  1139. into a variable, say C<bernint>. Then you can define under GP:
  1140.  
  1141.   bern(x) =
  1142.   {
  1143.     if (x == 1, return(-1/2));
  1144.     if (x < 0 || x % 2, return(0));
  1145.     bernint[x/2+1]
  1146.   }
  1147.  
  1148. and then C<bern(k)> gives the Bernoulli number of index C<k> as a
  1149. rational number, exactly as C<bernreal(k)> gives it as a real number. If
  1150. you need only a few values, calling C<bernfrac(k)> each time will be much
  1151. more efficient than computing the huge vector above.
  1152.  
  1153. X<bernvec>The library syntax is B<bernvec>C<(x)>.
  1154.  
  1155. =head2 X<besseljh>besseljhC<(n,x)>
  1156.  
  1157. C<J>-Bessel function of half integral index.
  1158. More precisely, C<besseljh(n,x)> computes C<J_{n+1/2}(x)> where C<n>
  1159. must be of type integer, and C<x> is any element of B<I<C>>. In the
  1160. present version B<2.2.0>, this function is not very accurate when C<x> is
  1161. small.
  1162.  
  1163. X<jbesselh>The library syntax is B<jbesselh>C<(n,x,I<prec>)>.
  1164.  
  1165. =head2 X<besselk>besselkC<(I<nu>,x,{I<flag> = 0})>
  1166.  
  1167. C<K>-Bessel function of index
  1168. I<nu> (which can be complex) and argument C<x>. Only real and positive
  1169. arguments
  1170. C<x> are allowed in the present version B<2.2.0>. If C<I<flag>> is equal to 1,
  1171. uses another implementation of this function which is often faster.
  1172.  
  1173. X<kbessel>The library syntax is B<kbessel>C<(I<nu>,x,I<prec>)> and
  1174. C<X<kbessel2>B<kbessel2>(I<nu>,x,I<prec>)> respectively.
  1175.  
  1176. =head2 X<cos>cosC<(x)>
  1177.  
  1178. cosine of C<x>.
  1179.  
  1180. X<gcos>The library syntax is B<gcos>C<(x,I<prec>)>.
  1181.  
  1182. =head2 X<cosh>coshC<(x)>
  1183.  
  1184. hyperbolic cosine of C<x>.
  1185.  
  1186. X<gch>The library syntax is B<gch>C<(x,I<prec>)>.
  1187.  
  1188. =head2 X<cotan>cotanC<(x)>
  1189.  
  1190. cotangent of C<x>.
  1191.  
  1192. X<gcotan>The library syntax is B<gcotan>C<(x,I<prec>)>.
  1193.  
  1194. =head2 X<dilog>dilogC<(x)>
  1195.  
  1196. principal branch of the dilogarithm of C<x>,
  1197. i.e.S< >analytic continuation of the power series C< F<log> _2(x) = F<sum>_{n E<gt>= 1}x^n/n^2>.
  1198.  
  1199. X<dilog>The library syntax is B<dilog>C<(x,I<prec>)>.
  1200.  
  1201. =head2 X<eint1>eint1C<(x,{n})>
  1202.  
  1203. exponential integral
  1204. C<F<int>_x^ oo (e^{-t})/(t)dt> (C<x belongs to B<I<R>>>)
  1205.  
  1206. If C<n> is present, outputs the C<n>-dimensional vector
  1207. C<[eint1(x),...,eint1(nx)]> (C<x E<gt>= 0>). This is faster than
  1208. repeatedly calling C<eint1(i * x)>.
  1209.  
  1210. X<veceint1>The library syntax is B<veceint1>C<(x,n,I<prec>)>. Also available is
  1211. C<X<eint1>B<eint1>(x,I<prec>)>.
  1212.  
  1213. =head2 X<erfc>erfcC<(x)>
  1214.  
  1215. complementary error function
  1216. C<(2/ F<sqrt> F<Pi>)F<int>_x^ oo e^{-t^2}dt>.
  1217.  
  1218. X<erfc>The library syntax is B<erfc>C<(x,I<prec>)>.
  1219.  
  1220. =head2 X<eta>etaC<(x,{I<flag> = 0})>
  1221.  
  1222. X<Dedekind>Dedekind's C<F<eta>> function, without the
  1223. C<q^{1/24}>. This means the following: if C<x> is a complex number with positive
  1224. imaginary part, the result is C<F<prod>_{n = 1}^ oo (1-q^n)>, where
  1225. C<q = e^{2iF<Pi> x}>. If C<x> is a power series (or can be converted to a power
  1226. series) with positive valuation, the result is C<F<prod>_{n = 1}^ oo (1-x^n)>.
  1227.  
  1228. If C<I<flag> = 1> and C<x> can be converted to a complex number (i.e.S< >is not a power
  1229. series), computes the true C<F<eta>> function, including the leading C<q^{1/24}>.
  1230.  
  1231. X<eta>The library syntax is B<eta>C<(x,I<prec>)>.
  1232.  
  1233. =head2 X<exp>expC<(x)>
  1234.  
  1235. exponential of C<x>.
  1236. C<p>-adic arguments with positive valuation are accepted.
  1237.  
  1238. X<gexp>The library syntax is B<gexp>C<(x,I<prec>)>.
  1239.  
  1240. =head2 X<gammah>gammahC<(x)>
  1241.  
  1242. gamma function evaluated at the argument
  1243. C<x+1/2>. When C<x> is an integer, this is much faster than using
  1244. C<gamma(x+1/2)>.
  1245.  
  1246. X<ggamd>The library syntax is B<ggamd>C<(x,I<prec>)>.
  1247.  
  1248. =head2 X<gamma>gammaC<(x)>
  1249.  
  1250. gamma function of C<x>. In the present version
  1251. B<2.2.0> the C<p>-adic gamma function is not implemented.
  1252.  
  1253. X<ggamma>The library syntax is B<ggamma>C<(x,I<prec>)>.
  1254.  
  1255. =head2 X<hyperu>hyperuC<(a,b,x)>
  1256.  
  1257. C<U>-confluent hypergeometric function with
  1258. parameters C<a> and C<b>. The parameters C<a> and C<b> can be complex but 
  1259. the present implementation requires C<x> to be positive.
  1260.  
  1261. X<hyperu>The library syntax is B<hyperu>C<(a,b,x,I<prec>)>.
  1262.  
  1263. =head2 X<incgam>incgamC<(s,x,{y})>
  1264.  
  1265. incomplete gamma function.
  1266.  
  1267. C<x> must be positive and C<s> real. The result returned is C<F<int>_x^ oo 
  1268. e^{-t}t^{s-1}dt>. When C<y> is given, assume (of course without checking!)
  1269. that C<y = F<Gamma>(s)>. For small C<x>, this will tremendously speed up the
  1270. computation.
  1271.  
  1272. X<incgam>The library syntax is B<incgam>C<(s,x,I<prec>)> and C<X<incgam4>B<incgam4>(s,x,y,I<prec>)>,
  1273. respectively. There exist also the functions X<incgam1>B<incgam1> and
  1274. X<incgam2>B<incgam2> which are used for internal purposes.
  1275.  
  1276. =head2 X<incgamc>incgamcC<(s,x)>
  1277.  
  1278. complementary incomplete gamma function.
  1279.  
  1280. The arguments C<s> and C<x> must be positive. The result returned is
  1281. C<F<int>_0^x e^{-t}t^{s-1}dt>, when C<x> is not too large.
  1282.  
  1283. X<incgam3>The library syntax is B<incgam3>C<(s,x,I<prec>)>.
  1284.  
  1285. =head2 X<log>logC<(x,{I<flag> = 0})>
  1286.  
  1287. principal branch of the natural logarithm of
  1288. C<x>, i.e.S< >such that C<Im(ln(x)) belongs to  ]-F<Pi>,F<Pi>]>. The result is complex
  1289. (with imaginary part equal to C<F<Pi>>) if C<x belongs to B<I<R>>> and C<x E<lt> 0>.
  1290.  
  1291. C<p>-adic arguments are also accepted for C<x>, with the convention that
  1292. C< F<ln> (p) = 0>. Hence in particular C< F<exp> ( F<ln> (x))/x> will not in general be
  1293. equal to 1 but to a C<(p-1)>-th root of unity (or C<F<+->1> if C<p = 2>)
  1294. times a power of C<p>.
  1295.  
  1296. If C<I<flag>> is equal to 1, use an agm formula suggested by Mestre, when C<x> is
  1297. real, otherwise identical to C<log>.
  1298.  
  1299. X<glog>The library syntax is B<glog>C<(x,I<prec>)> or C<X<glogagm>B<glogagm>(x,I<prec>)>.
  1300.  
  1301. =head2 X<lngamma>lngammaC<(x)>
  1302.  
  1303. principal branch of the logarithm of the gamma
  1304. function of C<x>. Can have much larger arguments than C<gamma> itself.
  1305. In the present version B<2.2.0>, the C<p>-adic C<lngamma> function is not
  1306. implemented.
  1307.  
  1308. X<glngamma>The library syntax is B<glngamma>C<(x,I<prec>)>.
  1309.  
  1310. =head2 X<polylog>polylogC<(m,x,{I<flag> = 0})>
  1311.  
  1312. one of the different polylogarithms,
  1313. depending on I<flag>:
  1314.  
  1315. If C<I<flag> = 0> or is omitted: C<m^th> polylogarithm of C<x>, i.e.S< >analytic
  1316. continuation of the power series C<Li_m(x) = F<sum>_{n E<gt>= 1}x^n/n^m>. The
  1317. program uses the power series when C<|x|^2 E<lt>= 1/2>, and the power series
  1318. expansion in C< F<log> (x)> otherwise. It is valid in a large domain (at least
  1319. C<|x| E<lt> 230>), but should not be used too far away from the unit circle since it
  1320. is then better to use the functional equation linking the value at C<x> to the
  1321. value at C<1/x>, which takes a trivial form for the variant below. Power
  1322. series, polynomial, rational and vector/matrix arguments are allowed.
  1323.  
  1324. For the variants to follow we need a notation: let C< F<Re> _m>
  1325. denotes C< F<Re> > or C< F<Im> > depending whether C<m> is odd or even.
  1326.  
  1327. If C<I<flag> = 1>: modified C<m^th> polylogarithm of C<x>, called
  1328. C<~ D_m(x)> in Zagier, defined for C<|x| E<lt>= 1> by
  1329.  
  1330. S<  >C< F<Re> _m(F<sum>_{k = 0}^{m-1} ((- F<log> |x|)^k)/(k!)Li_{m-k}(x)
  1331. +((- F<log> |x|)^{m-1})/(m!) F<log> |1-x|).>
  1332.  
  1333. If C<I<flag> = 2>: modified C<m^th> polylogarithm of C<x>,
  1334. called C<D_m(x)> in Zagier, defined for C<|x| E<lt>= 1> by
  1335.  
  1336. S<  >C< F<Re> _m(F<sum>_{k = 0}^{m-1}((- F<log> |x|)^k)/(k!)Li_{m-k}(x)
  1337. -(1)/(2)((- F<log> |x|)^m)/(m!)).>
  1338.  
  1339. If C<I<flag> = 3>: another modified C<m^th>
  1340. polylogarithm of C<x>, called C<P_m(x)> in Zagier, defined for C<|x| E<lt>= 1> by
  1341.  
  1342. S<  >C< F<Re> _m(F<sum>_{k = 0}^{m-1}(2^kB_k)/(k!)( F<log> |x|)^kLi_{m-k}(x)
  1343. -(2^{m-1}B_m)/(m!)( F<log> |x|)^m).>
  1344.  
  1345. These three functions satisfy the functional equation
  1346. C<f_m(1/x) = (-1)^{m-1}f_m(x)>.
  1347.  
  1348. X<polylog0>The library syntax is B<polylog0>C<(m,x,I<flag>,I<prec>)>.
  1349.  
  1350. =head2 X<psi>psiC<(x)>
  1351.  
  1352. the C<F<psi>>-function of C<x>, i.e.S< >the
  1353. logarithmic derivative C<F<Gamma>'(x)/F<Gamma>(x)>.
  1354.  
  1355. X<gpsi>The library syntax is B<gpsi>C<(x,I<prec>)>.
  1356.  
  1357. =head2 X<sin>sinC<(x)>
  1358.  
  1359. sine of C<x>.
  1360.  
  1361. X<gsin>The library syntax is B<gsin>C<(x,I<prec>)>.
  1362.  
  1363. =head2 X<sinh>sinhC<(x)>
  1364.  
  1365. hyperbolic sine of C<x>.
  1366.  
  1367. X<gsh>The library syntax is B<gsh>C<(x,I<prec>)>.
  1368.  
  1369. =head2 X<sqr>sqrC<(x)>
  1370.  
  1371. square of C<x>. This operation is not completely
  1372. straightforward, i.e.S< >identical to C<x * x>, since it can usually be
  1373. computed more efficiently (roughly one-half of the elementary
  1374. multiplications can be saved). Also, squaring a C<2>-adic number increases
  1375. its precision. For example,
  1376.  
  1377.   ? (1 + O(2^4))^2
  1378.   %1 = 1 + O(2^5)
  1379.   ? (1 + O(2^4)) * (1 + O(2^4))
  1380.   %2 = 1 + O(2^4)
  1381.  
  1382. Note that this function is also called whenever one multiplies two objects
  1383. which are known to be I<identical>, e.g.S< >they are the value of the same
  1384. variable, or we are computing a power.
  1385.  
  1386.   ? x = (1 + O(2^4)); x * x
  1387.   %3 = 1 + O(2^5)
  1388.   ? (1 + O(2^4))^4
  1389.   %4 = 1 + O(2^6)
  1390.  
  1391. (note the difference between C<%2> and C<%3> above).
  1392.  
  1393. X<gsqr>The library syntax is B<gsqr>C<(x)>.
  1394.  
  1395. =head2 X<sqrt>sqrtC<(x)>
  1396.  
  1397. principal branch of the square root of C<x>,
  1398. i.e.S< >such that C<Arg(sqrt(x)) belongs to  ]-F<Pi>/2, F<Pi>/2]>, or in other
  1399. words such that C< F<Re> (sqrt(x)) E<gt> 0> or C< F<Re> (sqrt(x)) = 0> and
  1400. C< F<Im> (sqrt(x)) E<gt>= 0>. If C<x belongs to B<I<R>>> and C<x E<lt> 0>, then the result is
  1401. complex with positive imaginary part.
  1402.  
  1403. Integermod a prime and C<p>-adics are allowed as arguments. In that case,
  1404. the square root (if it exists) which is returned is the one whose
  1405. first C<p>-adic digit (or its unique C<p>-adic digit in the case of
  1406. integermods) is in the interval C<[0,p/2]>. When the argument is an
  1407. integermod a non-prime (or a non-prime-adic), the result is undefined.
  1408.  
  1409. X<gsqrt>The library syntax is B<gsqrt>C<(x,I<prec>)>.
  1410.  
  1411. =head2 X<sqrtn>sqrtnC<(x,n,{&z})>
  1412.  
  1413. principal branch of the C<n>th root of C<x>,
  1414. i.e.S< >such that C<Arg(sqrt(x)) belongs to  ]-F<Pi>/n, F<Pi>/n]>.
  1415.  
  1416. Integermod a prime and C<p>-adics are allowed as arguments.
  1417.  
  1418. If C<z> is present, it is set to a suitable root of unity allowing to
  1419. recover all the other roots. If it was not possible, z is
  1420. set to zero.
  1421.  
  1422. The following script computes all roots in all possible cases:
  1423.  
  1424.   sqrtnall(x,n)=
  1425.   {
  1426.     local(V,r,z,r2);
  1427.     r = sqrtn(x,n, &z);
  1428.     if (!z, error("Impossible case in sqrtn"));
  1429.     if (type(x) == "t_INTMOD" || type(x)=="t_PADIC" ,
  1430.       r2 = r*z; n = 1;
  1431.       while (r2!=r, r2*=z;n++));
  1432.     V = vector(n); V[1] = r;
  1433.     for(i=2, n, V[i] = V[i-1]*z);
  1434.     V
  1435.   }
  1436.   addhelp(sqrtnall,"sqrtnall(x,n):compute the vector of nth-roots of x");
  1437.  
  1438. X<gsqrtn>The library syntax is B<gsqrtn>C<(x,n,&z,I<prec>)>.
  1439.  
  1440. =head2 X<tan>tanC<(x)>
  1441.  
  1442. tangent of C<x>.
  1443.  
  1444. X<gtan>The library syntax is B<gtan>C<(x,I<prec>)>.
  1445.  
  1446. =head2 X<tanh>tanhC<(x)>
  1447.  
  1448. hyperbolic tangent of C<x>.
  1449.  
  1450. X<gth>The library syntax is B<gth>C<(x,I<prec>)>.
  1451.  
  1452. =head2 X<teichmuller>teichmullerC<(x)>
  1453.  
  1454. TeichmE<uuml>ller character of the C<p>-adic number
  1455. C<x>.
  1456.  
  1457. X<teich>The library syntax is B<teich>C<(x)>.
  1458.  
  1459. =head2 X<theta>thetaC<(q,z)>
  1460.  
  1461. Jacobi sine theta-function.
  1462.  
  1463. X<theta>The library syntax is B<theta>C<(q,z,I<prec>)>.
  1464.  
  1465. =head2 X<thetanullk>thetanullkC<(q,k)>
  1466.  
  1467. C<k>-th derivative at C<z = 0> of
  1468. C<theta(q,z)>.
  1469.  
  1470. X<thetanullk>The library syntax is B<thetanullk>C<(q,k,I<prec>)>, where C<k> is a C<long>.
  1471.  
  1472. =head2 X<weber>weberC<(x,{I<flag> = 0})>
  1473.  
  1474. one of Weber's three C<f> functions.
  1475. If C<I<flag> = 0>, returns
  1476.  
  1477. S<  >C<f(x) =  F<exp> (-iF<Pi>/24).F<eta>((x+1)/2)/F<eta>(x)   such that  j = (f^{24}-16)^3/f^{24},>
  1478.  
  1479. where C<j> is the elliptic C<j>-invariant  (see the function C<ellj>).
  1480. If C<I<flag> = 1>, returns
  1481.  
  1482. S<  >C<f_1(x) = F<eta>(x/2)/F<eta>(x)  such that  j = (f_1^{24}+16)^3/f_1^{24}.>
  1483.  
  1484. Finally, if C<I<flag> = 2>, returns
  1485.  
  1486. S<  >C<f_2(x) =  F<sqrt> {2}F<eta>(2x)/F<eta>(x)  such that  j = (f_2^{24}+16)^3/f_2^{24}.>
  1487.  
  1488. Note the identities C<f^8 = f_1^8+f_2^8> and C<ff_1f_2 =  F<sqrt> 2>.
  1489.  
  1490. X<weber0>The library syntax is B<weber0>C<(x,I<flag>,I<prec>)>, or
  1491. C<X<wf>B<wf>(x,I<prec>)>, C<X<wf1>B<wf1>(x,I<prec>)> or
  1492. C<X<wf2>B<wf2>(x,I<prec>)>.
  1493.  
  1494. =head2 X<zeta>zetaC<(s)>
  1495.  
  1496. Riemann's zeta functionX<Riemann zeta-function>
  1497. C<F<zeta>(s) = F<sum>_{n E<gt>= 1}n^{-s}>, computed using the X<Euler-Maclaurin>Euler-Maclaurin
  1498. summation formula, except when C<s> is of type integer, in which case it
  1499. is computed using Bernoulli numbersX<Bernoulli numbers> for
  1500. C<s E<lt>= 0> or C<s E<gt> 0> and even, and using modular forms for C<s E<gt> 0> and odd.
  1501.  
  1502. X<gzeta>The library syntax is B<gzeta>C<(s,I<prec>)>.
  1503.  
  1504. =head1 Arithmetic functions
  1505.  
  1506. X<Label se:arithmetic>
  1507. These functions are by definition functions whose natural domain of
  1508. definition is either B<I<Z>> (or C<B<I<Z>>_{ E<gt> 0}>), or sometimes polynomials
  1509. over a base ring. Functions which concern polynomials exclusively will be
  1510. explained in the next section. The way these functions are used is
  1511. completely different from transcendental functions: in general only the types
  1512. integer and polynomial are accepted as arguments. If a vector or matrix type
  1513. is given, the function will be applied on each coefficient independently.
  1514.  
  1515. In the present version B<2.2.0>, all arithmetic functions in the narrow sense
  1516. of the wordS< >--- Euler's totientX<Euler totient function> function, the
  1517. X<Moebius>Moebius function, the sums over divisors or powers of divisors
  1518. etc.--- call, after trial division by small primes, the same versatile
  1519. factoring machinery described under C<factorint>. It includes
  1520. X<Shanks SQUFOF>Shanks SQUFOF, X<Pollard Rho>Pollard Rho, X<ECM>ECM and X<MPQS>MPQS stages, and
  1521. has an early exit option for the functions X<moebius>B<moebius> and (the integer
  1522. function underlying) X<issquarefree>B<issquarefree>. Note that it relies on a (fairly
  1523. strong) probabilistic primality test: numbers found to be strong
  1524. pseudo-primes after 10 successful trials of the X<Rabin-Miller>Rabin-Miller test are
  1525. declared primes.
  1526.  
  1527. =head2 X<addprimes>addprimesC<({x = []})>
  1528.  
  1529. adds the primes contained in the vector
  1530. C<x> (or the single integer C<x>) to the table computed upon GP initialization
  1531. (by C<pari_init> in library mode), and returns a row vector whose first
  1532. entries contain all primes added by the user and whose last entries have been
  1533. filled up with 1's. In total the returned row vector has 100 components.
  1534. Whenever C<factor> or C<smallfact> is subsequently called, first the
  1535. primes in the table computed by C<pari_init> will be checked, and then
  1536. the additional primes in this table. If C<x> is empty or omitted, just returns
  1537. the current list of extra primes.
  1538.  
  1539. The entries in C<x> are not checked for primality. They need only be positive
  1540. integers not divisible by any of the pre-computed primes. It's in fact a nice
  1541. trick to add composite numbers, which for example the function
  1542. C<factor(x,0)> was not able to factor. In case the message ``impossible
  1543. inverse modulo C<E<lt>>I<some integermod>C<E<gt>>'' shows up afterwards,
  1544. you have just stumbled over a non-trivial factor. Note that the arithmetic
  1545. functions in the narrow sense, like X<eulerphi>B<eulerphi>, do I<not> use this
  1546. extra table.
  1547.  
  1548. The present PARI version B<2.2.0> allows up to 100 user-specified
  1549. primes to be appended to the table. This limit may be changed
  1550. by altering C<NUMPRTBELT> in file C<init.c>. To remove primes from the
  1551. list use C<removeprimes>.
  1552.  
  1553. X<addprimes>The library syntax is B<addprimes>C<(x)>.
  1554.  
  1555. =head2 X<bestappr>bestapprC<(x,k)>
  1556.  
  1557. if C<x belongs to B<I<R>>>, finds the best rational
  1558. approximation to C<x> with denominator at most equal to C<k> using continued
  1559. fractions.
  1560.  
  1561. X<bestappr>The library syntax is B<bestappr>C<(x,k)>.
  1562.  
  1563. =head2 X<bezout>bezoutC<(x,y)>
  1564.  
  1565. finds C<u> and C<v> minimal in a
  1566. natural sense such that C<x*u+y*v = gcd(x,y)>. The arguments
  1567. must be both integers or both polynomials, and the result is a
  1568. row vector with three components C<u>, C<v>, and C<gcd(x,y)>.
  1569.  
  1570. X<vecbezout>The library syntax is B<vecbezout>C<(x,y)> to get the vector, or C<X<gbezout>B<gbezout>(x,y, &u, &v)>
  1571. which gives as result the address of the created gcd, and puts
  1572. the addresses of the corresponding created objects into C<u> and C<v>.
  1573.  
  1574. =head2 X<bezoutres>bezoutresC<(x,y)>
  1575.  
  1576. as C<bezout>, with the resultant of C<x> and
  1577. C<y> replacing the gcd.
  1578.  
  1579. X<vecbezoutres>The library syntax is B<vecbezoutres>C<(x,y)> to get the vector, or C<X<subresext>B<subresext>(x,y, &u,
  1580. &v)> which gives as result the address of the created gcd, and puts the
  1581. addresses of the corresponding created objects into C<u> and C<v>.
  1582.  
  1583. =head2 X<bigomega>bigomegaC<(x)>
  1584.  
  1585. number of prime divisors of C<|x|> counted with
  1586. multiplicity. C<x> must be an integer.
  1587.  
  1588. X<bigomega>The library syntax is B<bigomega>C<(x)>, the result is a C<long>.
  1589.  
  1590. =head2 X<binomial>binomialC<(x,y)>
  1591.  
  1592. X<binomial coefficient>binomial coefficient C<\binom x y>.
  1593. Here C<y> must be an integer, but C<x> can be any PARI object.
  1594.  
  1595. X<binome>The library syntax is B<binome>C<(x,y)>, where C<y> must be a C<long>.
  1596.  
  1597. =head2 X<chinese>chineseC<(x,y)>
  1598.  
  1599. if C<x> and C<y> are both integermods or both
  1600. polmods, creates (with the same type) a C<z> in the same residue class
  1601. as C<x> and in the same residue class as C<y>, if it is possible.
  1602.  
  1603. This function also allows vector and matrix arguments, in which case the
  1604. operation is recursively applied to each component of the vector or matrix.
  1605. For polynomial arguments, it is applied to each coefficient. Finally
  1606. C<chinese(x,x) = x> regardless of the type of C<x>; this allows vector
  1607. arguments to contain other data, so long as they are identical in both
  1608. vectors.
  1609.  
  1610. X<chinois>The library syntax is B<chinois>C<(x,y)>.
  1611.  
  1612. =head2 X<content>contentC<(x)>
  1613.  
  1614. computes the gcd of all the coefficients of C<x>,
  1615. when this gcd makes sense. If C<x> is a scalar, this simply returns C<x>. If C<x>
  1616. is a polynomial (and by extension a power series), it gives the usual content
  1617. of C<x>. If C<x> is a rational function, it gives the ratio of the contents of
  1618. the numerator and the denominator. Finally, if C<x> is a vector or a matrix,
  1619. it gives the gcd of all the entries.
  1620.  
  1621. X<content>The library syntax is B<content>C<(x)>.
  1622.  
  1623. =head2 X<contfrac>contfracC<(x,{b},{lmax})>
  1624.  
  1625. creates the row vector whose
  1626. components are the partial quotients of the X<continued fraction>continued fraction
  1627. expansion of C<x>, the number of partial quotients being limited to C<lmax>.
  1628. If C<x> is a real number, the expansion stops at the last significant partial
  1629. quotient if C<lmax> is omitted. C<x> can also be a rational function or a power
  1630. series.
  1631.  
  1632. If a vector C<b> is supplied, the numerators will be equal to the coefficients
  1633. of C<b>. The length of the result is then equal to the length of C<b>, unless a
  1634. partial remainder is encountered which is equal to zero. In which case the
  1635. expansion stops. In the case of real numbers, the stopping criterion is thus
  1636. different from the one mentioned above since, if C<b> is too long, some partial
  1637. quotients may not be significant.
  1638.  
  1639. If C<b> is an integer, the command is understood as C<contfrac(x,lmax)>.
  1640.  
  1641. X<contfrac0>The library syntax is B<contfrac0>C<(x,b,lmax)>. Also available are
  1642. C<X<gboundcf>B<gboundcf>(x,lmax)>, C<X<gcf>B<gcf>(x)>, or C<X<gcf2>B<gcf2>(b,x)>, where C<lmax>
  1643. is a C integer.
  1644.  
  1645. =head2 X<contfracpnqn>contfracpnqnC<(x)>
  1646.  
  1647. when C<x> is a vector or a one-row matrix, C<x>
  1648. is considered as the list of partial quotients C<[a_0,a_1,...,a_n]> of a
  1649. rational number, and the result is the 2 by 2 matrix
  1650. C<[p_n,p_{n-1};q_n,q_{n-1}]> in the standard notation of continued fractions,
  1651. so C<p_n/q_n = a_0+1/(a_1+...+1/a_n)...)>. If C<x> is a matrix with two rows
  1652. C<[b_0,b_1,...,b_n]> and C<[a_0,a_1,...,a_n]>, this is then considered as a
  1653. generalized continued fraction and we have similarly
  1654. C<p_n/q_n = 1/b_0(a_0+b_1/(a_1+...+b_n/a_n)...)>. Note that in this case one
  1655. usually has C<b_0 = 1>.
  1656.  
  1657. X<pnqn>The library syntax is B<pnqn>C<(x)>.
  1658.  
  1659. =head2 X<core>coreC<(n,{I<flag> = 0})>
  1660.  
  1661. if C<n> is a non-zero integer written as
  1662. C<n = df^2> with C<d> squarefree, returns C<d>. If C<I<flag>> is non-zero,
  1663. returns the two-element row vector C<[d,f]>.
  1664.  
  1665. X<core0>The library syntax is B<core0>C<(n,I<flag>)>.
  1666. Also available are
  1667. C<X<core>B<core>(n)> ( = X<core>B<core>C<(n,0)>) and
  1668. C<X<core2>B<core2>(n)> ( = X<core>B<core>C<(n,1)>).
  1669.  
  1670. =head2 X<coredisc>corediscC<(n,{I<flag>})>
  1671.  
  1672. if C<n> is a non-zero integer written as
  1673. C<n = df^2> with C<d> fundamental discriminant (including 1), returns C<d>. If
  1674. C<I<flag>> is non-zero, returns the two-element row vector C<[d,f]>. Note that if
  1675. C<n> is not congruent to 0 or 1 modulo 4, C<f> will be a half integer and not
  1676. an integer.
  1677.  
  1678. X<coredisc0>The library syntax is B<coredisc0>C<(n,I<flag>)>.
  1679. Also available are
  1680. C<X<coredisc>B<coredisc>(n)> ( = X<coredisc>B<coredisc>C<(n,0)>) and
  1681. C<X<coredisc2>B<coredisc2>(n)> ( = X<coredisc>B<coredisc>C<(n,1)>).
  1682.  
  1683. =head2 X<dirdiv>dirdivC<(x,y)>
  1684.  
  1685. C<x> and C<y> being vectors of perhaps different
  1686. lengths but with C<y[1] ! = 0> considered as X<Dirichlet series>Dirichlet series, computes
  1687. the quotient of C<x> by C<y>, again as a vector.
  1688.  
  1689. X<dirdiv>The library syntax is B<dirdiv>C<(x,y)>.
  1690.  
  1691. =head2 X<direuler>direulerC<(p = a,b,I<expr>,{c})>
  1692.  
  1693. computes the
  1694. X<Dirichlet series>Dirichlet series to C<b> terms of the X<Euler product>Euler product of
  1695. expression I<expr> as C<p> ranges through the primes from C<a> to C<b>.
  1696. I<expr> must be a polynomial or rational function in another variable
  1697. than C<p> (say C<X>) and C<I<expr>(X)> is understood as the Dirichlet
  1698. series (or more precisely the local factor) C<I<expr>(p^{-s})>. If C<c> is
  1699. present, output only the first C<c> coefficients in the series.
  1700.  
  1701. X<direuler>The library syntax is B<direuler>C<(entree *ep, GEN a, GEN b, char *expr)>
  1702.  
  1703. =head2 X<dirmul>dirmulC<(x,y)>
  1704.  
  1705. C<x> and C<y> being vectors of perhaps different
  1706. lengths considered as X<Dirichlet series>Dirichlet series, computes the product of
  1707. C<x> by C<y>, again as a vector.
  1708.  
  1709. X<dirmul>The library syntax is B<dirmul>C<(x,y)>.
  1710.  
  1711. =head2 X<divisors>divisorsC<(x)>
  1712.  
  1713. creates a row vector whose components are the
  1714. positive divisors of the integer C<x> in increasing order. The factorization
  1715. of C<x> (as output by X<factor>C<factor>) can be used instead.
  1716.  
  1717. X<divisors>The library syntax is B<divisors>C<(x)>.
  1718.  
  1719. =head2 X<eulerphi>eulerphiC<(x)>
  1720.  
  1721. Euler's C<F<phi>>
  1722. (totient)X<Euler totient function> function of C<|x|>, in other words
  1723. C<|(B<I<Z>>/xB<I<Z>>)^*|>. C<x> must be of type integer.
  1724.  
  1725. X<phi>The library syntax is B<phi>C<(x)>.
  1726.  
  1727. =head2 X<factor>factorC<(x,{I<lim> = -1})>
  1728.  
  1729. general factorization function.
  1730. If C<x> is of type integer, rational, polynomial or rational function, the
  1731. result is a two-column matrix, the first column being the irreducibles
  1732. dividing C<x> (prime numbers or polynomials), and the second the exponents.
  1733. If C<x> is a vector or a matrix, the factoring is done componentwise (hence
  1734. the result is a vector or matrix of two-column matrices). By definition,
  1735. C<0> is factored as C<0^1>.
  1736.  
  1737. If C<x> is of type integer or rational, an argument I<lim> can be
  1738. added, meaning that we look only for factors up to I<lim>, or to
  1739. C<primelimit>, whichever is lowest (except when C<I<lim> = 0> where the
  1740. effect is identical to setting C<I<lim> = primelimit>). Hence in this
  1741. case, the remaining part is not necessarily prime. See X<factorint>B<factorint> for
  1742. more information about the algorithms used.
  1743.  
  1744. The polynomials or rational functions to be factored must have scalar
  1745. coefficients. In particular PARI does I<not> know how to factor
  1746. multivariate polynomials.
  1747.  
  1748. Note that PARI tries to guess in a sensible way over which ring you want
  1749. to factor. Note also that factorization of polynomials is done up to
  1750. multiplication by a constant. In particular, the factors of rational
  1751. polynomials will have integer coefficients, and the content of a polynomial
  1752. or rational function is discarded and not included in the factorization. If
  1753. you need it, you can always ask for the content explicitly:
  1754.  
  1755.   ? factor(t^2 + 5/2*t + 1)
  1756.   %1 =
  1757.   [2*t + 1 1]
  1758.  
  1759.   [t + 2 1]
  1760.  
  1761.   ? content(t^2 + 5/2*t + 1)
  1762.   %2 = 1/2
  1763.  
  1764. See also X<factornf>B<factornf>.
  1765.  
  1766. X<factor0>The library syntax is B<factor0>C<(x,I<lim>)>, where I<lim> is a C integer.
  1767. Also available are
  1768. C<X<factor>B<factor>(x)> ( = C<X<factor0>B<factor0>(x,-1)>),
  1769. C<X<smallfact>B<smallfact>(x)> ( = C<X<factor0>B<factor0>(x,0)>).
  1770.  
  1771. =head2 X<factorback>factorbackC<(f,{nf})>
  1772.  
  1773. C<f> being any factorization, gives back
  1774. the factored object. If a second argument C<I<nf>> is supplied, C<f> is
  1775. assumed to be a prime ideal factorization in the number field C<I<nf>>.
  1776. The resulting ideal is given in HNFX<Hermite normal form> form.
  1777.  
  1778. X<factorback>The library syntax is B<factorback>C<(f,I<nf>)>, where an omitted
  1779. C<I<nf>> is entered as C<NULL>.
  1780.  
  1781. =head2 X<factorcantor>factorcantorC<(x,p)>
  1782.  
  1783. factors the polynomial C<x> modulo the
  1784. prime C<p>, using distinct degree plus
  1785. X<Cantor-Zassenhaus>Cantor-ZassenhausX<Zassenhaus>. The coefficients of C<x> must be
  1786. operation-compatible with C<B<I<Z>>/pB<I<Z>>>. The result is a two-column matrix, the
  1787. first column being the irreducible polynomials dividing C<x>, and the second
  1788. the exponents.  If you want only the I<degrees> of the irreducible
  1789. polynomials (for example for computing an C<L>-function), use
  1790. C<factormod(x,p,1)>. Note that the C<factormod> algorithm is
  1791. usually faster than C<factorcantor>.
  1792.  
  1793. X<factcantor>The library syntax is B<factcantor>C<(x,p)>.
  1794.  
  1795. =head2 X<factorff>factorffC<(x,p,a)>
  1796.  
  1797. factors the polynomial C<x> in the field
  1798. C<B<I<F>>_q> defined by the irreducible polynomial C<a> over C<B<I<F>>_p>. The
  1799. coefficients of C<x> must be operation-compatible with C<B<I<Z>>/pB<I<Z>>>. The result
  1800. is a two-column matrix, the first column being the irreducible polynomials
  1801. dividing C<x>, and the second the exponents. It is recommended to use for
  1802. the variable of C<a> (which will be used as variable of a polmod) a name
  1803. distinct from the other variables used, so that a C<lift()> of the
  1804. result will be legible. If all the coefficients of C<x> are in C<B<I<F>>_p>, a much faster algorithm is applied, using the computation of isomorphisms between finite fields.
  1805.  
  1806. X<factmod9>The library syntax is B<factmod9>C<(x,p,a)>.
  1807.  
  1808. =head2 X<factorial>factorialC<(x)> or C<x!>
  1809.  
  1810. factorial of C<x>. The expression C<x!>
  1811. gives a result which is an integer, while C<factorial(x)> gives a real
  1812. number.
  1813.  
  1814. X<mpfact>The library syntax is B<mpfact>C<(x)> for C<x!> and
  1815. C<X<mpfactr>B<mpfactr>(x,I<prec>)> for C<factorial(x)>. C<x> must be a C<long>
  1816. integer and not a PARI integer.
  1817.  
  1818. =head2 X<factorint>factorintC<(n,{I<flag> = 0})>
  1819.  
  1820. factors the integer n using a
  1821. combination of the X<Shanks SQUFOF>Shanks SQUFOF and X<Pollard Rho>Pollard Rho method (with
  1822. modifications due to Brent), X<Lenstra>Lenstra's X<ECM>ECM (with modifications by
  1823. Montgomery), and X<MPQS>MPQS (the latter adapted from the X<LiDIA>LiDIA code
  1824. with the kind permission of the LiDIA maintainers), as well as a search for
  1825. pure powers with exponentsC< E<lt>= 10>. The output is a two-column matrix as for
  1826. C<factor>.
  1827.  
  1828. This gives direct access to the integer factoring engine called by most
  1829. arithmetical functions. I<flag> is optional; its binary digits mean 1: avoid
  1830. MPQS, 2: skip first stage ECM (we may still fall back to it later), 4: avoid
  1831. Rho and SQUFOF, 8: don't run final ECM (as a result, a huge composite may be
  1832. declared to be prime). Note that a (strong) probabilistic primality test is
  1833. used; thus composites might (very rarely) not be detected.
  1834.  
  1835. The machinery underlying this function is still in a somewhat experimental
  1836. state, but should be much faster on average than pure ECM as used by all
  1837. PARI versions up to 2.0.8, at the expense of heavier memory use. You are
  1838. invited to play with the flag settings and watch the internals at work by
  1839. using GP's X<debuglevel>C<debuglevel> default parameter (level 3 shows just the
  1840. outline, 4 turns on time keeping, 5 and above show an increasing amount
  1841. of internal details). If you see anything funny happening, please let
  1842. us know.
  1843.  
  1844. X<factorint>The library syntax is B<factorint>C<(n,I<flag>)>.
  1845.  
  1846. =head2 X<factormod>factormodC<(x,p,{I<flag> = 0})>
  1847.  
  1848. factors the polynomial C<x> modulo
  1849. the prime integer C<p>, using X<Berlekamp>Berlekamp. The coefficients of C<x> must be
  1850. operation-compatible with C<B<I<Z>>/pB<I<Z>>>. The result is a two-column matrix, the
  1851. first column being the irreducible polynomials dividing C<x>, and the second
  1852. the exponents. If C<I<flag>> is non-zero, outputs only the I<degrees> of the
  1853. irreducible polynomials (for example, for computing an C<L>-function). A
  1854. different algorithm for computing the mod C<p> factorization is
  1855. C<factorcantor> which is sometimes faster.
  1856.  
  1857. X<factormod>The library syntax is B<factormod>C<(x,p,I<flag>)>. Also available are
  1858. C<X<factmod>B<factmod>(x,p)> (which is equivalent to C<X<factormod>B<factormod>(x,p,0)>) and
  1859. C<X<simplefactmod>B<simplefactmod>(x,p)> ( = C<X<factormod>B<factormod>(x,p,1)>).
  1860.  
  1861. =head2 X<fibonacci>fibonacciC<(x)>
  1862.  
  1863. C<x^{th}> Fibonacci number.
  1864.  
  1865. X<fibo>The library syntax is B<fibo>C<(x)>. C<x> must be a C<long>.
  1866.  
  1867. =head2 X<ffinit>ffinitC<(p,n,{v = x})>
  1868.  
  1869. computes a monic polynomial of degree
  1870. C<n> which is irreducible over C<B<I<F>>_p>. For instance if
  1871. C<P = ffinit(3,2,y)>, you can represent elements in C<B<I<F>>_{3^2}> as polmods
  1872. modulo C<P>.
  1873.  
  1874. X<ffinit>The library syntax is B<ffinit>C<(p,n,v)>, where C<v> is a variable number.
  1875.  
  1876. =head2 X<gcd>gcdC<(x,y,{I<flag> = 0})>
  1877.  
  1878. creates the greatest common divisor of C<x>
  1879. and C<y>. C<x> and C<y> can be of quite general types, for instance both
  1880. rational numbers. Vector/matrix types are also accepted, in which case
  1881. the GCD is taken recursively on each component. Note that for these
  1882. types, C<gcd> is not commutative.
  1883.  
  1884. If C<I<flag> = 0>, use X<Euclid>Euclid's algorithm.
  1885.  
  1886. If C<I<flag> = 1>, use the modular gcd algorithm (C<x> and C<y> have to be
  1887. polynomials, with integer coefficients).
  1888.  
  1889. If C<I<flag> = 2>, use the X<subresultant algorithm>subresultant algorithm.
  1890.  
  1891. X<gcd0>The library syntax is B<gcd0>C<(x,y,I<flag>)>. Also available are
  1892. C<X<ggcd>B<ggcd>(x,y)>, C<X<modulargcd>B<modulargcd>(x,y)>, and C<X<srgcd>B<srgcd>(x,y)>
  1893. corresponding to C<I<flag> = 0>, C<1> and C<2> respectively.
  1894.  
  1895. =head2 X<hilbert>hilbertC<(x,y,{p})>
  1896.  
  1897. X<Hilbert symbol>Hilbert symbol of C<x> and C<y> modulo
  1898. C<p>. If C<x> and C<y> are of type integer or fraction, an explicit third
  1899. parameter C<p> must be supplied, C<p = 0> meaning the place at infinity.
  1900. Otherwise, C<p> needs not be given, and C<x> and C<y> can be of compatible types
  1901. integer, fraction, real, integermod a prime (result is undefined if the
  1902. modulus is not prime), or C<p>-adic.
  1903.  
  1904. X<hil>The library syntax is B<hil>C<(x,y,p)>.
  1905.  
  1906. =head2 X<isfundamental>isfundamentalC<(x)>
  1907.  
  1908. true (1) if C<x> is equal to 1 or to the
  1909. discriminant of a quadratic field, false (0) otherwise.
  1910.  
  1911. X<gisfundamental>The library syntax is B<gisfundamental>C<(x)>, but the
  1912. simpler function C<X<isfundamental>B<isfundamental>(x)> which returns a C<long>
  1913. should be used if C<x> is known to be of type integer.
  1914.  
  1915. =head2 X<isprime>isprimeC<(x,{I<flag> = 0})>
  1916.  
  1917. if C<I<flag> = 0> (default), true (1) if C<x> is a strong pseudo-prime
  1918. for 10 randomly chosen bases, false (0) otherwise.
  1919.  
  1920. If C<I<flag> = 1>, use Pocklington-Lehmer ``P-1'' test. true (1) if C<x> is
  1921. prime, false (0) otherwise.
  1922.  
  1923. If C<I<flag> = 2>, use Pocklington-Lehmer ``P-1'' test and output a primality
  1924. certificate as follows: return 0 if C<x> is composite, 1 if C<x> is a
  1925. small prime (currently strictly less than C<341 550 071 728 321>), and
  1926. a matrix if C<x> is a large prime.  The matrix has three columns. The
  1927. first contains the prime factors C<p>, the second the corresponding
  1928. elements C<a_p> as in PropositionS< >8.3.1 in GTMS< >138, and the third the
  1929. output of isprime(p,2).
  1930.  
  1931. In the two last cases, the algorithm fails if one of the (strong
  1932. pseudo-)prime factors is not prime, but it should be exceedingly rare.
  1933.  
  1934. X<gisprime>The library syntax is B<gisprime>C<(x,I<flag>)>, but the simpler function C<X<isprime>B<isprime>(x)>
  1935. which returns a C<long> should be used if C<x> is known to be of
  1936. type integer. Also available is C<X<plisprime>B<plisprime>(N,I<flag>)>,
  1937. corresponding to C<X<gisprime>B<gisprime>(x,I<flag>+1)> if C<x> is known to be of
  1938. type integer.
  1939.  
  1940. =head2 X<ispseudoprime>ispseudoprimeC<(x)>
  1941.  
  1942. true (1) if C<x> is a strong
  1943. pseudo-prime for a randomly chosen base, false (0) otherwise.
  1944.  
  1945. X<gispsp>The library syntax is B<gispsp>C<(x)>, but the
  1946. simpler function C<X<ispsp>B<ispsp>(x)> which returns a C<long>
  1947. should be used if C<x> is known to be of type integer.
  1948.  
  1949. =head2 X<issquare>issquareC<(x,{&n})>
  1950.  
  1951. true (1) if C<x> is square, false (0) if
  1952. not. C<x> can be of any type. If C<n> is given and an exact square root had to
  1953. be computed in the checking process, puts that square root in C<n>. This is in
  1954. particular the case when C<x> is an integer or a polynomial. This is I<not>
  1955. the case for intmods (use quadratic reciprocity) or series (only check the
  1956. leading coefficient).
  1957.  
  1958. X<gcarrecomplet>The library syntax is B<gcarrecomplet>C<(x,&n)>. Also available is C<X<gcarreparfait>B<gcarreparfait>(x)>.
  1959.  
  1960. =head2 X<issquarefree>issquarefreeC<(x)>
  1961.  
  1962. true (1) if C<x> is squarefree, false (0) if not.
  1963. Here C<x> can be an integer or a polynomial.
  1964.  
  1965. X<gissquarefree>The library syntax is B<gissquarefree>C<(x)>, but the simpler function C<X<issquarefree>B<issquarefree>(x)>
  1966. which returns a C<long> should be used if C<x> is known to be of type
  1967. integer. This X<issquarefree>B<issquarefree> is just the square of the
  1968. X<Moebius>Moebius function, and is computed as a multiplicative
  1969. arithmetic function much like the latter.
  1970.  
  1971. =head2 X<kronecker>kroneckerC<(x,y)>
  1972.  
  1973. KroneckerX<Kronecker symbol>X<Legendre symbol>
  1974. (i.e.S< >generalized Legendre) symbol C<((x)/(y))>. C<x> and C<y>
  1975. must be of type integer.
  1976.  
  1977. X<kronecker>The library syntax is B<kronecker>C<(x,y)>, the result (C<0> or C<F<+-> 1>) is a C<long>.
  1978.  
  1979. =head2 X<lcm>lcmC<(x,y)>
  1980.  
  1981. least common multiple of C<x> and C<y>, i.e.S< >such
  1982. that C<lcm(x,y)*gcd(x,y) = abs(x*y)>.
  1983.  
  1984. X<glcm>The library syntax is B<glcm>C<(x,y)>.
  1985.  
  1986. =head2 X<moebius>moebiusC<(x)>
  1987.  
  1988. X<Moebius>Moebius C<F<mu>>-function of C<|x|>. C<x> must
  1989. be of type integer.
  1990.  
  1991. X<mu>The library syntax is B<mu>C<(x)>, the result (C<0> or C<F<+-> 1>) is a C<long>.
  1992.  
  1993. =head2 X<nextprime>nextprimeC<(x)>
  1994.  
  1995. finds the smallest prime greater than or
  1996. equal to C<x>. C<x> can be of any real type. Note that if C<x> is a prime,
  1997. this function returns C<x> and not the smallest prime strictly larger than C<x>.
  1998.  
  1999. X<nextprime>The library syntax is B<nextprime>C<(x)>.
  2000.  
  2001. =head2 X<numdiv>numdivC<(x)>
  2002.  
  2003. number of divisors of C<|x|>. C<x> must be of type
  2004. integer, and the result is a C<long>.
  2005.  
  2006. X<numbdiv>The library syntax is B<numbdiv>C<(x)>.
  2007.  
  2008. =head2 X<omega>omegaC<(x)>
  2009.  
  2010. number of distinct prime divisors of C<|x|>. C<x>
  2011. must be of type integer.
  2012.  
  2013. X<omega>The library syntax is B<omega>C<(x)>, the result is a C<long>.
  2014.  
  2015. =head2 X<precprime>precprimeC<(x)>
  2016.  
  2017. finds the largest prime less than or equal to
  2018. C<x>. C<x> can be of any real type. Returns 0 if C<x E<lt>= 1>.
  2019. Note that if C<x> is a prime, this function returns C<x> and not the largest
  2020. prime strictly smaller than C<x>.
  2021.  
  2022. X<precprime>The library syntax is B<precprime>C<(x)>.
  2023.  
  2024. =head2 X<prime>primeC<(x)>
  2025.  
  2026. the C<x^{th}> prime number, which must be among
  2027. the precalculated primes.
  2028.  
  2029. X<prime>The library syntax is B<prime>C<(x)>. C<x> must be a C<long>.
  2030.  
  2031. =head2 X<primes>primesC<(x)>
  2032.  
  2033. creates a row vector whose components
  2034. are the first C<x> prime numbers, which must be among the precalculated primes.
  2035.  
  2036. X<primes>The library syntax is B<primes>C<(x)>. C<x> must be a C<long>.
  2037.  
  2038. =head2 X<qfbclassno>qfbclassnoC<(x,{I<flag> = 0})>
  2039.  
  2040. class number of the quadratic field
  2041. of discriminant C<x>. In the present version B<2.2.0>, a simple algorithm is used
  2042. for C<x E<gt> 0>, so C<x> should not be too large (say C<x E<lt> 10^7>) for the time to be
  2043. reasonable. On the other hand, for C<x E<lt> 0> one can reasonably compute
  2044. classno(C<x>) for C<|x| E<lt> 10^{25}>, since the method used is X<Shanks>Shanks' method
  2045. which is in C<O(|x|^{1/4})>. For larger values of C<|D|>, see
  2046. C<quadclassunit>.
  2047.  
  2048. If C<I<flag> = 1>, compute the class number using X<Euler product>Euler products and the
  2049. functional equation. However, it is in C<O(|x|^{1/2})>.
  2050.  
  2051. B<Important warning.> For C<D E<lt> 0>, this function often gives
  2052. incorrect results when the class group is non-cyclic, because the authors
  2053. were too lazy to implement X<Shanks>Shanks' method completely. It is therefore
  2054. strongly recommended to use either the version with C<I<flag> = 1>, the function
  2055. C<qfbhclassno(-x)> if C<x> is known to be a fundamental discriminant, or
  2056. the function C<quadclassunit>.
  2057.  
  2058. X<qfbclassno0>The library syntax is B<qfbclassno0>C<(x,I<flag>)>. Also available are
  2059. C<X<classno>B<classno>(x)> ( = C<X<qfbclassno>B<qfbclassno>(x)>),
  2060. C<X<classno2>B<classno2>(x)> ( = C<X<qfbclassno>B<qfbclassno>(x,1)>), and finally
  2061. there exists the function C<X<hclassno>B<hclassno>(x)> which computes the class
  2062. number of an imaginary quadratic field by counting reduced forms, an C<O(|x|)>
  2063. algorithm. See also C<qfbhclassno>.
  2064.  
  2065. =head2 X<qfbcompraw>qfbcomprawC<(x,y)>
  2066.  
  2067. X<composition>composition of the binary quadratic forms
  2068. C<x> and C<y>, without X<reduction>reduction of the result. This is useful e.g.S< >to
  2069. compute a generating element of an ideal.
  2070.  
  2071. X<compraw>The library syntax is B<compraw>C<(x,y)>.
  2072.  
  2073. =head2 X<qfbhclassno>qfbhclassnoC<(x)>
  2074.  
  2075. X<Hurwitz class number>Hurwitz class number of C<x>, where C<x> is
  2076. non-negative and congruent to 0 or 3 modulo 4. See also C<qfbclassno>.
  2077.  
  2078. X<hclassno>The library syntax is B<hclassno>C<(x)>.
  2079.  
  2080. =head2 X<qfbnucomp>qfbnucompC<(x,y,l)>
  2081.  
  2082. X<composition>composition of the primitive positive
  2083. definite binary quadratic forms C<x> and C<y> using the NUCOMP and NUDUPL
  2084. algorithms of X<Shanks>Shanks (E<agrave> la Atkin). C<l> is any positive constant,
  2085. but for optimal speed, one should take C<l = |D|^{1/4}>, where C<D> is the common
  2086. discriminant of C<x> and C<y>. When C<x> and C<y> do not have the same
  2087. discriminant, the result is undefined.
  2088.  
  2089. X<nucomp>The library syntax is B<nucomp>C<(x,y,l)>. The auxiliary function
  2090. C<X<nudupl>B<nudupl>(x,l)> should be used instead for speed when C<x = y>.
  2091.  
  2092. =head2 X<qfbnupow>qfbnupowC<(x,n)>
  2093.  
  2094. C<n>-th power of the primitive positive definite
  2095. binary quadratic form C<x> using the NUCOMP and NUDUPL algorithms (see
  2096. C<qfbnucomp>).
  2097.  
  2098. X<nupow>The library syntax is B<nupow>C<(x,n)>.
  2099.  
  2100. =head2 X<qfbpowraw>qfbpowrawC<(x,n)>
  2101.  
  2102. C<n>-th power of the binary quadratic form
  2103. C<x>, computed without doing any X<reduction>reduction (i.e.S< >using C<qfbcompraw>).
  2104. Here C<n> must be non-negative and C<n E<lt> 2^{31}>.
  2105.  
  2106. X<powraw>The library syntax is B<powraw>C<(x,n)> where C<n> must be a C<long>
  2107. integer.
  2108.  
  2109. =head2 X<qfbprimeform>qfbprimeformC<(x,p)>
  2110.  
  2111. prime binary quadratic form of discriminant
  2112. C<x> whose first coefficient is the prime number C<p>. By abuse of notation,
  2113. C<p = 1> is a valid special case which returns the unit form. Returns an
  2114. error if C<x> is not a quadratic residue mod C<p>. In the case where C<x E<gt> 0>,
  2115. the ``distance'' component of the form is set equal to zero according to
  2116. the current precision.
  2117.  
  2118. X<primeform>The library syntax is B<primeform>C<(x,p,I<prec>)>, where the third variable C<I<prec>> is a
  2119. C<long>, but is only taken into account when C<x E<gt> 0>.
  2120.  
  2121. =head2 X<qfbred>qfbredC<(x,{I<flag> = 0},{D},{I<isqrtD>},{I<sqrtD>})>
  2122.  
  2123. reduces the binary quadratic form C<x> (updating Shanks's distance function
  2124. if C<x> is indefinite). The binary digits of C<I<flag>> are toggles meaning
  2125.  
  2126. S< >S< >1: perform a single X<reduction>reduction step
  2127.  
  2128. S< >S< >2: don't update X<Shanks>Shanks's distance
  2129.  
  2130. C<D>, I<isqrtD>, I<sqrtD>, if present, supply the values of the
  2131. discriminant, C<\lfloor  F<sqrt> {D}\rfloor>, and C< F<sqrt> {D}> respectively
  2132. (no checking is done of these facts). If C<D E<lt> 0> these values are useless,
  2133. and all references to Shanks's distance are irrelevant.
  2134.  
  2135. X<qfbred0>The library syntax is B<qfbred0>C<(x,I<flag>,D,I<isqrtD>,I<sqrtD>)>. Use C<NULL>
  2136. to omit any of C<D>, I<isqrtD>, I<sqrtD>.
  2137.  
  2138. Also available are
  2139.  
  2140. C<X<redimag>B<redimag>(x)> ( = C<X<qfbred>B<qfbred>(x)> where C<x> is definite),
  2141.  
  2142. and for indefinite forms:
  2143.  
  2144. C<X<redreal>B<redreal>(x)> ( = C<X<qfbred>B<qfbred>(x)>),
  2145.  
  2146. C<X<rhoreal>B<rhoreal>(x)> ( = C<X<qfbred>B<qfbred>(x,1)>),
  2147.  
  2148. C<X<redrealnod>B<redrealnod>(x,sq)> ( = C<X<qfbred>B<qfbred>(x,2,,isqrtD)>),
  2149.  
  2150. C<X<rhorealnod>B<rhorealnod>(x,sq)> ( = C<X<qfbred>B<qfbred>(x,3,,isqrtD)>).
  2151.  
  2152. =head2 X<quadclassunit>quadclassunitC<(D,{I<flag> = 0},{I<tech> = []})>
  2153.  
  2154. X<Buchmann-McCurley>Buchmann-McCurley's sub-exponential algorithm for computing the class
  2155. group of a quadratic field of discriminant C<D>. If C<D> is not fundamental,
  2156. the function may or may not be defined, but usually is, and often gives the
  2157. right answer (a warning is issued). The more general function X<bnrinit>C<bnrinit>
  2158. should be used to compute the class group of an order.
  2159.  
  2160. This function should be used instead of C<qfbclassno> or C<quadregula>
  2161. when C<D E<lt> -10^{25}>, C<D E<gt> 10^{10}>, or when the I<structure> is wanted.
  2162.  
  2163. If C<I<flag>> is non-zero I<and> C<D E<gt> 0>, computes the narrow class group and
  2164. regulator, instead of the ordinary (or wide) ones. In the current version
  2165. B<2.2.0>, this doesn't work at allS< >: use the general function X<bnfnarrow>C<bnfnarrow>.
  2166.  
  2167. Optional parameter I<tech> is a row vector of the form
  2168. C<[c_1,c_2]>, where C<c_1> and C<c_2> are positive real numbers which
  2169. control the execution time and the stack size. To get maximum speed,
  2170. set C<c_2 = c>. To get a rigorous result (under X<GRH>GRH) you must take
  2171. C<c_2 = 6>. Reasonable values for C<c> are between C<0.1> and C<2>.
  2172.  
  2173. The result of this function is a vector C<v> with 4 components if C<D E<lt> 0>, and
  2174. C<5> otherwise. The correspond respectively to
  2175.  
  2176. C<B<*>> C<v[1]>S< >: the class number
  2177.  
  2178. C<B<*>> C<v[2]>S< >: a vector giving the structure of the class group as a
  2179. product of cyclic groups;
  2180.  
  2181. C<B<*>> C<v[3]>S< >: a vector giving generators of those cyclic groups (as
  2182. binary quadratic forms).
  2183.  
  2184. C<B<*>> C<v[4]>S< >: (omitted if C<D E<lt> 0>) the regulator, computed to an
  2185. accuracy which is the maximum of an internal accuracy determined by the
  2186. program and the current default (note that once the regulator is known to a
  2187. small accuracy it is trivial to compute it to very high accuracy, see the
  2188. tutorial).
  2189.  
  2190. C<B<*>> C<v[5]>S< >: a measure of the correctness of the result. If it is
  2191. close to 1, the result is correct (under X<GRH>GRH). If it is close to a
  2192. larger integer, this shows that the class number is off by a factor equal
  2193. to this integer, and you must start again with a larger value for C<c_1> or
  2194. a different random seed. In this case, a warning message is printed.
  2195.  
  2196. X<quadclassunit0>The library syntax is B<quadclassunit0>C<(D,I<flag>,tech)>. Also available are
  2197. C<X<buchimag>B<buchimag>(D,c_1,c_2)> and C<X<buchreal>B<buchreal>(D,I<flag>,c_1,c_2)>.
  2198.  
  2199. =head2 X<quaddisc>quaddiscC<(x)>
  2200.  
  2201. discriminant of the quadratic field
  2202. C<B<I<Q>>( F<sqrt> {x})>, where C<x belongs to B<I<Q>>>.
  2203.  
  2204. X<quaddisc>The library syntax is B<quaddisc>C<(x)>.
  2205.  
  2206. =head2 X<quadhilbert>quadhilbertC<(D,{I<flag> = 0})>
  2207.  
  2208. relative equation defining the
  2209. X<Hilbert class field>Hilbert class field of the quadratic field of discriminant C<D>.
  2210. If C<I<flag>> is non-zero
  2211. and C<D E<lt> 0>, outputs C<[I<form>,I<root>(I<form>)]> (to be used for
  2212. constructing subfields). If C<I<flag>> is non-zero and C<D E<gt> 0>, try hard to 
  2213. get the best modulus.
  2214. Uses complex multiplication in the imaginary case and X<Stark units>Stark units
  2215. in the real case.
  2216.  
  2217. X<quadhilbert>The library syntax is B<quadhilbert>C<(D,I<flag>,I<prec>)>.
  2218.  
  2219. =head2 X<quadgen>quadgenC<(x)>
  2220.  
  2221. creates the quadratic numberX<omega>
  2222. C<F<omega> = (a+ F<sqrt> {x})/2> where C<a = 0> if C<x = 0 mod 4>,
  2223. C<a = 1> if C<x = 1 mod 4>, so that C<(1,F<omega>)> is an integral basis for
  2224. the quadratic order of discriminant C<x>. C<x> must be an integer congruent to
  2225. 0 or 1 modulo 4.
  2226.  
  2227. X<quadgen>The library syntax is B<quadgen>C<(x)>.
  2228.  
  2229. =head2 X<quadpoly>quadpolyC<(D,{v = x})>
  2230.  
  2231. creates the ``canonical'' quadratic
  2232. polynomial (in the variable C<v>) corresponding to the discriminant C<D>,
  2233. i.e.S< >the minimal polynomial of C<quadgen(x)>. C<D> must be an integer
  2234. congruent to 0 or 1 modulo 4.
  2235.  
  2236. X<quadpoly0>The library syntax is B<quadpoly0>C<(x,v)>.
  2237.  
  2238. =head2 X<quadray>quadrayC<(D,f,{I<flag> = 0})>
  2239.  
  2240. relative equation for the ray class
  2241. field of conductor C<f> for the quadratic field of discriminant C<D> (which
  2242. can also be a C<bnf>), using analytic methods.
  2243.  
  2244. For C<D E<lt> 0>, uses the C<F<sigma>> function. C<I<flag>> has the following meaning: if
  2245. it's an odd integer, outputs instead the vector of C<[I<ideal>,
  2246. I<corresponding root>]>. It can also be a two-component vector
  2247. C<[F<lambda>,I<flag>]>, where I<flag> is as above and C<F<lambda>> is the technical
  2248. element of C<bnf> necessary for Schertz's method. In that case, returns
  2249. 0 if C<F<lambda>> is not suitable.
  2250.  
  2251. For C<D E<gt> 0>, uses Stark's conjecture. If C<I<flag>> is non-zero, try hard to
  2252. get the best modulus. The function may fail with the following message
  2253.  
  2254.   "Cannot find a suitable modulus in FindModulus"
  2255.  
  2256. See X<bnrstark>C<bnrstark> for more details about the real case.
  2257.  
  2258. X<quadray>The library syntax is B<quadray>C<(D,f,I<flag>)>.
  2259.  
  2260. =head2 X<quadregulator>quadregulatorC<(x)>
  2261.  
  2262. regulator of the quadratic field of
  2263. positive discriminant C<x>. Returns an error if C<x> is not a discriminant
  2264. (fundamental or not) or if C<x> is a square. See also C<quadclassunit> if
  2265. C<x> is large.
  2266.  
  2267. X<regula>The library syntax is B<regula>C<(x,I<prec>)>.
  2268.  
  2269. =head2 X<quadunit>quadunitC<(x)>
  2270.  
  2271. fundamental unitX<fundamental units> of the
  2272. real quadratic field C<B<I<Q>>( F<sqrt>  x)> where  C<x> is the positive discriminant
  2273. of the field. If C<x> is not a fundamental discriminant, this probably gives
  2274. the fundamental unit of the corresponding order. C<x> must be of type
  2275. integer, and the result is a quadratic number.
  2276.  
  2277. X<fundunit>The library syntax is B<fundunit>C<(x)>.
  2278.  
  2279. =head2 X<removeprimes>removeprimesC<({x = []})>
  2280.  
  2281. removes the primes listed in C<x> from
  2282. the prime number table. In particular C<removeprimes(addprimes)> empties
  2283. the extra prime table. C<x> can also be a single integer. List the current
  2284. extra primes if C<x> is omitted.
  2285.  
  2286. X<removeprimes>The library syntax is B<removeprimes>C<(x)>.
  2287.  
  2288. =head2 X<sigma>sigmaC<(x,{k = 1})>
  2289.  
  2290. sum of the C<k^{th}> powers of the
  2291. positive divisors of C<|x|>. C<x> must be of type integer.
  2292.  
  2293. X<sumdiv>The library syntax is B<sumdiv>C<(x)> ( = C<X<sigma>B<sigma>(x)>) or C<X<gsumdivk>B<gsumdivk>(x,k)> ( = 
  2294. C<X<sigma>B<sigma>(x,k)>), where C<k> is a C long integer.
  2295.  
  2296. =head2 X<sqrtint>sqrtintC<(x)>
  2297.  
  2298. integer square root of C<x>, which must be of PARI
  2299. type integer. The result is non-negative and rounded towards zero. A
  2300. negative C<x> is allowed, and the result in that case is C<I*sqrtint(-x)>.
  2301.  
  2302. X<racine>The library syntax is B<racine>C<(x)>.
  2303.  
  2304. =head2 X<znlog>znlogC<(x,g)>
  2305.  
  2306. C<g> must be a primitive root mod a prime C<p>, and
  2307. the result is the discrete log of C<x> in the multiplicative group
  2308. C<(B<I<Z>>/pB<I<Z>>)^*>. This function using a simple-minded baby-step/giant-step
  2309. approach and requires C<O( F<sqrt> {p})> storage, hence it cannot be used for
  2310. C<p> greater than about C<10^{13}>.
  2311.  
  2312. X<znlog>The library syntax is B<znlog>C<(x,g)>.
  2313.  
  2314. =head2 X<znorder>znorderC<(x)>
  2315.  
  2316. C<x> must be an integer mod C<n>, and the result is the
  2317. order of C<x> in the multiplicative group C<(B<I<Z>>/nB<I<Z>>)^*>. Returns an error if C<x>
  2318. is not invertible.
  2319.  
  2320. X<order>The library syntax is B<order>C<(x)>.
  2321.  
  2322. =head2 X<znprimroot>znprimrootC<(x)>
  2323.  
  2324. returns a primitive root of C<x>, where C<x>
  2325. is a prime power.
  2326.  
  2327. X<gener>The library syntax is B<gener>C<(x)>.
  2328.  
  2329. =head2 X<znstar>znstarC<(n)>
  2330.  
  2331. gives the structure of the multiplicative group
  2332. C<(B<I<Z>>/nB<I<Z>>)^*> as a 3-component row vector C<v>, where C<v[1] = F<phi>(n)> is the
  2333. order of that group, C<v[2]> is a C<k>-component row-vector C<d> of integers
  2334. C<d[i]> such that C<d[i] E<gt> 1> and C<d[i] | d[i-1]> for C<i E<gt>= 2> and
  2335. C<(B<I<Z>>/nB<I<Z>>)^*  ~  F<prod>_{i = 1}^k(B<I<Z>>/d[i]B<I<Z>>)>, and C<v[3]> is a C<k>-component row
  2336. vector giving generators of the image of the cyclic groups C<B<I<Z>>/d[i]B<I<Z>>>.
  2337.  
  2338. X<znstar>The library syntax is B<znstar>C<(n)>.
  2339.  
  2340. =head1 Functions related to elliptic curves
  2341.  
  2342. We have implemented a number of functions which are useful for number
  2343. theorists working on elliptic curves. We always use X<Tate>Tate's notations.
  2344. The functions assume that the curve is given by a general Weierstrass
  2345. modelX<Weierstrass equation>
  2346.  
  2347. S<  >C<
  2348. y^2+a_1xy+a_3y = x^3+a_2x^2+a_4x+a_6,
  2349. >
  2350.  
  2351. where a priori the C<a_i> can be of any scalar type. This curve can be
  2352. considered as a five-component vector C<E = [a1,a2,a3,a4,a6]>. Points on
  2353. C<E> are represented as two-component vectors C<[x,y]>, except for the
  2354. point at infinity, i.e.S< >the identity element of the group law, represented by
  2355. the one-component vector C<[0]>.
  2356.  
  2357. It is useful to have at one's disposal more information. This is given by
  2358. the function X<ellinit>C<ellinit> (see there), which usually gives a 19 component
  2359. vector (which we will call a long vector in this section). If a specific flag
  2360. is added, a vector with only 13 component will be output (which we will call
  2361. a medium vector). A medium vector just gives the first 13 components of the
  2362. long vector corresponding to the same curve, but is of course faster to
  2363. compute. The following X<member functions>member functions are available to deal with the
  2364. output of C<ellinit>:
  2365.  
  2366. S< > C<a1>--C<a6>, C<b2>--C<b8>, C<c4>--C<c6>  :  
  2367. coefficients of the elliptic curve.
  2368.  
  2369. S< > X<area>C<area>  :    volume of the complex lattice defining C<E>.
  2370.  
  2371. S< > X<disc>C<disc>  :   discriminant of the curve.
  2372.  
  2373. S< > X<j>C<j>     :   C<j>-invariant of the curve.
  2374.  
  2375. S< > X<omega>C<omega> :   C<[F<omega>_1,F<omega>_2]>, periods forming a basis of
  2376. the complex lattice defining C<E> (C<F<omega>_1> is the
  2377.  
  2378. S< >                  real period, and C<F<omega>_2/F<omega>_1> belongs to
  2379. PoincarE<eacute>'s half-plane).
  2380.  
  2381. S< > X<eta>C<eta>   :   quasi-periods C<[F<eta>_1, F<eta>_2]>, such that
  2382. C<F<eta>_1F<omega>_2-F<eta>_2F<omega>_1 = iF<Pi>>.
  2383.  
  2384. S< > X<roots>C<roots> :   roots of the associated Weierstrass equation.
  2385.  
  2386. S< > X<tate>C<tate>  :   C<[u^2,u,v]> in the notation of Tate.
  2387.  
  2388. S< > X<w>C<w>  :   Mestre's C<w> (this is technical).
  2389.  
  2390. Their use is best described by an example: assume that C<E> was output by
  2391. C<ellinit>, then typing C<E.disc> will retrieve the curve's
  2392. discriminant. The member functions C<area>, C<eta> and C<omega> are
  2393. only available for curves over B<I<Q>>. Conversely, C<tate> and C<w> are
  2394. only available for curves defined over C<B<I<Q>>_p>.
  2395.  
  2396. Some functions, in particular those relative to height computations (see
  2397. C<ellheight>) require also that the curve be in minimal Weierstrass
  2398. form. This is achieved by the function C<ellglobalred>.
  2399.  
  2400. All functions related to elliptic curves share the prefix C<ell>, and the
  2401. precise curve we are interested in is always the first argument, in either
  2402. one of the three formats discussed above, unless otherwise specified. For
  2403. instance, in functions which do not use the extra information given by long
  2404. vectors, the curve can be given either as a five-component vector, or by one
  2405. of the longer vectors computed by C<ellinit>.
  2406.  
  2407. =head2 X<elladd>elladdC<(E,z1,z2)>
  2408.  
  2409. sum of the points C<z1> and C<z2> on the
  2410. elliptic curve corresponding to the vector C<E>.
  2411.  
  2412. X<addell>The library syntax is B<addell>C<(E,z1,z2)>.
  2413.  
  2414. =head2 X<ellak>ellakC<(E,n)>
  2415.  
  2416. computes the coefficient C<a_n> of the
  2417. C<L>-function of the elliptic curve C<E>, i.e.S< >in principle coefficients of a
  2418. newform of weight 2 assuming X<Taniyama-Weil conjecture>Taniyama-Weil conjecture (which is now
  2419. known to hold in full generality thanks to the work of X<Breuil>Breuil,
  2420. X<Conrad>Conrad, X<Diamond>Diamond, X<Taylor>Taylor and X<Wiles>Wiles). C<E> must be a
  2421. medium or long vector of the type given by C<ellinit>. For this function
  2422. to work for every C<n> and not just those prime to the conductor, C<E> must
  2423. be a minimal Weierstrass equation. If this is not the case, use the
  2424. function C<ellglobalred> first before using C<ellak>.
  2425.  
  2426. X<akell>The library syntax is B<akell>C<(E,n)>.
  2427.  
  2428. =head2 X<ellan>ellanC<(E,n)>
  2429.  
  2430. computes the vector of the first C<n> C<a_k>
  2431. corresponding to the elliptic curve C<E>. All comments in C<ellak>
  2432. description remain valid.
  2433.  
  2434. X<anell>The library syntax is B<anell>C<(E,n)>, where C<n> is a C integer.
  2435.  
  2436. =head2 X<ellap>ellapC<(E,p,{I<flag> = 0})>
  2437.  
  2438. computes the C<a_p> corresponding to the
  2439. elliptic curve C<E> and the prime number C<p>. These are defined by the
  2440. equation C<#E(B<I<F>>_p) = p+1 - a_p>, where C<#E(B<I<F>>_p)> stands for the number
  2441. of points of the curve C<E> over the finite field C<B<I<F>>_p>. When C<I<flag>> is C<0>,
  2442. this uses the baby-step giant-step method and a trick due to Mestre. This
  2443. runs in time C<O(p^{1/4})> and requires C<O(p^{1/4})> storage, hence becomes
  2444. unreasonable when C<p> has about 30 digits.
  2445.  
  2446. If C<I<flag>> is C<1>, computes the C<a_p> as a sum of Legendre symbols. This is
  2447. slower than the previous method as soon as C<p> is greater than 100, say.
  2448.  
  2449. No checking is done that C<p> is indeed prime. C<E> must be a medium or long
  2450. vector of the type given by C<ellinit>, defined over B<I<Q>>, C<B<I<F>>_p> or
  2451. C<B<I<Q>>_p>. C<E> must be given by a Weierstrass equation minimal at C<p>.
  2452.  
  2453. X<ellap0>The library syntax is B<ellap0>C<(E,p,I<flag>)>. Also available are C<X<apell>B<apell>(E,p)>, corresponding
  2454. to C<I<flag> = 0>, and C<X<apell2>B<apell2>(E,p)> (C<I<flag> = 1>).
  2455.  
  2456. =head2 X<ellbil>ellbilC<(E,z1,z2)>
  2457.  
  2458. if C<z1> and C<z2> are points on the elliptic
  2459. curve C<E>, this function computes the value of the canonical bilinear form on
  2460. C<z1>, C<z2>:
  2461.  
  2462. S<  >C<
  2463. ellheight(E,z1+z2) - ellheight(E,z1) - ellheight(E,z2)
  2464. >
  2465.  
  2466. where C<+> denotes of course addition on C<E>. In addition, C<z1> or C<z2>
  2467. (but not both) can be vectors or matrices. Note that this is equal to twice
  2468. some normalizations. C<E> is assumed to be integral, given by a minimal model.
  2469.  
  2470. X<bilhell>The library syntax is B<bilhell>C<(E,z1,z2,I<prec>)>.
  2471.  
  2472. =head2 X<ellchangecurve>ellchangecurveC<(E,v)>
  2473.  
  2474. changes the data for the elliptic curve C<E>
  2475. by changing the coordinates using the vector C<v = [u,r,s,t]>, i.e.S< >if C<x'>
  2476. and C<y'> are the new coordinates, then C<x = u^2x'+r>, C<y = u^3y'+su^2x'+t>.
  2477. The vector C<E> must be a medium or long vector of the type given by
  2478. C<ellinit>.
  2479.  
  2480. X<coordch>The library syntax is B<coordch>C<(E,v)>.
  2481.  
  2482. =head2 X<ellchangepoint>ellchangepointC<(x,v)>
  2483.  
  2484. changes the coordinates of the point or
  2485. vector of points C<x> using the vector C<v = [u,r,s,t]>, i.e.S< >if C<x'> and
  2486. C<y'> are the new coordinates, then C<x = u^2x'+r>, C<y = u^3y'+su^2x'+t> (see also
  2487. C<ellchangecurve>).
  2488.  
  2489. X<pointch>The library syntax is B<pointch>C<(x,v)>.
  2490.  
  2491. =head2 X<elleisnum>elleisnumC<(E,k,{I<flag> = 0})>
  2492.  
  2493. C<E> being an elliptic curve as
  2494. output by C<ellinit> (or, alternatively, given by a 2-component vector
  2495. C<[F<omega>_1,F<omega>_2]>), and C<k> being an even positive integer, computes
  2496. the numerical value of the Eisenstein series of weight C<k> at C<E>. When
  2497. I<flag> is non-zero and C<k = 4> or 6, returns C<g_2> or C<g_3> with the correct
  2498. normalization.
  2499.  
  2500. X<elleisnum>The library syntax is B<elleisnum>C<(E,k,I<flag>)>.
  2501.  
  2502. =head2 X<elleta>elletaC<(om)>
  2503.  
  2504. returns the two-component row vector
  2505. C<[F<eta>_1,F<eta>_2]> of quasi-periods associated to C<om = [F<omega>_1,
  2506. F<omega>_2]>
  2507.  
  2508. X<elleta>The library syntax is B<elleta>C<(om, I<prec>)>
  2509.  
  2510. =head2 X<ellglobalred>ellglobalredC<(E)>
  2511.  
  2512. calculates the arithmetic conductor, the global
  2513. minimal model of C<E> and the global X<Tamagawa number>Tamagawa number C<c>. Here C<E> is an
  2514. elliptic curve given by a medium or long vector of the type given by
  2515. C<ellinit>, I<and is supposed to have all its coefficients C<a_i> in>
  2516. B<I<Q>>. The result is a 3 component vector C<[N,v,c]>. C<N> is the arithmetic
  2517. conductor of the curve, C<v> is itself a vector C<[u,r,s,t]> with rational
  2518. components. It gives a coordinate change for C<E> over B<I<Q>> such that the
  2519. resulting model has integral coefficients, is everywhere minimal, C<a_1> is 0
  2520. or 1, C<a_2> is 0, 1 or C<-1> and C<a_3> is 0 or 1. Such a model is unique, and
  2521. the vector C<v> is unique if we specify that C<u> is positive. To get the new
  2522. model, simply type C<ellchangecurve(E,v)>. Finally C<c> is the product of
  2523. the local Tamagawa numbers C<c_p>, a quantity which enters in the
  2524. X<Birch and Swinnerton-Dyer conjecture>Birch and Swinnerton-Dyer conjecture.
  2525.  
  2526. X<globalreduction>The library syntax is B<globalreduction>C<(E)>.
  2527.  
  2528. =head2 X<ellheight>ellheightC<(E,z,{I<flag> = 0})>
  2529.  
  2530. global X<NE<eacute>ron-Tate height>NE<eacute>ron-Tate height of
  2531. the point C<z> on the elliptic curve C<E>. The vector C<E> must be a long vector
  2532. of the type given by C<ellinit>, with C<I<flag> = 1>. If C<I<flag> = 0>, this
  2533. computation is done using sigma and theta-functions and a trick due to J.
  2534. Silverman. If C<I<flag> = 1>, use Tate's C<4^n> algorithm, which is much slower.
  2535. C<E> is assumed to be integral, given by a minimal model.
  2536.  
  2537. X<ellheight0>The library syntax is B<ellheight0>C<(E,z,I<flag>,I<prec>)>. The Archimedean
  2538. contribution alone is given by the library function
  2539. C<X<hell>B<hell>(E,z,I<prec>)>.
  2540. Also available are C<X<ghell>B<ghell>(E,z,I<prec>)> (C<I<flag> = 0>) and
  2541. C<X<ghell2>B<ghell2>(E,z,I<prec>)> (C<I<flag> = 1>).
  2542.  
  2543. =head2 X<ellheightmatrix>ellheightmatrixC<(E,x)>
  2544.  
  2545. C<x> being a vector of points, this
  2546. function outputs the Gram matrix of C<x> with respect to the NE<eacute>ron-Tate
  2547. height, in other words, the C<(i,j)> component of the matrix is equal to
  2548. C<ellbil(E,x[i],x[j])>. The rank of this matrix, at least in some
  2549. approximate sense, gives the rank of the set of points, and if C<x> is a
  2550. basis of the X<Mordell-Weil group>Mordell-Weil group of C<E>, its determinant is equal to
  2551. the regulator of C<E>. Note that this matrix should be divided by 2 to be in
  2552. accordance with certain normalizations. C<E> is assumed to be integral,
  2553. given by a minimal model.
  2554.  
  2555. X<mathell>The library syntax is B<mathell>C<(E,x,I<prec>)>.
  2556.  
  2557. =head2 X<ellinit>ellinitC<(E,{I<flag> = 0})>
  2558.  
  2559. computes some fixed data concerning the
  2560. elliptic curve given by the five-component vector C<E>, which will be
  2561. essential for most further computations on the curve. The result is a
  2562. 19-component vector E (called a long vector in this section), shortened
  2563. to 13 components (medium vector) if C<I<flag> = 1>. Both contain the
  2564. following information in the first 13 components:
  2565.  
  2566. S<  >C< a_1,a_2,a_3,a_4,a_6,b_2,b_4,b_6,b_8,c_4,c_6,F<Delta>,j.>
  2567.  
  2568. In particular, the discriminant is C<E[12]> (or C<E.disc>), and the
  2569. C<j>-invariant is C<E[13]> (or C<E.j>).
  2570.  
  2571. The other six components are only present if C<I<flag>> is C<0> (or omitted!).
  2572. Their content depends on whether the curve is defined over B<I<R>> or not:
  2573.  
  2574. C<B<*>> When C<E> is defined over B<I<R>>, C<E[14]> (C<E.roots>) is a
  2575. vector whose three components contain the roots of the associated Weierstrass
  2576. equation. If the roots are all real, then they are ordered by decreasing
  2577. value. If only one is real, it is the first component of C<E[14]>.
  2578.  
  2579. C<E[15]> (C<E.omega[1]>) is the real period of C<E> (integral of
  2580. C<dx/(2y+a_1x+a_3)> over the connected component of the identity element of
  2581. the real points of the curve), and C<E[16]> (C<E.omega[2]>) is a complex
  2582. period. In other words, C<F<omega>_1 = E[15]> and C<F<omega>_2 = E[16]> form a basis of
  2583. the complex lattice defining C<E> (C<E.omega>), with
  2584. C<F<tau> = (F<omega>_2)/(F<omega>_1)> having positive imaginary part.
  2585.  
  2586. C<E[17]> and C<E[18]> are the corresponding values C<F<eta>_1> and C<F<eta>_2> such
  2587. that C<F<eta>_1F<omega>_2-F<eta>_2F<omega>_1 = iF<Pi>>, and both can be retrieved by
  2588. typing C<E.eta> (as a row vector whose components are the C<F<eta>_i>).
  2589.  
  2590. Finally, C<E[19]> (C<E.area>) is the volume of the complex lattice defining
  2591. C<E>.
  2592.  
  2593. C<B<*>> When C<E> is defined over C<B<I<Q>>_p>, the C<p>-adic valuation of C<j>
  2594. must be negative. Then C<E[14]> (C<E.roots>) is the vector with a single
  2595. component equal to the C<p>-adic root of the associated Weierstrass equation
  2596. corresponding to C<-1> under the Tate parametrization.
  2597.  
  2598. C<E[15]> is equal to the square of the C<u>-value, in the notation of Tate.
  2599.  
  2600. C<E[16]> is the C<u>-value itself, if it belongs to C<B<I<Q>>_p>, otherwise zero.
  2601.  
  2602. C<E[17]> is the value of Tate's C<q> for the curve C<E>.
  2603.  
  2604. C<E.tate> will yield the three-component vector C<[u^2,u,q]>.
  2605.  
  2606. C<E[18]> (C<E.w>) is the value of Mestre's C<w> (this is technical), and
  2607. C<E[19]> is arbitrarily set equal to zero.
  2608.  
  2609. For all other base fields or rings, the last six components are arbitrarily
  2610. set equal to zero (see also the description of member functions related to
  2611. elliptic curves at the beginning of this section).
  2612.  
  2613. X<ellinit0>The library syntax is B<ellinit0>C<(E,I<flag>,I<prec>)>. Also available are
  2614. C<X<initell>B<initell>(E,I<prec>)> (C<I<flag> = 0>) and
  2615. C<X<smallinitell>B<smallinitell>(E,I<prec>)> (C<I<flag> = 1>).
  2616.  
  2617. =head2 X<ellisoncurve>ellisoncurveC<(E,z)>
  2618.  
  2619. gives 1 (i.e.S< >true) if the point C<z> is on
  2620. the elliptic curve C<E>, 0 otherwise. If C<E> or C<z> have imprecise coefficients,
  2621. an attempt is made to take this into account, i.e.S< >an imprecise equality is
  2622. checked, not a precise one.
  2623.  
  2624. X<oncurve>The library syntax is B<oncurve>C<(E,z)>, and the result is a C<long>.
  2625.  
  2626. =head2 X<ellj>elljC<(x)>
  2627.  
  2628. elliptic C<j>-invariant. C<x> must be a complex number
  2629. with positive imaginary part, or convertible into a power series or a
  2630. C<p>-adic number with positive valuation.
  2631.  
  2632. X<jell>The library syntax is B<jell>C<(x,I<prec>)>.
  2633.  
  2634. =head2 X<elllocalred>elllocalredC<(E,p)>
  2635.  
  2636. calculates the X<Kodaira>Kodaira type of the
  2637. local fiber of the elliptic curve C<E> at the prime C<p>.
  2638. C<E> must be given by a medium or
  2639. long vector of the type given by C<ellinit>, and is assumed to have all
  2640. its coefficients C<a_i> in B<I<Z>>. The result is a 4-component vector
  2641. C<[f,kod,v,c]>. Here C<f> is the exponent of C<p> in the arithmetic conductor of
  2642. C<E>, and C<kod> is the Kodaira type which is coded as follows:
  2643.  
  2644. 1 means good reduction (type IC<_0>), 2, 3 and 4 mean types II, III and IV
  2645. respectively, C<4+F<nu>> with C<F<nu> E<gt> 0> means type IC<_F<nu>>;
  2646. finally the opposite values C<-1>, C<-2>, etc.S< >refer to the starred types
  2647. IC<_0^*>, IIC<^*>, etc. The third component C<v> is itself a vector C<[u,r,s,t]>
  2648. giving the coordinate changes done during the local reduction. Normally, this
  2649. has no use if C<u> is 1, that is, if the given equation was already minimal.
  2650. Finally, the last component C<c> is the local X<Tamagawa number>Tamagawa number C<c_p>.
  2651.  
  2652. X<localreduction>The library syntax is B<localreduction>C<(E,p)>.
  2653.  
  2654. =head2 X<elllseries>elllseriesC<(E,s,{A = 1})>
  2655.  
  2656. C<E> being a medium or long vector
  2657. given by C<ellinit>, this computes the value of the L-series of C<E> at
  2658. C<s>. It is assumed that C<E> is a minimal model over B<I<Z>> and that the curve
  2659. is a modular elliptic curve. The optional parameter C<A> is a cutoff point for
  2660. the integral, which must be chosen close to 1 for best speed. The result
  2661. must be independent of C<A>, so this allows some internal checking of the
  2662. function.
  2663.  
  2664. Note that if the conductor of the curve is large, say greater than C<10^{12}>,
  2665. this function will take an unreasonable amount of time since it uses an
  2666. C<O(N^{1/2})> algorithm.
  2667.  
  2668. X<lseriesell>The library syntax is B<lseriesell>C<(E,s,A,I<prec>)> where C<I<prec>> is a C<long> and an
  2669. omitted C<A> is coded as C<NULL>.
  2670.  
  2671. =head2 X<ellorder>ellorderC<(E,z)>
  2672.  
  2673. gives the order of the point C<z> on the elliptic
  2674. curve C<E> if it is a torsion point, zero otherwise. In the present version
  2675. B<2.2.0>, this is implemented only for elliptic curves defined over B<I<Q>>.
  2676.  
  2677. X<orderell>The library syntax is B<orderell>C<(E,z)>.
  2678.  
  2679. =head2 X<ellordinate>ellordinateC<(E,x)>
  2680.  
  2681. gives a 0, 1 or 2-component vector containing
  2682. the C<y>-coordinates of the points of the curve C<E> having C<x> as
  2683. C<x>-coordinate.
  2684.  
  2685. X<ordell>The library syntax is B<ordell>C<(E,x)>.
  2686.  
  2687. =head2 X<ellpointtoz>ellpointtozC<(E,z)>
  2688.  
  2689. if C<E> is an elliptic curve with coefficients
  2690. in B<I<R>>, this computes a complex number C<t> (modulo the lattice defining
  2691. C<E>) corresponding to the point C<z>, i.e.S< >such that, in the standard
  2692. Weierstrass model, C< F<wp> (t) = z[1], F<wp> '(t) = z[2]>. In other words, this is the
  2693. inverse function of C<ellztopoint>.
  2694.  
  2695. If C<E> has coefficients in C<B<I<Q>>_p>, then either Tate's C<u> is in C<B<I<Q>>_p>, in
  2696. which case the output is a C<p>-adic number C<t> corresponding to the point C<z>
  2697. under the Tate parametrization, or only its square is, in which case the
  2698. output is C<t+1/t>. C<E> must be a long vector output by C<ellinit>.
  2699.  
  2700. X<zell>The library syntax is B<zell>C<(E,z,I<prec>)>.
  2701.  
  2702. =head2 X<ellpow>ellpowC<(E,z,n)>
  2703.  
  2704. computes C<n> times the point C<z> for the
  2705. group law on the elliptic curve C<E>. Here, C<n> can be in B<I<Z>>, or C<n>
  2706. can be a complex quadratic integer if the curve C<E> has complex multiplication
  2707. by C<n> (if not, an error message is issued).
  2708.  
  2709. X<powell>The library syntax is B<powell>C<(E,z,n)>.
  2710.  
  2711. =head2 X<ellrootno>ellrootnoC<(E,{p = 1})>
  2712.  
  2713. C<E> being a medium or long vector given
  2714. by C<ellinit>, this computes the local (if C<p ! = 1>) or global (if C<p = 1>)
  2715. root number of the L-series of the elliptic curve C<E>. Note that the global
  2716. root number is the sign of the functional equation and conjecturally is the
  2717. parity of the rank of the X<Mordell-Weil group>Mordell-Weil group.
  2718. The equation for C<E> must have
  2719. coefficients in B<I<Q>> but need I<not> be minimal.
  2720.  
  2721. X<ellrootno>The library syntax is B<ellrootno>C<(E,p)> and the result (equal to C<F<+->1>) is a C<long>.
  2722.  
  2723. =head2 X<ellsigma>ellsigmaC<(E,z,{I<flag> = 0})>
  2724.  
  2725. value of the Weierstrass C<F<sigma>>
  2726. function of the lattice associated to C<E> as given by C<ellinit>
  2727. (alternatively, C<E> can be given as a lattice C<[F<omega>_1,F<omega>_2]>).
  2728.  
  2729. If C<I<flag> = 1>, computes an (arbitrary) determination of C< F<log> (F<sigma>(z))>.
  2730.  
  2731. If C<I<flag> = 2,3>, same using the product expansion instead of theta series.
  2732. X<ellsigma>The library syntax is B<ellsigma>C<(E,z,I<flag>)>
  2733.  
  2734. =head2 X<ellsub>ellsubC<(E,z1,z2)>
  2735.  
  2736. difference of the points C<z1> and C<z2> on the
  2737. elliptic curve corresponding to the vector C<E>.
  2738.  
  2739. X<subell>The library syntax is B<subell>C<(E,z1,z2)>.
  2740.  
  2741. =head2 X<elltaniyama>elltaniyamaC<(E)>
  2742.  
  2743. computes the modular parametrization of the
  2744. elliptic curve C<E>, where C<E> is given in the (long or medium) format output
  2745. by C<ellinit>, in the form of a two-component vector C<[u,v]> of power
  2746. series, given to the current default series precision. This vector is
  2747. characterized by the following two properties. First the point C<(x,y) = (u,v)>
  2748. satisfies the equation of the elliptic curve. Second, the differential
  2749. C<du/(2v+a_1u+a_3)> is equal to C<f(z)dz>, a differential form on
  2750. C<H/F<Gamma>_0(N)> where C<N> is the conductor of the curve. The variable used in
  2751. the power series for C<u> and C<v> is C<x>, which is implicitly understood to be
  2752. equal to C< F<exp> (2iF<Pi> z)>. It is assumed that the curve is a I<strong>
  2753. X<Weil curve>Weil curve, and the Manin constant is equal to 1. The equation of
  2754. the curve C<E> must be minimal (use C<ellglobalred> to get a minimal
  2755. equation).
  2756.  
  2757. X<taniyama>The library syntax is B<taniyama>C<(E)>, and the precision of the result is determined by the
  2758. global variable C<precdl>.
  2759.  
  2760. =head2 X<elltors>elltorsC<(E,{I<flag> = 0})>
  2761.  
  2762. if C<E> is an elliptic curve I<defined
  2763. over B<I<Q>>>, outputs the torsion subgroup of C<E> as a 3-component vector
  2764. C<[t,v1,v2]>, where C<t> is the order of the torsion group, C<v1>
  2765. gives the structure of the torsion group as a product of cyclic groups
  2766. (sorted by decreasing order), and C<v2> gives generators for these cyclic
  2767. groups. C<E> must be a long vector as output by C<ellinit>.
  2768.  
  2769.   ?  E = ellinit([0,0,0,-1,0]);
  2770.   ?  elltors(E)
  2771.   %1 = [4, [2, 2], [[0, 0], [1, 0]]]
  2772.  
  2773. Here, the torsion subgroup is isomorphic to C<B<I<Z>>/2B<I<Z>>  x B<I<Z>>/2B<I<Z>>>, with
  2774. generators C<[0,0]> and C<[1,0]>.
  2775.  
  2776. If C<I<flag> = 0>, use Doud's algorithmS< >: bound torsion by computing C<#E(B<I<F>>_p)>
  2777. for small primes of good reduction, then look for torsion points using
  2778. Weierstrass parametrization (and Mazur's classification).
  2779.  
  2780. If C<I<flag> = 1>, use Lutz--Nagell (I<much> slower), C<E> is allowed to be a
  2781. medium vector.
  2782.  
  2783. X<elltors0>The library syntax is B<elltors0>C<(E,flag)>.
  2784.  
  2785. =head2 X<ellwp>ellwpC<(E,{z = x},{I<flag> = 0})>
  2786.  
  2787. Computes the value at C<z> of the Weierstrass C< F<wp> > function attached to the
  2788. elliptic curve C<E> as given by C<ellinit> (alternatively, C<E> can be
  2789. given as a lattice C<[F<omega>_1,F<omega>_2]>).
  2790.  
  2791. If C<z> is omitted or is a simple variable, computes the I<power series>
  2792. expansion in C<z> (starting C<z^{-2}+O(z^2)>). The number of terms to an
  2793. I<even> power in the expansion is the default serieslength in GP, and the
  2794. second argument (C long integer) in library mode.
  2795.  
  2796. Optional I<flag> is (for now) only taken into account when C<z> is numeric, and
  2797. means 0: compute only C< F<wp> (z)>, 1: compute C<[ F<wp> (z), F<wp> '(z)]>.
  2798.  
  2799. X<ellwp0>The library syntax is B<ellwp0>C<(E,z,I<flag>,I<prec>,I<precdl>)>. Also available is
  2800. X<weipell>B<weipell>C<(E,I<precdl>)> for the power series (in
  2801. C<x = polx[0]>).
  2802.  
  2803. =head2 X<ellzeta>ellzetaC<(E,z)>
  2804.  
  2805. value of the Weierstrass C<F<zeta>> function of the
  2806. lattice associated to C<E> as given by C<ellinit> (alternatively, C<E> can
  2807. be given as a lattice C<[F<omega>_1,F<omega>_2]>).
  2808.  
  2809. X<ellzeta>The library syntax is B<ellzeta>C<(E,z)>.
  2810.  
  2811. =head2 X<ellztopoint>ellztopointC<(E,z)>
  2812.  
  2813. C<E> being a long vector, computes the
  2814. coordinates C<[x,y]> on the curve C<E> corresponding to the complex number C<z>.
  2815. Hence this is the inverse function of C<ellpointtoz>. In other words, if
  2816. the curve is put in Weierstrass form, C<[x,y]> represents the
  2817. X<Weierstrass  F<wp> -function>Weierstrass C< F<wp> >-function and its derivative.
  2818. If C<z> is in the lattice defining C<E> over
  2819. B<I<C>>, the result is the point at infinity C<[0]>.
  2820.  
  2821. X<pointell>The library syntax is B<pointell>C<(E,z,I<prec>)>.
  2822.  
  2823. =head1 Functions related to general number fields
  2824.  
  2825. In this section can be found functions which are used almost exclusively for
  2826. working in general number fields. Other less specific functions can be found
  2827. in the next section on polynomials. Functions related to quadratic number
  2828. fields can be found in the section L<Label se:arithmetic> (Arithmetic
  2829. functions).
  2830.  
  2831. We shall use the following conventions:
  2832.  
  2833. C<B<*>> C<X<nf>I<nf>> denotes a number field, i.e.S< >a 9-component vector
  2834. in the format output by X<nfinit>C<nfinit>. This contains the basic arithmetic data
  2835. associated to the number field: signature, maximal order, discriminant, etc.
  2836.  
  2837. C<B<*>> C<X<bnf>I<bnf>> denotes a big number field, i.e.S< >a 10-component
  2838. vector in the format output by X<bnfinit>C<bnfinit>. This contains C<I<nf>> and
  2839. the deeper invariants of the field: units, class groups, as well as a lot of
  2840. technical data necessary for some complex fonctions like C<bnfisprincipal>.
  2841.  
  2842. C<B<*>> C<X<bnr>I<bnr>> denotes a big ``ray number field'', i.e.S< >some data
  2843. structure output by C<bnrinit>, even more complicated than C<I<bnf>>,
  2844. corresponding to the ray class group structure of the field, for some
  2845. modulus.
  2846.  
  2847. C<B<*>> C<X<rnf>I<rnf>> denotes a relative number field (see below).
  2848.  
  2849. C<B<*>> C<X<ideal>I<ideal>> can mean any of the following:
  2850.  
  2851. S< >S< >-- a B<I<Z>>-basis, in X<Hermite normal form>Hermite normal form
  2852. (HNF) or not. In this case C<x> is a square matrix.
  2853.  
  2854. S< >S< >-- an X<idele>I<idele>, i.e.S< >a 2-component vector, the first being an
  2855. ideal given as a B<I<Z>>--basis, the second being a C<r_1+r_2>-component row
  2856. vector giving the complex logarithmic Archimedean information.
  2857.  
  2858. S< >S< >-- a C<B<I<Z>>_K>-generating system for an ideal.
  2859.  
  2860. S< >S< >-- a I<column> vector C<x> expressing an element of the number field
  2861. on the integral basis, in which case the ideal is treated as being the
  2862. principal idele (or ideal) generated by C<x>.
  2863.  
  2864. S< >S< >-- a prime ideal, i.e.S< >a 5-component vector in the format output by
  2865. C<idealprimedec>.
  2866.  
  2867. S< >S< >-- a polmod C<x>, i.e.S< >an algebraic integer, in which case the ideal
  2868. is treated as being the principal idele generated by C<x>.
  2869.  
  2870. S< >S< >-- an integer or a rational number, also treated as a principal idele.
  2871.  
  2872. C<B<*>> a I<{character>} on the Abelian group
  2873. C<\bigoplus (B<I<Z>>/N_iB<I<Z>>) g_i>
  2874. is given by a row vector C<F<chi> = [a_1,...,a_n]> such that
  2875. C<F<chi>(F<prod> g_i^{n_i}) = exp(2iF<Pi>F<sum> a_i n_i / N_i)>.
  2876.  
  2877. B<Warnings:>
  2878.  
  2879. 1) An element in C<I<nf>> can be expressed either as a polmod or as a
  2880. vector of components on the integral basis C<I<nf>.zk>. It is absolutely
  2881. essential that all such vectors be I<column> vectors.
  2882.  
  2883. 2) When giving an ideal by a C<B<I<Z>>_K> generating system to a function expecting
  2884. an ideal, it must be ensured that the function understands that it is a
  2885. C<B<I<Z>>_K>-generating system and not a B<I<Z>>-generating system. When the number of
  2886. generators is strictly less than the degree of the field, there is no
  2887. ambiguity and the program assumes that one is giving a C<B<I<Z>>_K>-generating set.
  2888. When the number of generators is greater than or equal to the degree of the
  2889. field, however, the program assumes on the contrary that you are giving a
  2890. B<I<Z>>-generating set. If this is not the case, you I<must> absolutely
  2891. change it into a B<I<Z>>-generating set, the simplest manner being to use
  2892. C<idealhnf(I<nf>,x)>.
  2893.  
  2894. Concerning relative extensions, some additional definitions are necessary.
  2895.  
  2896. C<B<*>> A I<{relative matrix>} will be a matrix whose entries are
  2897. elements of a (given) number field C<I<nf>>, always expressed as column
  2898. vectors on the integral basis C<I<nf>.zk>. Hence it is a matrix of
  2899. vectors.
  2900.  
  2901. C<B<*>> An X<ideal list>I<ideal list> will be a row vector of (fractional)
  2902. ideals of the number field C<I<nf>>.
  2903.  
  2904. C<B<*>> A X<pseudo-matrix>I<pseudo-matrix> will be a pair C<(A,I)> where C<A> is a
  2905. relative matrix and C<I> an ideal list whose length is the same as the number
  2906. of columns of C<A>. This pair will be represented by a 2-component row vector.
  2907.  
  2908. C<B<*>> The X<module>I<module> generated by a pseudo-matrix C<(A,I)> is
  2909. the sum C<F<sum>_i{B<I<a>>}_jA_j> where the C<{B<I<a>>}_j> are the ideals of C<I>
  2910. and C<A_j> is the C<j>-th column of C<A>.
  2911.  
  2912. C<B<*>> A pseudo-matrix C<(A,I)> is a X<pseudo-basis>I<pseudo-basis> of the module
  2913. it generates if C<A> is a square matrix with non-zero determinant and all the
  2914. ideals of C<I> are non-zero. We say that it is in Hermite Normal
  2915. FormX<Hermite normal form> (HNF) if it is upper triangular and all the
  2916. elements of the diagonal are equal to 1.
  2917.  
  2918. C<B<*>> The I<determinant> of a pseudo-basis C<(A,I)> is the ideal
  2919. equal to the product of the determinant of C<A> by all the ideals of C<I>. The
  2920. determinant of a pseudo-matrix is the determinant of any pseudo-basis of the
  2921. module it generates.
  2922.  
  2923. Finally, when defining a relative extension, the base field should be
  2924. defined by a variable having a lower priority (i.e.S< >a higher number)
  2925. than the variable defining the extension. For example, under GP you can
  2926. use the variable name C<y> (or C<t>) to define the base field, and the
  2927. variable name C<x> to define the relative extension.
  2928.  
  2929. Now a last set of definitions concerning the way big ray number fields
  2930. (or I<bnr>) are input, using class field theory.
  2931. These are defined by a triple
  2932. C<a1>, C<a2>, C<a3>, where the defining set C<[a1,a2,a3]> can have any of the
  2933. following forms: C<[I<bnr>]>, C<[I<bnr>,I<subgroup>]>,
  2934. C<[I<bnf>,I<module>]>, C<[I<bnf>,I<module>,I<subgroup>]>, where:
  2935.  
  2936. C<B<*>> C<I<bnf>> is as output by C<bnfclassunit> or C<bnfinit>,
  2937. where units are mandatory unless the ideal is trivial; I<bnr> by
  2938. C<bnrclass> (with C<I<flag> E<gt> 0>) or C<bnrinit>. This is the ground field.
  2939.  
  2940. C<B<*>> I<module> is either an ideal in any form (see above) or a
  2941. two-component row vector containing an ideal and an C<r_1>-component row
  2942. vector of flags indicating which real Archimedean embeddings to take in the
  2943. module.
  2944.  
  2945. C<B<*>> I<subgroup> is the HNF matrix of a subgroup of the ray class group
  2946. of the ground field for the modulus I<module>. This is input as a square
  2947. matrix expressing generators of a subgroup of the ray class group
  2948. C<I<bnr>.clgp> on the given generators.
  2949.  
  2950. The corresponding I<bnr> is then the subfield of the ray class field of the
  2951. ground field for the given modulus, associated to the given subgroup.
  2952.  
  2953. All the functions which are specific to relative extensions, number fields,
  2954. big number fields, big number rays, share the prefix C<rnf>, C<nf>,
  2955. C<bnf>, C<bnr> respectively. They are meant to take as first argument a
  2956. number field of that precise type, respectively output by C<rnfinit>,
  2957. C<nfinit>, C<bnfinit>, and C<bnrinit>.
  2958.  
  2959. However, and even though it may not be specified in the descriptions of the
  2960. functions below, it is permissible, if the function expects a C<I<nf>>, to
  2961. use a C<I<bnf>> instead (which contains much more information). The program
  2962. will make the effort of converting to what it needs. On the other hand, if
  2963. the program requires a big number field, the program will I<not> launch
  2964. C<bnfinit> for you, which can be a costly operation. Instead, it will give
  2965. you a specific error message.
  2966.  
  2967. The data types corresponding to the structures described above are rather
  2968. complicated. Thus, as we already have seen it with elliptic curves, GP
  2969. provides you with some ``member functions'' to retrieve the data you need
  2970. from these structures (once they have been initialized of course). The
  2971. relevant types of number fields are indicated between parentheses:
  2972.  
  2973. X<member functions>
  2974. S< >X<bnf>C<bnf>     (I<bnr>,  I<bnf> ) :   big number field.
  2975.  
  2976. S< >X<clgp>C<clgp>   (I<bnr>,  I<bnf> ) :   classgroup. This one admits the
  2977. following three subclasses:
  2978.  
  2979. S< >        X<cyc>C<cyc>  :     cyclic decomposition
  2980. (SNF)X<Smith normal form>.
  2981.  
  2982. S< >        C<gen>X<gen (member function)>  :  
  2983. generators.
  2984.  
  2985. S< >        X<no>C<no>   :     number of elements.
  2986.  
  2987. S< >X<diff>C<diff>   (I<bnr>,  I<bnf>,  I<nf> ) :   the different ideal.
  2988.  
  2989. S< >X<codiff>C<codiff> (I<bnr>,  I<bnf>,  I<nf> ) :   the codifferent
  2990. (inverse of the different in the ideal group).
  2991.  
  2992. S< >X<disc>C<disc>  (I<bnr>,  I<bnf>,  I<nf> ) :   discriminant.
  2993.  
  2994. S< >X<fu>C<fu>    (I<bnr>,  I<bnf>,  I<nf> ) :  
  2995. X<fundamental units>fundamental units.
  2996.  
  2997. S< >X<futu>C<futu>  (I<bnr>,  I<bnf> ) :   C<[u,w]>, C<u> is a vector of
  2998. fundamental units, C<w> generates the torsion.
  2999.  
  3000. S< >X<nf>C<nf>    (I<bnr>,  I<bnf>,  I<nf> ) :   number field.
  3001.  
  3002. S< >X<reg>C<reg>   (I<bnr>,  I<bnf>, ) :   regulator.
  3003.  
  3004. S< >X<roots>C<roots> (I<bnr>,  I<bnf>,  I<nf> ) :   roots of the
  3005. polnomial generating the field.
  3006.  
  3007. S< >X<sign>C<sign>  (I<bnr>,  I<bnf>,  I<nf> ) :   C<[r_1,r_2]> the
  3008. signature of the field. This means that the field has C<r_1> real 
  3009. S< >    embeddings, C<2r_2> complex ones.
  3010.  
  3011. S< >X<t2>C<t2>    (I<bnr>,  I<bnf>,  I<nf> ) :   the T2 matrix (see
  3012. C<nfinit>).
  3013.  
  3014. S< >X<tu>C<tu>    (I<bnr>,  I<bnf>, ) :   a generator for the torsion
  3015. units.
  3016.  
  3017. S< >X<tufu>C<tufu>  (I<bnr>,  I<bnf>, ) :   as C<futu>, but outputs
  3018. C<[w,u]>.
  3019.  
  3020. S< >X<zk>C<zk>    (I<bnr>,  I<bnf>,  I<nf> ) :   integral basis, i.e.S< >a
  3021. B<I<Z>>-basis of the maximal order.
  3022.  
  3023. S< >X<zkst>C<zkst>  (I<bnr>           ) :   structure of C<(B<I<Z>>_K/m)^*> (can be
  3024. extracted also from an I<idealstar>).
  3025.  
  3026. For instance, assume that C<I<bnf> = bnfinit(I<pol>)>, for some
  3027. polynomial. Then C<I<bnf>.clgp> retrieves the class group, and
  3028. C<I<bnf>.clgp.no> the class number. If we had set C<I<bnf> = 
  3029. nfinit(I<pol>)>, both would have output an error message. All these
  3030. functions are completely recursive, thus for instance
  3031. C<I<bnr>.bnf.nf.zk> will yield the maximal order of I<bnr> (which
  3032. you could get directly with a simple C<I<bnr>.zk> of course).
  3033.  
  3034. The following functions, starting with C<buch> in library mode, and with
  3035. C<bnf> under GP, are implementations of the sub-exponential algorithms for
  3036. finding class and unit groups under X<GRH>GRH, due to Hafner-McCurley,
  3037. X<Buchmann>Buchmann and Cohen-Diaz-Olivier.
  3038.  
  3039. The general call to the functions concerning class groups of general number
  3040. fields (i.e.S< >excluding C<quadclassunit>) involves a polynomial C<P> and a
  3041. technical vector
  3042.  
  3043. S<  >C<I<tech> = [c,c2,I<nrel>,I<borne>,I<nrpid>,I<minsfb>],>
  3044.  
  3045. where the parameters are to be understood as follows:
  3046.  
  3047. C<P> is the defining polynomial for the number field, which must be in
  3048. C<B<I<Z>>[X]>, irreducible and, preferably, monic. In fact, if you supply a
  3049. non-monic polynomial at this point, GP will issue a warning, then
  3050. I<transform your polynomial> so that it becomes monic. Instead of the
  3051. normal result, say C<res>, you then get a vector C<[res,Mod(a,Q)]>,
  3052. where C<Mod(a,Q) = Mod(X,P)> gives the change of variables.
  3053.  
  3054. The numbers C<c> and C<c2> are positive real numbers which control the
  3055. execution time and the stack size. To get maximum speed, set C<c2 = c>. To get a
  3056. rigorous result (under X<GRH>GRH) you must take C<c2 = 12> (or C<c2 = 6> in the
  3057. quadratic case, but then you should use the much faster function
  3058. C<quadclassunit>). Reasonable values for C<c> are between C<0.1> and
  3059. C<2>. (The defaults are C<c = c2 = 0.3>).
  3060.  
  3061. C<I<nrel>> is the number of initial extra relations requested in
  3062. computing the
  3063. relation matrix. Reasonable values are between 5 and 20. (The default is 5).
  3064.  
  3065. C<I<borne>> is a multiplicative coefficient of the Minkowski bound which
  3066. controls
  3067. the search for small norm relations. If this parameter is set equal to 0, the
  3068. program does not search for small norm relations. Otherwise reasonable values
  3069. are between C<0.5> and C<2.0>. (The default is C<1.0>).
  3070.  
  3071. C<I<nrpid>> is the maximal number of small norm relations associated to each
  3072. ideal in the factor base. Irrelevant when C<I<borne> = 0>. Otherwise,
  3073. reasonable values are between 4 and 20. (The default is 4).
  3074.  
  3075. C<I<minsfb>> is the minimal number of elements in the ``sub-factorbase''.
  3076. If the
  3077. program does not seem to succeed in finding a full rank matrix (which you can
  3078. see in GP by typing C<\g 2>), increase this number. Reasonable values
  3079. are between 2 and 5. (The default is 3).
  3080.  
  3081. B<Remarks.>
  3082.  
  3083. Apart from the polynomial C<P>, you don't need to supply any of the technical
  3084. parameters (under the library you still need to send at least an empty
  3085. vector, C<cgetg(1,t_VEC)>). However, should you choose to set some of
  3086. them, they I<must> be given in the requested order. For example, if you
  3087. want to specify a given value of C<nrel>, you must give some values as well
  3088. for C<c> and C<c2>, and provide a vector C<[c,c2,nrel]>.
  3089.  
  3090. Note also that you can use an C<I<nf>> instead of C<P>, which avoids
  3091. recomputing the integral basis and analogous quantities.
  3092.  
  3093. =head2 X<bnfcertify>bnfcertifyC<(I<bnf>)>
  3094.  
  3095. C<I<bnf>> being a big number field
  3096. as output by C<bnfinit> or C<bnfclassunit>, checks whether the result
  3097. is correct, i.e.S< >whether it is possible to remove the assumption of the
  3098. Generalized Riemann HypothesisX<GRH>. If it is correct, the answer is 1.
  3099. If not, the program may output some error message, but more probably will loop
  3100. indefinitely. In I<no> occasion can the program give a wrong answer
  3101. (barring bugs of course): if the program answers 1, the answer is certified.
  3102.  
  3103. X<certifybuchall>The library syntax is B<certifybuchall>C<(I<bnf>)>, and the result is a C long.
  3104.  
  3105. =head2 X<bnfclassunit>bnfclassunitC<(P,{I<flag> = 0},{I<tech> = []})>
  3106.  
  3107. X<Buchmann>Buchmann's
  3108. sub-exponential algorithm for computing the class group, the regulator and a
  3109. system of X<fundamental units>fundamental units of the general algebraic number field C<K>
  3110. defined by the irreducible polynomial C<P> with integer coefficients.
  3111.  
  3112. The result of this function is a vector C<v> with 10 components (it is
  3113. I<not> a C<I<bnf>>, you need C<bnfinit> for that), which for ease of
  3114. presentation is in fact output as a one column matrix. First we describe the
  3115. default behaviour (C<I<flag> = 0>):
  3116.  
  3117. C<v[1]> is equal to the polynomial C<P>. Note that for optimum performance,
  3118. C<P> should have gone through C<polred> or C<nfinit(x,2)>.
  3119.  
  3120. C<v[2]> is the 2-component vector C<[r1,r2]>, where C<r1> and C<r2> are as usual
  3121. the number of real and half the number of complex embeddings of the number
  3122. field C<K>.
  3123.  
  3124. C<v[3]> is the 2-component vector containing the field discriminant and the
  3125. index.
  3126.  
  3127. C<v[4]> is an integral basis in Hermite normal form.
  3128.  
  3129. C<v[5]> (C<v.clgp>) is a 3-component vector containing the class number
  3130. (C<v.clgp.no>), the structure of the class group as a product of cyclic
  3131. groups of order C<n_i> (C<v.clgp.cyc>), and the corresponding generators
  3132. of the class group of respective orders C<n_i> (C<v.clgp.gen>).
  3133.  
  3134. C<v[6]> (C<v.reg>) is the regulator computed to an accuracy which is the
  3135. maximum of an internally determined accuracy and of the default.
  3136.  
  3137. C<v[7]> is a measure of the correctness of the result. If it is close to 1,
  3138. the results are correct (under X<GRH>GRH). If it is close to a larger integer,
  3139. this shows that the product of the class number by the regulator is off by a
  3140. factor equal to this integer, and you must start again with a larger value
  3141. for C<c> or a different random seed, i.e.S< >use the function C<setrand>.
  3142. (Since the computation involves a random process, starting again with exactly
  3143. the same parameters may give the correct result.) In this case a warning
  3144. message is printed.
  3145.  
  3146. C<v[8]> (C<v.tu>) a vector with 2 components, the first being the number
  3147. C<w> of roots of unity in C<K> and the second a primitive C<w>-th root of unity
  3148. expressed as a polynomial.
  3149.  
  3150. C<v[9]> (C<v.fu>) is a system of fundamental units also expressed as
  3151. polynomials.
  3152.  
  3153. C<v[10]> gives a measure of the correctness of the computations of the
  3154. fundamental units (not of the regulator), expressed as a number of bits. If
  3155. this number is greater than C<20>, say, everything is OK. If C<v[10] E<lt>= 0>,
  3156. then we have lost all accuracy in computing the units (usually an error
  3157. message will be printed and the units not given). In the intermediate cases,
  3158. one must proceed with caution (for example by increasing the current
  3159. precision).
  3160.  
  3161. If C<I<flag> = 1>, and the precision happens to be insufficient for obtaining the
  3162. fundamental units exactly, the internal precision is doubled and the
  3163. computation redone, until the exact results are obtained. The user should be
  3164. warned that this can take a very long time when the coefficients of the
  3165. fundamental units on the integral basis are very large, for example in the
  3166. case of large real quadratic fields. In that case, there are alternate
  3167. methods for representing algebraic numbers which are not implemented in PARI.
  3168.  
  3169. If C<I<flag> = 2>, the fundamental units and roots of unity are not computed.
  3170. Hence the result has only 7 components, the first seven ones.
  3171.  
  3172. C<I<tech>> is a technical vector (empty by default) containing C<c>, C<c2>,
  3173. I<nrel>, I<borne>, I<nbpid>, I<minsfb>, in this order (see
  3174. the beginning of the section or the keyword C<bnf>).
  3175. You can supply any number of these I<provided you give an actual value to
  3176. each of them> (the ``empty arg'' trick won't work here). Careful use of these
  3177. parameters may speed up your computations considerably.
  3178.  
  3179. X<bnfclassunit0>The library syntax is B<bnfclassunit0>C<(P,I<flag>,I<tech>,I<prec>)>.
  3180.  
  3181. =head2 X<bnfclgp>bnfclgpC<(P,{I<tech> = []})>
  3182.  
  3183. as C<bnfclassunit>, but only
  3184. outputs C<v[5]>, i.e.S< >the class group.
  3185.  
  3186. X<bnfclassgrouponly>The library syntax is B<bnfclassgrouponly>C<(P,I<tech>,I<prec>)>, where I<tech>
  3187. is as described under C<bnfclassunit>.
  3188.  
  3189. =head2 X<bnfdecodemodule>bnfdecodemoduleC<(I<nf>,m)>
  3190.  
  3191. if C<m> is a module as output in the
  3192. first component of an extension given by C<bnrdisclist>, outputs the
  3193. true module.
  3194.  
  3195. X<decodemodule>The library syntax is B<decodemodule>C<(I<nf>,m)>.
  3196.  
  3197. =head2 X<bnfinit>bnfinitC<(P,{I<flag> = 0},{I<tech> = []})>
  3198.  
  3199. essentially identical
  3200. to C<bnfclassunit> except that the output contains a lot of technical data,
  3201. and should not be printed out explicitly in general. The result of
  3202. C<bnfinit> is used in programs such as C<bnfisprincipal>,
  3203. C<bnfisunit> or C<bnfnarrow>. The result is a 10-component vector
  3204. C<I<bnf>>.
  3205.  
  3206. C<B<*>> The first 6 and last 2 components are technical and in
  3207. principle are not used by the casual user. However, for the sake of
  3208. completeness, their description is as follows. We use the notations explained
  3209. in the book by H. Cohen, I<A Course in Computational Algebraic Number
  3210. Theory>, Graduate Texts in Maths B<138>, Springer-Verlag, 1993, Section
  3211. 6.5, and subsection 6.5.5 in particular.
  3212.  
  3213. C<I<bnf>[1]> contains the matrix C<W>, i.e.S< >the matrix in Hermite normal
  3214. form giving relations for the class group on prime ideal generators
  3215. C<(B<I<p>>_i)_{1 E<lt>= i E<lt>= r}>.
  3216.  
  3217. C<I<bnf>[2]> contains the matrix C<B>, i.e.S< >the matrix containing the
  3218. expressions of the prime ideal factorbase in terms of the C<B<I<p>>_i>. It is an
  3219. C<r x c> matrix.
  3220.  
  3221. C<I<bnf>[3]> contains the complex logarithmic embeddings of the system of
  3222. fundamental units which has been found. It is an C<(r_1+r_2) x (r_1+r_2-1)>
  3223. matrix.
  3224.  
  3225. C<I<bnf>[4]> contains the matrix C<M''_C> of Archimedean components of the
  3226. relations of the matrix C<(W|B)>.
  3227.  
  3228. C<I<bnf>[5]> contains the prime factor base, i.e.S< >the list of prime
  3229. ideals used in finding the relations.
  3230.  
  3231. C<I<bnf>[6]> contains the permutation of the prime factor base which was
  3232. necessary to reduce the relation matrix to the form explained in subsection
  3233. 6.5.5 of GTMS< >138 (i.e.S< >with a big C<c x c> identity matrix on the lower
  3234. right). Note that in the above mentioned book, the need to permute the rows
  3235. of the relation matrices which occur was not emphasized.
  3236.  
  3237. C<I<bnf>[9]> is a 3-element row vector used in X<bnfisprincipal>C<bnfisprincipal> only
  3238. and obtained as follows.  Let C<D = U W V> obtained by applying the
  3239. X<Smith normal form>Smith normal form algorithm to the matrix C<W> ( = C<I<bnf>[1]>) and
  3240. let C<U_r> be the reduction of C<U> modulo C<D>. The first elements of the
  3241. factorbase are given (in terms of C<bnf.gen>) by the columns of C<U_r>,
  3242. with archimedian component C<g_a>; let also C<GD_a> be the archimedian
  3243. components of the generators of the (principal) ideals defined by the
  3244. C<bnf.gen[i]^bnf.cyc[i]>. Then C<I<bnf>[9] = [U_r, g_a, GD_a]>.
  3245.  
  3246. Finally, C<I<bnf>[10]> is by default unused and set equal to 0. This
  3247. field is used to store further information about the field as it becomes
  3248. available (which is rarely needed, hence would be too expensive to compute
  3249. during the initial C<bnfinit> call). For instance, the generators of the
  3250. principal ideals C<bnf.gen[i]^bnf.cyc[i]> (during a call to
  3251. X<bnrisprincipal>C<bnrisprincipal>), or those corresponding to the relations in C<W> and
  3252. C<B> (when the C<bnf> internal precision needs to be increased).
  3253.  
  3254. C<B<*>> The less technical components are as follows:
  3255.  
  3256. C<I<bnf>[7]> or C<I<bnf>.nf> is equal to the number field data
  3257. C<I<nf>> as would be given by C<nfinit>.
  3258.  
  3259. C<I<bnf>[8]> is a vector containing the last 6 components of
  3260. C<bnfclassunit[,1]>, i.e.S< >the classgroup C<I<bnf>.clgp>, the
  3261. regulator C<I<bnf>.reg>, the general ``check'' number which should be
  3262. close to 1, the number of roots of unity and a generator C<I<bnf>.tu>,
  3263. the fundamental units C<I<bnf>.fu>, and finally the check on their
  3264. computation. If the precision becomes insufficient, GP outputs a warning
  3265. (C<fundamental units too large, not given>) and does not strive to
  3266. compute the units by default (C<I<flag> = 0>).
  3267.  
  3268. When C<I<flag> = 1>, GP insists on finding the fundamental units exactly, the
  3269. internal precision being doubled and the computation redone, until the exact
  3270. results are obtained. The user should be warned that this can take a very
  3271. long time when the coefficients of the fundamental units on the integral
  3272. basis are very large.
  3273.  
  3274. When C<I<flag> = 2>, on the contrary, it is initially agreed that GP
  3275. will not compute units.
  3276.  
  3277. When C<I<flag> = 3>, computes a very small version of C<bnfinit>, a ``small big
  3278. number field'' (or I<sbnf> for short) which contains enough information
  3279. to recover the full C<I<bnf>> vector very rapidly, but which is much
  3280. smaller and hence easy to store and print. It is supposed to be used in
  3281. conjunction with C<bnfmake>. The output is a 12 component vector C<v>, as
  3282. follows. Let C<I<bnf>> be the result of a full C<bnfinit>, complete with
  3283. units. Then C<v[1]> is the polynomial C<P>, C<v[2]> is the number of real
  3284. embeddings C<r_1>, C<v[3]> is the field discriminant, C<v[4]> is the integral
  3285. basis, C<v[5]> is the list of roots as in the sixth component of C<nfinit>,
  3286. C<v[6]> is the matrix C<MD> of C<nfinit> giving a B<I<Z>>-basis of the
  3287. different, C<v[7]> is the matrix C<W = I<bnf>[1]>, C<v[8]> is the
  3288. matrix C<matalpha = I<bnf>[2]>, C<v[9]> is the prime ideal factor base
  3289. C<I<bnf>[5]> coded in a compact way, and ordered according to the
  3290. permutation C<I<bnf>[6]>, C<v[10]> is the 2-component vector giving the
  3291. number of roots of unity and a generator, expressed on the integral basis,
  3292. C<v[11]> is the list of fundamental units, expressed on the integral basis,
  3293. C<v[12]> is a vector containing the algebraic numbers alpha corresponding to
  3294. the columns of the matrix C<matalpha>, expressed on the integral basis.
  3295.  
  3296. Note that all the components are exact (integral or rational), except for
  3297. the roots in C<v[5]>. In practice, this is the only component which a user
  3298. is allowed to modify, by recomputing the roots to a higher accuracy if
  3299. desired. Note also that the member functions will I<not> work on
  3300. I<sbnf>, you have to use C<bnfmake> explicitly first.
  3301.  
  3302. X<bnfinit0>The library syntax is B<bnfinit0>C<(P,I<flag>,I<tech>,I<prec>)>.
  3303.  
  3304. =head2 X<bnfisintnorm>bnfisintnormC<(I<bnf>,x)>
  3305.  
  3306. computes a complete system of
  3307. solutions (modulo units of positive norm) of the absolute norm equation
  3308. C<Norm(a) = x>,
  3309. where C<a> is an integer in C<I<bnf>>. If C<I<bnf>> has not been certified,
  3310. the correctness of the result depends on the validity of X<GRH>GRH.
  3311.  
  3312. X<bnfisintnorm>The library syntax is B<bnfisintnorm>C<(I<bnf>,x)>.
  3313.  
  3314. =head2 X<bnfisnorm>bnfisnormC<(I<bnf>,x,{I<flag> = 1})>
  3315.  
  3316. tries to tell whether the
  3317. rational number C<x> is the norm of some element y in C<I<bnf>>. Returns a
  3318. vector C<[a,b]> where C<x = Norm(a)*b>. Looks for a solution which is an C<S>-unit,
  3319. with C<S> a certain set of prime ideals containing (among others) all primes
  3320. dividing C<x>. If C<I<bnf>> is known to be X<Galois>Galois, set C<I<flag> = 0> (in
  3321. this case,
  3322. C<x> is a norm iff C<b = 1>). If C<I<flag>> is non zero the program adds to C<S> the
  3323. following prime ideals, depending on the sign of C<I<flag>>. If C<I<flag> E<gt> 0>, the
  3324. ideals of norm less than C<I<flag>>. And if C<I<flag> E<lt> 0> the ideals dividing C<I<flag>>.
  3325.  
  3326. If you are willing to assume X<GRH>GRH, the answer is guaranteed
  3327. (i.e.S< >C<x> is a norm iff C<b = 1>), if C<S> contains all primes less than
  3328. C<12 F<log> (I<disc>(I<Bnf>))^2>,
  3329. where C<I<Bnf>> is the Galois closure of C<I<bnf>>.
  3330.  
  3331. X<bnfisnorm>The library syntax is B<bnfisnorm>C<(I<bnf>,x,I<flag>,I<prec>)>, where C<I<flag>> and
  3332. C<I<prec>> are C<long>s.
  3333.  
  3334. =head2 X<bnfissunit>bnfissunitC<(I<bnf>,I<sfu>,x)>
  3335.  
  3336. C<I<bnf>> being output by
  3337. C<bnfinit>, I<sfu> by C<bnfsunit>, gives the column vector of
  3338. exponents of C<x> on the fundamental C<S>-units and the roots of unity.
  3339. If C<x> is not a unit, outputs an empty vector.
  3340.  
  3341. X<bnfissunit>The library syntax is B<bnfissunit>C<(I<bnf>,I<sfu>,x)>.
  3342.  
  3343. =head2 X<bnfisprincipal>bnfisprincipalC<(I<bnf>,x,{I<flag> = 1})>
  3344.  
  3345. C<I<bnf>> being the
  3346. number field data output by C<bnfinit>, and C<x> being either a B<I<Z>>-basis
  3347. of an ideal in the number field (not necessarily in HNF) or a prime ideal in
  3348. the format output by the function C<idealprimedec>, this function tests
  3349. whether the ideal is principal or not. The result is more complete than a
  3350. simple true/false answer: it gives a row vector C<[v_1,v_2,check]>, where
  3351.  
  3352. C<v_1> is the vector of components C<c_i> of the class of the ideal C<x> in the
  3353. class group, expressed on the generators C<g_i> given by C<bnfinit>
  3354. (specifically C<I<bnf>.clgp.gen> which is the same as
  3355. C<I<bnf>[8][1][3]>). The C<c_i> are chosen so that C<0 E<lt>= c_i E<lt> n_i>
  3356. where C<n_i> is the order of C<g_i> (the vector of C<n_i> being
  3357. C<I<bnf>.clgp.cyc>, that is C<I<bnf>[8][1][2]>).
  3358.  
  3359. C<v_2> gives on the integral basis the components of C<F<alpha>> such that
  3360. C<x = F<alpha>F<prod>_ig_i^{c_i}>. In particular, C<x> is principal if and only if
  3361. C<v_1> is equal to the zero vector, and if this the case C<x = F<alpha>B<I<Z>>_K> where
  3362. C<F<alpha>> is given by C<v_2>. Note that if C<F<alpha>> is too large to be given, a
  3363. warning message will be printed and C<v_2> will be set equal to the empty
  3364. vector.
  3365.  
  3366. Finally the third component I<check> is analogous to the last component of
  3367. C<bnfclassunit>: it gives a check on the accuracy of the result, in bits.
  3368. I<check> should be at least C<10>, and preferably much more. In any case, the
  3369. result is checked for correctness.
  3370.  
  3371. If C<I<flag> = 0>, outputs only C<v_1>, which is much easier to compute.
  3372.  
  3373. If C<I<flag> = 2>, does as if C<I<flag>> were C<0>, but doubles the precision until a
  3374. result is obtained.
  3375.  
  3376. If C<I<flag> = 3>, as in the default behaviour (C<I<flag> = 1>), but doubles the precision
  3377. until a result is obtained.
  3378.  
  3379. The user is warned that these two last setting may induce I<very> lengthy
  3380. computations.
  3381.  
  3382. X<isprincipalall>The library syntax is B<isprincipalall>C<(I<bnf>,x,I<flag>)>.
  3383.  
  3384. =head2 X<bnfisunit>bnfisunitC<(I<bnf>,x)>
  3385.  
  3386. C<I<bnf>> being the number field data
  3387. output by
  3388. C<bnfinit> and C<x> being an algebraic number (type integer, rational or
  3389. polmod), this outputs the decomposition of C<x> on the fundamental units and
  3390. the roots of unity if C<x> is a unit, the empty vector otherwise. More
  3391. precisely, if C<u_1>,...,C<u_r> are the fundamental units, and C<F<zeta>> is
  3392. the generator of the group of roots of unity (found by C<bnfclassunit> or
  3393. C<bnfinit>), the output is a vector C<[x_1,...,x_r,x_{r+1}]> such that
  3394. C<x = u_1^{x_1}...u_r^{x_r}.F<zeta>^{x_{r+1}}>. The C<x_i> are integers for
  3395. C<i E<lt>= r> and is an integer modulo the order of C<F<zeta>> for C<i = r+1>.
  3396.  
  3397. X<isunit>The library syntax is B<isunit>C<(I<bnf>,x)>.
  3398.  
  3399. =head2 X<bnfmake>bnfmakeC<(I<sbnf>)>
  3400.  
  3401. I<sbnf> being a ``small C<I<bnf>>''
  3402. as output by C<bnfinit>C<(x,3)>, computes the complete C<bnfinit>
  3403. information. The result is I<not> identical to what C<bnfinit> would
  3404. yield, but is functionally identical. The execution time is very small
  3405. compared to a complete C<bnfinit>. Note that if the default precision in
  3406. GP (or C<I<prec>> in library mode) is greater than the precision of the
  3407. roots C<I<sbnf>[5]>, these are recomputed so as to get a result with
  3408. greater accuracy.
  3409.  
  3410. Note that the member functions are I<not> available for I<sbnf>, you
  3411. have to use C<bnfmake> explicitly first.
  3412.  
  3413. X<makebigbnf>The library syntax is B<makebigbnf>C<(I<sbnf>,I<prec>)>, where C<I<prec>> is a
  3414. C long integer.
  3415.  
  3416. =head2 X<bnfnarrow>bnfnarrowC<(I<bnf>)>
  3417.  
  3418. C<I<bnf>> being a big number field as
  3419. output by C<bnfinit>, computes the narrow class group of C<I<bnf>>. The
  3420. output is a 3-component row vector C<v> analogous to the corresponding
  3421. class group component C<I<bnf>.clgp> (C<I<bnf>[8][1]>): the
  3422. first component is the narrow class number C<v.no>, the second component
  3423. is a vector containing the SNFX<Smith normal form> cyclic components
  3424. C<v.cyc> of the narrow
  3425. class group, and the third is a vector giving the generators of the
  3426. corresponding C<v.gen> cyclic groups. Note that this function is a
  3427. special case of C<bnrclass>.
  3428.  
  3429. X<buchnarrow>The library syntax is B<buchnarrow>C<(I<bnf>)>.
  3430.  
  3431. =head2 X<bnfsignunit>bnfsignunitC<(I<bnf>)>
  3432.  
  3433. C<I<bnf>> being a big number field
  3434. output by C<bnfinit>, this computes an C<r_1 x (r_1+r_2-1)> matrix
  3435. having C<F<+->1> components, giving the signs of the real embeddings of the
  3436. fundamental units.
  3437.  
  3438. X<signunits>The library syntax is B<signunits>C<(I<bnf>)>.
  3439.  
  3440. =head2 X<bnfreg>bnfregC<(I<bnf>)>
  3441.  
  3442. C<I<bnf>> being a big number field
  3443. output by C<bnfinit>, computes its regulator.
  3444.  
  3445. X<regulator>The library syntax is B<regulator>C<(I<bnf>,I<tech>,I<prec>)>, where I<tech> is as in
  3446. C<bnfclassunit>.
  3447.  
  3448. =head2 X<bnfsunit>bnfsunitC<(I<bnf>,S)>
  3449.  
  3450. computes the fundamental C<S>-units of the
  3451. number field C<I<bnf>> (output by C<bnfinit>), where C<S> is a list of
  3452. prime ideals (output by C<idealprimedec>). The output is a vector C<v> with
  3453. 6 components.
  3454.  
  3455. C<v[1]> gives a minimal system of (integral) generators of the C<S>-unit group
  3456. modulo the unit group.
  3457.  
  3458. C<v[2]> contains technical data needed by C<bnfissunit>.
  3459.  
  3460. C<v[3]> is an empty vector (used to give the logarithmic embeddings of the
  3461. generators in C<v[1]> in version 2.0.16).
  3462.  
  3463. C<v[4]> is the C<S>-regulator (this is the product of the regulator, the
  3464. determinant of C<v[2]> and the natural logarithms of the norms of the ideals
  3465. in C<S>).
  3466.  
  3467. C<v[5]> gives the C<S>-class group structure, in the usual format
  3468. (a row vector whose three components give in order the C<S>-class number,
  3469. the cyclic components and the generators).
  3470.  
  3471. C<v[6]> is a copy of C<S>.
  3472.  
  3473. X<bnfsunit>The library syntax is B<bnfsunit>C<(I<bnf>,S,I<prec>)>.
  3474.  
  3475. =head2 X<bnfunit>bnfunitC<(I<bnf>)>
  3476.  
  3477. C<I<bnf>> being a big number field as
  3478. output by
  3479. C<bnfinit>, outputs a two-component row vector giving in the first
  3480. component the vector of fundamental units of the number field, and in the
  3481. second component the number of bit of accuracy which remained in the
  3482. computation (which is always correct, otherwise an error message is printed).
  3483. This function is mainly for people who used the wrong flag in C<bnfinit>
  3484. and would like to skip part of a lengthy C<bnfinit> computation.
  3485.  
  3486. X<buchfu>The library syntax is B<buchfu>C<(I<bnf>)>.
  3487.  
  3488. =head2 X<bnrL1>bnrL1C<(I<bnr>,I<subgroup>,{I<flag> = 0})>
  3489.  
  3490. I<bnr> being the number field data which is output by
  3491. C<bnrinit(,,1)> and I<subgroup> being a square matrix defining a
  3492. congruence subgroup of the ray class group corresponding to I<bnr>
  3493. (or C<0> for the trivial congruence subgroup), returns for each
  3494. X<character>character C<F<chi>> of the ray class group which is trivial on this
  3495. subgroup, the value at C<s = 1> (or C<s = 0>) of the abelian
  3496. C<L>-function associated to C<F<chi>>. For the value at C<s = 0>, the
  3497. function returns in fact for each character C<F<chi>> a vector C<[r_F<chi> ,
  3498. c_F<chi>]> where C<r_F<chi>> is the order of C<L(s, F<chi>)> at C<s = 0> and
  3499. C<c_F<chi>> the first non-zero term in the expansion of C<L(s,
  3500. F<chi>)> at C<s = 0>; in other words
  3501.  
  3502. S<  >C<L(s, F<chi>) = c_F<chi>.s^{r_F<chi>} + O(s^{r_F<chi> + 1})>
  3503.  
  3504. near C<0>. I<flag> is optional, default value is 0; its binary digits
  3505. mean 1: compute at C<s = 1> if set to 1 or C<s = 0> if set to 0, 2: compute
  3506. the primitive C<L>-functions associated to C<F<chi>> if set to 0 or the
  3507. C<L>-function with Euler factors at prime ideals dividing the modulus of
  3508. I<bnr> removed if set to 1 (this is the so-called C<L_S(s, F<chi>)>
  3509. function where C<S> is the set of infinite places of the number field
  3510. together with the finite prime ideals dividing the modulus of I<bnr>,
  3511. see the example below), 3: returns also the character.
  3512.  
  3513. Example:
  3514.  
  3515.   bnf = bnfinit(x^2 - 229);
  3516.   bnr = bnrinit(bnf,1,1);
  3517.   bnrL1(bnr, 0)
  3518.  
  3519. returns the order and the first non-zero term of the abelian
  3520. C<L>-functions C<L(s, F<chi>)> at C<s = 0> where C<F<chi>> runs through the
  3521. characters of the class group of C<B<I<Q>>( F<sqrt> {229})>. Then
  3522.  
  3523.   bnr2 = bnrinit(bnf,2,1);
  3524.   bnrL1(bnr2,0,2)
  3525.  
  3526. returns the order and the first non-zero terms of the abelian
  3527. C<L>-functions C<L_S(s, F<chi>)> at C<s = 0> where C<F<chi>> runs through the
  3528. characters of the class group of C<B<I<Q>>( F<sqrt> {229})> and C<S> is the set
  3529. of infinite places of C<B<I<Q>>( F<sqrt> {229})> together with the finite prime
  3530. C<2> (note that the ray class group modulo C<2> is in fact the class
  3531. group, so C<bnrL1(bnr2,0)> returns exactly the same answer as
  3532. C<bnrL1(bnr,0)>!).
  3533.  
  3534. X<bnrL1>The library syntax is B<bnrL1>C<(I<bnr>,I<subgroup>,I<flag>,I<prec>)>
  3535.  
  3536. =head2 X<bnrclass>bnrclassC<(I<bnf>,I<ideal>,{I<flag> = 0})>
  3537.  
  3538. C<I<bnf>> being a big number field
  3539. as output by C<bnfinit> (the units are mandatory unless the ideal is
  3540. trivial), and I<ideal> being either an ideal in any form or a two-component
  3541. row vector containing an ideal and an C<r_1>-component row vector of flags
  3542. indicating which real Archimedean embeddings to take in the module, computes
  3543. the ray class group of the number field for the module I<ideal>, as a
  3544. 3-component vector as all other finite Abelian groups (cardinality, vector of
  3545. cyclic components, corresponding generators).
  3546.  
  3547. If C<I<flag> = 2>, the output is different. It is a 6-component vector C<w>. C<w[1]>
  3548. is C<I<bnf>>. C<w[2]> is the result of applying
  3549. C<idealstar(I<bnf>,I,2)>. C<w[3]>, C<w[4]> and C<w[6]> are technical
  3550. components used only by the function C<bnrisprincipal>. C<w[5]> is the
  3551. structure of the ray class group as would have been output with C<I<flag> = 0>.
  3552.  
  3553. If C<I<flag> = 1>, as above, except that the generators of the ray class group are
  3554. not computed, which saves time.
  3555.  
  3556. X<bnrclass0>The library syntax is B<bnrclass0>C<(I<bnf>,I<ideal>,I<flag>,I<prec>)>.
  3557.  
  3558. =head2 X<bnrclassno>bnrclassnoC<(I<bnf>,I)>
  3559.  
  3560. C<I<bnf>> being a big number field
  3561. as output
  3562. by C<bnfinit> (units are mandatory unless the ideal is trivial), and C<I>
  3563. being either an ideal in any form or a two-component row vector containing an
  3564. ideal and an C<r_1>-component row vector of flags indicating which real
  3565. Archimedean embeddings to take in the modulus, computes the ray class number
  3566. of the number field for the modulus C<I>. This is faster than C<bnrclass>
  3567. and should be used if only the ray class number is desired.
  3568.  
  3569. X<rayclassno>The library syntax is B<rayclassno>C<(I<bnf>,I)>.
  3570.  
  3571. =head2 X<bnrclassnolist>bnrclassnolistC<(I<bnf>,I<list>)>
  3572.  
  3573. C<I<bnf>> being a
  3574. big number field as output by C<bnfinit> (units are mandatory unless
  3575. the ideal is trivial), and I<list> being a list of modules as output
  3576. by C<ideallist> of C<ideallistarch>,
  3577. outputs the list of the class numbers of the corresponding ray class groups.
  3578.  
  3579. X<rayclassnolist>The library syntax is B<rayclassnolist>C<(I<bnf>,I<list>)>.
  3580.  
  3581. =head2 X<bnrconductor>bnrconductorC<(a_1,{a_2},{a_3}, {I<flag> = 0})>
  3582.  
  3583. conductor of the
  3584. subfield of a ray class field as defined by C<[a_1,a_2,a_3]> (see C<bnr>
  3585. at the beginning of this section).
  3586.  
  3587. X<bnrconductor>The library syntax is B<bnrconductor>C<(a_1,a_2,a_3,I<flag>,I<prec>)>, where an omitted argument
  3588. among the C<a_i> is input as C<gzero>, and C<I<flag>> is a C long.
  3589.  
  3590. =head2 X<bnrconductorofchar>bnrconductorofcharC<(I<bnr>,I<chi>)>
  3591.  
  3592. I<bnr> being a
  3593. big ray number field
  3594. as output by C<bnrclass>, and I<chi> being a row vector representing a
  3595. X<character>character as expressed on the generators of the ray class group, gives
  3596. the conductor of this character as a modulus.
  3597.  
  3598. X<bnrconductorofchar>The library syntax is B<bnrconductorofchar>C<(I<bnr>,I<chi>,I<prec>)> where C<I<prec>>
  3599. is a C<long>.
  3600.  
  3601. =head2 X<bnrdisc>bnrdiscC<(a1,{a2},{a3},{I<flag> = 0})>
  3602.  
  3603. C<a1>, C<a2>, C<a3>
  3604. defining a big ray number field C<L> over a groud field C<K> (see C<bnr>
  3605. at the beginning of this section for the
  3606. meaning of C<a1>, C<a2>, C<a3>), outputs a 3-component row vector C<[N,R_1,D]>,
  3607. where C<N> is the (absolute) degree of C<L>, C<R_1> the number of real places of
  3608. C<L>, and C<D> the discriminant of C<L/B<I<Q>>>, including sign (if C<I<flag> = 0>).
  3609.  
  3610. If C<I<flag> = 1>, as above but outputs relative data. C<N> is now the degree of
  3611. C<L/K>, C<R_1> is the number of real places of C<K> unramified in C<L> (so that
  3612. the number of real places of C<L> is equal to C<R_1> times the relative degree
  3613. C<N>), and C<D> is the relative discriminant ideal of C<L/K>.
  3614.  
  3615. If C<I<flag> = 2>, does as in case 0, except that if the modulus is not the exact
  3616. conductor corresponding to the C<L>, no data is computed and the result is C<0>
  3617. (C<gzero>).
  3618.  
  3619. If C<I<flag> = 3>, as case 2, outputting relative data.
  3620.  
  3621. X<bnrdisc0>The library syntax is B<bnrdisc0>C<(a1,a2,a3,I<flag>,I<prec>)>.
  3622.  
  3623. =head2 X<bnrdisclist>bnrdisclistC<(I<bnf>,I<bound>,{I<arch>},{I<flag> = 0})>
  3624.  
  3625. C<I<bnf>> being a big
  3626. number field as output by C<bnfinit> (the units are mandatory), computes a
  3627. list of discriminants of Abelian extensions of the number field by increasing
  3628. modulus norm up to bound I<bound>, where the ramified Archimedean places are
  3629. given by I<arch> (unramified at infinity if I<arch> is void or
  3630. omitted). If
  3631. I<flag> is non-zero, give I<arch> all the possible values. (See C<bnr>
  3632. at the beginning of this section for the meaning of C<a1>, C<a2>, C<a3>.)
  3633.  
  3634. The alternative syntax C<bnrdisclist(I<bnf>,I<list>)>
  3635. is supported, where I<list> is as output by C<ideallist> or
  3636. C<ideallistarch> (with units).
  3637.  
  3638. The output format is as follows. The output C<v> is a row vector of row
  3639. vectors, allowing the bound to be greater than C<2^{16}> for 32-bit machines,
  3640. and C<v[i][j]> is understood to be in fact C<V[2^{15}(i-1)+j]> of a unique big
  3641. vector C<V> (note that C<2^{15}> is hardwired and can be increased in the
  3642. source code only on 64-bit machines and higher).
  3643.  
  3644. Such a component C<V[k]> is itself a vector C<W> (maybe of length 0) whose
  3645. components correspond to each possible ideal of norm C<k>. Each component
  3646. C<W[i]> corresponds to an Abelian extension C<L> of C<I<bnf>> whose modulus is
  3647. an ideal of norm C<k> and no Archimedean components (hence the extension is
  3648. unramified at infinity). The extension C<W[i]> is represented by a 4-component
  3649. row vector C<[m,d,r,D]> with the following meaning. C<m> is the prime ideal
  3650. factorization of the modulus, C<d = [L:B<I<Q>>]> is the absolute degree of C<L>,
  3651. C<r> is the number of real places of C<L>, and C<D> is the factorization of the
  3652. absolute discriminant. Each prime ideal C<pr = [p,F<alpha>,e,f,F<beta>]> in the
  3653. prime factorization C<m> is coded as C<p.n^2+(f-1).n+(j-1)>, where
  3654. C<n> is the degree of the base field and C<j> is such that
  3655.  
  3656. C<pr = idealprimedec(I<nf>,p)[j]>.
  3657.  
  3658. C<m> can be decoded using C<bnfdecodemodule>.
  3659.  
  3660. X<bnrdisclist0>The library syntax is B<bnrdisclist0>C<(a1,a2,a3,I<bound>,I<arch>,I<flag>)>.
  3661.  
  3662. =head2 X<bnrinit>bnrinitC<(I<bnf>,I<ideal>,{I<flag> = 0})>
  3663.  
  3664. C<I<bnf>> is as
  3665. output by C<bnfinit>, I<ideal> is a valid ideal (or a module),
  3666. initializes data linked
  3667. to the ray class group structure corresponding to this module. This is the
  3668. same as C<bnrclass(I<bnf>,I<ideal>,I<flag>+1)>.
  3669.  
  3670. X<bnrinit0>The library syntax is B<bnrinit0>C<(I<bnf>,I<ideal>,I<flag>,I<prec>)>.
  3671.  
  3672. =head2 X<bnrisconductor>bnrisconductorC<(a1,{a2},{a3})>
  3673.  
  3674. C<a1>, C<a2>, C<a3> represent
  3675. an extension of the base field, given by class field theory for some modulus
  3676. encoded in the parameters. Outputs 1 if this modulus is the conductor, and 0
  3677. otherwise. This is slightly faster than C<bnrconductor>.
  3678.  
  3679. X<bnrisconductor>The library syntax is B<bnrisconductor>C<(a1,a2,a3)> and the result is a C<long>.
  3680.  
  3681. =head2 X<bnrisprincipal>bnrisprincipalC<(I<bnr>,x,{I<flag> = 1})>
  3682.  
  3683. I<bnr> being the
  3684. number field data which is output by C<bnrinit>C<(,,1)> and C<x> being an
  3685. ideal in any form, outputs the components of C<x> on the ray class group
  3686. generators in a way similar to C<bnfisprincipal>. That is a 3-component
  3687. vector C<v> where C<v[1]> is the vector of components of C<x> on the ray class
  3688. group generators, C<v[2]> gives on the integral basis an element C<F<alpha>> such
  3689. that C<x = F<alpha>F<prod>_ig_i^{x_i}>. Finally C<v[3]> indicates the number of bits
  3690. of accuracy left in the result. In any case the result is checked for
  3691. correctness, but C<v[3]> is included to see if it is necessary to increase the
  3692. accuracy in other computations.
  3693.  
  3694. If C<I<flag> = 0>, outputs only C<v_1>. In that case, I<bnr> need not contain the
  3695. ray class group generators, i.e.S< >it may be created with C<bnrinit>C<(,,0)>
  3696.  
  3697. X<isprincipalrayall>The library syntax is B<isprincipalrayall>C<(I<bnr>,x,I<flag>)>.
  3698.  
  3699. =head2 X<bnrrootnumber>bnrrootnumberC<(I<bnr>,I<chi>,{I<flag> = 0})>
  3700.  
  3701. if C<F<chi> = I<chi>> is a (not necessarily primitive)
  3702. X<character>character over I<bnr>, let
  3703. C<L(s,F<chi>) = F<sum>_{id} F<chi>(id) N(id)^{-s}> be the associated
  3704. X<Artin L-function>Artin L-function. Returns the so-called X<Artin root number>Artin root number, i.e.S< >the
  3705. complex number C<W(F<chi>)> of modulus 1 such that
  3706.  
  3707. S<  >C<F<Lambda>(1-s,F<chi>) = W(F<chi>) F<Lambda>(s,\overline{F<chi>})>
  3708.  
  3709. where C<F<Lambda>(s,F<chi>) = A(F<chi>)^{s/2}F<gamma>_F<chi>(s) L(s,F<chi>)> is
  3710. the enlarged L-function associated to C<L>.
  3711.  
  3712. The generators of the ray class group are needed, and you can set C<I<flag> = 1> if
  3713. the character is known to be primitive. Example:
  3714.  
  3715.   bnf = bnfinit(x^2 - 145);
  3716.   bnr = bnrinit(bnf,7,1);
  3717.   bnrrootnumber(bnr, [5])
  3718.  
  3719. returns the root number of the character C<F<chi>> of C<Cl_7(B<I<Q>>( F<sqrt> {145}))>
  3720. such that C<F<chi>(g) = F<zeta>^5>, where C<g> is the generator of the ray-class
  3721. field and C<F<zeta> = e^{2iF<Pi>/N}> where C<N> is the order of C<g> (C<N = 12> as
  3722. C<bnr.cyc> readily tells us).
  3723.  
  3724. X<bnrrootnumber>The library syntax is B<bnrrootnumber>C<(I<bnf>,I<chi>,I<flag>)>
  3725.  
  3726. =head2 bnrstarkC<{(I<bnr>,I<subgroup>,{I<flag> = 0})}>
  3727.  
  3728. I<bnr>
  3729. being as output by C<bnrinit(,,1)>, finds a relative equation for the
  3730. class field corresponding to the modulus in I<bnr> and the given
  3731. congruence subgroup using X<Stark units>Stark units (set C<I<subgroup> = 0> if you
  3732. want the whole ray class group). The main variable of I<bnr> must not be
  3733. C<x>, and the ground field and the class field must be totally real and not
  3734. isomorphic to B<I<Q>> (over the rationnals, use X<polsubcyclo>C<polsubcyclo> or
  3735. X<galoissubcyclo>C<galoissubcyclo>). I<flag> is optional and may be set to 0 to obtain a
  3736. reduced relative polynomial, 1 to be satisfied with any relative
  3737. polynomial, 2 to obtain an absolute polynomial and 3 to obtain the
  3738. irreducible relative polynomial of the Stark unit, 0 being default.
  3739. Example: 
  3740.  
  3741.   bnf = bnfinit(y^2 - 3);
  3742.   bnr = bnrinit(bnf, 5, 1);
  3743.   bnrstark(bnr, 0)
  3744.  
  3745. returns the ray class field of C<B<I<Q>>( F<sqrt> {3})> modulo C<5>.
  3746.  
  3747. B<Remark.> The result of the computation depends on the choice of
  3748. a modulus verifying special conditions. By default the function will try
  3749. few moduli, choosing the one giving the smallest result. In some cases
  3750. where the result is however very large, you can tell the function to 
  3751. try more moduli by adding C<4> to the value of flag. Whether this flag is
  3752. set or not, the function may fail in some extreme cases, returning the
  3753. error message 
  3754.  
  3755. C<"Cannot find a suitable modulus in FindModule">.
  3756.  
  3757. In this case, the corresponding congruence group is a product of cyclic
  3758. groups and, for the time being, the class field has to be obtained by
  3759. splitting this group into its cyclic components.
  3760.  
  3761. X<bnrstark>The library syntax is B<bnrstark>C<(I<bnr>,I<subgroup>,I<flag>)>.
  3762.  
  3763. =head2 X<dirzetak>dirzetakC<(I<nf>,b)>
  3764.  
  3765. gives as a vector the first C<b>
  3766. coefficients of the X<Dedekind>Dedekind zeta function of the number field C<I<nf>>
  3767. considered as a X<Dirichlet series>Dirichlet series.
  3768.  
  3769. X<dirzetak>The library syntax is B<dirzetak>C<(I<nf>,b)>.
  3770.  
  3771. =head2 X<factornf>factornfC<(x,t)>
  3772.  
  3773. factorization of the univariate polynomial C<x>
  3774. over the number field defined by the (univariate) polynomial C<t>. C<x> may
  3775. have coefficients in B<I<Q>> or in the number field. The main variable of
  3776. C<t> must be of I<lower> priority than that of C<x> (in other words the
  3777. variable number of C<t> must be I<greater> than that of C<x>). However if
  3778. the coefficients of the number field occur explicitly (as polmods) as
  3779. coefficients of C<x>, the variable of these polmods I<must> be the same as
  3780. the main variable of C<t>. For example
  3781.  
  3782.   ? factornf(x^2 + Mod(y, y^2+1), y^2+1);
  3783.   ? factornf(x^2 + 1, y^2+1); \\ these two are OK
  3784.   ? factornf(x^2 + Mod(z,z^2+1), y^2+1)
  3785.     ***   incorrect type in gmulsg
  3786.  
  3787. X<polfnf>The library syntax is B<polfnf>C<(x,t)>.
  3788.  
  3789. =head2 X<galoisfixedfield>galoisfixedfieldC<(I<gal>,I<perm>,{fl = 0},{v = y}))>
  3790.  
  3791. I<gal> being be a Galois field as output by X<galoisinit>C<galoisinit> and
  3792. I<perm> an element of C<I<gal>.group> or a vector of such elements,
  3793. computes the fixed field of I<gal> by the automorphism defined by the
  3794. permutations I<perm> of the roots C<I<gal>.roots>. C<P> is guaranteed to
  3795. be squarefree modulo C<I<gal>.p>.
  3796.  
  3797. If no flags or C<I<flag> = 0>, output format is the same as for X<nfsubfield>C<nfsubfield>,
  3798. returning C<[P,x]> such that C<P> is a polynomial defining the fixed field, and
  3799. C<x> is a root of C<P> expressed as a polmod in C<I<gal>.pol>.
  3800.  
  3801. If C<I<flag> = 1> return only the polynomial C<P>.
  3802.  
  3803. If C<I<flag> = 2> return C<[P,x,F]> where C<P> and C<x> are as above and C<F> is the
  3804. factorization of C<I<gal>.pol> over the field defined by C<P>, where
  3805. variable C<v> (C<y> by default) stands for a root of C<P>. The priority of C<v>
  3806. must be less than the priority of the variable of C<I<gal>.pol>.
  3807.  
  3808. Example:
  3809.  
  3810.   G = galoisinit(x^4+1);
  3811.   galoisfixedfield(G,G.group[2],2)
  3812.     [x^2 + 2, Mod(x^3 + x, x^4 + 1), [x^2 - y*x - 1, x^2 + y*x - 1]]
  3813.  
  3814. computes the factorization  C<x^4+1 = (x^2- F<sqrt> {-2}x-1)(x^2+ F<sqrt> {-2}x-1)>
  3815.  
  3816. X<galoisfixedfield>The library syntax is B<galoisfixedfield>C<(I<gal>,I<perm>,p)>.
  3817.  
  3818. =head2 X<galoisinit>galoisinitC<(I<pol>,{den})>
  3819.  
  3820. computes the Galois group
  3821. and all neccessary information for computing the fixed fields of the
  3822. Galois extension C<K/B<I<Q>>> where C<K> is the number field defined by
  3823. C<I<pol>> (monic irreducible polynomial in C<B<I<Z>>[X]> or
  3824. a number field as output by X<nfinit>C<nfinit>). The extension C<K/B<I<Q>>> must be
  3825. Galois with Galois group ``weakly'' super-solvable (see X<nfgaloisconj>C<nfgaloisconj>)
  3826.  
  3827. B<Warning:> The interface of this function is experimental,
  3828. so the described output can be subject to important changes in the
  3829. near future. However the function itself should work as described. For any
  3830. remarks about this interface, please mail C<allomber@math.u-bordeaux.fr>.
  3831.  
  3832. The output is an 8-component vector I<gal>.
  3833.  
  3834. C<I<gal>[1]> contains the polynomial I<pol>
  3835. (C<I<gal>.pol>).
  3836.  
  3837. C<I<gal>[2]> is a three--components vector C<[p,e,q]> where C<p> is a
  3838. prime number (C<I<gal>.p>) such that I<pol> totally split
  3839. modulo C<p> , C<e> is an integer and C<q = p^e> (C<I<gal>.mod>) is the
  3840. modulus of the roots in C<I<gal>.roots>.
  3841.  
  3842. C<I<gal>[3]> is a vector C<L> containing the C<p>-adic roots of
  3843. I<pol> as integers implicitly modulo C<I<gal>.mod>.
  3844. (C<I<gal>.roots>).
  3845.  
  3846. C<I<gal>[4]> is the inverse of the Van der Monde matrix of the
  3847. C<p>-adic roots of I<pol>, multiplied by C<I<gal>[5]>.
  3848.  
  3849. C<I<gal>[5]> is a multiple of the least common denominator of the
  3850. automorphisms expressed as polynomial in a root of I<pol>.
  3851.  
  3852. C<I<gal>[6]> is the Galois group C<G> expressed as a vector of
  3853. permutations of C<L> (C<I<gal>.group>).
  3854.  
  3855. C<I<gal>[7]> is a generating subset C<S = [s_1,...,s_g]> of C<G>
  3856. expressed as a vector of permutations of C<L> (C<I<gal>.gen>).
  3857.  
  3858. C<I<gal>[8]> contains the relative orders C<[o_1,...,o_g]> of
  3859. the generators of C<S> (C<I<gal>.orders>).
  3860.  
  3861. Let C<H> be the maximal normal supersolvable subgroup of C<G>, we have the
  3862. following properties:
  3863.  
  3864. S< >S< >C<B<*>> if C<G/H ~  A_4> then C<[o_1,...,o_g]> ends by
  3865. C<[2,2,3]>.
  3866.  
  3867. S< >S< >C<B<*>> if C<G/H ~  S_4> then C<[o_1,...,o_g]> ends by
  3868. C<[2,2,3,2]>.
  3869.  
  3870. S< >S< >C<B<*>> else C<G> is super-solvable.
  3871.  
  3872. S< >S< >C<B<*>> for C<1 E<lt>= i E<lt>= g> the subgroup of C<G> generated by
  3873. C<[s_1,...,s_g]> is normal, with the exception of C<i = g-2> in the
  3874. second case and of C<i = g-3> in the third.
  3875.  
  3876. S< >S< >C<B<*>> the relative order C<o_i> of C<s_i> is its order in the
  3877. quotient group C<G/E<lt>s_1,...,s_{i-1}E<gt>>, with the same
  3878. exceptions.
  3879.  
  3880. S< >S< >C<B<*>> for any C<x belongs to G> there exists a unique family
  3881. C<[e_1,...,e_g]> such that (no exceptions):
  3882.  
  3883. -- for C<1 E<lt>= i E<lt>= g> we have C<0 E<lt>= e_i E<lt> o_i>
  3884.  
  3885. -- C<x = g_1^{e_1}g_2^{e_2}...g_n^{e_n}>
  3886.  
  3887. If present C<den> must be a suitable value for C<I<gal>[5]>.
  3888.  
  3889. X<galoisinit>The library syntax is B<galoisinit>C<(I<gal>,I<den>)>.
  3890.  
  3891. =head2 X<galoispermtopol>galoispermtopolC<(I<gal>,I<perm>)>
  3892.  
  3893. I<gal> being a
  3894. galois field as output by C<galoisinit> and I<perm> a element of
  3895. C<I<gal>.group>, return the polynomial defining the Galois
  3896. automorphism, as output by C<nfgaloisconj>, associated with the
  3897. permutation I<perm> of the roots C<I<gal>.roots>. I<perm> can
  3898. also be a vector or matrix, in this case, C<galoispermtopol> is
  3899. applied to all components recursively.
  3900.  
  3901. Note that
  3902.  
  3903.   G = galoisinit(pol);
  3904.   galoispermtopol(G, G[6])~
  3905.  
  3906. is equivalent to C<nfgaloisconj(pol)>, if degree of I<pol>
  3907. is greater or equal to C<2>.
  3908.  
  3909. X<galoispermtopol>The library syntax is B<galoispermtopol>C<(I<gal>,I<perm>)>.
  3910.  
  3911. =head2 X<galoissubcyclo>galoissubcycloC<(n,H,{Z},{v})>
  3912.  
  3913. compute a polynomial
  3914. defining the subfield of C<B<I<Q>>(F<zeta>_n)> fixed by the subgroup I<H> of
  3915. C<B<I<Z>>/nB<I<Z>>>. The subgroup I<H> can be given by a generator, a set of
  3916. generators given by a vector or a HNF matrix. If present C<Z> must be
  3917. C<znstar(n)>, and is currently only used when I<H> is a HNF matrix. If
  3918. I<v> is given, the polynomial is given in the variable I<v>.
  3919.  
  3920. The following function can be used to compute all subfields of
  3921. C<B<I<Q>>(F<zeta>_n)> (of order less than C<d>, if C<d> is set):
  3922.  
  3923.   subcyclo(n, d = -1)=
  3924.   {
  3925.     local(Z,G,S);
  3926.     if (d < 0, d = n);
  3927.     Z = znstar(n);
  3928.     G = matdiagonal(Z[2]);
  3929.     S = [];
  3930.     forsubgroup(H = G, d,
  3931.       S = concat(S, galoissubcyclo(n, mathnf(concat(G,H)),Z));
  3932.     );
  3933.     S
  3934.   }
  3935.  
  3936. X<galoissubcyclo>The library syntax is B<galoissubcyclo>C<(n,H,Z,v)> where n is a C long integer.
  3937.  
  3938. =head2 X<idealadd>idealaddC<(I<nf>,x,y)>
  3939.  
  3940. sum of the two ideals C<x> and C<y> in the
  3941. number field C<I<nf>>. When C<x> and C<y> are given by B<I<Z>>-bases, this does
  3942. not depend on C<I<nf>> and can be used to compute the sum of any two
  3943. B<I<Z>>-modules. The result is given in HNF.
  3944.  
  3945. X<idealadd>The library syntax is B<idealadd>C<(I<nf>,x,y)>.
  3946.  
  3947. =head2 X<idealaddtoone>idealaddtooneC<(I<nf>,x,{y})>
  3948.  
  3949. C<x> and C<y> being two co-prime
  3950. integral ideals (given in any form), this gives a two-component row vector
  3951. C<[a,b]> such that C<a belongs to x>, C<b belongs to y> and C<a+b = 1>.
  3952.  
  3953. The alternative syntax C<idealaddtoone(I<nf>,v)>, is supported, where
  3954. C<v> is a C<k>-component vector of ideals (given in any form) which sum to
  3955. C<B<I<Z>>_K>. This outputs a C<k>-component vector C<e> such that C<e[i] belongs to x[i]> for
  3956. C<1 E<lt>= i E<lt>= k> and C<F<sum>_{1 E<lt>= i E<lt>= k}e[i] = 1>.
  3957.  
  3958. X<idealaddtoone0>The library syntax is B<idealaddtoone0>C<(I<nf>,x,y)>, where an omitted C<y> is coded as
  3959. C<NULL>.
  3960.  
  3961. =head2 X<idealappr>idealapprC<(I<nf>,x,{I<flag> = 0})>
  3962.  
  3963. if C<x> is a fractional ideal
  3964. (given in any form), gives an element C<F<alpha>> in C<I<nf>> such that for
  3965. all prime ideals C<B<I<p>>> such that the valuation of C<x> at C<B<I<p>>> is non-zero, we
  3966. have C<v_{B<I<p>>}(F<alpha>) = v_{B<I<p>>}(x)>, and. C<v_{B<I<p>>}(F<alpha>) E<gt>= 0> for all other
  3967. C<{B<I<p>>}>.
  3968.  
  3969. If C<I<flag>> is non-zero, C<x> must be given as a prime ideal factorization, as
  3970. output by C<idealfactor>, but possibly with zero or negative exponents.
  3971. This yields an element C<F<alpha>> such that for all prime ideals C<B<I<p>>> occurring
  3972. in C<x>, C<v_{B<I<p>>}(F<alpha>)> is equal to the exponent of C<B<I<p>>> in C<x>, and for all
  3973. other prime ideals, C<v_{B<I<p>>}(F<alpha>) E<gt>= 0>. This generalizes
  3974. C<idealappr(I<nf>,x,0)> since zero exponents are allowed. Note that
  3975. the algorithm used is slightly different, so that
  3976. C<idealapp(I<nf>,idealfactor(I<nf>,x))> may not be the same as
  3977. C<idealappr(I<nf>,x,1)>.
  3978.  
  3979. X<idealappr0>The library syntax is B<idealappr0>C<(I<nf>,x,I<flag>)>.
  3980.  
  3981. =head2 X<idealchinese>idealchineseC<(I<nf>,x,y)>
  3982.  
  3983. C<x> being a prime ideal factorization
  3984. (i.e.S< >a 2 by 2 matrix whose first column contain prime ideals, and the second
  3985. column integral exponents), C<y> a vector of elements in C<I<nf>> indexed by
  3986. the ideals in C<x>, computes an element C<b> such that
  3987.  
  3988. C<v_B<I<p>>(b - y_B<I<p>>) E<gt>= v_B<I<p>>(x)> for all prime ideals in C<x> and C<v_B<I<p>>(b) E<gt>= 0>
  3989. for all other C<B<I<p>>>.
  3990.  
  3991. X<idealchinese>The library syntax is B<idealchinese>C<(I<nf>,x,y)>.
  3992.  
  3993. =head2 X<idealcoprime>idealcoprimeC<(I<nf>,x,y)>
  3994.  
  3995. given two integral ideals C<x> and C<y>
  3996. in the number field C<I<nf>>, finds a C<F<beta>> in the field, expressed on the
  3997. integral basis C<I<nf>[7]>, such that C<F<beta>.y> is an integral ideal
  3998. coprime to C<x>.
  3999.  
  4000. X<idealcoprime>The library syntax is B<idealcoprime>C<(I<nf>,x)>.
  4001.  
  4002. =head2 X<idealdiv>idealdivC<(I<nf>,x,y,{I<flag> = 0})>
  4003.  
  4004. quotient C<x.y^{-1}> of the
  4005. two ideals C<x> and C<y> in the number field C<I<nf>>. The result is given in
  4006. HNF.
  4007.  
  4008. If C<I<flag>> is non-zero, the quotient C<x.y^{-1}> is assumed to be an
  4009. integral ideal. This can be much faster when the norm of the quotient is
  4010. small even though the norms of C<x> and C<y> are large.
  4011.  
  4012. X<idealdiv0>The library syntax is B<idealdiv0>C<(I<nf>,x,y,I<flag>)>. Also available
  4013. are C<X<idealdiv>B<idealdiv>(I<nf>,x,y)> (C<I<flag> = 0>) and
  4014. C<X<idealdivexact>B<idealdivexact>(I<nf>,x,y)> (C<I<flag> = 1>).
  4015.  
  4016. =head2 X<idealfactor>idealfactorC<(I<nf>,x)>
  4017.  
  4018. factors into prime ideal powers the
  4019. ideal C<x> in the number field C<I<nf>>. The output format is similar to the
  4020. C<factor> function, and the prime ideals are represented in the form
  4021. output by the C<idealprimedec> function, i.e.S< >as 5-element vectors.
  4022.  
  4023. X<idealfactor>The library syntax is B<idealfactor>C<(I<nf>,x)>.
  4024.  
  4025. =head2 X<idealhnf>idealhnfC<(I<nf>,a,{b})>
  4026.  
  4027. gives the X<Hermite normal form>Hermite normal form
  4028. matrix of the ideal C<a>. The ideal can be given in any form whatsoever
  4029. (typically by an algebraic number if it is principal, by a C<B<I<Z>>_K>-system of
  4030. generators, as a prime ideal as given by C<idealprimedec>, or by a
  4031. B<I<Z>>-basis).
  4032.  
  4033. If C<b> is not omitted, assume the ideal given was C<aB<I<Z>>_K+bB<I<Z>>_K>, where C<a>
  4034. and C<b> are elements of C<K> given either as vectors on the integral basis
  4035. C<I<nf>[7]> or as algebraic numbers.
  4036.  
  4037. X<idealhnf0>The library syntax is B<idealhnf0>C<(I<nf>,a,b)> where an omitted C<b> is coded as C<NULL>.
  4038. Also available is C<X<idealhermite>B<idealhermite>(I<nf>,a)> (C<b> omitted).
  4039.  
  4040. =head2 X<idealintersect>idealintersectC<(I<nf>,x,y)>
  4041.  
  4042. intersection of the two ideals
  4043. C<x> and C<y> in the number field C<I<nf>>. When C<x> and C<y> are given by
  4044. B<I<Z>>-bases, this does not depend on C<I<nf>> and can be used to compute the
  4045. intersection of any two B<I<Z>>-modules. The result is given in HNF.
  4046.  
  4047. X<idealintersect>The library syntax is B<idealintersect>C<(I<nf>,x,y)>.
  4048.  
  4049. =head2 X<idealinv>idealinvC<(I<nf>,x)>
  4050.  
  4051. inverse of the ideal C<x> in the
  4052. number field C<I<nf>>. The result is the Hermite normal form of the inverse
  4053. of the ideal, together with the opposite of the Archimedean information if it
  4054. is given.
  4055.  
  4056. X<idealinv>The library syntax is B<idealinv>C<(I<nf>,x)>.
  4057.  
  4058. =head2 X<ideallist>ideallistC<(I<nf>,I<bound>,{I<flag> = 4})>
  4059.  
  4060. computes the list
  4061. of all ideals of norm less or equal to I<bound> in the number field
  4062. I<nf>. The result is a row vector with exactly I<bound> components.
  4063. Each component is itself a row vector containing the information about
  4064. ideals of a given norm, in no specific order. This information can be
  4065. either the HNF of the ideal or the C<idealstar> with possibly some
  4066. additional information.
  4067.  
  4068. If C<I<flag>> is present, its binary digits are toggles meaning
  4069.  
  4070. S< >S< >1: give also the generators in the C<idealstar>.
  4071.  
  4072. S< >S< >2: output C<[L,U]>, where C<L> is as before and C<U> is a vector of
  4073. C<zinternallog>s of the units.
  4074.  
  4075. S< >S< >4: give only the ideals and not the C<idealstar> or the C<ideallog>
  4076. of the units.
  4077.  
  4078. X<ideallist0>The library syntax is B<ideallist0>C<(I<nf>,I<bound>,I<flag>)>, where I<bound> must
  4079. be a C long integer. Also available is C<X<ideallist>B<ideallist>(I<nf>,I<bound>)>,
  4080. corresponding to the case C<I<flag> = 0>.
  4081.  
  4082. =head2 X<ideallistarch>ideallistarchC<(I<nf>,I<list>,{I<arch> = []},{I<flag> = 0})>
  4083.  
  4084. vector of vectors of all C<idealstarinit> (see C<idealstar>) of all
  4085. modules in I<list>, with Archimedean part I<arch> added (void if
  4086. omitted). I<list> is a vector of big ideals, as output by
  4087. C<ideallist>C<(..., I<flag>)> for instance. C<I<flag>> is optional; its binary
  4088. digits are toggles meaning: 1: give generators as well, 2: list format is
  4089. C<[L,U]> (see C<ideallist>).
  4090.  
  4091. X<ideallistarch0>The library syntax is B<ideallistarch0>C<(I<nf>,I<list>,I<arch>,I<flag>)>, where an omitted
  4092. I<arch> is coded as C<NULL>.
  4093.  
  4094. =head2 X<ideallog>ideallogC<(I<nf>,x,I<bid>)>
  4095.  
  4096. C<I<nf>> being a number field,
  4097. I<bid> being a ``big ideal'' as output by C<idealstar> and C<x> being a
  4098. non-necessarily integral element of I<nf> which must have valuation
  4099. equal to 0 at all prime ideals dividing C<I = I<bid>[1]>, computes the
  4100. ``discrete logarithm'' of C<x> on the generators given in C<I<bid>[2]>.
  4101. In other words, if C<g_i> are these generators, of orders C<d_i> respectively,
  4102. the result is a column vector of integers C<(x_i)> such that C<0 E<lt>= x_i E<lt> d_i> and
  4103.  
  4104. S<  >C<x = F<prod>_ig_i^{x_i} (mod ^*I) .>
  4105.  
  4106. Note that when C<I> is a module, this implies also sign conditions on the
  4107. embeddings.
  4108.  
  4109. X<zideallog>The library syntax is B<zideallog>C<(I<nf>,x,I<bid>)>.
  4110.  
  4111. =head2 X<idealmin>idealminC<(I<nf>,x,{I<vdir>})>
  4112.  
  4113. computes a minimum of
  4114. the ideal C<x> in the direction I<vdir> in the number field I<nf>.
  4115.  
  4116. X<minideal>The library syntax is B<minideal>C<(I<nf>,x,I<vdir>,I<prec>)>, where an omitted
  4117. I<vdir> is coded as C<NULL>.
  4118.  
  4119. =head2 X<idealmul>idealmulC<(I<nf>,x,y,{I<flag> = 0})>
  4120.  
  4121. ideal multiplication of the
  4122. ideals C<x> and C<y> in the number field I<nf>. The result is a generating
  4123. set for the ideal product with at most C<n> elements, and is in Hermite normal
  4124. form if either C<x> or C<y> is in HNF or is a prime ideal as output by
  4125. C<idealprimedec>, and this is given together with the sum of the
  4126. Archimedean information in C<x> and C<y> if both are given.
  4127.  
  4128. If C<I<flag>> is non-zero, reduce the result using C<idealred>.
  4129.  
  4130. X<idealmul>The library syntax is B<idealmul>C<(I<nf>,x,y)> (C<I<flag> = 0>) or
  4131. C<X<idealmulred>B<idealmulred>(I<nf>,x,y,I<prec>)> (C<I<flag> ! = 0>), where as usual,
  4132. C<I<prec>> is a C long integer representing the precision.
  4133.  
  4134. =head2 X<idealnorm>idealnormC<(I<nf>,x)>
  4135.  
  4136. computes the norm of the idealS< >C<x>
  4137. in the number fieldS< >C<I<nf>>.
  4138.  
  4139. X<idealnorm>The library syntax is B<idealnorm>C<(I<nf>, x)>.
  4140.  
  4141. =head2 X<idealpow>idealpowC<(I<nf>,x,k,{I<flag> = 0})>
  4142.  
  4143. computes the C<k>-th power of
  4144. the ideal C<x> in the number field C<I<nf>>. C<k> can be positive, negative
  4145. or zero. The result is NOT reduced, it is really the C<k>-th ideal power, and
  4146. is given in HNF.
  4147.  
  4148. If C<I<flag>> is non-zero, reduce the result using C<idealred>. Note however
  4149. that this is NOT the same as as C<idealpow(I<nf>,x,k)> followed by
  4150. reduction, since the reduction is performed throughout the powering process.
  4151.  
  4152. The library syntax corresponding to C<I<flag> = 0> is
  4153. C<X<idealpow>B<idealpow>(I<nf>,x,k)>. If C<k> is a C<long>, you can use
  4154. C<X<idealpows>B<idealpows>(I<nf>,x,k)>. Corresponding to C<I<flag> = 1> is
  4155. C<X<idealpowred>B<idealpowred>(I<nf>,vp,k,I<prec>)>, where C<I<prec>> is a
  4156. C<long>.
  4157.  
  4158. =head2 X<idealprimedec>idealprimedecC<(I<nf>,p)>
  4159.  
  4160. computes the prime ideal
  4161. decomposition of the prime number C<p> in the number field C<I<nf>>. C<p>
  4162. must be a (positive) prime number. Note that the fact that C<p> is prime is
  4163. not checked, so if a non-prime number C<p> is given it may lead to
  4164. unpredictable results.
  4165.  
  4166. The result is a vector of 5-component vectors, each representing one of the
  4167. prime ideals above C<p> in the number field C<I<nf>>. The representation
  4168. C<vp = [p,a,e,f,b]> of a prime ideal means the following. The prime ideal is
  4169. equal to C<pB<I<Z>>_K+F<alpha>B<I<Z>>_K> where C<B<I<Z>>_K> is the ring of integers of the field
  4170. and C<F<alpha> = F<sum>_i a_iF<omega>_i> where the C<F<omega>_i> form the integral basis
  4171. C<I<nf>.zk>, C<e> is the ramification index, C<f> is the residual index,
  4172. and C<b> is an C<n>-component column vector representing a C<F<beta> belongs to B<I<Z>>_K> such
  4173. that C<vp^{-1} = B<I<Z>>_K+F<beta>/pB<I<Z>>_K> which will be useful for computing
  4174. valuations, but which the user can ignore. The number C<F<alpha>> is guaranteed
  4175. to have a valuation equal to 1 at the prime ideal (this is automatic if
  4176. C<e E<gt> 1>).
  4177.  
  4178. X<idealprimedec>The library syntax is B<idealprimedec>C<(I<nf>,p)>.
  4179.  
  4180. =head2 X<idealprincipal>idealprincipalC<(I<nf>,x)>
  4181.  
  4182. creates the principal ideal
  4183. generated by the algebraic number C<x> (which must be of type integer,
  4184. rational or polmod) in the number field C<I<nf>>. The result is a
  4185. one-column matrix.
  4186.  
  4187. X<principalideal>The library syntax is B<principalideal>C<(I<nf>,x)>.
  4188.  
  4189. =head2 X<idealred>idealredC<(I<nf>,I,{I<vdir> = 0})>
  4190.  
  4191. X<LLL>LLL reduction of
  4192. the ideal C<I> in the number field I<nf>, along the direction I<vdir>.
  4193. If I<vdir> is present, it must be an C<r1+r2>-component vector (C<r1> and
  4194. C<r2> number of real and complex places of I<nf> as usual).
  4195.  
  4196. This function finds a ``small'' C<a> in C<I> (it is an LLL pseudo-minimum
  4197. along direction I<vdir>). The result is the X<Hermite normal form>Hermite normal form of
  4198. the LLL-reduced ideal C<r I/a>, where C<r> is a rational number such that the
  4199. resulting ideal is integral and primitive. This is often, but not always, a
  4200. reduced ideal in the sense of X<Buchmann>Buchmann. If C<I> is an idele, the
  4201. logarithmic embeddings of C<a> are subtracted to the Archimedean part.
  4202.  
  4203. More often than not, a X<principal ideal>principal ideal will yield the identity
  4204. matrix. This is a quick and dirty way to check if ideals are principal
  4205. without computing a full C<bnf> structure, but it's not a necessary
  4206. condition; hence, a non-trivial result doesn't prove the ideal is
  4207. non-trivial in the class group.
  4208.  
  4209. Note that this is I<not> the same as the LLL reduction of the lattice
  4210. C<I> since ideal operations are involved.
  4211.  
  4212. X<ideallllred>The library syntax is B<ideallllred>C<(I<nf>,x,I<vdir>,I<prec>)>, where an omitted
  4213. I<vdir> is coded as C<NULL>.
  4214.  
  4215. =head2 X<idealstar>idealstarC<(I<nf>,I,{I<flag> = 1})>
  4216.  
  4217. I<nf> being a number
  4218. field, and C<I>
  4219. either and ideal in any form, or a row vector whose first component is an
  4220. ideal and whose second component is a row vector of C<r_1> 0 or 1, outputs
  4221. necessary data for computing in the group C<(B<I<Z>>_K/I)^*>.
  4222.  
  4223. If C<I<flag> = 2>, the result is a 5-component vector C<w>. C<w[1]> is the ideal
  4224. or module C<I> itself. C<w[2]> is the structure of the group. The other
  4225. components are difficult to describe and are used only in conjunction with
  4226. the function C<ideallog>.
  4227.  
  4228. If C<I<flag> = 1> (default), as C<I<flag> = 2>, but do not compute explicit generators
  4229. for the cyclic components, which saves time.
  4230.  
  4231. If C<I<flag> = 0>, computes the structure of C<(B<I<Z>>_K/I)^*> as a 3-component vector
  4232. C<v>. C<v[1]> is the order, C<v[2]> is the vector of SNFX<Smith normal form>
  4233. cyclic components and
  4234. C<v[3]> the corresponding generators. When the row vector is explicitly
  4235. included, the
  4236. non-zero elements of this vector are considered as real embeddings of
  4237. I<nf> in the order given by C<polroots>, i.e.S< >in I<nf>[6]
  4238. (C<I<nf>.roots>), and then C<I> is a module with components at infinity.
  4239.  
  4240. To solve discrete logarithms (using C<ideallog>), you have to choose
  4241. C<I<flag> = 2>.
  4242.  
  4243. X<idealstar0>The library syntax is B<idealstar0>C<(I<nf>,I,I<flag>)>.
  4244.  
  4245. =head2 X<idealtwoelt>idealtwoeltC<(I<nf>,x,{a})>
  4246.  
  4247. computes a two-element
  4248. representation of the ideal C<x> in the number field C<I<nf>>, using a
  4249. straightforward (exponential time) search. C<x> can be an ideal in any form,
  4250. (including perhaps an Archimedean part, which is ignored) and the result is a
  4251. row vector C<[a,F<alpha>]> with two components such that C<x = aB<I<Z>>_K+F<alpha>B<I<Z>>_K>
  4252. and C<a belongs to B<I<Z>>>, where C<a> is the one passed as argument if any. If C<x> is given
  4253. by at least two generators, C<a> is chosen to be the positive generator of
  4254. C<x F<cap> B<I<Z>>>.
  4255.  
  4256. Note that when an explicit C<a> is given, we use an asymptotically faster
  4257. method, however in practice it is usually slower.
  4258.  
  4259. X<ideal_two_elt0>The library syntax is B<ideal_two_elt0>C<(I<nf>,x,a)>, where an omitted C<a> is entered as
  4260. C<NULL>.
  4261.  
  4262. =head2 X<idealval>idealvalC<(I<nf>,x,I<vp>)>
  4263.  
  4264. gives the valuation of the
  4265. ideal C<x> at the prime ideal I<vp> in the number field C<I<nf>>,
  4266. where I<vp> must be a
  4267. 5-component vector as given by C<idealprimedec>.
  4268.  
  4269. X<idealval>The library syntax is B<idealval>C<(I<nf>,x,I<vp>)>, and the result is a C<long>
  4270. integer.
  4271.  
  4272. =head2 X<ideleprincipal>ideleprincipalC<(I<nf>,x)>
  4273.  
  4274. creates the principal idele
  4275. generated by the algebraic number C<x> (which must be of type integer,
  4276. rational or polmod) in the number field C<I<nf>>. The result is a
  4277. two-component vector, the first being a one-column matrix representing the
  4278. corresponding principal ideal, and the second being the vector with C<r_1+r_2>
  4279. components giving the complex logarithmic embedding of C<x>.
  4280.  
  4281. X<principalidele>The library syntax is B<principalidele>C<(I<nf>,x)>.
  4282.  
  4283. =head2 X<matalgtobasis>matalgtobasisC<(I<nf>,x)>
  4284.  
  4285. C<I<nf>> being a number field in
  4286. C<nfinit> format, and C<x> a matrix whose coefficients are expressed as
  4287. polmods in C<I<nf>>, transforms this matrix into a matrix whose
  4288. coefficients are expressed on the integral basis of C<I<nf>>. This is the
  4289. same as applying C<nfalgtobasis> to each entry, but it would be dangerous
  4290. to use the same name.
  4291.  
  4292. X<matalgtobasis>The library syntax is B<matalgtobasis>C<(I<nf>,x)>.
  4293.  
  4294. =head2 X<matbasistoalg>matbasistoalgC<(I<nf>,x)>
  4295.  
  4296. C<I<nf>> being a number field in
  4297. C<nfinit> format, and C<x> a matrix whose coefficients are expressed as
  4298. column vectors on the integral basis of C<I<nf>>, transforms this matrix
  4299. into a matrix whose coefficients are algebraic numbers expressed as
  4300. polmods. This is the same as applying C<nfbasistoalg> to each entry, but
  4301. it would be dangerous to use the same name.
  4302.  
  4303. X<matbasistoalg>The library syntax is B<matbasistoalg>C<(I<nf>,x)>.
  4304.  
  4305. =head2 X<modreverse>modreverseC<(a)>
  4306.  
  4307. C<a> being a polmod C<A(X)> modulo C<T(X)>, finds
  4308. the ``reverse polmod'' C<B(X)> modulo C<Q(X)>, where C<Q> is the minimal
  4309. polynomial of C<a>, which must be equal to the degree of C<T>, and such that if
  4310. C<F<theta>> is a root of C<T> then C<F<theta> = B(F<alpha>)> for a certain root C<F<alpha>>
  4311. of C<Q>.
  4312.  
  4313. This is very useful when one changes the generating element in algebraic
  4314. extensions.
  4315.  
  4316. X<polmodrecip>The library syntax is B<polmodrecip>C<(x)>.
  4317.  
  4318. =head2 X<newtonpoly>newtonpolyC<(x,p)>
  4319.  
  4320. gives the vector of the slopes of the Newton
  4321. polygon of the polynomial C<x> with respect to the prime number C<p>. The C<n>
  4322. components of the vector are in decreasing order, where C<n> is equal to the
  4323. degree of C<x>. Vertical slopes occur iff the constant coefficient of C<x> is
  4324. zero and are denoted by C<VERYBIGINT>, the biggest single precision
  4325. integer representable on the machine (C<2^{31}-1> (resp.S< >C<2^{63}-1>) on 32-bit
  4326. (resp.S< >64-bit) machines), see L<Label se:valuation>.
  4327.  
  4328. X<newtonpoly>The library syntax is B<newtonpoly>C<(x,p)>.
  4329.  
  4330. =head2 X<nfalgtobasis>nfalgtobasisC<(I<nf>,x)>
  4331.  
  4332. this is the inverse function of
  4333. C<nfbasistoalg>. Given an object C<x> whose entries are expressed as
  4334. algebraic numbers in the number field C<I<nf>>, transforms it so that the
  4335. entries are expressed as a column vector on the integral basis
  4336. C<I<nf>.zk>.
  4337.  
  4338. X<algtobasis>The library syntax is B<algtobasis>C<(I<nf>,x)>.
  4339.  
  4340. =head2 X<nfbasis>nfbasisC<(x,{I<flag> = 0},{p})>
  4341.  
  4342. X<integral basis>integral basis of the number
  4343. field defined by the irreducible, preferably monic, polynomial C<x>,
  4344. using a modified version of the X<round 4>round 4 algorithm by
  4345. default. The binary digits of C<I<flag>> have the following meaning:
  4346.  
  4347. 1: assume that no square of a prime greater than the default C<primelimit>
  4348. divides the discriminant of C<x>, i.e.S< >that the index of C<x> has only small
  4349. prime divisors.
  4350.  
  4351. 2: use X<round 2>round 2 algorithm. For small degrees and coefficient size, this is
  4352. sometimes a little faster. (This program is the translation into C of a program
  4353. written by David X<Ford>Ford in Algeb.)
  4354.  
  4355. Thus for instance, if C<I<flag> = 3>, this uses the round 2 algorithm and outputs
  4356. an order which will be maximal at all the small primes.
  4357.  
  4358. If C<p> is present, we assume (without checking!) that it is the two-column
  4359. matrix of the factorization of the discriminant of the polynomial C<x>. Note
  4360. that it does I<not> have to be a complete factorization. This is
  4361. especially useful if only a local integral basis for some small set of places
  4362. is desired: only factors with exponents greater or equal to 2 will be
  4363. considered.
  4364.  
  4365. X<nfbasis0>The library syntax is B<nfbasis0>C<(x,I<flag>,p)>. An extended version
  4366. is C<X<nfbasis>B<nfbasis>(x,&d,I<flag>,p)>, where C<d> will receive the discriminant of
  4367. the number field (I<not> of the polynomial C<x>), and an omitted C<p> should
  4368. be input as C<gzero>. Also available are C<X<base>B<base>(x,&d)> (C<I<flag> = 0>),
  4369. C<X<base2>B<base2>(x,&d)> (C<I<flag> = 2>) and C<X<factoredbase>B<factoredbase>(x,p,&d)>.
  4370.  
  4371. =head2 X<nfbasistoalg>nfbasistoalgC<(I<nf>,x)>
  4372.  
  4373. this is the inverse function of
  4374. C<nfalgtobasis>. Given an object C<x> whose entries are expressed on the
  4375. integral basis C<I<nf>.zk>, transforms it into an object whose entries
  4376. are algebraic numbers (i.e.S< >polmods).
  4377.  
  4378. X<basistoalg>The library syntax is B<basistoalg>C<(I<nf>,x)>.
  4379.  
  4380. =head2 X<nfdetint>nfdetintC<(I<nf>,x)>
  4381.  
  4382. given a pseudo-matrix C<x>, computes a
  4383. non-zero ideal contained in (i.e.S< >multiple of) the determinant of C<x>. This
  4384. is particularly useful in conjunction with C<nfhnfmod>.
  4385.  
  4386. X<nfdetint>The library syntax is B<nfdetint>C<(I<nf>,x)>.
  4387.  
  4388. =head2 X<nfdisc>nfdiscC<(x,{I<flag> = 0},{p})>
  4389.  
  4390. X<field discriminant>field discriminant of the
  4391. number field defined by the integral, preferably monic, irreducible
  4392. polynomial C<x>. C<I<flag>> and C<p> are exactly as in C<nfbasis>. That is, C<p>
  4393. provides the matrix of a partial factorization of the discriminant of C<x>,
  4394. and binary digits of C<I<flag>> are as follows:
  4395.  
  4396. 1: assume that no square of a prime greater than C<primelimit>
  4397. divides the discriminant.
  4398.  
  4399. 2: use the round 2 algorithm, instead of the default X<round 4>round 4.
  4400. This should be
  4401. slower except maybe for polynomials of small degree and coefficients.
  4402.  
  4403. X<nfdiscf0>The library syntax is B<nfdiscf0>C<(x,I<flag>,p)> where, to omit C<p>, you should input C<gzero>. You
  4404. can also use C<X<discf>B<discf>(x)> (C<I<flag> = 0>).
  4405.  
  4406. =head2 X<nfeltdiv>nfeltdivC<(I<nf>,x,y)>
  4407.  
  4408. given two elements C<x> and C<y> in
  4409. I<nf>, computes their quotient C<x/y> in the number field C<I<nf>>.
  4410.  
  4411. X<element_div>The library syntax is B<element_div>C<(I<nf>,x,y)>.
  4412.  
  4413. =head2 X<nfeltdiveuc>nfeltdiveucC<(I<nf>,x,y)>
  4414.  
  4415. given two elements C<x> and C<y> in
  4416. I<nf>, computes an algebraic integer C<q> in the number field C<I<nf>>
  4417. such that the components of C<x-qy> are reasonably small. In fact, this is
  4418. functionally identical to C<round(nfeltdiv(I<nf>,x,y))>.
  4419.  
  4420. X<nfdiveuc>The library syntax is B<nfdiveuc>C<(I<nf>,x,y)>.
  4421.  
  4422. =head2 X<nfeltdivmodpr>nfeltdivmodprC<(I<nf>,x,y,I<pr>)>
  4423.  
  4424. given two elements C<x>
  4425. and C<y> in I<nf> and I<pr> a prime ideal in C<modpr> format (see
  4426. X<nfmodprinit>C<nfmodprinit>), computes their quotient C<x / y> modulo the prime ideal
  4427. I<pr>.
  4428.  
  4429. X<element_divmodpr>The library syntax is B<element_divmodpr>C<(I<nf>,x,y,I<pr>)>.
  4430.  
  4431. =head2 X<nfeltdivrem>nfeltdivremC<(I<nf>,x,y)>
  4432.  
  4433. given two elements C<x> and C<y> in
  4434. I<nf>, gives a two-element row vector C<[q,r]> such that C<x = qy+r>, C<q> is
  4435. an algebraic integer in C<I<nf>>, and the components of C<r> are
  4436. reasonably small.
  4437.  
  4438. X<nfdivres>The library syntax is B<nfdivres>C<(I<nf>,x,y)>.
  4439.  
  4440. =head2 X<nfeltmod>nfeltmodC<(I<nf>,x,y)>
  4441.  
  4442. given two elements C<x> and C<y> in
  4443. I<nf>, computes an element C<r> of C<I<nf>> of the form C<r = x-qy> with
  4444. C<q> and algebraic integer, and such that C<r> is small. This is functionally
  4445. identical to
  4446.  
  4447. S<  >C<x - nfeltmul(I<nf>,round(nfeltdiv(I<nf>,x,y)),y).>
  4448.  
  4449. X<nfmod>The library syntax is B<nfmod>C<(I<nf>,x,y)>.
  4450.  
  4451. =head2 X<nfeltmul>nfeltmulC<(I<nf>,x,y)>
  4452.  
  4453. given two elements C<x> and C<y> in
  4454. I<nf>, computes their product C<x*y> in the number field C<I<nf>>.
  4455.  
  4456. X<element_mul>The library syntax is B<element_mul>C<(I<nf>,x,y)>.
  4457.  
  4458. =head2 X<nfeltmulmodpr>nfeltmulmodprC<(I<nf>,x,y,I<pr>)>
  4459.  
  4460. given two elements C<x> and
  4461. C<y> in I<nf> and I<pr> a prime ideal in C<modpr> format (see
  4462. X<nfmodprinit>C<nfmodprinit>), computes their product C<x*y> modulo the prime ideal
  4463. I<pr>.
  4464.  
  4465. X<element_mulmodpr>The library syntax is B<element_mulmodpr>C<(I<nf>,x,y,I<pr>)>.
  4466.  
  4467. =head2 X<nfeltpow>nfeltpowC<(I<nf>,x,k)>
  4468.  
  4469. given an element C<x> in I<nf>,
  4470. and a positive or negative integer C<k>, computes C<x^k> in the number field
  4471. C<I<nf>>.
  4472.  
  4473. X<element_pow>The library syntax is B<element_pow>C<(I<nf>,x,k)>.
  4474.  
  4475. =head2 X<nfeltpowmodpr>nfeltpowmodprC<(I<nf>,x,k,I<pr>)>
  4476.  
  4477. given an element C<x> in
  4478. I<nf>, an integer C<k> and a prime ideal I<pr> in C<modpr> format
  4479. (see X<nfmodprinit>C<nfmodprinit>), computes C<x^k> modulo the prime ideal I<pr>.
  4480.  
  4481. X<element_powmodpr>The library syntax is B<element_powmodpr>C<(I<nf>,x,k,I<pr>)>.
  4482.  
  4483. =head2 X<nfeltreduce>nfeltreduceC<(I<nf>,x,I<ideal>)>
  4484.  
  4485. given an ideal in
  4486. Hermite normal form and an element C<x> of the number field C<I<nf>>,
  4487. finds an element C<r> in C<I<nf>> such that C<x-r> belongs to the ideal
  4488. and C<r> is small.
  4489.  
  4490. X<element_reduce>The library syntax is B<element_reduce>C<(I<nf>,x,I<ideal>)>.
  4491.  
  4492. =head2 X<nfeltreducemodpr>nfeltreducemodprC<(I<nf>,x,I<pr>)>
  4493.  
  4494. given
  4495. an element C<x> of the number field C<I<nf>> and a prime ideal I<pr> in
  4496. C<modpr> format compute a canonical representative for the class of C<x>
  4497. modulo I<pr>.
  4498.  
  4499. X<nfreducemodpr2>The library syntax is B<nfreducemodpr2>C<(I<nf>,x,I<pr>)>.
  4500.  
  4501. =head2 X<nfeltval>nfeltvalC<(I<nf>,x,I<pr>)>
  4502.  
  4503. given an element C<x> in
  4504. I<nf> and a prime ideal I<pr> in the format output by
  4505. C<idealprimedec>, computes their the valuation at I<pr> of the
  4506. element C<x>. The same result could be obtained using
  4507. C<idealval(I<nf>,x,I<pr>)> (since C<x> would then be converted to a
  4508. principal ideal), but it would be less efficient.
  4509.  
  4510. X<element_val>The library syntax is B<element_val>C<(I<nf>,x,I<pr>)>, and the result is a C<long>.
  4511.  
  4512. =head2 X<nffactor>nffactorC<(I<nf>,x)>
  4513.  
  4514. factorization of the univariate
  4515. polynomial C<x> over the number field C<I<nf>> given by C<nfinit>. C<x>
  4516. has coefficients in C<I<nf>> (i.e.S< >either scalar, polmod, polynomial or
  4517. column vector). The main variable of C<I<nf>> must be of I<lower>
  4518. priority than that of C<x> (in other words, the variable number of C<I<nf>>
  4519. must be I<greater> than that of C<x>). However if the polynomial defining
  4520. the number field occurs explicitly  in the coefficients of C<x> (as modulus of
  4521. a C<t_POLMOD>), its main variable must be I<the same> as the main
  4522. variable of C<x>. For example,
  4523.  
  4524.   ? nf = nfinit(y^2 + 1);
  4525.   ? nffactor(nf, x^2 + y); \\ OK
  4526.   ? nffactor(nf, x^2 + Mod(y, y^2+1)); \\  OK
  4527.   ? nffactor(nf, x^2 + Mod(z, z^2+1)); \\  WRONG
  4528.  
  4529. X<nffactor>The library syntax is B<nffactor>C<(I<nf>,x)>.
  4530.  
  4531. =head2 X<nffactormod>nffactormodC<(I<nf>,x,I<pr>)>
  4532.  
  4533. factorization of the
  4534. univariate polynomial C<x> modulo the prime ideal I<pr> in the number
  4535. field C<I<nf>>. C<x> can have coefficients in the number field (scalar,
  4536. polmod, polynomial, column vector) or modulo the prime ideal (integermod
  4537. modulo the rational prime under I<pr>, polmod or polynomial with
  4538. integermod coefficients, column vector of integermod). The prime ideal
  4539. I<pr> I<must> be in the format output by C<idealprimedec>. The
  4540. main variable of C<I<nf>> must be of lower priority than that of C<x> (in
  4541. other words the variable number of C<I<nf>> must be greater than that of
  4542. C<x>). However if the coefficients of the number field occur explicitly (as
  4543. polmods) as coefficients of C<x>, the variable of these polmods I<must>
  4544. be the same as the main variable of C<t> (see C<nffactor>).
  4545.  
  4546. X<nffactormod>The library syntax is B<nffactormod>C<(I<nf>,x,I<pr>)>.
  4547.  
  4548. =head2 X<nfgaloisapply>nfgaloisapplyC<(I<nf>,I<aut>,x)>
  4549.  
  4550. C<I<nf>> being a
  4551. number field as output by C<nfinit>, and I<aut> being a X<Galois>Galois
  4552. automorphism of C<I<nf>> expressed either as a polynomial or a polmod
  4553. (such automorphisms being found using for example one of the variants of
  4554. C<nfgaloisconj>), computes the action of the automorphism I<aut> on
  4555. the object C<x> in the number field. C<x> can be an element (scalar, polmod,
  4556. polynomial or column vector) of the number field, an ideal (either given by
  4557. C<B<I<Z>>_K>-generators or by a B<I<Z>>-basis), a prime ideal (given as a 5-element
  4558. row vector) or an idele (given as a 2-element row vector). Because of
  4559. possible confusion with elements and ideals, other vector or matrix
  4560. arguments are forbidden.
  4561.  
  4562. X<galoisapply>The library syntax is B<galoisapply>C<(I<nf>,I<aut>,x)>.
  4563.  
  4564. =head2 X<nfgaloisconj>nfgaloisconjC<(I<nf>,{I<flag> = 0},{d})>
  4565.  
  4566. C<I<nf>> being a
  4567. number field as output by C<nfinit>, computes the conjugates of a root
  4568. C<r> of the non-constant polynomial C<x = I<nf>[1]> expressed as
  4569. polynomials in C<r>. This can be used even if the number field C<I<nf>> is
  4570. not X<Galois>Galois since some conjugates may lie in the field. As a note to
  4571. old-timers of PARI, starting with version 2.0.17 this function works much
  4572. better than in earlier versions.
  4573.  
  4574. C<I<nf>> can simply be a polynomial if C<I<flag> ! = 1>.
  4575.  
  4576. If no flags or C<I<flag> = 0>, if C<I<nf>> is a number field use a
  4577. combination of flag C<4> and C<1> and the result is always complete,
  4578. else use a combination of flag C<4> and C<2> and the result is subject
  4579. to the restriction of C<I<flag> = 2>, but a warning is issued when it is not
  4580. proven complete.
  4581.  
  4582. If C<I<flag> = 1>, use C<nfroots> (require a number field). 
  4583.  
  4584. If C<I<flag> = 2>, use complex approximations to the roots and an integral
  4585. X<LLL>LLL. The result is not guaranteed to be complete: some
  4586. conjugates may be missing (no warning issued), especially so if the
  4587. corresponding polynomial has a huge index. In that case, increasing
  4588. the default precision may help.
  4589.  
  4590. If C<I<flag> = 4>, use Allombert's algorithm and permutation testing. If the
  4591. field is Galois with ``weakly'' super solvable Galois group, return
  4592. the complete list of automorphisms, else only the identity element. If
  4593. present, C<d> is assumed to be a multiple of the least common
  4594. denominator of the conjugates expressed as polynomial in a root of
  4595. I<pol>.
  4596.  
  4597. A group G is ``weakly'' super solvable if it contains a super solvable
  4598. normal subgroup C<H> such that C<G = H> , or C<G/H  ~  A_4> , or C<G/H  ~ 
  4599. S_4>. Abelian and nilpotent groups are ``weakly'' super solvable.  In
  4600. practice, almost all groups of small order are ``weakly'' super solvable, the
  4601. exceptions having order 36(1 exception), 48(2), 56(1), 60(1), 72(5), 75(1),
  4602. 80(1), 96(10) and C< E<gt>= 108>.
  4603.  
  4604. Hence C<I<flag> = 4> permits to quickly check whether a polynomial of order
  4605. strictly less than C<36> is Galois or not. This method is much faster than
  4606. C<nfroots> and can be applied to polynomials of degree larger than C<50>. 
  4607.  
  4608. X<galoisconj0>The library syntax is B<galoisconj0>C<(I<nf>,I<flag>,d,I<prec>)>. Also available are
  4609. C<X<galoisconj>B<galoisconj>(I<nf>)> for C<I<flag> = 0>,
  4610. C<X<galoisconj2>B<galoisconj2>(I<nf>,n,I<prec>)> for C<I<flag> = 2> where C<n> is a bound
  4611. on the number of conjugates, and  C<X<galoisconj4>B<galoisconj4>(I<nf>,d)>
  4612. corresponding to C<I<flag> = 4>.
  4613.  
  4614. =head2 X<nfhilbert>nfhilbertC<(I<nf>,a,b,{I<pr>})>
  4615.  
  4616. if I<pr> is omitted,
  4617. compute the global X<Hilbert symbol>Hilbert symbol C<(a,b)> in C<I<nf>>, that is C<1>
  4618. if C<x^2 - a y^2 - b z^2> has a non trivial solution C<(x,y,z)> in C<I<nf>>,
  4619. and C<-1> otherwise. Otherwise compute the local symbol modulo the prime ideal
  4620. I<pr> (as output by C<idealprimedec>).
  4621.  
  4622. X<nfhilbert>The library syntax is B<nfhilbert>C<(I<nf>,a,b,I<pr>)>, where an omitted I<pr> is coded
  4623. as C<NULL>.
  4624.  
  4625. =head2 X<nfhnf>nfhnfC<(I<nf>,x)>
  4626.  
  4627. given a pseudo-matrix C<(A,I)>, finds a
  4628. pseudo-basis in X<Hermite normal form>Hermite normal form of the module it generates.
  4629.  
  4630. X<nfhermite>The library syntax is B<nfhermite>C<(I<nf>,x)>.
  4631.  
  4632. =head2 X<nfhnfmod>nfhnfmodC<(I<nf>,x,I<detx>)>
  4633.  
  4634. given a pseudo-matrix C<(A,I)>
  4635. and an ideal I<detx> which is contained in (read integral multiple of) the
  4636. determinant of C<(A,I)>, finds a pseudo-basis in X<Hermite normal form>Hermite normal form
  4637. of the module generated by C<(A,I)>. This avoids coefficient explosion.
  4638. I<detx> can be computed using the function C<nfdetint>.
  4639.  
  4640. X<nfhermitemod>The library syntax is B<nfhermitemod>C<(I<nf>,x,I<detx>)>.
  4641.  
  4642. =head2 X<nfinit>nfinitC<(I<pol>,{I<flag> = 0})>
  4643.  
  4644. I<pol> being a non-constant,
  4645. preferably monic, irreducible polynomial in C<B<I<Z>>[X]>, initializes a
  4646. I<number field> structure (C<nf>) associated to the field C<K> defined
  4647. by I<pol>. As such, it's a technical object passed as the first argument
  4648. to most C<nf>I<xxx> functions, but it contains some information which
  4649. may be directly useful. Access to this information via I<member
  4650. functions> is prefered since the specific data organization specified below
  4651. may change in the future. Currently, C<nf> is a row vector with 9
  4652. components:
  4653.  
  4654. C<I<nf>[1]> contains the polynomial I<pol> (C<I<nf>.pol>).
  4655.  
  4656. C<I<nf>[2]> contains C<[r1,r2]> (C<I<nf>.sign>), the number of real
  4657. and complex places of C<K>.
  4658.  
  4659. C<I<nf>[3]> contains the discriminant C<d(K)> (C<I<nf>.disc>) of C<K>.
  4660.  
  4661. C<I<nf>[4]> contains the index of C<I<nf>[1]>,
  4662. i.e.S< >C<[B<I<Z>>_K : B<I<Z>>[F<theta>]]>, where C<F<theta>> is any root of C<I<nf>[1]>.
  4663.  
  4664. C<I<nf>[5]> is a vector containing 7 matrices C<M>, C<MC>, C<T2>, C<T>,
  4665. C<MD>, C<TI>, C<MDI> useful for certain computations in the number field C<K>.
  4666.  
  4667. S< >S< >C<B<*>> C<M> is the C<(r1+r2) x n> matrix whose columns represent
  4668. the numerical values of the conjugates of the elements of the integral
  4669. basis. 
  4670.  
  4671. S< >S< >C<B<*>> C<MC> is essentially the conjugate of the transpose of C<M>,
  4672. except that the last C<r2> columns are also multiplied by 2.
  4673.  
  4674. S< >S< >C<B<*>> C<T2> is an C<n x n> matrix equal to the real part of the
  4675. product C<MC.M> (which is a real positive definite symmetric matrix), the
  4676. so-called C<T_2>-matrix (C<I<nf>.t2>). 
  4677.  
  4678. S< >S< >C<B<*>> C<T> is the C<n x n> matrix whose coefficients are
  4679. C<Tr(F<omega>_iF<omega>_j)> where the C<F<omega>_i> are the elements of the
  4680. integral basis. Note that C<T = \overline{MC}.M> and in particular that
  4681. C<T = T_2> if the field is totally real (in practice C<T_2> will have real
  4682. approximate entries and C<T> will have integer entries). Note also that
  4683. C< F<det> (T)> is equal to the discriminant of the field C<K>.
  4684.  
  4685. S< >S< >C<B<*>> The columns of C<MD> (C<I<nf>.diff>) express a B<I<Z>>-basis
  4686. of the different of C<K> on the integral basis.
  4687.  
  4688. S< >S< >C<B<*>> C<TI> is equal to C<d(K)T^{-1}>, which has integral
  4689. coefficients. Note that, understood as as ideal, the matrix C<T^{-1}>
  4690. generates the codifferent ideal.
  4691.  
  4692. S< >S< >C<B<*>> Finally, C<MDI> is a two-element representation (for faster
  4693. ideal product) of C<d(K)> times the codifferent ideal
  4694. (C<I<nf>.disc*I<nf>.codiff>, which is an integral ideal). C<MDI>
  4695. is only used in X<idealinv>C<idealinv>.
  4696.  
  4697. C<I<nf>[6]> is the vector containing the C<r1+r2> roots
  4698. (C<I<nf>.roots>) of C<I<nf>[1]> corresponding to the C<r1+r2>
  4699. embeddings of the number field into B<I<C>> (the first C<r1> components are real,
  4700. the next C<r2> have positive imaginary part).
  4701.  
  4702. C<I<nf>[7]> is an integral basis in Hermite normal form for C<B<I<Z>>_K>
  4703. (C<I<nf>.zk>) expressed on the powers ofS< >C<F<theta>>.
  4704.  
  4705. C<I<nf>[8]> is the C<n x n> integral matrix expressing the power
  4706. basis in terms of the integral basis, and finally
  4707.  
  4708. C<I<nf>[9]> is the C<n x n^2> matrix giving the multiplication table
  4709. of the integral basis.
  4710.  
  4711. If a non monic polynomial is input, C<nfinit> will transform it into a
  4712. monic one, then reduce it (see C<I<flag> = 3>). It is allowed, though not very
  4713. useful given the existence of X<nfnewprec>B<nfnewprec>, to input a C<nf> or a
  4714. C<bnf> instead of a polynomial.
  4715.  
  4716. The special input format C<[x,B]> is also accepted where C<x> is a polynomial
  4717. as above and C<B> is the integer basis, as computed by X<nfbasis>C<nfbasis>. This can
  4718. be useful since C<nfinit> uses the round 4 algorithm by default, which can
  4719. be very slow in pathological cases where round 2 (C<nfbasis(x,2)>) would
  4720. succeed very quickly.
  4721.  
  4722. If C<I<flag> = 2>: I<pol> is changed into another polynomial C<P> defining the same
  4723. number field, which is as simple as can easily be found using the
  4724. C<polred> algorithm, and all the subsequent computations are done using
  4725. this new polynomial. In particular, the first component of the result is the
  4726. modified polynomial.
  4727.  
  4728. If C<I<flag> = 3>, does a C<polred> as in case 2, but outputs
  4729. C<[I<nf>,Mod(a,P)]>, where C<I<nf>> is as before and
  4730. C<Mod(a,P) = Mod(x,I<pol>)> gives the change of
  4731. variables. This is implicit when I<pol> is not monic: first a linear change
  4732. of variables is performed, to get a monic polynomial, then a C<polred>
  4733. reduction.
  4734.  
  4735. If C<I<flag> = 4>, as C<2> but uses a partial C<polred>.
  4736.  
  4737. If C<I<flag> = 5>, as C<3> using a partial C<polred>.
  4738.  
  4739. X<nfinit0>The library syntax is B<nfinit0>C<(x,I<flag>,I<prec>)>.
  4740.  
  4741. =head2 X<nfisideal>nfisidealC<(I<nf>,x)>
  4742.  
  4743. returns 1 if C<x> is an ideal in
  4744. the number field C<I<nf>>, 0 otherwise.
  4745.  
  4746. X<isideal>The library syntax is B<isideal>C<(x)>.
  4747.  
  4748. =head2 X<nfisincl>nfisinclC<(x,y)>
  4749.  
  4750. tests whether the number field C<K> defined
  4751. by the polynomial C<x> is conjugate to a subfield of the field C<L> defined
  4752. by C<y> (where C<x> and C<y> must be in C<B<I<Q>>[X]>). If they are not, the output
  4753. is the number 0. If they are, the output is a vector of polynomials, each
  4754. polynomial C<a> representing an embedding of C<K> into C<L>, i.e.S< >being such
  4755. that C<y | x o a>.
  4756.  
  4757. If C<y> is a number field (I<nf>), a much faster algorithm is used
  4758. (factoring C<x> over C<y> using X<nffactor>C<nffactor>). Before version 2.0.14, this
  4759. wasn't guaranteed to return all the embeddings, hence was triggered by a
  4760. special flag. This is no more the case.
  4761.  
  4762. X<nfisincl>The library syntax is B<nfisincl>C<(x,y,I<flag>)>.
  4763.  
  4764. =head2 X<nfisisom>nfisisomC<(x,y)>
  4765.  
  4766. as X<nfisincl>C<nfisincl>, but tests
  4767. for isomorphism. If either C<x> or C<y> is a number field, a much faster
  4768. algorithm will be used.
  4769.  
  4770. X<nfisisom>The library syntax is B<nfisisom>C<(x,y,I<flag>)>.
  4771.  
  4772. =head2 X<nfnewprec>nfnewprecC<(I<nf>)>
  4773.  
  4774. transforms the number field C<I<nf>>
  4775. into the corresponding data using current (usually larger) precision. This
  4776. function works as expected if C<I<nf>> is in fact a C<I<bnf>> (update
  4777. C<I<bnf>> to current precision) but may be quite slow (many generators of
  4778. principal ideals have to be computed).
  4779.  
  4780. X<nfnewprec>The library syntax is B<nfnewprec>C<(I<nf>,I<prec>)>.
  4781.  
  4782. =head2 X<nfkermodpr>nfkermodprC<(I<nf>,a,I<pr>)>
  4783.  
  4784. kernel of the matrix C<a> in
  4785. C<B<I<Z>>_K/I<pr>>, where I<pr> is in B<modpr> format
  4786. (see C<nfmodprinit>).
  4787.  
  4788. X<nfkermodpr>The library syntax is B<nfkermodpr>C<(I<nf>,a,I<pr>)>.
  4789.  
  4790. =head2 X<nfmodprinit>nfmodprinitC<(I<nf>,I<pr>)>
  4791.  
  4792. transforms the prime ideal
  4793. I<pr> into X<modpr>C<modpr> format necessary for all operations modulo
  4794. I<pr> in the number field I<nf>. Returns a two-component vector
  4795. C<[P,a]>, where C<P> is the X<Hermite normal form>Hermite normal form of I<pr>, and C<a> is
  4796. an integral element congruent to C<1> modulo I<pr>, and congruent to C<0>
  4797. modulo C<p / pr^e>. Here C<p = B<I<Z>>  F<cap>  I<pr>> and C<e>
  4798. is the absolute ramification index.X<Label se:nfmodprinit>
  4799.  
  4800. X<nfmodprinit>The library syntax is B<nfmodprinit>C<(I<nf>,I<pr>)>.
  4801.  
  4802. =head2 X<nfsubfields>nfsubfieldsC<(I<nf>,{d = 0})>
  4803.  
  4804. finds all subfields of degree C<d>
  4805. of the number field C<I<nf>> (all subfields if C<d> is null or omitted).
  4806. The result is a vector of subfields, each being given by C<[g,h]>, where C<g> is an
  4807. absolute equation and C<h> expresses one of the roots of C<g> in terms of the
  4808. root C<x> of the polynomial defining C<I<nf>>. This is a crude
  4809. implementation by M.S< >Olivier of an algorithm due to J.S< >KlE<uuml>ners.
  4810.  
  4811. X<subfields>The library syntax is B<subfields>C<(I<nf>,d)>.
  4812.  
  4813. =head2 X<nfroots>nfrootsC<(I<nf>,x)>
  4814.  
  4815. roots of the polynomial C<x> in the number
  4816. field C<I<nf>> given by C<nfinit> without multiplicity. C<x> has
  4817. coefficients in the number field (scalar, polmod, polynomial, column
  4818. vector). The main variable of C<I<nf>> must be of lower priority than that
  4819. of C<x> (in other words the variable number of C<I<nf>> must be greater than
  4820. that of C<x>). However if the coefficients of the number field occur
  4821. explicitly (as polmods) as coefficients of C<x>, the variable of these
  4822. polmods I<must> be the same as the main variable of C<t> (see
  4823. C<nffactor>).
  4824.  
  4825. X<nfroots>The library syntax is B<nfroots>C<(I<nf>,x)>.
  4826.  
  4827. =head2 X<nfrootsof1>nfrootsof1C<(I<nf>)>
  4828.  
  4829. computes the number of roots of unity
  4830. C<w> and a primitive C<w>-th root of unity (expressed on the integral basis)
  4831. belonging to the number field C<I<nf>>. The result is a two-component
  4832. vector C<[w,z]> where C<z> is a column vector expressing a primitive C<w>-th
  4833. root of unity on the integral basis C<I<nf>.zk>.
  4834.  
  4835. X<rootsof1>The library syntax is B<rootsof1>C<(I<nf>)>.
  4836.  
  4837. =head2 X<nfsnf>nfsnfC<(I<nf>,x)>
  4838.  
  4839. given a torsion module C<x> as a 3-component
  4840. row
  4841. vector C<[A,I,J]> where C<A> is a square invertible C<n x n> matrix, C<I> and
  4842. C<J> are two ideal lists, outputs an ideal list C<d_1,...,d_n> which is the
  4843. X<Smith normal form>Smith normal form of C<x>. In other words, C<x> is isomorphic to
  4844. C<B<I<Z>>_K/d_1 F<oplus> ... F<oplus> B<I<Z>>_K/d_n> and C<d_i> divides C<d_{i-1}> for C<i E<gt>= 2>.
  4845. The link between C<x> and C<[A,I,J]> is as follows: if C<e_i> is the canonical
  4846. basis of C<K^n>, C<I = [b_1,...,b_n]> and C<J = [a_1,...,a_n]>, then C<x> is
  4847. isomorphic to
  4848.  
  4849. S<  >C< (b_1e_1 F<oplus> ... F<oplus>  b_ne_n) / (a_1A_1 F<oplus> ... F<oplus>  a_nA_n)
  4850.  , >
  4851.  
  4852. where the C<A_j> are the columns of the matrix C<A>. Note that every finitely
  4853. generated torsion module can be given in this way, and even with C<b_i = Z_K>
  4854. for all C<i>.
  4855.  
  4856. X<nfsmith>The library syntax is B<nfsmith>C<(I<nf>,x)>.
  4857.  
  4858. =head2 X<nfsolvemodpr>nfsolvemodprC<(I<nf>,a,b,I<pr>)>
  4859.  
  4860. solution of C<a.x = b>
  4861. in C<B<I<Z>>_K/I<pr>>, where C<a> is a matrix and C<b> a column vector, and where
  4862. I<pr> is in B<modpr> format (see C<nfmodprinit>).
  4863.  
  4864. X<nfsolvemodpr>The library syntax is B<nfsolvemodpr>C<(I<nf>,a,b,I<pr>)>.
  4865.  
  4866. =head2 X<polcompositum>polcompositumC<(x,y,{I<flag> = 0})>
  4867.  
  4868. C<x> and C<y> being polynomials
  4869. in C<B<I<Z>>[X]> in the same variable, outputs a vector giving the list of all
  4870. possible composita of the number fields defined by C<x> and C<y>, if C<x> and
  4871. C<y> are irreducible, or of the corresponding E<eacute>tale algebras, if they are
  4872. only squarefree. Returns an error if one of the polynomials is not
  4873. squarefree. When one of the polynomials is irreducible (say C<x>), it is
  4874. often I<much> faster to use C<nffactor(nfinit(x), y)> then
  4875. X<rnfequation>C<rnfequation>.
  4876.  
  4877. If C<I<flag> = 1>, outputs a vector of 4-component vectors C<[z,a,b,k]>, where C<z>
  4878. ranges through the list of all possible compositums as above, and C<a>
  4879. (resp. C<b>) expresses the root of C<x> (resp. C<y>) as a polmod in a root of
  4880. C<z>, and C<k> is a small integer k such that C<a+kb> is the chosen root of
  4881. C<z>.
  4882.  
  4883. The compositum will quite often be defined by a complicated polynomial,
  4884. which it is advisable to reduce before further work. Here is a simple
  4885. example involving the field C<B<I<Q>>(F<zeta>_5, 5^{1/5})>:
  4886.  
  4887.   ? z = polcompositum(x^5 - 5, polcyclo(5), 1)[1];
  4888.   ? pol = z[1]                 \\ pol defines the compositum
  4889.   %2 = x^20 + 5*x^19 + 15*x^18 + 35*x^17 + 70*x^16 + 141*x^15 + 260*x^14 \
  4890.     + 355*x^13 + 95*x^12 - 1460*x^11 - 3279*x^10 - 3660*x^9 - 2005*x^8    \
  4891.     + 705*x^7 + 9210*x^6 + 13506*x^5 + 7145*x^4 - 2740*x^3 + 1040*x^2     \
  4892.     - 320*x + 256
  4893.   ? a = z[2]; a^5 - 5          \\ a is a fifth root of 5
  4894.   %3 = 0
  4895.   ? z = polredabs(pol, 1);     \\ look for a simpler polynomial
  4896.   ? pol = z[1]
  4897.   %5 = x^20 + 25*x^10 + 5
  4898.   ? a = subst(a.pol, x, z[2])  \\ a in the new coordinates
  4899.   %6 = Mod(-5/22*x^19 + 1/22*x^14 - 123/22*x^9 + 9/11*x^4, x^20 + 25*x^10 + 5)
  4900.  
  4901. X<polcompositum0>The library syntax is B<polcompositum0>C<(x,y,I<flag>)>.
  4902.  
  4903. =head2 X<polgalois>polgaloisC<(x)>
  4904.  
  4905. X<Galois>Galois group of the non-constant polynomial
  4906. C<x belongs to B<I<Q>>[X]>. In the present version B<2.2.0>, C<x> must be irreducible and
  4907. the degree of C<x> must be less than or equal to 7. On certain versions for
  4908. which the data file of Galois resolvents has been installed (available
  4909. in the Unix distribution as a separate package), degrees 8, 9, 10 and 11
  4910. are also implemented.
  4911.  
  4912. The output is a 3-component vector C<[n,s,k]> with the following meaning: C<n>
  4913. is the cardinality of the group, C<s> is its signature (C<s = 1> if the group is
  4914. a subgroup of the alternating group C<A_n>, C<s = -1> otherwise), and C<k> is the
  4915. number of the group corresponding to a given pair C<(n,s)> (C<k = 1> except in 2
  4916. cases). Specifically, the groups are coded as follows, using standard
  4917. notations (see GTM 138, quoted at the beginning of this section; see also
  4918. ``The transitive groups of degree up to eleven'', by G.S< >Butler and J.S< >McKay
  4919. in Communications in Algebra, vol.S< >11, 1983, pp.S< >863--911):
  4920.  
  4921. In degree 1: C<S_1 = [1,-1,1]>.
  4922.  
  4923. In degree 2: C<S_2 = [2,-1,1]>.
  4924.  
  4925. In degree 3: C<A_3 = C_3 = [3,1,1]>, C<S_3 = [6,-1,1]>.
  4926.  
  4927. In degree 4: C<C_4 = [4,-1,1]>, C<V_4 = [4,1,1]>, C<D_4 = [8,-1,1]>, C<A_4 = [12,1,1]>,
  4928. C<S_4 = [24,-1,1]>.
  4929.  
  4930. In degree 5: C<C_5 = [5,1,1]>, C<D_5 = [10,1,1]>, C<M_{20} = [20,-1,1]>,
  4931. C<A_5 = [60,1,1]>, C<S_5 = [120,-1,1]>.
  4932.  
  4933. In degree 6: C<C_6 = [6,-1,1]>, C<S_3 = [6,-1,2]>, C<D_6 = [12,-1,1]>, C<A_4 = [12,1,1]>,
  4934. C<G_{18} = [18,-1,1]>, C<S_4^ -= [24,-1,1]>, C<A_4 x C_2 = [24,-1,2]>,
  4935. C<S_4^ += [24,1,1]>, C<G_{36}^ -= [36,-1,1]>, C<G_{36}^ += [36,1,1]>,
  4936. C<S_4 x C_2 = [48,-1,1]>, C<A_5 = PSL_2(5) = [60,1,1]>, C<G_{72} = [72,-1,1]>,
  4937. C<S_5 = PGL_2(5) = [120,-1,1]>, C<A_6 = [360,1,1]>, C<S_6 = [720,-1,1]>.
  4938.  
  4939. In degree 7: C<C_7 = [7,1,1]>, C<D_7 = [14,-1,1]>, C<M_{21} = [21,1,1]>,
  4940. C<M_{42} = [42,-1,1]>, C<PSL_2(7) = PSL_3(2) = [168,1,1]>, C<A_7 = [2520,1,1]>,
  4941. C<S_7 = [5040,-1,1]>.
  4942.  
  4943. The method used is that of resolvent polynomials and is sensitive to the
  4944. current precision. The precision is updated internally but, in very rare
  4945. cases, a wrong result may be returned if the initial precision was not
  4946. sufficient.
  4947.  
  4948. X<galois>The library syntax is B<galois>C<(x,I<prec>)>.
  4949.  
  4950. =head2 X<polred>polredC<(x,{I<flag> = 0},{p})>
  4951.  
  4952. finds polynomials with reasonably
  4953. small coefficients defining subfields of the number field defined by C<x>.
  4954. One of the polynomials always defines B<I<Q>> (hence is equal to C<x-1>),
  4955. and another always defines the same number field as C<x> if C<x> is irreducible.
  4956. All C<x> accepted by X<nfinit>C<nfinit> are also allowed here (e.g. non-monic
  4957. polynomials, C<nf>, C<bnf>, C<[x,Z_K_basis]>).
  4958.  
  4959. The following binary digits of C<I<flag>> are significant:
  4960.  
  4961. 1: does a partial reduction only. This means that only a suborder of the
  4962. maximal order may be used.
  4963.  
  4964. 2: gives also elements. The result is a two-column matrix, the first column
  4965. giving the elements defining these subfields, the second giving the
  4966. corresponding minimal polynomials.
  4967.  
  4968. If C<p> is given, it is assumed that it is the two-column matrix of the
  4969. factorization of the discriminant of the polynomial C<x>.
  4970.  
  4971. X<polred0>The library syntax is B<polred0>C<(x,I<flag>,p,I<prec>)>, where an omitted C<p> is
  4972. coded by C<gzero>. Also available are C<X<polred>B<polred>(x,I<prec>)> and
  4973. C<X<factoredpolred>B<factoredpolred>(x,p,I<prec>)>, both corresponding to C<I<flag> = 0>.
  4974.  
  4975. =head2 X<polredabs>polredabsC<(x,{I<flag> = 0})>
  4976.  
  4977. finds one of the polynomial defining
  4978. the same number field as the one defined by C<x>, and such that the sum of the
  4979. squares of the modulus of the roots (i.e.S< >the C<T_2>-norm) is minimal.
  4980. All C<x> accepted by X<nfinit>C<nfinit> are also allowed here (e.g. non-monic
  4981. polynomials, C<nf>, C<bnf>, C<[x,Z_K_basis]>).
  4982.  
  4983. The binary digits of C<I<flag>> mean
  4984.  
  4985. 1: outputs a two-component row vector C<[P,a]>, where C<P> is the default
  4986. output and C<a> is an element expressed on a root of the polynomial C<P>,
  4987. whose minimal polynomial is equal to C<x>.
  4988.  
  4989. 4: gives I<all> polynomials of minimal C<T_2> norm (of the two polynomials 
  4990. C<P(x)> and C<P(-x)>, only one is given).
  4991.  
  4992. X<polredabs0>The library syntax is B<polredabs0>C<(x,I<flag>,I<prec>)>.
  4993.  
  4994. =head2 X<polredord>polredordC<(x)>
  4995.  
  4996. finds polynomials with reasonably small
  4997. coefficients and of the same degree as that of C<x> defining suborders of the
  4998. order defined by C<x>. One of the polynomials always defines B<I<Q>> (hence
  4999. is equal to C<(x-1)^n>, where C<n> is the degree), and another always defines
  5000. the same order as C<x> if C<x> is irreducible.
  5001.  
  5002. X<ordred>The library syntax is B<ordred>C<(x)>.
  5003.  
  5004. =head2 X<poltschirnhaus>poltschirnhausC<(x)>
  5005.  
  5006. applies a random Tschirnhausen
  5007. transformation to the polynomial C<x>, which is assumed to be non-constant
  5008. and separable, so as to obtain a new equation for the E<eacute>tale algebra
  5009. defined by C<x>. This is for instance useful when computing resolvents,
  5010. hence is used by the C<polgalois> function.
  5011.  
  5012. X<tschirnhaus>The library syntax is B<tschirnhaus>C<(x)>.
  5013.  
  5014. =head2 X<rnfalgtobasis>rnfalgtobasisC<(I<rnf>,x)>
  5015.  
  5016. C<I<rnf>> being a relative number
  5017. field extension C<L/K> as output by C<rnfinit> and C<x> being an element of
  5018. C<L> expressed as a polynomial or polmod with polmod coefficients, expresses
  5019. C<x> on the relative integral basis.
  5020.  
  5021. X<rnfalgtobasis>The library syntax is B<rnfalgtobasis>C<(I<rnf>,x)>.
  5022.  
  5023. =head2 X<rnfbasis>rnfbasisC<(I<bnf>,x)>
  5024.  
  5025. given a big number field C<I<bnf>> as
  5026. output by C<bnfinit>, and either a polynomial C<x> with coefficients in
  5027. C<I<bnf>> defining a relative extension C<L> of C<I<bnf>>, or a
  5028. pseudo-basis C<x> of such an extension, gives either a true C<I<bnf>>-basis
  5029. of C<L> if it exists, or an C<n+1>-element generating set of C<L> if not, where
  5030. C<n> is the rank of C<L> over C<I<bnf>>.
  5031.  
  5032. X<rnfbasis>The library syntax is B<rnfbasis>C<(I<bnf>,x)>.
  5033.  
  5034. =head2 X<rnfbasistoalg>rnfbasistoalgC<(I<rnf>,x)>
  5035.  
  5036. C<I<rnf>> being a relative number
  5037. field extension C<L/K> as output by C<rnfinit> and C<x> being an element of
  5038. C<L> expressed on the relative integral basis, computes the representation of
  5039. C<x> as a polmod with polmods coefficients.
  5040.  
  5041. X<rnfbasistoalg>The library syntax is B<rnfbasistoalg>C<(I<rnf>,x)>.
  5042.  
  5043. =head2 X<rnfcharpoly>rnfcharpolyC<(I<nf>,T,a,{v = x})>
  5044.  
  5045. characteristic polynomial of
  5046. C<a> over C<I<nf>>, where C<a> belongs to the algebra defined by C<T> over
  5047. C<I<nf>>, i.e.S< >C<I<nf>[X]/(T)>. Returns a polynomial in variable C<v>
  5048. (C<x> by default).
  5049.  
  5050. X<rnfcharpoly>The library syntax is B<rnfcharpoly>C<(I<nf>,T,a,v)>, where C<v> is a variable number.
  5051.  
  5052. =head2 X<rnfconductor>rnfconductorC<(I<bnf>,I<pol>)>
  5053.  
  5054. C<I<bnf>> being a big number
  5055. field as output by C<bnfinit>, and I<pol> a relative polynomial defining
  5056. an X<Abelian extension>Abelian extension, computes the class field theory conductor of this
  5057. Abelian extension. The result is a 3-component vector
  5058. C<[I<conductor>,I<rayclgp>,I<subgroup>]>, where I<conductor> is
  5059. the conductor of the extension given as a 2-component row vector
  5060. C<[f_0,f_ oo ]>, I<rayclgp> is the full ray class group corresponding to
  5061. the conductor given as a 3-component vector [h,cyc,gen] as usual for a group,
  5062. and I<subgroup> is a matrix in HNF defining the subgroup of the ray class
  5063. group on the given generators gen.
  5064.  
  5065. X<rnfconductor>The library syntax is B<rnfconductor>C<(I<rnf>,I<pol>,I<prec>)>.
  5066.  
  5067. =head2 X<rnfdedekind>rnfdedekindC<(I<nf>,I<pol>,I<pr>)>
  5068.  
  5069. given a number field
  5070. C<I<nf>> as output by C<nfinit> and a polynomial I<pol> with
  5071. coefficients in C<I<nf>> defining a relative extension C<L> of C<I<nf>>,
  5072. evaluates the relative X<Dedekind>Dedekind criterion over the order defined by a
  5073. root of I<pol> for the prime ideal I<pr> and outputs a 3-component
  5074. vector as the result. The first component is a flag equal to 1 if the
  5075. enlarged order could be proven to be I<pr>-maximal and to 0 otherwise (it
  5076. may be maximal in the latter case if I<pr> is ramified in C<L>), the second
  5077. component is a pseudo-basis of the enlarged order and the third component is
  5078. the valuation at I<pr> of the order discriminant.
  5079.  
  5080. X<rnfdedekind>The library syntax is B<rnfdedekind>C<(I<nf>,I<pol>,I<pr>)>.
  5081.  
  5082. =head2 X<rnfdet>rnfdetC<(I<nf>,M)>
  5083.  
  5084. given a pseudomatrix C<M> over the maximal
  5085. order of C<I<nf>>, computes its pseudodeterminant.
  5086.  
  5087. X<rnfdet>The library syntax is B<rnfdet>C<(I<nf>,M)>.
  5088.  
  5089. =head2 X<rnfdisc>rnfdiscC<(I<nf>,I<pol>)>
  5090.  
  5091. given a number field C<I<nf>> as
  5092. output by C<nfinit> and a polynomial I<pol> with coefficients in
  5093. C<I<nf>> defining a relative extension C<L> of C<I<nf>>, computes
  5094. the relative
  5095. discriminant of C<L>. This is a two-element row vector C<[D,d]>, where C<D> is
  5096. the relative ideal discriminant and C<d> is the relative discriminant
  5097. considered as an element of C<I<nf>^*/{I<nf>^*}^2>. The main variable of
  5098. C<I<nf>> I<must> be of lower priority than that of I<pol>.
  5099.  
  5100. Note: As usual, C<I<nf>> can be a C<I<bnf>> as output by C<nfinit>.
  5101.  
  5102. X<rnfdiscf>The library syntax is B<rnfdiscf>C<(I<bnf>,I<pol>)>.
  5103.  
  5104. =head2 X<rnfeltabstorel>rnfeltabstorelC<(I<rnf>,x)>
  5105.  
  5106. C<I<rnf>> being a relative
  5107. number field
  5108. extension C<L/K> as output by C<rnfinit> and C<x> being an element of C<L>
  5109. expressed as a polynomial modulo the absolute equation C<I<rnf>[11][1]>,
  5110. computes C<x> as an element of the relative extension C<L/K> as a polmod with
  5111. polmod coefficients.
  5112.  
  5113. X<rnfelementabstorel>The library syntax is B<rnfelementabstorel>C<(I<rnf>,x)>.
  5114.  
  5115. =head2 X<rnfeltdown>rnfeltdownC<(I<rnf>,x)>
  5116.  
  5117. C<I<rnf>> being a relative number
  5118. field extension C<L/K> as output by C<rnfinit> and C<x> being an element of
  5119. C<L> expressed as a polynomial or polmod with polmod coefficients, computes
  5120. C<x> as an element of C<K> as a polmod, assuming C<x> is in C<K> (otherwise an
  5121. error will occur). If C<x> is given on the relative integral basis, apply
  5122. C<rnfbasistoalg> first, otherwise PARI will believe you are dealing with a
  5123. vector.
  5124.  
  5125. X<rnfelementdown>The library syntax is B<rnfelementdown>C<(I<rnf>,x)>.
  5126.  
  5127. =head2 X<rnfeltreltoabs>rnfeltreltoabsC<(I<rnf>,x)>
  5128.  
  5129. C<I<rnf>> being a relative
  5130. number field extension C<L/K> as output by C<rnfinit> and C<x> being an
  5131. element of C<L> expressed as a polynomial or polmod with polmod
  5132. coefficients, computes C<x> as an element of the absolute extension C<L/B<I<Q>>> as
  5133. a polynomial modulo the absolute equation C<I<rnf>[11][1]>. If C<x> is
  5134. given on the relative integral basis, apply C<rnfbasistoalg> first,
  5135. otherwise PARI will believe you are dealing with a vector.
  5136.  
  5137. X<rnfelementreltoabs>The library syntax is B<rnfelementreltoabs>C<(I<rnf>,x)>.
  5138.  
  5139. =head2 X<rnfeltup>rnfeltupC<(I<rnf>,x)>
  5140.  
  5141. C<I<rnf>> being a relative number
  5142. field extension C<L/K> as output by C<rnfinit> and C<x> being an element of
  5143. C<K> expressed as a polynomial or polmod, computes C<x> as an element of the
  5144. absolute extension C<L/B<I<Q>>> as a polynomial modulo the absolute equation
  5145. C<I<rnf>[11][1]>. Note that it is unnecessary to compute C<x> as an
  5146. element of the relative extension C<L/K> (its expression would be identical to
  5147. itself). If C<x> is given on the integral basis of C<K>, apply
  5148. C<nfbasistoalg> first, otherwise PARI will believe you are dealing with a
  5149. vector.
  5150.  
  5151. X<rnfelementup>The library syntax is B<rnfelementup>C<(I<rnf>,x)>.
  5152.  
  5153. =head2 X<rnfequation>rnfequationC<(I<nf>,I<pol>,{I<flag> = 0})>
  5154.  
  5155. given a number field
  5156. C<I<nf>> as output by C<nfinit> (or simply a polynomial) and a
  5157. polynomial I<pol> with coefficients in C<I<nf>> defining a relative
  5158. extension C<L> of C<I<nf>>, computes the absolute equation of C<L> over
  5159. B<I<Q>>.
  5160.  
  5161. If C<I<flag>> is non-zero, outputs a 3-component row vector C<[z,a,k]>, where
  5162. C<z> is the absolute equation of C<L> over B<I<Q>>, as in the default behaviour,
  5163. C<a> expresses as an element of C<L> a root C<F<alpha>> of the polynomial
  5164. defining the base field C<I<nf>>, and C<k> is a small integer such that
  5165. C<F<theta> = F<beta>+kF<alpha>> where C<F<theta>> is a root of C<z> and C<F<beta>> a root
  5166. of C<I<pol>>.
  5167.  
  5168. The main variable of C<I<nf>> I<must> be of lower priority than that
  5169. of I<pol>. Note that for efficiency, this does not check whether the
  5170. relative equation is irreducible over C<I<nf>>, but only if it is
  5171. squarefree. If it is reducible but squarefree, the result will be the
  5172. absolute equation of the E<eacute>tale algebra defined by I<pol>. If I<pol>
  5173. is not squarefree, an error message will be issued.
  5174.  
  5175. X<rnfequation0>The library syntax is B<rnfequation0>C<(I<nf>,I<pol>,I<flag>)>.
  5176.  
  5177. =head2 X<rnfhnfbasis>rnfhnfbasisC<(I<bnf>,x)>
  5178.  
  5179. given a big number field C<I<bnf>>
  5180. as output by C<bnfinit>, and either a polynomial C<x> with coefficients in
  5181. C<I<bnf>> defining a relative extension C<L> of C<I<bnf>>, or a
  5182. pseudo-basis C<x> of such an extension, gives either a true C<I<bnf>>-basis
  5183. of C<L> in upper triangular Hermite normal form, if it exists,
  5184. zero otherwise.
  5185.  
  5186. X<rnfhermitebasis>The library syntax is B<rnfhermitebasis>C<(I<nf>,x)>.
  5187.  
  5188. =head2 X<rnfidealabstorel>rnfidealabstorelC<(I<rnf>,x)>
  5189.  
  5190. C<I<rnf>> being a relative
  5191. number field extension C<L/K> as output by C<rnfinit> and C<x> being an
  5192. ideal of the absolute extension C<L/B<I<Q>>> given in HNFX<Hermite normal form>
  5193. (if it is not, apply C<idealhnf> first), computes the relative pseudomatrix
  5194. in HNF giving the ideal C<x> considered as an ideal of the relative extension
  5195. C<L/K>.
  5196.  
  5197. X<rnfidealabstorel>The library syntax is B<rnfidealabstorel>C<(I<rnf>,x)>.
  5198.  
  5199. =head2 X<rnfidealdown>rnfidealdownC<(I<rnf>,x)>
  5200.  
  5201. C<I<rnf>> being a relative number
  5202. field extension C<L/K> as output by C<rnfinit> and C<x> being an ideal of
  5203. the absolute extension C<L/B<I<Q>>> given in HNF (if it is not, apply
  5204. C<idealhnf> first), gives the ideal of C<K> below C<x>, i.e.S< >the
  5205. intersection of C<x> with C<K>. Note that, if C<x> is given as a relative ideal
  5206. (i.e.S< >a pseudomatrix in HNF), then it is not necessary to use this function
  5207. since the result is simply the first ideal of the ideal list of the
  5208. pseudomatrix.
  5209.  
  5210. X<rnfidealdown>The library syntax is B<rnfidealdown>C<(I<rnf>,x)>.
  5211.  
  5212. =head2 X<rnfidealhnf>rnfidealhnfC<(I<rnf>,x)>
  5213.  
  5214. C<I<rnf>> being a relative number
  5215. field extension C<L/K> as output by C<rnfinit> and C<x> being a relative
  5216. ideal (which can be, as in the absolute case, of many different types,
  5217. including of course elements), computes as a 2-component row vector the
  5218. relative Hermite normal form of C<x>, the first component being the HNF matrix
  5219. (with entries on the integral basis), and the second component the ideals.
  5220.  
  5221. X<rnfidealhermite>The library syntax is B<rnfidealhermite>C<(I<rnf>,x)>.
  5222.  
  5223. =head2 X<rnfidealmul>rnfidealmulC<(I<rnf>,x,y)>
  5224.  
  5225. C<I<rnf>> being a relative number
  5226. field extension C<L/K> as output by C<rnfinit> and C<x> and C<y> being ideals
  5227. of the relative extension C<L/K> given by pseudo-matrices, outputs the ideal
  5228. product, again as a relative ideal.
  5229.  
  5230. X<rnfidealmul>The library syntax is B<rnfidealmul>C<(I<rnf>,x,y)>.
  5231.  
  5232. =head2 X<rnfidealnormabs>rnfidealnormabsC<(I<rnf>,x)>
  5233.  
  5234. C<I<rnf>> being a relative
  5235. number field extension C<L/K> as output by C<rnfinit> and C<x> being a
  5236. relative ideal (which can be, as in the absolute case, of many different
  5237. types, including of course elements), computes the norm of the ideal C<x>
  5238. considered as an ideal of the absolute extension C<L/B<I<Q>>>. This is identical to
  5239. C<idealnorm(rnfidealnormrel(I<rnf>,x))>, only faster.
  5240.  
  5241. X<rnfidealnormabs>The library syntax is B<rnfidealnormabs>C<(I<rnf>,x)>.
  5242.  
  5243. =head2 X<rnfidealnormrel>rnfidealnormrelC<(I<rnf>,x)>
  5244.  
  5245. C<I<rnf>> being a relative
  5246. number field
  5247. extension C<L/K> as output by C<rnfinit> and C<x> being a relative ideal
  5248. (which can be, as in the absolute case, of many different types, including
  5249. of course elements), computes the relative norm of C<x> as a ideal of C<K>
  5250. in HNF.
  5251.  
  5252. X<rnfidealnormrel>The library syntax is B<rnfidealnormrel>C<(I<rnf>,x)>.
  5253.  
  5254. =head2 X<rnfidealreltoabs>rnfidealreltoabsC<(I<rnf>,x)>
  5255.  
  5256. C<I<rnf>> being a relative
  5257. number field
  5258. extension C<L/K> as output by C<rnfinit> and C<x> being a relative ideal
  5259. (which can be, as in the absolute case, of many different types, including
  5260. of course elements), computes the HNF matrix of the ideal C<x> considered
  5261. as an ideal of the absolute extension C<L/B<I<Q>>>.
  5262.  
  5263. X<rnfidealreltoabs>The library syntax is B<rnfidealreltoabs>C<(I<rnf>,x)>.
  5264.  
  5265. =head2 X<rnfidealtwoelt>rnfidealtwoeltC<(I<rnf>,x)>
  5266.  
  5267. C<I<rnf>> being a relative
  5268. number field
  5269. extension C<L/K> as output by C<rnfinit> and C<x> being an ideal of the
  5270. relative extension C<L/K> given by a pseudo-matrix, gives a vector of
  5271. two generators of C<x> over C<B<I<Z>>_L> expressed as polmods with polmod
  5272. coefficients.
  5273.  
  5274. X<rnfidealtwoelement>The library syntax is B<rnfidealtwoelement>C<(I<rnf>,x)>.
  5275.  
  5276. =head2 X<rnfidealup>rnfidealupC<(I<rnf>,x)>
  5277.  
  5278. C<I<rnf>> being a relative number
  5279. field
  5280. extension C<L/K> as output by C<rnfinit> and C<x> being an ideal of
  5281. C<K>, gives the ideal C<xB<I<Z>>_L> as an absolute ideal of C<L/B<I<Q>>> (the relative
  5282. ideal representation is trivial: the matrix is the identity matrix, and
  5283. the ideal list starts with C<x>, all the other ideals being C<B<I<Z>>_K>).
  5284.  
  5285. X<rnfidealup>The library syntax is B<rnfidealup>C<(I<rnf>,x)>.
  5286.  
  5287. =head2 X<rnfinit>rnfinitC<(I<nf>,I<pol>)>
  5288.  
  5289. C<I<nf>> being a number field in
  5290. C<nfinit>
  5291. format considered as base field, and I<pol> a polynomial defining a relative
  5292. extension over C<I<nf>>, this computes all the necessary data to work in the
  5293. relative extension. The main variable of I<pol> must be of higher priority
  5294. (i.e.S< >lower number) than that of C<I<nf>>, and the coefficients of I<pol>
  5295. must be in C<I<nf>>.
  5296.  
  5297. The result is an 11-component row vector as follows (most of the components
  5298. are technical), the numbering being very close to that of C<nfinit>. In
  5299. the following description, we let C<K> be the base field defined by
  5300. C<I<nf>>, C<m> the degree of the base field, C<n> the relative degree, C<L>
  5301. the large field (of relative degree C<n> or absolute degree C<nm>), C<r_1> and
  5302. C<r_2> the number of real and complex places of C<K>.
  5303.  
  5304. C<I<rnf>[1]> contains the relative polynomial I<pol>.
  5305.  
  5306. C<I<rnf>[2]> is a row vector with C<r_1+r_2> entries, entry C<j> being
  5307. a 2-component row vector C<[r_{j,1},r_{j,2}]> where C<r_{j,1}> and C<r_{j,2}>
  5308. are the number of real and complex places of C<L> above the C<j>-th place of
  5309. C<K> so that C<r_{j,1} = 0> and C<r_{j,2} = n> if C<j> is a complex place, while if
  5310. C<j> is a real place we have C<r_{j,1}+2r_{j,2} = n>.
  5311.  
  5312. C<I<rnf>[3]> is a two-component row vector C<[B<I<d>>(L/K),s]> where C<B<I<d>>(L/K)>
  5313. is the relative ideal discriminant of C<L/K> and C<s> is the discriminant of
  5314. C<L/K> viewed as an element of C<K^*/(K^*)^2>, in other words it is the output
  5315. of C<rnfdisc>.
  5316.  
  5317. C<I<rnf>[4]> is the ideal index C<B<I<f>>>, i.e.S< >such that
  5318. C<d(pol)B<I<Z>>_K = B<I<f>>^2B<I<d>>(L/K)>.
  5319.  
  5320. C<I<rnf>[5]> is a vector I<vm> with 7 entries useful for certain
  5321. computations in the relative extension C<L/K>. C<I<vm>[1]> is a vector of
  5322. C<r_1+r_2> matrices, the C<j>-th matrix being an C<(r_{1,j}+r_{2,j}) x n>
  5323. matrix C<M_j> representing the numerical values of the conjugates of the
  5324. C<j>-th embedding of the elements of the integral basis, where C<r_{i,j}> is as
  5325. in C<I<rnf>[2]>. C<I<vm>[2]> is a vector of C<r_1+r_2> matrices, the
  5326. C<j>-th matrix C<MC_j> being essentially the conjugate of the matrix C<M_j>
  5327. except that the last C<r_{2,j}> columns are also multiplied by 2.
  5328. C<I<vm>[3]> is a vector of C<r_1+r_2> matrices C<T2_j>, where C<T2_j> is
  5329. an C<n x n> matrix equal to the real part of the product C<MC_j.M_j>
  5330. (which is a real positive definite matrix). C<I<vm>[4]> is the C<n x n>
  5331. matrix C<T> whose entries are the relative traces of C<F<omega>_iF<omega>_j>
  5332. expressed as polmods in C<I<nf>>, where the C<F<omega>_i> are the elements
  5333. of the relative integral basis. Note that the C<j>-th embedding of C<T> is
  5334. equal to C<\overline{MC_j}.M_j>, and in particular will be equal to
  5335. C<T2_j> if C<r_{2,j} = 0>. Note also that the relative ideal discriminant of
  5336. C<L/K> is equal to C< F<det> (T)> times the square of the product of the ideals
  5337. in the relative pseudo-basis (in C<I<rnf>[7][2]>). The last 3 entries
  5338. C<I<vm>[5]>, C<I<vm>[6]> and C<I<vm>[7]> are linked to the different
  5339. as in C<nfinit>, but have not yet been implemented.
  5340.  
  5341. C<I<rnf>[6]> is a row vector with C<r_1+r_2> entries, the C<j>-th entry
  5342. being the
  5343. row vector with C<r_{1,j}+r_{2,j}> entries of the roots of the C<j>-th embedding
  5344. of the relative polynomial I<pol>.
  5345.  
  5346. C<I<rnf>[7]> is a two-component row vector, where the first component is
  5347. the relative integral pseudo basis expressed as polynomials (in the variable of
  5348. C<pol>) with polmod coefficients in C<I<nf>>, and the second component is the
  5349. ideal list of the pseudobasis in HNF.
  5350.  
  5351. C<I<rnf>[8]> is the inverse matrix of the integral basis matrix, with
  5352. coefficients polmods in C<I<nf>>.
  5353.  
  5354. C<I<rnf>[9]> may be the multiplication table of the integral basis, but
  5355. is not implemented at present.
  5356.  
  5357. C<I<rnf>[10]> is C<I<nf>>.
  5358.  
  5359. C<I<rnf>[11]> is a vector I<vabs> with 5 entries describing the
  5360. I<absolute> extension C<L/B<I<Q>>>. C<I<vabs>[1]> is an absolute equation.
  5361. C<I<vabs>[2]> expresses the generator C<F<alpha>> of the number field
  5362. C<I<nf>> as a polynomial modulo the absolute equation C<I<vabs>[1]>.
  5363. C<I<vabs>[3]> is a small integer C<k> such that, if C<F<beta>> is an abstract
  5364. root of I<pol> and C<F<alpha>> the generator of C<I<nf>>, the generator
  5365. whose root is I<vabs> will be C<F<beta> + k F<alpha>>. Note that one must
  5366. be very careful if C<k ! = 0> when dealing simultaneously with absolute and
  5367. relative quantities since the generator chosen for the absolute extension
  5368. is not the same as for the relative one. If this happens, one can of course
  5369. go on working, but we strongly advise to change the relative polynomial so
  5370. that its root will be C<F<beta> + k F<alpha>>. Typically, the GP instruction would
  5371. be
  5372.  
  5373. C<pol = subst(pol, x, x - k*Mod(y,I<nf>.pol))>
  5374.  
  5375. Finally, C<I<vabs>[4]> is the absolute integral basis of C<L> expressed in HNF
  5376. (hence as would be output by C<nfinit(vabs[1])>), and C<I<vabs>[5]> the
  5377. inverse matrix of the integral basis, allowing to go from polmod to integral
  5378. basis representation.
  5379.  
  5380. X<rnfinitalg>The library syntax is B<rnfinitalg>C<(I<nf>,I<pol>,I<prec>)>.
  5381.  
  5382. =head2 X<rnfisfree>rnfisfreeC<(I<bnf>,x)>
  5383.  
  5384. given a big number field C<I<bnf>> as
  5385. output by C<bnfinit>, and either a polynomial C<x> with coefficients in
  5386. C<I<bnf>> defining a relative extension C<L> of C<I<bnf>>, or a
  5387. pseudo-basis C<x> of such an extension, returns true (1) if C<L/I<bnf>> is
  5388. free, false (0) if not.
  5389.  
  5390. X<rnfisfree>The library syntax is B<rnfisfree>C<(I<bnf>,x)>, and the result is a C<long>.
  5391.  
  5392. =head2 X<rnfisnorm>rnfisnormC<(I<bnf>,I<ext>,I<el>,{I<flag> = 1})>
  5393.  
  5394. similar to
  5395. C<bnfisnorm> but in the relative case. This tries to decide whether the
  5396. element I<el> in I<bnf> is the norm of some C<y> in I<ext>.
  5397. C<I<bnf>> is as output by C<bnfinit>.
  5398.  
  5399. C<I<ext>> is a relative extension which has to be a row vector whose
  5400. components are:
  5401.  
  5402. C<I<ext>[1]>: a relative equation of the number field I<ext> over
  5403. I<bnf>. As usual, the priority of the variable of the polynomial
  5404. defining the ground field I<bnf> (say C<y>) must be lower than the
  5405. main variable of C<I<ext>[1]>, say C<x>.
  5406.  
  5407. C<I<ext>[2]>: the generator C<y> of the base field as a polynomial in C<x> (as
  5408. given by C<rnfequation> with C<I<flag> = 1>).
  5409.  
  5410. C<I<ext>[3]>: is the C<bnfinit> of the absolute extension C<I<ext>/B<I<Q>>>.
  5411.  
  5412. This returns a vector C<[a,b]>, where C<I<el> = I<Norm>(a)*b>. It looks for a
  5413. solution which is an C<S>-integer, with C<S> a list of places (of I<bnf>)
  5414. containing the ramified primes, the generators of the class group of
  5415. I<ext>, as well as those primes dividing I<el>. If C<I<ext>/I<bnf>>
  5416. is known to be X<Galois>Galois, set C<I<flag> = 0> (here I<el> is a norm iff C<b = 1>).
  5417. If C<I<flag>> is non zero add to C<S> all the places above the primes which: divide
  5418. C<I<flag>> if C<I<flag> E<lt> 0>, or are less than C<I<flag>> if C<I<flag> E<gt> 0>. The answer is guaranteed
  5419. (i.e.S< >I<el> is a norm iff C<b = 1>) under X<GRH>GRH, if C<S> contains all
  5420. primes less than C<12 F<log> ^2|disc(I<Ext>)|>, where
  5421. I<Ext> is the normal closure of C<I<ext> / I<bnf>>. Example:
  5422.  
  5423.   bnf = bnfinit(y^3 + y^2 - 2*y - 1);
  5424.   p = x^2 + Mod(y^2 + 2*y + 1, bnf.pol);
  5425.   rnf = rnfequation(bnf,p,1);
  5426.   ext = [p, rnf[2], bnfinit(rnf[1])];
  5427.   rnfisnorm(bnf,ext,17, 1)
  5428.  
  5429. checks whether C<17> is a norm in the Galois extension C<B<I<Q>>(F<beta>) /
  5430. B<I<Q>>(F<alpha>)>, where C<F<alpha>^3 + F<alpha>^2 - 2F<alpha> - 1 = 0> and C<F<beta>^2 +
  5431. F<alpha>^2 + 2*F<alpha> + 1 = 0> (it is).
  5432.  
  5433. X<rnfisnorm>The library syntax is B<rnfisnorm>C<(I<bnf>,ext,x,I<flag>,I<prec>)>.
  5434.  
  5435. =head2 X<rnfkummer>rnfkummerC<(I<bnr>,I<subgroup>,{deg = 0})>
  5436.  
  5437. I<bnr>
  5438. being as output by C<bnrinit>, finds a relative equation for the
  5439. class field corresponding to the module in I<bnr> and the given
  5440. congruence subgroup. If I<deg> is positive, outputs the list of all
  5441. relative equations of degree I<deg> contained in the ray class field
  5442. defined by I<bnr>.
  5443.  
  5444. (THIS PROGRAM IS STILL IN DEVELOPMENT STAGE)
  5445.  
  5446. X<rnfkummer>The library syntax is B<rnfkummer>C<(I<bnr>,I<subgroup>,I<deg>,I<prec>)>,
  5447. where I<deg> is a C<long>.
  5448.  
  5449. =head2 X<rnflllgram>rnflllgramC<(I<nf>,I<pol>,I<order>)>
  5450.  
  5451. given a polynomial
  5452. I<pol> with coefficients in I<nf> and an order I<order> as output
  5453. by C<rnfpseudobasis> or similar, gives C<[[I<neworder>],U]>, where
  5454. I<neworder> is a reduced order and C<U> is the unimodular transformation
  5455. matrix.
  5456.  
  5457. X<rnflllgram>The library syntax is B<rnflllgram>C<(I<nf>,I<pol>,I<order>,I<prec>)>.
  5458.  
  5459. =head2 X<rnfnormgroup>rnfnormgroupC<(I<bnr>,I<pol>)>
  5460.  
  5461. I<bnr> being a big ray
  5462. class field as output by C<bnrinit> and I<pol> a relative polynomial
  5463. defining an X<Abelian extension>Abelian extension, computes the norm group (alias Artin
  5464. or Takagi group) corresponding to the Abelian extension of C<I<bnf> = bnr[1]>
  5465. defined by I<pol>, where the module corresponding to I<bnr> is assumed
  5466. to be a multiple of the conductor (i.e.S< >polrel defines a subextension of
  5467. bnr). The result is the HNF defining the norm group on the given generators
  5468. of C<I<bnr>[5][3]>. Note that neither the fact that I<pol> defines an
  5469. Abelian extension nor the fact that the module is a multiple of the conductor
  5470. is checked. The result is undefined if the assumption is not correct.
  5471.  
  5472. X<rnfnormgroup>The library syntax is B<rnfnormgroup>C<(I<bnr>,I<pol>)>.
  5473.  
  5474. =head2 X<rnfpolred>rnfpolredC<(I<nf>,I<pol>)>
  5475.  
  5476. relative version of C<polred>.
  5477. Given a monic polynomial I<pol> with coefficients in C<I<nf>>, finds a
  5478. list of relative polynomials defining some subfields, hopefully simpler and
  5479. containing the original field. In the present version B<2.2.0>, this is slower
  5480. than C<rnfpolredabs>.
  5481.  
  5482. X<rnfpolred>The library syntax is B<rnfpolred>C<(I<nf>,I<pol>,I<prec>)>.
  5483.  
  5484. =head2 X<rnfpolredabs>rnfpolredabsC<(I<nf>,I<pol>,{I<flag> = 0})>
  5485.  
  5486. relative version of
  5487. C<polredabs>. Given a monic polynomial I<pol> with coefficients in
  5488. C<I<nf>>, finds a simpler relative polynomial defining the same field. If
  5489. C<I<flag> = 1>, returns C<[P,a]> where C<P> is the default output and C<a> is an
  5490. element expressed on a root of C<P> whose characteristic polynomial is
  5491. I<pol>, if C<I<flag> = 2>, returns an absolute polynomial (same as
  5492.  
  5493. C<rnfequation(I<nf>,rnfpolredabs(I<nf>,I<pol>))>
  5494.  
  5495. but faster).
  5496.  
  5497. B<Remark.> In the present implementation, this is both faster and
  5498. much more efficient than C<rnfpolred>, the difference being more
  5499. dramatic than in the absolute case. This is because the implementation of
  5500. C<rnfpolred> is based on (a partial implementation of) an incomplete
  5501. reduction theory of lattices over number fields (i.e.S< >the function
  5502. C<rnflllgram>) which deserves to be improved.
  5503.  
  5504. X<rnfpolredabs>The library syntax is B<rnfpolredabs>C<(I<nf>,I<pol>,I<flag>,I<prec>)>.
  5505.  
  5506. =head2 X<rnfpseudobasis>rnfpseudobasisC<(I<nf>,I<pol>)>
  5507.  
  5508. given a number field
  5509. C<I<nf>> as output by C<nfinit> and a polynomial I<pol> with
  5510. coefficients in C<I<nf>> defining a relative extension C<L> of C<I<nf>>,
  5511. computes a pseudo-basis C<(A,I)> and the relative discriminant of C<L>.
  5512. This is output as
  5513. a four-element row vector C<[A,I,D,d]>, where C<D> is the relative ideal
  5514. discriminant and C<d> is the relative discriminant considered as an element of
  5515. C<I<nf>^*/{I<nf>^*}^2>.
  5516.  
  5517. Note: As usual, C<I<nf>> can be a C<I<bnf>> as output by C<bnfinit>.
  5518.  
  5519. X<rnfpseudobasis>The library syntax is B<rnfpseudobasis>C<(I<nf>,I<pol>)>.
  5520.  
  5521. =head2 X<rnfsteinitz>rnfsteinitzC<(I<nf>,x)>
  5522.  
  5523. given a number field C<I<nf>> as
  5524. output by C<nfinit> and either a polynomial C<x> with coefficients in
  5525. C<I<nf>> defining a relative extension C<L> of C<I<nf>>, or a pseudo-basis
  5526. C<x> of such an extension as output for example by C<rnfpseudobasis>,
  5527. computes another pseudo-basis C<(A,I)> (not in HNF in general) such that all
  5528. the ideals of C<I> except perhaps the last one are equal to the ring of
  5529. integers of C<I<nf>>, and outputs the four-component row vector C<[A,I,D,d]>
  5530. as in C<rnfpseudobasis>. The name of this function comes from the fact
  5531. that the ideal class of the last ideal of C<I> (which is well defined) is
  5532. called the X<Steinitz class>I<Steinitz class> of the module C<B<I<Z>>_L>.
  5533.  
  5534. Note: C<I<nf>> can be a C<I<bnf>> as output by C<bnfinit>.
  5535.  
  5536. X<rnfsteinitz>The library syntax is B<rnfsteinitz>C<(I<nf>,x)>.
  5537.  
  5538. =head2 X<subgrouplist>subgrouplistC<(I<bnr>,{I<bound>},{I<flag> = 0})>
  5539.  
  5540. I<bnr> being as output by C<bnrinit> or a list of cyclic components
  5541. of a finite Abelian group C<G>, outputs the list of subgroups of C<G>
  5542. (of index bounded by I<bound>, if not omitted). Subgroups are given
  5543. as HNFX<Hermite normal form> left divisors of the
  5544. SNFX<Smith normal form> matrix corresponding to C<G>. If C<I<flag> = 0>
  5545. (default) and I<bnr> is as output by
  5546. C<bnrinit>, gives only the subgroups whose modulus is the conductor.
  5547.  
  5548. X<subgrouplist0>The library syntax is B<subgrouplist0>C<(I<bnr>,I<bound>,I<flag>,I<prec>)>, where
  5549. I<bound>, C<I<flag>> and C<I<prec>> are long integers.
  5550.  
  5551. =head2 X<zetak>zetakC<(I<znf>,x,{I<flag> = 0})>
  5552.  
  5553. I<znf> being a number
  5554. field initialized by C<zetakinit> (I<not> by C<nfinit>),
  5555. computes the value of the X<Dedekind>Dedekind zeta function of the number
  5556. field at the complex number C<x>. If C<I<flag> = 1> computes Dedekind C<F<Lambda>>
  5557. function instead (i.e.S< >the product of the
  5558. Dedekind zeta function by its gamma and exponential factors).
  5559.  
  5560. The accuracy of the result depends in an essential way on the accuracy of
  5561. both the C<zetakinit> program and the current accuracy, but even so the
  5562. result may be off by up to 5 or 10 decimal digits.
  5563.  
  5564. X<glambdak>The library syntax is B<glambdak>C<(I<znf>,x,I<prec>)> or
  5565. C<X<gzetak>B<gzetak>(I<znf>,x,I<prec>)>.
  5566.  
  5567. =head2 X<zetakinit>zetakinitC<(x)>
  5568.  
  5569. computes a number of initialization data
  5570. concerning the number field defined by the polynomial C<x> so as to be able
  5571. to compute the X<Dedekind>Dedekind zeta and lambda functions (respectively
  5572. C<zetak(x)> and C<zetak(x,1)>). This function calls in particular
  5573. the C<bnfinit> program. The result is a 9-component vector C<v> whose
  5574. components are very technical and cannot really be used by the user except
  5575. through the C<zetak> function. The only component which can be used if
  5576. it has not been computed already is C<v[1][4]> which is the result of the
  5577. C<bnfinit> call.
  5578.  
  5579. This function is very inefficient and should be rewritten. It needs to
  5580. computes millions of coefficients of the corresponding Dirichlet series if
  5581. the precision is big. Unless the discriminant is small it will not be able
  5582. to handle more than 9 digits of relative precision
  5583. (e.gS< >C<zetakinit(x^8 - 2)> needs 440MB of memory at default
  5584. precision).
  5585.  
  5586. X<initzeta>The library syntax is B<initzeta>C<(x)>.
  5587.  
  5588. =head1 Polynomials and power series
  5589.  
  5590. We group here all functions which are specific to polynomials or power
  5591. series. Many other functions which can be applied on these objects are
  5592. described in the other sections. Also, some of the functions described here
  5593. can be applied to other types.
  5594.  
  5595. =head2 X<O>OC<(a>C<^>C<b)>
  5596.  
  5597. C<p>-adic (if C<a> is an integer greater or
  5598. equal to 2) or power series zero (in all other cases), with precision given
  5599. by C<b>.
  5600.  
  5601. X<ggrandocp>The library syntax is B<ggrandocp>C<(a,b)>, where C<b> is a C<long>.
  5602.  
  5603. =head2 X<deriv>derivC<(x,{v})>
  5604.  
  5605. derivative of C<x> with respect to the main
  5606. variable if C<v> is omitted, and with respect to C<v> otherwise. C<x> can be any
  5607. type except polmod. The derivative of a scalar type is zero, and the
  5608. derivative of a vector or matrix is done componentwise. One can use C<x'> as a
  5609. shortcut if the derivative is with respect to the main variable of C<x>.
  5610.  
  5611. X<deriv>The library syntax is B<deriv>C<(x,v)>, where C<v> is a C<long>, and an omitted C<v> is coded as
  5612. C<-1>.
  5613.  
  5614. =head2 X<eval>evalC<(x)>
  5615.  
  5616. replaces in C<x> the formal variables by the values that
  5617. have been assigned to them after the creation of C<x>. This is mainly useful
  5618. in GP, and not in library mode. Do not confuse this with substitution (see
  5619. C<subst>). Applying this function to a character string yields the
  5620. output from the corresponding GP command, as if directly input from the
  5621. keyboard (see L<Label se:strings>).X<Label se:eval>
  5622.  
  5623. X<geval>The library syntax is B<geval>C<(x)>. The more basic functions C<X<poleval>B<poleval>(q,x)>,
  5624. C<X<qfeval>B<qfeval>(q,x)>, and C<X<hqfeval>B<hqfeval>(q,x)> evaluate C<q> at C<x>, where C<q>
  5625. is respectively assumed to be a polynomial, a quadratic form (a symmetric
  5626. matrix), or an Hermitian form (an Hermitian complex matrix).
  5627.  
  5628. =head2 X<factorpadic>factorpadicC<(I<pol>,p,r,{I<flag> = 0})>
  5629.  
  5630. C<p>-adic factorization
  5631. of the polynomial I<pol> to precision C<r>, the result being a
  5632. two-column matrix as in C<factor>. The factors are normalized so that
  5633. their leading coefficient is a power of C<p>. C<r> must be strictly larger than
  5634. the C<p>-adic valuation of the discriminant of I<pol> for the result to
  5635. make any sense. The method used is a modified version of the X<round 4>round 4
  5636. algorithm of X<Zassenhaus>Zassenhaus.
  5637.  
  5638. If C<I<flag> = 1>, use an algorithm due to X<Buchmann>Buchmann and X<Lenstra>Lenstra, which is
  5639. usually less efficient.
  5640.  
  5641. X<factorpadic4>The library syntax is B<factorpadic4>C<(I<pol>,p,r)>, where C<r> is a C<long> integer.
  5642.  
  5643. =head2 X<intformal>intformalC<(x,{v})>
  5644.  
  5645. X<formal integration>formal integration of C<x> with
  5646. respect to the main variable if C<v> is omitted, with respect to the variable
  5647. C<v> otherwise. Since PARI does not know about ``abstract'' logarithms (they
  5648. are immediately evaluated, if only to a power series), logarithmic terms in
  5649. the result will yield an error. C<x> can be of any type. When C<x> is a
  5650. rational function, it is assumed that the base ring is an integral domain of
  5651. characteristic zero.
  5652.  
  5653. X<integ>The library syntax is B<integ>C<(x,v)>, where C<v> is a C<long> and an omitted C<v> is coded
  5654. as C<-1>.
  5655.  
  5656. =head2 X<padicappr>padicapprC<(I<pol>,a)>
  5657.  
  5658. vector of C<p>-adic roots of the
  5659. polynomial
  5660. C<pol> congruent to the C<p>-adic number C<a> modulo C<p> (or modulo 4 if C<p = 2>),
  5661. and with the same C<p>-adic precision as C<a>. The number C<a> can be an
  5662. ordinary C<p>-adic number (type C<t_PADIC>, i.e.S< >an element of C<B<I<Q>>_p>) or
  5663. can be an element of a finite extension of C<B<I<Q>>_p>, in which case it is of
  5664. type C<t_POLMOD>, where at least one of the coefficients of the polmod is a
  5665. C<p>-adic number. In this case, the result is the vector of roots belonging to
  5666. the same extension of C<B<I<Q>>_p> as C<a>.
  5667.  
  5668. X<apprgen9>The library syntax is B<apprgen9>C<(I<pol>,a)>, but if C<a> is known to be simply a C<p>-adic number
  5669. (type C<t_PADIC>), the syntax C<X<apprgen>B<apprgen>(I<pol>,a)> can be used.
  5670.  
  5671. =head2 X<polcoeff>polcoeffC<(x,s,{v})>
  5672.  
  5673. coefficient of degree C<s> of the
  5674. polynomial C<x>, with respect to the main variable if C<v> is omitted, with
  5675. respect to C<v> otherwise.
  5676.  
  5677. X<polcoeff0>The library syntax is B<polcoeff0>C<(x,s,v)>, where C<v> is a C<long> and an omitted C<v> is coded
  5678. as C<-1>. Also available is X<truecoeff>B<truecoeff>C<(x,v)>.
  5679.  
  5680. =head2 X<poldegree>poldegreeC<(x,{v})>
  5681.  
  5682. degree of the polynomial C<x> in the main
  5683. variable if C<v> is omitted, in the variable C<v> otherwise. This is to be
  5684. understood as follows. When C<x> is a polynomial or a rational function, it
  5685. gives the degree of C<x>, the degree of C<0> being C<-1> by convention. When C<x>
  5686. is a non-zero scalar, it gives 0, and when C<x> is a zero scalar, it gives
  5687. C<-1>. Return an error otherwise.
  5688.  
  5689. X<poldegree>The library syntax is B<poldegree>C<(x,v)>, where C<v> and the result are C<long>s (and an
  5690. omitted C<v> is coded as C<-1>). Also available is X<degree>B<degree>C<(x)>, which is
  5691. equivalent to C<poldegree(x,-1)>.
  5692.  
  5693. =head2 X<polcyclo>polcycloC<(n,{v = x})>
  5694.  
  5695. C<n>-th cyclotomic polynomial, in variable
  5696. C<v> (C<x> by default). The integer C<n> must be positive.
  5697.  
  5698. X<cyclo>The library syntax is B<cyclo>C<(n,v)>, where C<n> and C<v> are C<long>
  5699. integers (C<v> is a variable number, usually obtained through C<varn>).
  5700.  
  5701. =head2 X<poldisc>poldiscC<(I<pol>,{v})>
  5702.  
  5703. discriminant of the polynomial
  5704. I<pol> in the main variable is C<v> is omitted, in C<v> otherwise. The
  5705. algorithm used is the X<subresultant algorithm>subresultant algorithm.
  5706.  
  5707. X<poldisc0>The library syntax is B<poldisc0>C<(x,v)>. Also available is X<discsr>B<discsr>C<(x)>, equivalent
  5708. to C<poldisc0(x,-1)>.
  5709.  
  5710. =head2 X<poldiscreduced>poldiscreducedC<(f)>
  5711.  
  5712. reduced discriminant vector of the
  5713. (integral, monic) polynomial C<f>. This is the vector of elementary divisors
  5714. of C<B<I<Z>>[F<alpha>]/f'(F<alpha>)B<I<Z>>[F<alpha>]>, where C<F<alpha>> is a root of the
  5715. polynomial C<f>. The components of the result are all positive, and their
  5716. product is equal to the absolute value of the discriminant ofS< >C<f>.
  5717.  
  5718. X<reduceddiscsmith>The library syntax is B<reduceddiscsmith>C<(x)>.
  5719.  
  5720. =head2 X<polhensellift>polhenselliftC<(x, y, p, e)>
  5721.  
  5722. given a vector C<y> of
  5723. polynomials that are pairwise relatively prime modulo the prime C<p>,
  5724. and whose product is congruent to C<x> modulo C<p>, lift the elements of
  5725. C<y> to polynomials whose product is congruent to C<x> modulo C<p^e>.
  5726.  
  5727. X<polhensellift>The library syntax is B<polhensellift>C<(x,y,p,e)> where C<e> must be a C<long>.
  5728.  
  5729. =head2 X<polinterpolate>polinterpolateC<(xa,{ya},{v = x},{&e})>
  5730.  
  5731. given the data vectors
  5732. C<xa> and C<ya> of the same length C<n> (C<xa> containing the C<x>-coordinates,
  5733. and C<ya> the corresponding C<y>-coordinates), this function finds the
  5734. X<interpolating polynomial>interpolating polynomial passing through these points and evaluates it
  5735. atS< >C<v>. If C<ya> is omitted, return the polynomial interpolating the
  5736. C<(i,xa[i])>. If present, C<e> will contain an error estimate on the returned
  5737. value.
  5738.  
  5739. X<polint>The library syntax is B<polint>C<(xa,ya,v,&e)>, where C<e> will contain an error estimate on the
  5740. returned value.
  5741.  
  5742. =head2 X<polisirreducible>polisirreducibleC<(I<pol>)>
  5743.  
  5744. I<pol> being a polynomial
  5745. (univariate in the present version B<2.2.0>), returns 1 if I<pol> is
  5746. non-constant and irreducible, 0 otherwise. Irreducibility is checked over
  5747. the smallest base field over which I<pol> seems to be defined.
  5748.  
  5749. X<gisirreducible>The library syntax is B<gisirreducible>C<(I<pol>)>.
  5750.  
  5751. =head2 X<pollead>polleadC<(x,{v})>
  5752.  
  5753. leading coefficient of the polynomial or
  5754. power series C<x>. This is computed with respect to the main variable of C<x>
  5755. if C<v> is omitted, with respect to the variable C<v> otherwise.
  5756.  
  5757. X<pollead>The library syntax is B<pollead>C<(x,v)>, where C<v> is a C<long> and an omitted C<v> is coded as
  5758. C<-1>. Also available is X<leadingcoeff>B<leadingcoeff>C<(x)>.
  5759.  
  5760. =head2 X<pollegendre>pollegendreC<(n,{v = x})>
  5761.  
  5762. creates the C<n^{th}>
  5763. X<Legendre polynomial>Legendre polynomial, in variable C<v>.
  5764.  
  5765. X<legendre>The library syntax is B<legendre>C<(n)>, where C<x> is a C<long>.
  5766.  
  5767. =head2 X<polrecip>polrecipC<(I<pol>)>
  5768.  
  5769. reciprocal polynomial of I<pol>,
  5770. i.e.S< >the coefficients are in reverse order. I<pol> must be a polynomial.
  5771.  
  5772. X<polrecip>The library syntax is B<polrecip>C<(x)>.
  5773.  
  5774. =head2 X<polresultant>polresultantC<(x,y,{v},{I<flag> = 0})>
  5775.  
  5776. resultant of the two
  5777. polynomials C<x> and C<y> with exact entries, with respect to the main
  5778. variables of C<x> and C<y> if C<v> is omitted, with respect to the variable C<v>
  5779. otherwise. The algorithm used is the X<subresultant algorithm>subresultant algorithm by default.
  5780.  
  5781. If C<I<flag> = 1>, uses the determinant of Sylvester's matrix instead (here C<x> and
  5782. C<y> may have non-exact coefficients).
  5783.  
  5784. If C<I<flag> = 2>, uses Ducos's modified subresultant algorithm. It should be much
  5785. faster than the default if the coefficient ring is complicated (e.g
  5786. multivariate polynomials or huge coefficients), and slightly slower
  5787. otherwise.
  5788.  
  5789. X<polresultant0>The library syntax is B<polresultant0>C<(x,y,v,I<flag>)>, where C<v> is a C<long> and an omitted C<v>
  5790. is coded as C<-1>. Also available are C<X<subres>B<subres>(x,y)> (C<I<flag> = 0>) and
  5791. C<X<resultant2>B<resultant2>(x,y)> (C<I<flag> = 1>).
  5792.  
  5793. =head2 X<polroots>polrootsC<(I<pol>,{I<flag> = 0})>
  5794.  
  5795. complex roots of the polynomial
  5796. I<pol>, given as a column vector where each root is repeated according to
  5797. its multiplicity. The precision is given as for transcendental functions: under
  5798. GP it is kept in the variable C<realprecision> and is transparent to the
  5799. user, but it must be explicitly given as a second argument in library mode.
  5800.  
  5801. The algorithm used is a modification of A.S< >X<SchE<ouml>nhage>SchE<ouml>nhage's remarkable
  5802. root-finding algorithm, due to and implemented by X.S< >Gourdon. Barring bugs,
  5803. it is guaranteed to converge and to give the roots to the required accuracy.
  5804.  
  5805. If C<I<flag> = 1>, use a variant of the Newton-Raphson method, which is I<not>
  5806. guaranteed to converge, but is rather fast. If you get the messages ``too
  5807. many iterations in roots'' or ``INTERNAL ERROR: incorrect result in roots'',
  5808. use the default function (i.e.S< >no flag or C<I<flag> = 0>). This used to be the
  5809. default root-finding function in PARI until version 1.39.06.
  5810.  
  5811. X<roots>The library syntax is B<roots>C<(I<pol>,I<prec>)> or C<X<rootsold>B<rootsold>(I<pol>,I<prec>)>.
  5812.  
  5813. =head2 X<polrootsmod>polrootsmodC<(I<pol>,p,{I<flag> = 0})>
  5814.  
  5815. row vector of roots modulo
  5816. C<p> of the polynomial I<pol>. The particular non-prime value C<p = 4> is
  5817. accepted, mainly for C<2>-adic computations. Multiple roots are I<not>
  5818. repeated.
  5819.  
  5820. If C<p E<lt> 100>, you may try setting C<I<flag> = 1>, which uses a naive search. In this
  5821. case, multiple roots I<are> repeated with their order of multiplicity.
  5822.  
  5823. X<rootmod>The library syntax is B<rootmod>C<(I<pol>,p)> (C<I<flag> = 0>) or
  5824. C<X<rootmod2>B<rootmod2>(I<pol>,p)> (C<I<flag> = 1>).
  5825.  
  5826. =head2 X<polrootspadic>polrootspadicC<(I<pol>,p,r)>
  5827.  
  5828. row vector of C<p>-adic roots of the
  5829. polynomial I<pol> with C<p>-adic precision equal to C<r>. Multiple roots are
  5830. I<not> repeated. C<p> is assumed to be a prime.
  5831.  
  5832. X<rootpadic>The library syntax is B<rootpadic>C<(I<pol>,p,r)>, where C<r> is a C<long>.
  5833.  
  5834. =head2 X<polsturm>polsturmC<(I<pol>,{a},{b})>
  5835.  
  5836. number of real roots of the real
  5837. polynomial I<pol> in the interval C<]a,b]>, using Sturm's algorithm. C<a>
  5838. (resp.S< >C<b>) is taken to be C<- oo > (resp.S< >C<+ oo >) if omitted.
  5839.  
  5840. X<sturmpart>The library syntax is B<sturmpart>C<(I<pol>,a,b)>. Use C<NULL> to omit an argument.
  5841. X<sturm>B<sturm>C<(I<pol>)> is equivalent to
  5842. B<sturmpart>C<(I<pol>,NULL,NULL)>. The result is a C<long>.
  5843.  
  5844. =head2 X<polsubcyclo>polsubcycloC<(n,d,{v = x})>
  5845.  
  5846. gives a polynomial (in variable
  5847. C<v>) defining the sub-Abelian extension of degree C<d> of the cyclotomic
  5848. field C<B<I<Q>>(F<zeta>_n)>, where C<d | F<phi>(n)>. C<(B<I<Z>>/nB<I<Z>>)^*> has to be cyclic
  5849. (i.e.S< >C<n = 2>, C<4>, C<p^k> or C<2p^k> for an odd prime C<p>). The function 
  5850. X<galoissubcyclo>C<galoissubcyclo> covers the general case.
  5851.  
  5852. X<subcyclo>The library syntax is B<subcyclo>C<(n,d,v)>, where C<v> is a variable number.
  5853.  
  5854. =head2 X<polsylvestermatrix>polsylvestermatrixC<(x,y)>
  5855.  
  5856. forms the Sylvester matrix
  5857. corresponding to the two polynomials C<x> and C<y>, where the coefficients of
  5858. the polynomials are put in the columns of the matrix (which is the natural
  5859. direction for solving equations afterwards). The use of this matrix can be
  5860. essential when dealing with polynomials with inexact entries, since
  5861. polynomial Euclidean division doesn't make much sense in this case.
  5862.  
  5863. X<sylvestermatrix>The library syntax is B<sylvestermatrix>C<(x,y)>.
  5864.  
  5865. =head2 X<polsym>polsymC<(x,n)>
  5866.  
  5867. creates the vector of the X<symmetric powers>symmetric powers
  5868. of the roots of the polynomial C<x> up to power C<n>, using Newton's
  5869. formula.
  5870.  
  5871. X<polsym>The library syntax is B<polsym>C<(x)>.
  5872.  
  5873. =head2 X<poltchebi>poltchebiC<(n,{v = x})>
  5874.  
  5875. creates the C<n^{th}>
  5876. X<Chebyshev>Chebyshev polynomial, in variable C<v>.
  5877.  
  5878. X<tchebi>The library syntax is B<tchebi>C<(n,v)>, where C<n> and C<v> are C<long>
  5879. integers (C<v> is a variable number).
  5880.  
  5881. =head2 X<polzagier>polzagierC<(n,m)>
  5882.  
  5883. creates Zagier's polynomial C<P_{n,m}> used in
  5884. the functions C<sumalt> and C<sumpos> (with C<I<flag> = 1>). The exact
  5885. definition can be found in a forthcoming paper. One must have C<m E<lt>= n>.
  5886.  
  5887. X<polzagreel>The library syntax is B<polzagreel>C<(n,m,I<prec>)> if the result is only wanted as a polynomial
  5888. with real coefficients to the precision C<I<prec>>, or C<X<polzag>B<polzag>(n,m)>
  5889. if the result is wanted exactly, where C<n> and C<m> are C<long>s.
  5890.  
  5891. =head2 X<serconvol>serconvolC<(x,y)>
  5892.  
  5893. convolution (or X<Hadamard product>Hadamard product) of the
  5894. two power series C<x> and C<y>; in other words if C<x = F<sum> a_k*X^k> and C<y = F<sum>
  5895. b_k*X^k> then C<serconvol(x,y) = F<sum> a_k*b_k*X^k>.
  5896.  
  5897. X<convol>The library syntax is B<convol>C<(x,y)>.
  5898.  
  5899. =head2 X<serlaplace>serlaplaceC<(x)>
  5900.  
  5901. C<x> must be a power series with only
  5902. non-negative exponents. If C<x = F<sum> (a_k/k!)*X^k> then the result is C<F<sum>
  5903. a_k*X^k>.
  5904.  
  5905. X<laplace>The library syntax is B<laplace>C<(x)>.
  5906.  
  5907. =head2 X<serreverse>serreverseC<(x)>
  5908.  
  5909. reverse power series (i.e.S< >C<x^{-1}>, not C<1/x>)
  5910. of C<x>. C<x> must be a power series whose valuation is exactly equal to one.
  5911.  
  5912. X<recip>The library syntax is B<recip>C<(x)>.
  5913.  
  5914. =head2 X<subst>substC<(x,y,z)>
  5915.  
  5916. replace the simple variable C<y> by the argument C<z> in the ``polynomial''
  5917. expression C<x>. Every type is allowed for C<x>, but if it is not a genuine
  5918. polynomial (or power series, or rational function), the substitution will be
  5919. done as if the scalar components were polynomials of degree one. In
  5920. particular, beware that:
  5921.  
  5922.   ? subst(1, x, [1,2; 3,4])
  5923.   %1 =
  5924.   [1 0]
  5925.  
  5926.   [0 1]
  5927.  
  5928.   ? subst(1, x, Mat([0,1]))
  5929.     ***   forbidden substitution by a non square matrix
  5930.  
  5931. If C<x> is a power series, C<z> must be either a polynomial, a power series, or
  5932. a rational function. C<y> must be a simple variable name.
  5933.  
  5934. X<gsubst>The library syntax is B<gsubst>C<(x,v,z)>, where C<v> is the number of
  5935. the variable C<y>.
  5936.  
  5937. =head2 X<taylor>taylorC<(x,y)>
  5938.  
  5939. Taylor expansion around C<0> of C<x> with respect
  5940. toX<Label se:taylor>
  5941. the simple variable C<y>. C<x> can be of any reasonable type, for example a
  5942. rational function. The number of terms of the expansion is transparent to the
  5943. user under GP, but must be given as a second argument in library mode.
  5944.  
  5945. X<tayl>The library syntax is B<tayl>C<(x,y,n)>, where the C<long> integer C<n> is the desired number of
  5946. terms in the expansion.
  5947.  
  5948. =head2 X<thue>thueC<(I<tnf>,a,{I<sol>})>
  5949.  
  5950. solves the equation
  5951. C<P(x,y) = a> in integers C<x> and C<y>, where I<tnf> was created with
  5952. C<thueinit(P)>. I<sol>, if present, contains the solutions of
  5953. C<Norm(x) = a> modulo units of positive norm in the number field
  5954. defined by C<P> (as computed by C<bnfisintnorm>). If I<tnf> was
  5955. computed without assuming X<GRH>GRH (C<I<flag> = 1> in C<thueinit>), the
  5956. result is unconditional. For instance, here's how to solve the Thue
  5957. equation C<x^{13} - 5y^{13} = - 4>:
  5958.  
  5959.   ? tnf = thueinit(x^13 - 5);
  5960.   ? thue(tnf, -4)
  5961.   %1 = [[1, 1]]
  5962.  
  5963. Hence, assuming GRH, the only solution is C<x = 1>, C<y = 1>.
  5964.  
  5965. X<thue>The library syntax is B<thue>C<(I<tnf>,a,I<sol>)>, where an omitted I<sol> is coded
  5966. as C<NULL>.
  5967.  
  5968. =head2 X<thueinit>thueinitC<(P,{I<flag> = 0})>
  5969.  
  5970. initializes the I<tnf>
  5971. corresponding to C<P>. It is meant to be used in conjunction with X<thue>C<thue>
  5972. to solve Thue equations C<P(x,y) = a>, where C<a> is an integer. If C<I<flag>> is
  5973. non-zero, certify the result unconditionnaly, Otherwise, assume X<GRH>GRH,
  5974. this being much faster of course.
  5975.  
  5976. X<thueinit>The library syntax is B<thueinit>C<(P,I<flag>,I<prec>)>.
  5977.  
  5978. =head1 Vectors, matrices, linear algebra and sets
  5979.  
  5980. X<Label se:linear_algebra>
  5981. Note that most linear algebra functions operating on subspaces defined by
  5982. generating sets (such as X<mathnf>C<mathnf>, X<qflll>C<qflll>, etc.) take matrices as
  5983. arguments. As usual, the generating vectors are taken to be the
  5984. I<columns> of the given matrix.
  5985.  
  5986. =head2 X<algdep>algdepC<(x,k,{I<flag> = 0})>
  5987.  
  5988. X<algebraic dependence>C<x> being
  5989. real, complex, or C<p>-adic, finds a polynomial of degree at most C<k> with
  5990. integer coefficients having C<x> as approximate root. Note that the polynomial
  5991. which is obtained is not necessarily the ``correct'' one (it's not even
  5992. guaranteed to be irreducible!). One can check the closeness either by a
  5993. polynomial evaluation or substitution, or by computing the roots of the
  5994. polynomial given by algdep.
  5995.  
  5996. If C<x> is padic, C<I<flag>> is meaningless and the algorithm LLL-reduces the
  5997. ``dual lattice'' corresponding to the powers of C<x>.
  5998.  
  5999. Otherwise, if C<I<flag>> is zero, the algorithm used is a variant of the X<LLL>LLL
  6000. algorithm due to Hastad, Lagarias and Schnorr (STACS 1986). If the precision
  6001. is too low, the routine may enter an infinite loop.
  6002.  
  6003. If C<I<flag>> is non-zero, use a standard LLL. C<I<flag>> then indicates a precision,
  6004. which should be between C<0.5> and C<1.0> times the number of decimal digits
  6005. to which C<x> was computed.
  6006.  
  6007. X<algdep0>The library syntax is B<algdep0>C<(x,k,I<flag>,I<prec>)>, where C<k> and C<I<flag>> are C<long>s.
  6008. Also available is C<X<algdep>B<algdep>(x,k,I<prec>)> (C<I<flag> = 0>).
  6009.  
  6010. =head2 X<charpoly>charpolyC<(A,{v = x},{I<flag> = 0})>
  6011.  
  6012. X<characteristic polynomial>characteristic polynomial
  6013. of C<A> with respect to the variable C<v>, i.e.S< >determinant of C<v*I-A> if C<A>
  6014. is a square matrix, determinant of the map ``multiplication by C<A>'' if C<A>
  6015. is a scalar, in particular a polmod (e.g.S< >C<charpoly(I,x) = x^2+1>).
  6016. Note that in the latter case, the X<minimal polynomial>minimal polynomial can be obtained
  6017. as
  6018.  
  6019.   minpoly(A)=
  6020.   {
  6021.     local(y);
  6022.     y = charpoly(A);
  6023.     y / gcd(y,y')
  6024.   }
  6025.  
  6026. The value of C<I<flag>> is only significant for matrices.
  6027.  
  6028. If C<I<flag> = 0>, the method used is essentially the same as for computing the
  6029. adjoint matrix, i.e.S< >computing the traces of the powers of C<A>.
  6030.  
  6031. If C<I<flag> = 1>, uses Lagrange interpolation which is almost always slower.
  6032.  
  6033. If C<I<flag> = 2>, uses the Hessenberg form. This is faster than the default when
  6034. the coefficients are integermod a prime or real numbers, but is usually
  6035. slower in other base rings.
  6036.  
  6037. X<charpoly0>The library syntax is B<charpoly0>C<(A,v,I<flag>)>, where C<v> is the variable number. Also available
  6038. are the functions C<X<caract>B<caract>(A,v)> (C<I<flag> = 1>), C<X<carhess>B<carhess>(A,v)>
  6039. (C<I<flag> = 2>), and C<X<caradj>B<caradj>(A,v,I<pt>)> where, in this last case,
  6040. I<pt> is a C<GEN*> which, if not equal to C<NULL>, will receive
  6041. the address of the adjoint matrix of C<A> (see C<matadjoint>), so both
  6042. can be obtained at once.
  6043.  
  6044. =head2 X<concat>concatC<(x,{y})>
  6045.  
  6046. concatenation of C<x> and C<y>. If C<x> or C<y> is
  6047. not a vector or matrix, it is considered as a one-dimensional vector. All
  6048. types are allowed for C<x> and C<y>, but the sizes must be compatible. Note
  6049. that matrices are concatenated horizontally, i.e.S< >the number of rows stays
  6050. the same. Using transpositions, it is easy to concatenate them vertically.
  6051.  
  6052. To concatenate vectors sideways (i.e.S< >to obtain a two-row or two-column
  6053. matrix), first transform the vector into a one-row or one-column matrix using
  6054. the function X<Mat>C<Mat>. Concatenating a row vector to a matrix having the
  6055. same number of columns will add the row to the matrix (top row if the vector
  6056. is C<x>, i.e.S< >comes first, and bottom row otherwise).
  6057.  
  6058. The empty matrix C<[;]> is considered to have a number of rows compatible
  6059. with any operation, in particular concatenation. (Note that this is
  6060. definitely I<not> the case for empty vectors C<[S< >]> or C<[S< >]~>.)
  6061.  
  6062. If C<y> is omitted, C<x> has to be a row vector or a list, in which case its
  6063. elements are concatenated, from left to right, using the above rules.
  6064.  
  6065.   ? concat([1,2], [3,4])
  6066.   %1 = [1, 2, 3, 4]
  6067.   ? a = [[1,2]~, [3,4]~]; concat(a)
  6068.   %2 = [1, 2, 3, 4]~
  6069.   ? a[1] = Mat(a[1]); concat(a)
  6070.   %3 = 
  6071.   [1 3]
  6072.  
  6073.   [2 4]
  6074.  
  6075.   ? concat([1,2; 3,4], [5,6]~)
  6076.   %4 =
  6077.   [1 2 5]
  6078.  
  6079.   [3 4 6]
  6080.   ? concat([%, [7,8]~, [1,2,3,4]])
  6081.   %5 =
  6082.   [1 2 5 7]
  6083.  
  6084.   [3 4 6 8]
  6085.  
  6086.   [1 2 3 4]
  6087.  
  6088. X<concat>The library syntax is B<concat>C<(x,y)>.
  6089.  
  6090. =head2 X<lindep>lindepC<(x,{I<flag> = 0})>
  6091.  
  6092. X<linear dependence>C<x> being a
  6093. vector with real or complex coefficients, finds a small integral linear
  6094. combination among these coefficients.
  6095.  
  6096. If C<I<flag> = 0>, uses a variant of the X<LLL>LLL algorithm due to Hastad, Lagarias
  6097. and Schnorr (STACS 1986).
  6098.  
  6099. If C<I<flag> E<gt> 0>, uses the LLL algorithm. C<I<flag>> is a parameter which should be
  6100. between one half the number of decimal digits of precision and that number
  6101. (see C<algdep>).
  6102.  
  6103. If C<I<flag> E<lt> 0>, returns as soon as one relation has been found.
  6104.  
  6105. X<lindep0>The library syntax is B<lindep0>C<(x,I<flag>,I<prec>)>. Also available is
  6106. C<X<lindep>B<lindep>(x,I<prec>)> (C<I<flag> = 0>).
  6107.  
  6108. =head2 X<listcreate>listcreateC<(n)>
  6109.  
  6110. creates an empty list of maximal length C<n>.
  6111.  
  6112. This function is useless in library mode.
  6113.  
  6114. =head2 X<listinsert>listinsertC<(I<list>,x,n)>
  6115.  
  6116. inserts the object C<x> at
  6117. position C<n> in I<list> (which must be of type C<t_LIST>). All the
  6118. remaining elements of I<list> (from position C<n+1> onwards) are shifted
  6119. to the right. This and C<listput> are the only commands which enable
  6120. you to increase a list's effective length (as long as it remains under
  6121. the maximal length specified at the time of the C<listcreate>).
  6122.  
  6123. This function is useless in library mode.
  6124.  
  6125. =head2 X<listkill>listkillC<(I<list>)>
  6126.  
  6127. kill I<list>. This deletes all
  6128. elements from I<list> and sets its effective length to C<0>. The maximal
  6129. length is not affected.
  6130.  
  6131. This function is useless in library mode.
  6132.  
  6133. =head2 X<listput>listputC<(I<list>,x,{n})>
  6134.  
  6135. sets the C<n>-th element of the list
  6136. I<list> (which must be of type C<t_LIST>) equal to C<x>. If C<n> is omitted,
  6137. or greater than the list current effective length, just appends C<x>. This and
  6138. C<listinsert> are the only commands which enable you to increase a list's
  6139. effective length (as long as it remains under the maximal length specified at
  6140. the time of the C<listcreate>).
  6141.  
  6142. If you want to put an element into an occupied cell, i.e.S< >if you don't want to
  6143. change the effective length, you can consider the list as a vector and use
  6144. the usual C<list[n] = x> construct.
  6145.  
  6146. This function is useless in library mode.
  6147.  
  6148. =head2 X<listsort>listsortC<(I<list>,{I<flag> = 0})>
  6149.  
  6150. sorts I<list> (which must
  6151. be of type C<t_LIST>) in place. If C<I<flag>> is non-zero, suppresses all repeated
  6152. coefficients. This is much faster than the C<vecsort> command since no
  6153. copy has to be made.
  6154.  
  6155. This function is useless in library mode.
  6156.  
  6157. =head2 X<matadjoint>matadjointC<(x)>
  6158.  
  6159. X<adjoint matrix>adjoint matrix of C<x>, i.e.S< >the matrix C<y>
  6160. of cofactors of C<x>, satisfying C<x*y =  F<det> (x)*Id>. C<x> must be a
  6161. (non-necessarily invertible) square matrix.
  6162.  
  6163. X<adj>The library syntax is B<adj>C<(x)>.
  6164.  
  6165. =head2 X<matcompanion>matcompanionC<(x)>
  6166.  
  6167. the left companion matrix to the polynomial C<x>.
  6168.  
  6169. X<assmat>The library syntax is B<assmat>C<(x)>.
  6170.  
  6171. =head2 X<matdet>matdetC<(x,{I<flag> = 0})>
  6172.  
  6173. determinant of C<x>. C<x> must be a
  6174. square matrix.
  6175.  
  6176. If C<I<flag> = 0>, uses Gauss-Bareiss.
  6177.  
  6178. If C<I<flag> = 1>, uses classical Gaussian elimination, which is better when the
  6179. entries of the matrix are reals or integers for example, but usually much
  6180. worse for more complicated entries like multivariate polynomials.
  6181.  
  6182. X<det>The library syntax is B<det>C<(x)> (C<I<flag> = 0>) and C<X<det2>B<det2>(x)>
  6183. (C<I<flag> = 1>).
  6184.  
  6185. =head2 X<matdetint>matdetintC<(x)>
  6186.  
  6187. C<x> being an C<m x n> matrix with integer
  6188. coefficients, this function computes a multiple of the determinant of the
  6189. lattice generated by the columns of C<x> if it is of rank C<m>, and returns
  6190. zero otherwise. This function can be useful in conjunction with the function
  6191. C<mathnfmod> which needs to know such a multiple. Other ways to obtain
  6192. this determinant (assuming the rank is maximal) is
  6193. C<matdet(qflll(x,4)[2]*x)> or more simply C<matdet(mathnf(x))>.
  6194. Experiment to see which is faster for your applications.
  6195.  
  6196. X<detint>The library syntax is B<detint>C<(x)>.
  6197.  
  6198. =head2 X<matdiagonal>matdiagonalC<(x)>
  6199.  
  6200. C<x> being a vector, creates the diagonal matrix
  6201. whose diagonal entries are those of C<x>.
  6202.  
  6203. X<diagonal>The library syntax is B<diagonal>C<(x)>.
  6204.  
  6205. =head2 X<mateigen>mateigenC<(x)>
  6206.  
  6207. gives the eigenvectors of C<x> as columns of a
  6208. matrix.
  6209.  
  6210. X<eigen>The library syntax is B<eigen>C<(x)>.
  6211.  
  6212. =head2 X<mathess>mathessC<(x)>
  6213.  
  6214. Hessenberg form of the square matrix C<x>.
  6215.  
  6216. X<hess>The library syntax is B<hess>C<(x)>.
  6217.  
  6218. =head2 X<mathilbert>mathilbertC<(x)>
  6219.  
  6220. C<x> being a C<long>, creates the X<Hilbert
  6221. matrix>Hilbert
  6222. matrix of order C<x>, i.e.S< >the matrix whose coefficient (C<i>,C<j>) is C<1/
  6223. (i+j-1)>.
  6224.  
  6225. X<mathilbert>The library syntax is B<mathilbert>C<(x)>.
  6226.  
  6227. =head2 X<mathnf>mathnfC<(x,{I<flag> = 0})>
  6228.  
  6229. if C<x> is a (not necessarily square)
  6230. matrix of maximal rank, finds the I<upper triangular>
  6231. X<Hermite normal form>Hermite normal form of C<x>. If the rank of C<x> is equal to its number
  6232. of rows, the result is a square matrix. In general, the columns of the
  6233. result form a basis of the lattice spanned by the columns of C<x>.
  6234.  
  6235. If C<I<flag> = 0>, uses the naive algorithm. If the B<I<Z>>-module generated by the
  6236. columns is a lattice, it is recommanded to use
  6237. C<mathnfmod(x, matdetint(x))> instead (much faster).
  6238.  
  6239. If C<I<flag> = 1>, uses Batut's algorithm. Outputs a two-component row vector
  6240. C<[H,U]>, where C<H> is the I<upper triangular> Hermite normal form
  6241. of C<x> (i.e.S< >the default result) and C<U> is the unimodular transformation
  6242. matrix such that C<xU = [0|H]>. If the rank of C<x> is equal to its number of
  6243. rows, C<H> is a square matrix. In general, the columns of C<H> form a basis
  6244. of the lattice spanned by the columns of C<x>.
  6245.  
  6246. If C<I<flag> = 2>, uses Havas's algorithm. Outputs C<[H,U,P]>, such that
  6247. C<H> and C<U> are as before and C<P> is a permutation of the rows such that C<P>
  6248. applied to C<xU> gives C<H>. This does not work very well in present version
  6249. B<2.2.0>.
  6250.  
  6251. If C<I<flag> = 3>, uses Batut's algorithm, and outputs C<[H,U,P]> as in the previous
  6252. case.
  6253.  
  6254. If C<I<flag> = 4>, as in case 1 above, but uses X<LLL>LLL reduction along the way.
  6255.  
  6256. X<mathnf0>The library syntax is B<mathnf0>C<(x,I<flag>)>. Also available are C<X<hnf>B<hnf>(x)> (C<I<flag> = 0>) and
  6257. C<X<hnfall>B<hnfall>(x)> (C<I<flag> = 1>). To reduce I<huge> (say C<400  x 400> and
  6258. more) relation matrices (sparse with small entries), you can use the pair
  6259. C<hnfspec> / C<hnfadd>. Since this is rather technical and the
  6260. calling interface may change, they are not documented yet. Look at the code
  6261. in C<basemath/alglin1.c>.
  6262.  
  6263. =head2 X<mathnfmod>mathnfmodC<(x,d)>
  6264.  
  6265. if C<x> is a (not necessarily square) matrix of
  6266. maximal rank with integer entries, and C<d> is a multiple of the (non-zero)
  6267. determinant of the lattice spanned by the columns of C<x>, finds the
  6268. I<upper triangular> X<Hermite normal form>Hermite normal form of C<x>.
  6269.  
  6270. If the rank of C<x> is equal to its number of rows, the result is a square
  6271. matrix. In general, the columns of the result form a basis of the lattice
  6272. spanned by the columns of C<x>. This is much faster than C<mathnf> when C<d>
  6273. is known.
  6274.  
  6275. X<hnfmod>The library syntax is B<hnfmod>C<(x,d)>.
  6276.  
  6277. =head2 X<mathnfmodid>mathnfmodidC<(x,d)>
  6278.  
  6279. outputs the (upper triangular)
  6280. X<Hermite normal form>Hermite normal form of C<x> concatenated with C<d> times
  6281. the identity matrix.
  6282.  
  6283. X<hnfmodid>The library syntax is B<hnfmodid>C<(x,d)>.
  6284.  
  6285. =head2 X<matid>matidC<(n)>
  6286.  
  6287. creates the C<n x n> identity matrix.
  6288.  
  6289. X<idmat>The library syntax is B<idmat>C<(n)> where C<n> is a C<long>.
  6290.  
  6291. Related functions are C<X<gscalmat>B<gscalmat>(x,n)>, which creates C<x> times the
  6292. identity matrix (C<x> being a C<GEN> and C<n> a C<long>), and
  6293. C<X<gscalsmat>B<gscalsmat>(x,n)> which is the same when C<x> is a C<long>.
  6294.  
  6295. =head2 X<matimage>matimageC<(x,{I<flag> = 0})>
  6296.  
  6297. gives a basis for the image of the
  6298. matrix C<x> as columns of a matrix. A priori the matrix can have entries of
  6299. any type. If C<I<flag> = 0>, use standard Gauss pivot. If C<I<flag> = 1>, use
  6300. C<matsupplement>.
  6301.  
  6302. X<matimage0>The library syntax is B<matimage0>C<(x,I<flag>)>. Also available is C<X<image>B<image>(x)> (C<I<flag> = 0>).
  6303.  
  6304. =head2 X<matimagecompl>matimagecomplC<(x)>
  6305.  
  6306. gives the vector of the column indices which
  6307. are not extracted by the function C<matimage>. Hence the number of
  6308. components of C<matimagecompl(x)> plus the number of columns of
  6309. C<matimage(x)> is equal to the number of columns of the matrix C<x>.
  6310.  
  6311. X<imagecompl>The library syntax is B<imagecompl>C<(x)>.
  6312.  
  6313. =head2 X<matindexrank>matindexrankC<(x)>
  6314.  
  6315. C<x> being a matrix of rank C<r>, gives two
  6316. vectors C<y> and C<z> of length C<r> giving a list of rows and columns
  6317. respectively (starting from 1) such that the extracted matrix obtained from
  6318. these two vectors using C<X<vecextract>vecextract(x,y,z)> is invertible.
  6319.  
  6320. X<indexrank>The library syntax is B<indexrank>C<(x)>.
  6321.  
  6322. =head2 X<matintersect>matintersectC<(x,y)>
  6323.  
  6324. C<x> and C<y> being two matrices with the same
  6325. number of rows each of whose columns are independent, finds a basis of the
  6326. B<I<Q>>-vector space equal to the intersection of the spaces spanned by the
  6327. columns of C<x> and C<y> respectively. See also the function
  6328. X<idealintersect>C<idealintersect>, which does the same for free B<I<Z>>-modules.
  6329.  
  6330. X<intersect>The library syntax is B<intersect>C<(x,y)>.
  6331.  
  6332. =head2 X<matinverseimage>matinverseimageC<(x,y)>
  6333.  
  6334. gives a column vector belonging to the
  6335. inverse image of the column vector C<y> by the matrix C<x> if one exists, the
  6336. empty vector otherwise. To get the complete inverse image, it suffices to add
  6337. to the result any element of the kernel of C<x> obtained for example by
  6338. C<matker>.
  6339.  
  6340. X<inverseimage>The library syntax is B<inverseimage>C<(x,y)>.
  6341.  
  6342. =head2 X<matisdiagonal>matisdiagonalC<(x)>
  6343.  
  6344. returns true (1) if C<x> is a diagonal matrix,
  6345. false (0) if not.
  6346.  
  6347. X<isdiagonal>The library syntax is B<isdiagonal>C<(x)>, and this returns a C<long>
  6348. integer.
  6349.  
  6350. =head2 X<matker>matkerC<(x,{I<flag> = 0})>
  6351.  
  6352. gives a basis for the kernel of the
  6353. matrix C<x> as columns of a matrix. A priori the matrix can have entries of
  6354. any type.
  6355.  
  6356. If C<x> is known to have integral entries, set C<I<flag> = 1>.
  6357.  
  6358. Note: The library function C<X<ker_mod_p>ker_mod_p(x, p)>, where C<x> has
  6359. integer entries and C<p> is prime, which is equivalent to but many orders of
  6360. magnitude faster than C<matker(x*Mod(1,p))> and needs much less stack
  6361. space. To use it under GP, type C<install(ker_mod_p, GG)> first.
  6362.  
  6363. X<matker0>The library syntax is B<matker0>C<(x,I<flag>)>. Also available are C<X<ker>B<ker>(x)> (C<I<flag> = 0>),
  6364. C<X<keri>B<keri>(x)> (C<I<flag> = 1>) and C<ker_mod_p(x,p)>.
  6365.  
  6366. =head2 X<matkerint>matkerintC<(x,{I<flag> = 0})>
  6367.  
  6368. gives an X<LLL>LLL-reduced B<I<Z>>-basis
  6369. for the lattice equal to the kernel of the matrix C<x> as columns of the
  6370. matrix C<x> with integer entries (rational entries are not permitted).
  6371.  
  6372. If C<I<flag> = 0>, uses a modified integer LLL algorithm.
  6373.  
  6374. If C<I<flag> = 1>, uses C<matrixqz(x,-2)>. If LLL reduction of the final result
  6375. is not desired, you can save time using C<matrixqz(matker(x),-2)> instead.
  6376.  
  6377. If C<I<flag> = 2>, uses another modified LLL. In the present version B<2.2.0>, only
  6378. independent rows are allowed in this case.
  6379.  
  6380. X<matkerint0>The library syntax is B<matkerint0>C<(x,I<flag>)>. Also available is
  6381. C<X<kerint>B<kerint>(x)> (C<I<flag> = 0>).
  6382.  
  6383. =head2 X<matmuldiagonal>matmuldiagonalC<(x,d)>
  6384.  
  6385. product of the matrix C<x> by the diagonal
  6386. matrix whose diagonal entries are those of the vector C<d>. Equivalent to,
  6387. but much faster than C<x*matdiagonal(d)>.
  6388.  
  6389. X<matmuldiagonal>The library syntax is B<matmuldiagonal>C<(x,d)>.
  6390.  
  6391. =head2 X<matmultodiagonal>matmultodiagonalC<(x,y)>
  6392.  
  6393. product of the matrices C<x> and C<y>
  6394. knowing that the result is a diagonal matrix. Much faster than C<x*y> in
  6395. that case.
  6396.  
  6397. X<matmultodiagonal>The library syntax is B<matmultodiagonal>C<(x,y)>.
  6398.  
  6399. =head2 X<matpascal>matpascalC<(x,{q})>
  6400.  
  6401. creates as a matrix the lower triangular
  6402. X<Pascal triangle>Pascal triangle of order C<x+1> (i.e.S< >with binomial coefficients
  6403. up to C<x>). If C<q> is given, compute the C<q>-Pascal triangle (i.e.S< >using
  6404. C<q>-binomial coefficients).
  6405.  
  6406. X<matqpascal>The library syntax is B<matqpascal>C<(x,q)>, where C<x> is a C<long> and C<q = NULL> is used
  6407. to omit C<q>. Also available is X<matpascal>B<matpascal>{x}.
  6408.  
  6409. =head2 X<matrank>matrankC<(x)>
  6410.  
  6411. rank of the matrix C<x>.
  6412.  
  6413. X<rank>The library syntax is B<rank>C<(x)>, and the result is a C<long>.
  6414.  
  6415. =head2 X<matrix>matrixC<(m,n,{X},{Y},{I<expr> = 0})>
  6416.  
  6417. creation of the
  6418. C<m x n> matrix whose coefficients are given by the expression
  6419. I<expr>. There are two formal parameters in I<expr>, the first one
  6420. (C<X>) corresponding to the rows, the second (C<Y>) to the columns, and C<X>
  6421. goes from 1 to C<m>, C<Y> goes from 1 to C<n>. If one of the last 3 parameters
  6422. is omitted, fill the matrix with zeroes.
  6423.  
  6424. X<matrice>The library syntax is B<matrice>C<(GEN nlig,GEN ncol,entree *e1,entree *e2,char *expr)>.
  6425.  
  6426. =head2 X<matrixqz>matrixqzC<(x,p)>
  6427.  
  6428. C<x> being an C<m x n> matrix with C<m E<gt>= n>
  6429. with rational or integer entries, this function has varying behaviour
  6430. depending on the sign of C<p>:
  6431.  
  6432. If C<p E<gt>= 0>, C<x> is assumed to be of maximal rank. This function returns a
  6433. matrix having only integral entries, having the same image as C<x>, such that
  6434. the GCD of all its C<n x n> subdeterminants is equal to 1 when C<p> is
  6435. equal to 0, or not divisible by C<p> otherwise. Here C<p> must be a prime
  6436. number (when it is non-zero). However, if the function is used when C<p> has
  6437. no small prime factors, it will either work or give the message ``impossible
  6438. inverse modulo'' and a non-trivial divisor of C<p>.
  6439.  
  6440. If C<p = -1>, this function returns a matrix whose columns form a basis of the
  6441. lattice equal to C<B<I<Z>>^n> intersected with the lattice generated by the
  6442. columns of C<x>.
  6443.  
  6444. If C<p = -2>, returns a matrix whose columns form a basis of the lattice equal
  6445. to C<B<I<Z>>^n> intersected with the B<I<Q>>-vector space generated by the
  6446. columns of C<x>.
  6447.  
  6448. X<matrixqz0>The library syntax is B<matrixqz0>C<(x,p)>.
  6449.  
  6450. =head2 X<matsize>matsizeC<(x)>
  6451.  
  6452. C<x> being a vector or matrix, returns a row vector
  6453. with two components, the first being the number of rows (1 for a row vector),
  6454. the second the number of columns (1 for a column vector).
  6455.  
  6456. X<matsize>The library syntax is B<matsize>C<(x)>.
  6457.  
  6458. =head2 X<matsnf>matsnfC<(X,{I<flag> = 0})>
  6459.  
  6460. if C<X> is a (singular or non-singular)
  6461. square matrix outputs the vector of elementary divisors of C<X> (i.e.S< >the
  6462. diagonal of the X<Smith normal form>Smith normal form of C<X>).
  6463.  
  6464. The binary digits of I<flag> mean:
  6465.  
  6466. 1 (complete output): if set, outputs C<[U,V,D]>, where C<U> and C<V> are two
  6467. unimodular matrices such that C<UXV> is the diagonal matrix C<D>. Otherwise
  6468. output only the diagonal of C<D>.
  6469.  
  6470. 2 (generic input): if set, allows polynomial entries. Otherwise, assume
  6471. that C<X> has integer coefficients.
  6472.  
  6473. 4 (cleanup): if set, cleans up the output. This means that elementary
  6474. divisors equal to C<1> will be deleted, i.e.S< >outputs a shortened vector C<D'>
  6475. instead of C<D>. If complete output was required, returns C<[U',V',D']> so
  6476. that C<U'XV' = D'> holds. If this flag is set, C<X> is allowed to be of the
  6477. form C<D> or C<[U,V,D]> as would normally be output with the cleanup flag
  6478. unset.
  6479.  
  6480. X<matsnf0>The library syntax is B<matsnf0>C<(X,I<flag>)>. Also available is C<X<smith>B<smith>(X)> (C<I<flag> = 0>).
  6481.  
  6482. =head2 X<matsolve>matsolveC<(x,y)>
  6483.  
  6484. C<x> being an invertible matrix and C<y> a column
  6485. vector, finds the solution C<u> of C<x*u = y>, using Gaussian elimination. This
  6486. has the same effect as, but is a bit faster, than C<x^{-1}*y>.
  6487.  
  6488. X<gauss>The library syntax is B<gauss>C<(x,y)>.
  6489.  
  6490. =head2 X<matsolvemod>matsolvemodC<(m,d,y,{I<flag> = 0})>
  6491.  
  6492. C<m> being any integral matrix,
  6493. C<d> a vector of positive integer moduli, and C<y> an integral
  6494. column vector, gives a small integer solution to the system of congruences
  6495. C<F<sum>_i m_{i,j}x_j = y_i (mod d_i)> if one exists, otherwise returns
  6496. zero. Shorthand notation: C<y> (resp.S< >C<d>) can be given as a single integer,
  6497. in which case all the C<y_i> (resp.S< >C<d_i>) above are taken to be equal to C<y>
  6498. (resp.S< >C<d>).
  6499.  
  6500. If C<I<flag> = 1>, all solutions are returned in the form of a two-component row
  6501. vector C<[x,u]>, where C<x> is a small integer solution to the system of
  6502. congruences and C<u> is a matrix whose columns give a basis of the homogeneous
  6503. system (so that all solutions can be obtained by adding C<x> to any linear
  6504. combination of columns of C<u>). If no solution exists, returns zero.
  6505.  
  6506. X<matsolvemod0>The library syntax is B<matsolvemod0>C<(m,d,y,I<flag>)>. Also available
  6507. are C<X<gaussmodulo>B<gaussmodulo>(m,d,y)> (C<I<flag> = 0>)
  6508. and C<X<gaussmodulo2>B<gaussmodulo2>(m,d,y)> (C<I<flag> = 1>).
  6509.  
  6510. =head2 X<matsupplement>matsupplementC<(x)>
  6511.  
  6512. assuming that the columns of the matrix C<x>
  6513. are linearly independent (if they are not, an error message is issued), finds
  6514. a square invertible matrix whose first columns are the columns of C<x>,
  6515. i.e.S< >supplement the columns of C<x> to a basis of the whole space.
  6516.  
  6517. X<suppl>The library syntax is B<suppl>C<(x)>.
  6518.  
  6519. =head2 X<mattranspose>mattransposeC<(x)> or C<x~>
  6520.  
  6521. transpose of C<x>.
  6522. This has an effect only on vectors and matrices.
  6523.  
  6524. X<gtrans>The library syntax is B<gtrans>C<(x)>.
  6525.  
  6526. =head2 X<qfgaussred>qfgaussredC<(q)>
  6527.  
  6528. X<decomposition into squares>decomposition into squares of the
  6529. quadratic form represented by the symmetric matrix C<q>. The result is a
  6530. matrix whose diagonal entries are the coefficients of the squares, and the
  6531. non-diagonal entries represent the bilinear forms. More precisely, if
  6532. C<(a_{ij})> denotes the output, one has
  6533.  
  6534. S<  >C< q(x) = F<sum>_i a_{ii} (x_i + F<sum>_{j E<gt> i} a_{ij} x_j)^2 >
  6535.  
  6536. X<sqred>The library syntax is B<sqred>C<(x)>.
  6537.  
  6538. =head2 X<qfjacobi>qfjacobiC<(x)>
  6539.  
  6540. C<x> being a real symmetric matrix, this gives a
  6541. vector having two components: the first one is the vector of eigenvalues of
  6542. C<x>, the second is the corresponding orthogonal matrix of eigenvectors of
  6543. C<x>. The method used is Jacobi's method for symmetric matrices.
  6544.  
  6545. X<jacobi>The library syntax is B<jacobi>C<(x)>.
  6546.  
  6547. =head2 X<qflll>qflllC<(x,{I<flag> = 0})>
  6548.  
  6549. X<LLL>LLL algorithm applied to the
  6550. I<columns> of the (not necessarily square) matrix C<x>. The columns of C<x>
  6551. must however be linearly independent, unless specified otherwise below. The
  6552. result is a transformation matrix C<T> such that C<x.T> is an LLL-reduced
  6553. basis of the lattice generated by the column vectors of C<x>.
  6554.  
  6555. If C<I<flag> = 0> (default), the computations are done with real numbers (i.e.S< >not
  6556. with rational numbers) hence are fast but as presently programmed (version
  6557. B<2.2.0>) are numerically unstable.
  6558.  
  6559. If C<I<flag> = 1>, it is assumed that the corresponding Gram matrix is integral.
  6560. The computation is done entirely with integers and the algorithm is both
  6561. accurate and quite fast. In this case, C<x> needs not be of maximal rank, but
  6562. if it is not, C<T> will not be square.
  6563.  
  6564. If C<I<flag> = 2>, similar to case 1, except C<x> should be an integer matrix whose
  6565. columns are linearly independent. The lattice generated by the columns of
  6566. C<x> is first partially reduced before applying the LLL algorithm. [A basis
  6567. is said to be I<partially reduced> if C<|v_i F<+-> v_j| E<gt>= |v_i|> for any
  6568. two distinct basis vectors C<v_i,  v_j>.]
  6569.  
  6570. This can be significantly faster than C<I<flag> = 1> when one row is huge compared
  6571. to the other rows.
  6572.  
  6573. If C<I<flag> = 3>, all computations are done in rational numbers. This does not
  6574. incur numerical instability, but is extremely slow. This function is
  6575. essentially superseded by case 1, so will soon disappear.
  6576.  
  6577. If C<I<flag> = 4>, C<x> is assumed to have integral entries, but needs not be of
  6578. maximal rank. The result is a two-component vector of matricesS< >: the
  6579. columns of the first matrix represent a basis of the integer kernel of C<x>
  6580. (not necessarily LLL-reduced) and the second matrix is the transformation
  6581. matrix C<T> such that C<x.T> is an LLL-reduced B<I<Z>>-basis of the image
  6582. of the matrix C<x>.
  6583.  
  6584. If C<I<flag> = 5>, case as case C<4>, but C<x> may have polynomial coefficients.
  6585.  
  6586. If C<I<flag> = 7>, uses an older version of case C<0> above.
  6587.  
  6588. If C<I<flag> = 8>, same as case C<0>, where C<x> may have polynomial coefficients.
  6589.  
  6590. If C<I<flag> = 9>, variation on case C<1>, using content.
  6591.  
  6592. X<qflll0>The library syntax is B<qflll0>C<(x,I<flag>,I<prec>)>. Also available are
  6593. C<X<lll>B<lll>(x,I<prec>)> (C<I<flag> = 0>), C<X<lllint>B<lllint>(x)> (C<I<flag> = 1>), and
  6594. C<X<lllkerim>B<lllkerim>(x)> (C<I<flag> = 4>).
  6595.  
  6596. =head2 X<qflllgram>qflllgramC<(x,{I<flag> = 0})>
  6597.  
  6598. same as C<qflll> except that the
  6599. matrix C<x> which must now be a square symmetric real matrix is the Gram
  6600. matrix of the lattice vectors, and not the coordinates of the vectors
  6601. themselves. The result is again the transformation matrix C<T> which gives (as
  6602. columns) the coefficients with respect to the initial basis vectors. The
  6603. flags have more or less the same meaning, but some are missing. In brief:
  6604.  
  6605. C<I<flag> = 0>: numerically unstable in the present version B<2.2.0>.
  6606.  
  6607. C<I<flag> = 1>: C<x> has integer entries, the computations are all done in integers.
  6608.  
  6609. C<I<flag> = 4>: C<x> has integer entries, gives the kernel and reduced image.
  6610.  
  6611. C<I<flag> = 5>: same as C<4> for generic C<x>.
  6612.  
  6613. C<I<flag> = 7>: an older version of case C<0>.
  6614.  
  6615. X<qflllgram0>The library syntax is B<qflllgram0>C<(x,I<flag>,I<prec>)>. Also available are
  6616. C<X<lllgram>B<lllgram>(x,I<prec>)> (C<I<flag> = 0>), C<X<lllgramint>B<lllgramint>(x)> (C<I<flag> = 1>), and
  6617. C<X<lllgramkerim>B<lllgramkerim>(x)> (C<I<flag> = 4>).
  6618.  
  6619. =head2 X<qfminim>qfminimC<(x,b,m,{I<flag> = 0})>
  6620.  
  6621. C<x> being a square and symmetric
  6622. matrix representing a positive definite quadratic form, this function
  6623. deals with the minimal vectors of C<x>, depending on C<I<flag>>.
  6624.  
  6625. If C<I<flag> = 0> (default), seeks vectors of square norm less than or equal to C<b>
  6626. (for the norm defined by C<x>), and at most C<2m> of these vectors. The result
  6627. is a three-component vector, the first component being the number of vectors,
  6628. the second being the maximum norm found, and the last vector is a matrix
  6629. whose columns are the vectors found, only one being given for each
  6630. pair C<F<+-> v> (at most C<m> such pairs).
  6631.  
  6632. If C<I<flag> = 1>, ignores C<m> and returns the first vector whose norm is less than
  6633. C<b>.
  6634.  
  6635. In both these cases, C<x> I<is assumed to have integral entries>, and the
  6636. function searches for the minimal non-zero vectors whenever C<b = 0>.
  6637.  
  6638. If C<I<flag> = 2>, C<x> can have non integral real entries, but C<b = 0> is now
  6639. meaningless (uses Fincke-Pohst algorithm).
  6640.  
  6641. X<qfminim0>The library syntax is B<qfminim0>C<(x,b,m,I<flag>,I<prec>)>, also available are C< B<minim>(x,b,m)>X<minim>
  6642. (C<I<flag> = 0>), C< B<minim2>(x,b,m)>X<minim2> (C<I<flag> = 1>), and finally
  6643. C< B<fincke_pohst>(x,b,m,I<prec>)>X<fincke_pohst> (C<I<flag> = 2>).
  6644.  
  6645. =head2 X<qfperfection>qfperfectionC<(x)>
  6646.  
  6647. C<x> being a square and symmetric matrix with
  6648. integer entries representing a positive definite quadratic form, outputs the
  6649. perfection rank of the form. That is, gives the rank of the family of the C<s>
  6650. symmetric matrices C<v_iv_i^t>, where C<s> is half the number of minimal
  6651. vectors and the C<v_i> (C<1 E<lt>= i E<lt>= s>) are the minimal vectors.
  6652.  
  6653. As a side note to old-timers, this used to fail bluntly when C<x> had more
  6654. than C<5000> minimal vectors. Beware that the computations can now be very
  6655. lengthy when C<x> has many minimal vectors.
  6656.  
  6657. X<perf>The library syntax is B<perf>C<(x)>.
  6658.  
  6659. =head2 X<qfsign>qfsignC<(x)>
  6660.  
  6661. signature of the quadratic form represented by the
  6662. symmetric matrix C<x>. The result is a two-component vector.
  6663.  
  6664. X<signat>The library syntax is B<signat>C<(x)>.
  6665.  
  6666. =head2 X<setintersect>setintersectC<(x,y)>
  6667.  
  6668. intersection of the two sets C<x> and C<y>.
  6669.  
  6670. X<setintersect>The library syntax is B<setintersect>C<(x,y)>.
  6671.  
  6672. =head2 X<setisset>setissetC<(x)>
  6673.  
  6674. returns true (1) if C<x> is a set, false (0) if
  6675. not. In PARI, a set is simply a row vector whose entries are strictly
  6676. increasing. To convert any vector (and other objects) into a set, use the
  6677. function C<Set>.
  6678.  
  6679. X<setisset>The library syntax is B<setisset>C<(x)>, and this returns a C<long>.
  6680.  
  6681. =head2 X<setminus>setminusC<(x,y)>
  6682.  
  6683. difference of the two sets C<x> and C<y>,
  6684. i.e.S< >set of elements of C<x> which do not belong to C<y>.
  6685.  
  6686. X<setminus>The library syntax is B<setminus>C<(x,y)>.
  6687.  
  6688. =head2 X<setsearch>setsearchC<(x,y,{I<flag> = 0})>
  6689.  
  6690. searches if C<y> belongs to the set
  6691. C<x>. If it does and C<I<flag>> is zero or omitted, returns the index C<j> such that
  6692. C<x[j] = y>, otherwise returns 0. If C<I<flag>> is non-zero returns the index C<j>
  6693. where C<y> should be inserted, and C<0> if it already belongs to C<x> (this is
  6694. meant to be used in conjunction with C<listinsert>).
  6695.  
  6696. This function works also if C<x> is a I<sorted> list (see C<listsort>).
  6697.  
  6698. X<setsearch>The library syntax is B<setsearch>C<(x,y,I<flag>)> which returns a C<long>
  6699. integer.
  6700.  
  6701. =head2 X<setunion>setunionC<(x,y)>
  6702.  
  6703. union of the two sets C<x> and C<y>.
  6704.  
  6705. X<setunion>The library syntax is B<setunion>C<(x,y)>.
  6706.  
  6707. =head2 X<trace>traceC<(x)>
  6708.  
  6709. this applies to quite general C<x>. If C<x> is not a
  6710. matrix, it is equal to the sum of C<x> and its conjugate, except for polmods
  6711. where it is the trace as an algebraic number.
  6712.  
  6713. For C<x> a square matrix, it is the ordinary trace. If C<x> is a
  6714. non-square matrix (but not a vector), an error occurs.
  6715.  
  6716. X<gtrace>The library syntax is B<gtrace>C<(x)>.
  6717.  
  6718. =head2 X<vecextract>vecextractC<(x,y,{z})>
  6719.  
  6720. extraction of components of the
  6721. vector or matrix C<x> according to C<y>. In case C<x> is a matrix, its
  6722. components are as usual the I<columns> of C<x>. The parameter C<y> is a
  6723. component specifier, which is either an integer, a string describing a
  6724. range, or a vector.
  6725.  
  6726. If C<y> is an integer, it is considered as a mask: the binary bits of C<y> are
  6727. read from right to left, but correspond to taking the components from left to
  6728. right. For example, if C<y = 13 = (1101)_2> then the components 1,3 and 4 are
  6729. extracted.
  6730.  
  6731. If C<y> is a vector, which must have integer entries, these entries correspond
  6732. to the component numbers to be extracted, in the order specified.
  6733.  
  6734. If C<y> is a string, it can be 
  6735.  
  6736. C<B<*>> a single (non-zero) index giving a component number (a negative
  6737. index means we start counting from the end).
  6738.  
  6739. C<B<*>> a range of the form C<"a..b">, where C<a> and C<b> are
  6740. indexes as above. Any of C<a> and C<b> can be omitted; in this case, we take
  6741. as default values C<a = 1> and C<b = -1>, i.e.S< >the first and last components
  6742. respectively. We then extract all components in the interval C<[a,b]>, in
  6743. reverse order if C<b E<lt> a>.
  6744.  
  6745. In addition, if the first character in the string is C<^>, the
  6746. complement of the given set of indices is taken.
  6747.  
  6748. If C<z> is not omitted, C<x> must be a matrix. C<y> is then the I<line>
  6749. specifier, and C<z> the I<column> specifier, where the component specifier
  6750. is as explained above.
  6751.  
  6752.   ? v = [a, b, c, d, e];
  6753.   ? vecextract(v, 5)          \\ mask
  6754.   %1 = [a, c]
  6755.   ? vecextract(v, [4, 2, 1])  \\ component list
  6756.   %2 = [d, b, a]
  6757.   ? vecextract(v, "2..4")     \\ interval
  6758.   %3 = [b, c, d]
  6759.   ? vecextract(v, "-1..-3")   \\ interval + reverse order
  6760.   %4 = [e, d, c]
  6761.   ? vecextract([1,2,3], "^2") \\ complement
  6762.   %5 = [1, 3]
  6763.   ? vecextract(matid(3), "2..", "..")
  6764.   %6 =
  6765.   [0 1 0]
  6766.  
  6767.   [0 0 1]
  6768.  
  6769. X<extract>The library syntax is B<extract>C<(x,y)> or C<X<matextract>B<matextract>(x,y,z)>.
  6770.  
  6771. =head2 X<vecsort>vecsortC<(x,{k},{I<flag> = 0})>
  6772.  
  6773. sorts the vector C<x> in ascending
  6774. order, using the heapsort method. C<x> must be a vector, and its components
  6775. integers, reals, or fractions.
  6776.  
  6777. If C<k> is present and is an integer, sorts according to the value of the
  6778. C<k>-th subcomponents of the components ofS< >C<x>. C<k> can also be a vector,
  6779. in which case the
  6780. sorting is done lexicographically according to the components listed in the
  6781. vector C<k>. For example, if C<k = [2,1,3]>, sorting will be done with respect
  6782. to the second component, and when these are equal, with respect to the
  6783. first, and when these are equal, with respect to the third.
  6784.  
  6785. The binary digits of I<flag> mean:
  6786.  
  6787. C<B<*>> 1: indirect sorting of the vector C<x>, i.e.S< >if C<x> is an
  6788. C<n>-component vector, returns a permutation of C<[1,2,...,n]> which
  6789. applied to the components of C<x> sorts C<x> in increasing order.
  6790. For example, C<vecextract(x, vecsort(x,,1))> is equivalent to
  6791. C<vecsort(x)>.
  6792.  
  6793. C<B<*>> 2: sorts C<x> by ascending lexicographic order (as per the
  6794. C<lex> comparison function).
  6795.  
  6796. C<B<*>> 4: use decreasing instead of ascending order.
  6797.  
  6798. X<vecsort0>The library syntax is B<vecsort0>C<(x,k,flag)>. To omit C<k>, use C<NULL> instead. You can also
  6799. use the simpler functions
  6800.  
  6801. C<X<sort>B<sort>(x)> ( = C<vecsort0(x,NULL,0)>).
  6802.  
  6803. C<X<indexsort>B<indexsort>(x)> ( = C<vecsort0(x,NULL,1)>).
  6804.  
  6805. C<X<lexsort>B<lexsort>(x)> ( = C<vecsort0(x,NULL,2)>).
  6806.  
  6807. Also available are X<sindexsort>B<sindexsort> and X<sindexlexsort>B<sindexlexsort> which return a
  6808. vector of C-long integers (private type C<t_VECSMALL>) C<v>, where
  6809. C<v[1]...v[n]> contain the indices. Note that the resulting C<v> is
  6810. I<not> a generic PARI object, but is in general easier to use in C
  6811. programs!
  6812.  
  6813. =head2 X<vector>vectorC<(n,{X},{I<expr> = 0})>
  6814.  
  6815. creates a row vector (type
  6816. C<t_VEC>) with C<n> components whose components are the expression
  6817. I<expr> evaluated at the integer points between 1 and C<n>. If one of the
  6818. last two arguments is omitted, fill the vector with zeroes.
  6819.  
  6820. X<vecteur>The library syntax is B<vecteur>C<(GEN nmax, entree *ep, char *expr)>.
  6821.  
  6822. =head2 X<vectorv>vectorvC<(n,X,I<expr>)>
  6823.  
  6824. as X<vector>B<vector>, but returns a
  6825. column vector (type C<t_COL>).
  6826.  
  6827. X<vvecteur>The library syntax is B<vvecteur>C<(GEN nmax, entree *ep, char *expr)>.
  6828.  
  6829. =head1 Sums, products, integrals and similar functions
  6830.  
  6831. X<Label se:sums>
  6832. Although the GP calculator is programmable, it is useful to have
  6833. preprogrammed a number of loops, including sums, products, and a certain
  6834. number of recursions. Also, a number of functions from numerical analysis
  6835. like numerical integration and summation of series will be described here.
  6836.  
  6837. One of the parameters in these loops must be the control variable, hence a
  6838. simple variable name. The last parameter can be any legal PARI expression,
  6839. including of course expressions using loops. Since it is much easier to
  6840. program directly the loops in library mode, these functions are mainly
  6841. useful for GP programming. The use of these functions in library mode is a
  6842. little tricky and its explanation will be mostly omitted, although the
  6843. reader can try and figure it out by himself by checking the example given
  6844. for the X<sum>C<sum> function. In this section we only give the library
  6845. syntax, with no semantic explanation.
  6846.  
  6847. The letter C<X> will always denote any simple variable name, and represents
  6848. the formal parameter used in the function.
  6849.  
  6850. B<(numerical) integration>:X<numerical integration> A number
  6851. of Romberg-like integration methods are implemented (see C<intnum> as
  6852. opposed to C<intformal> which we already described). The user should not
  6853. require too much accuracy: 18 or 28 decimal digits is OK, but not much more.
  6854. In addition, analytical cleanup of the integral must have been done: there
  6855. must be no singularities in the interval or at the boundaries. In practice
  6856. this can be accomplished with a simple change of variable. Furthermore, for
  6857. improper integrals, where one or both of the limits of integration are plus
  6858. or minus infinity, the function must decrease sufficiently rapidly at
  6859. infinity. This can often be accomplished through integration by parts. 
  6860. Finally, the function to be integrated should not be very small
  6861. (compared to the current precision) on the entire interval. This can
  6862. of course be accomplished by just multiplying by an appropriate
  6863. constant.
  6864.  
  6865. Note that X<infinity>infinity can be represented with essentially no loss of
  6866. accuracy by 1e4000. However beware of real underflow when dealing with
  6867. rapidly decreasing functions. For example, if one wants to compute the
  6868. C<F<int>_0^ oo e^{-x^2}dx> to 28 decimal digits, then one should set
  6869. infinity equal to 10 for example, and certainly not to 1e4000.
  6870.  
  6871. The integrand may have values belonging to a vector space over the real
  6872. numbers; in particular, it can be complex-valued or vector-valued.
  6873.  
  6874. See also the discrete summation methods below (sharing the prefix C<sum>).
  6875.  
  6876. =head2 X<intnum>intnumC<(X = a,b,I<expr>,{I<flag> = 0})>
  6877.  
  6878. numerical integration of
  6879. I<expr> (smooth in C<]a,b[>), with respect to C<X>.
  6880.  
  6881. Set C<I<flag> = 0> (or omit it altogether) when C<a> and C<b> are not too large, the
  6882. function is smooth, and can be evaluated exactly everywhere on the interval
  6883. C<[a,b]>.
  6884.  
  6885. If C<I<flag> = 1>, uses a general driver routine for doing numerical integration,
  6886. making no particular assumption (slow).
  6887.  
  6888. C<I<flag> = 2> is tailored for being used when C<a> or C<b> are infinite. One
  6889. I<must> have C<ab E<gt> 0>, and in fact if for example C<b = + oo >, then it is
  6890. preferable to have C<a> as large as possible, at least C<a E<gt>= 1>.
  6891.  
  6892. If C<I<flag> = 3>, the function is allowed to be undefined (but continuous) at C<a>
  6893. or C<b>, for example the function C< F<sin> (x)/x> at C<x = 0>.
  6894.  
  6895. X<intnum0>The library syntax is B<intnum0>C<(entree*e,GEN a,GEN b,char*expr,long I<flag>,long prec)>.
  6896.  
  6897. =head2 X<prod>prodC<(X = a,b,I<expr>,{x = 1})>
  6898.  
  6899. product of expression I<expr>,
  6900. initialized at C<x>, the formal parameter C<X> going from C<a> to C<b>. As for
  6901. C<sum>, the main purpose of the initialization parameter C<x> is to force
  6902. the type of the operations being performed. For example if it is set equal to
  6903. the integer 1, operations will start being done exactly. If it is set equal
  6904. to the real C<1.>, they will be done using real numbers having the default
  6905. precision. If it is set equal to the power series C<1+O(X^k)> for a certain
  6906. C<k>, they will be done using power series of precision at most C<k>. These
  6907. are the three most common initializations.
  6908.  
  6909. As an extreme example, compare
  6910.  
  6911.   ? prod(i=1, 100, 1 - X^i);  \\ this has degree 5050 !!
  6912.   time = 3,335 ms.
  6913.   ? prod(i=1, 100, 1 - X^i, 1 + O(X^101))
  6914.   time = 43 ms.
  6915.   %2 = 1 - X - X^2 + X^5 + X^7 - X^12 - X^15 + X^22 + X^26 - X^35 - X^40 + \
  6916.     X^51 + X^57 - X^70 - X^77 + X^92 + X^100 + O(X^101)
  6917.  
  6918. X<produit>The library syntax is B<produit>C<(entree *ep, GEN a, GEN b, char *expr, GEN x)>.
  6919.  
  6920. =head2 X<prodeuler>prodeulerC<(X = a,b,I<expr>)>
  6921.  
  6922. product of expression I<expr>,
  6923. initialized at 1. (i.e.S< >to a I<real> number equal to 1 to the current
  6924. C<realprecision>), the formal parameter C<X> ranging over the prime numbers
  6925. between C<a> and C<b>.X<Euler product>
  6926.  
  6927. X<prodeuler>The library syntax is B<prodeuler>C<(entree *ep, GEN a, GEN b, char *expr, long prec)>.
  6928.  
  6929. =head2 X<prodinf>prodinfC<(X = a,I<expr>,{I<flag> = 0})>
  6930.  
  6931. X<infinite product>infinite product of
  6932. expression I<expr>, the formal parameter C<X> starting at C<a>. The evaluation
  6933. stops when the relative error of the expression minus 1 is less than the
  6934. default precision. The expressions must always evaluate to an element of
  6935. B<I<C>>.
  6936.  
  6937. If C<I<flag> = 1>, do the product of the (C<1+I<expr>>) instead.
  6938.  
  6939. X<prodinf>The library syntax is B<prodinf>C<(entree *ep, GEN a, char *expr, long prec)> (C<I<flag> = 0>), or
  6940. X<prodinf1>B<prodinf1> with the same arguments (C<I<flag> = 1>).
  6941.  
  6942. =head2 X<solve>solveC<(X = a,b,I<expr>)>
  6943.  
  6944. find a real root of expression
  6945. I<expr> between C<a> and C<b>, under the condition 
  6946. C<I<expr>(X = a) * I<expr>(X = b) E<lt>= 0>.
  6947. This routine uses Brent's method and can fail miserably if I<expr> is
  6948. not defined in the whole of C<[a,b]> (try C<solve(x = 1, 2, tan(x)>).
  6949.  
  6950. X<zbrent>The library syntax is B<zbrent>C<(entree *ep, GEN a, GEN b, char *expr, long prec)>.
  6951.  
  6952. =head2 X<sum>sumC<(X = a,b,I<expr>,{x = 0})>
  6953.  
  6954. sum of expression I<expr>,
  6955. initialized at C<x>, the formal parameter going from C<a> to C<b>. As for
  6956. C<prod>, the initialization parameter C<x> may be given to force the type
  6957. of the operations being performed.
  6958.  
  6959. As an extreme example, compare
  6960.  
  6961.   ? sum(i=1, 5000, 1/i); \\ rational number: denominator has 2166 digits.
  6962.   time = 1,241 ms.
  6963.   ? sum(i=1, 5000, 1/i, 0.)
  6964.   time = 158 ms.
  6965.   %2 = 9.094508852984436967261245533
  6966.  
  6967. X<somme>The library syntax is B<somme>C<(entree *ep, GEN a, GEN b, char *expr, GEN x)>. This is to be
  6968. used as follows: C<ep> represents the dummy variable used in the
  6969. expression C<expr>
  6970.  
  6971.   /* compute a^2 + ... + b^2 */
  6972.   {
  6973.     /* define the dummy variable "i" */
  6974.     entree *ep = is_entry("i");
  6975.     /* sum for a <= i <= b */
  6976.     return somme(ep, a, b, "i^2", gzero);
  6977.   }
  6978.  
  6979. =head2 X<sumalt>sumaltC<(X = a,I<expr>,{I<flag> = 0})>
  6980.  
  6981. numerical summation of the
  6982. series I<expr>, which should be an X<alternating series>alternating series, the formal
  6983. variable C<X> starting at C<a>.
  6984.  
  6985. If C<I<flag> = 0>, use an algorithm of F.S< >Villegas as modified by D.S< >Zagier. This
  6986. is much better than X<Euler>Euler-Van Wijngaarden's method which was used
  6987. formerly.
  6988. Beware that the stopping criterion is that the term gets small enough, hence
  6989. terms which are equal to 0 will create problems and should be removed.
  6990.  
  6991. If C<I<flag> = 1>, use a variant with slightly different polynomials. Sometimes
  6992. faster.
  6993.  
  6994. Divergent alternating series can sometimes be summed by this method, as well
  6995. as series which are not exactly alternating (see for example
  6996. L<Label se:user_defined>).
  6997.  
  6998. B<Important hint:> a significant speed gain can be obtained by
  6999. writing the C<(-1)^X> which may occur in the expression as
  7000. C<(1.S< >- X%2*2)>.
  7001.  
  7002. X<sumalt>The library syntax is B<sumalt>C<(entree *ep, GEN a, char *expr, long I<flag>, long prec)>.
  7003.  
  7004. =head2 X<sumdiv>sumdivC<(n,X,I<expr>)>
  7005.  
  7006. sum of expression I<expr> over
  7007. the positive divisors of C<n>.
  7008.  
  7009. Arithmetic functions like X<sigma>B<sigma> use the multiplicativity of the
  7010. underlying expression to speed up the computation. In the present version
  7011. B<2.2.0>, there is no way to indicate that I<expr> is multiplicative in
  7012. C<n>, hence specialized functions should be prefered whenever possible.
  7013.  
  7014. X<divsum>The library syntax is B<divsum>C<(entree *ep, GEN num, char *expr)>.
  7015.  
  7016. =head2 X<suminf>suminfC<(X = a,I<expr>)>
  7017.  
  7018. X<infinite sum>infinite sum of expression
  7019. I<expr>, the formal parameter C<X> starting at C<a>. The evaluation stops
  7020. when the relative error of the expression is less than the default precision.
  7021. The expressions must always evaluate to a complex number.
  7022.  
  7023. X<suminf>The library syntax is B<suminf>C<(entree *ep, GEN a, char *expr, long prec)>.
  7024.  
  7025. =head2 X<sumpos>sumposC<(X = a,I<expr>,{I<flag> = 0})>
  7026.  
  7027. numerical summation of the
  7028. series I<expr>, which must be a series of terms having the same sign,
  7029. the formal
  7030. variable C<X> starting at C<a>. The algorithm used is Van Wijngaarden's trick
  7031. for converting such a series into an alternating one, and is quite slow.
  7032. Beware that the stopping criterion is that the term gets small enough, hence
  7033. terms which are equal to 0 will create problems and should be removed.
  7034.  
  7035. If C<I<flag> = 1>, use slightly different polynomials. Sometimes faster.
  7036.  
  7037. X<sumpos>The library syntax is B<sumpos>C<(entree *ep, GEN a, char *expr, long I<flag>, long prec)>.
  7038.  
  7039. =head1 Plotting functions
  7040.  
  7041. Although plotting is not even a side purpose of PARI, a number of plotting
  7042. functions are provided. Moreover, a lot of people felt like suggesting
  7043. ideas or submitting huge patches for this section of the code. Among these,
  7044. special thanks go to Klaus-Peter Nischke who suggested the recursive plotting
  7045. and the forking/resizing stuff under X11, and Ilya Zakharevich who
  7046. undertook a complete rewrite of the graphic code, so that most of it is now
  7047. platform-independent and should be relatively easy to port or expand.
  7048.  
  7049. These graphic functions are either
  7050.  
  7051. C<B<*>> high-level plotting functions (all the functions starting with
  7052. C<ploth>) in which the user has little to do but explain what type of plot
  7053. he wants, and whose syntax is similar to the one used in the preceding
  7054. section (with somewhat more complicated flags).
  7055.  
  7056. C<B<*>> low-level plotting functions, where every drawing primitive (point,
  7057. line, box, etc.) must be specified by the user. These low-level functions
  7058. (called I<rectplot> functions, sharing the prefix C<plot>) work as
  7059. follows. You have at your disposal 16 virtual windows which are filled
  7060. independently, and can then be physically ORed on a single window at
  7061. user-defined positions. These windows are numbered from 0 to 15, and must be
  7062. initialized before being used by the function C<plotinit>, which specifies
  7063. the height and width of the virtual window (called a I<rectwindow> in the
  7064. sequel). At all times, a virtual cursor (initialized at C<[0,0]>) is
  7065. associated to the window, and its current value can be obtained using the
  7066. function C<plotcursor>.
  7067.  
  7068. A number of primitive graphic objects (called I<rect> objects) can then
  7069. be drawn in these windows, using a default color associated to that window
  7070. (which can be changed under X11, using the C<plotcolor> function, black
  7071. otherwise) and only the part of the object which is inside the window will be
  7072. drawn, with the exception of polygons and strings which are drawn entirely
  7073. (but the virtual cursor can move outside of the window). The ones sharing the
  7074. prefix C<plotr> draw relatively to the current position of the virtual
  7075. cursor, the others use absolute coordinates. Those having the prefix
  7076. C<plotrecth> put in the rectwindow a large batch of rect objects
  7077. corresponding to the output of the related C<ploth> function.
  7078.  
  7079. Finally, the actual physical drawing is done using the function
  7080. C<plotdraw>. Note that the windows are preserved so that further drawings
  7081. using the same windows at different positions or different windows can be
  7082. done without extra work. If you want to erase a window (and free the
  7083. corresponding memory), use the function C<plotkill>. It is not possible to
  7084. partially erase a window. Erase it completely, initialize it again and then
  7085. fill it with the graphic objects that you want to keep.
  7086.  
  7087. In addition to initializing the window, you may want to have a scaled
  7088. window to avoid unnecessary conversions. For this, use the function
  7089. C<plotscale> below. As long as this function is not called, the scaling is
  7090. simply the number of pixels, the origin being at the upper left and the
  7091. C<y>-coordinates going downwards.
  7092.  
  7093. Note that in the present version B<2.2.0> all these plotting functions
  7094. (both low and high level) have been written for the X11-window system
  7095. (hence also for GUI's based on X11 such as Openwindows and Motif) only,
  7096. though very little code remains which is actually platform-dependent. A
  7097. Suntools/Sunview, Macintosh, and an Atari/Gem port were provided for
  7098. previous versions. These I<may> be adapted in future releases.
  7099.  
  7100. Under X11/Suntools, the physical window (opened by C<plotdraw> or any
  7101. of the C<ploth*> functions) is completely separated from GP (technically,
  7102. a C<fork> is done, and the non-graphical memory is immediately freed in
  7103. the child process), which means you can go on working in the current GP
  7104. session, without having to kill the window first. Under X11, this window can
  7105. be closed, enlarged or reduced using the standard window manager functions.
  7106. No zooming procedure is implemented though (yet).
  7107.  
  7108. C<B<*>> Finally, note that in the same way that C<printtex> allows you
  7109. to have a TeX output corresponding to printed results, the functions
  7110. starting with C<ps> allow you to have X<PostScript>C<PostScript> output of the
  7111. plots. This will not be absolutely identical with the screen output, but will
  7112. be sufficiently close. Note that you can use PostScript output even if you do
  7113. not have the plotting routines enabled. The PostScript output is written in a
  7114. file whose name is derived from the X<psfile>C<psfile> default (C<./pari.ps> if
  7115. you did not tamper with it). Each time a new PostScript output is asked for,
  7116. the PostScript output is appended to that file. Hence the user must remove
  7117. this file, or change the value of C<psfile>, first if he does not want
  7118. unnecessary drawings from preceding sessions to appear. On the other hand, in
  7119. this manner as many plots as desired can be kept in a single file. 
  7120.  
  7121. I<None of the graphic functions are available within the PARI library, you
  7122. must be under GP to use them>. The reason for that is that you really should
  7123. not use PARI for heavy-duty graphical work, there are much better specialized
  7124. alternatives around. This whole set of routines was only meant as a
  7125. convenient, but simple-minded, visual aid. If you really insist on using
  7126. these in your program (we warned you), the source (C<plot*.c>) should be
  7127. readable enough for you to achieve something.
  7128.  
  7129. =head2 X<plot>plotC<(X = a,b,I<expr>,{I<Ymin>},{I<Ymax>})>
  7130.  
  7131. crude
  7132. (ASCII) plot of the function represented by expression I<expr> from
  7133. C<a> to C<b>, with I<Y> ranging from I<Ymin> to I<Ymax>. If
  7134. I<Ymin> (resp. I<Ymax>) is not given, the minima (resp. the
  7135. maxima) of the computed values of the expression is used instead.
  7136.  
  7137. =head2 X<plotbox>plotboxC<(w,x2,y2)>
  7138.  
  7139. let C<(x1,y1)> be the current position of the
  7140. virtual cursor. Draw in the rectwindow C<w> the outline of the rectangle which
  7141. is such that the points C<(x1,y1)> and C<(x2,y2)> are opposite corners. Only
  7142. the part of the rectangle which is in C<w> is drawn. The virtual cursor does
  7143. I<not> move.
  7144.  
  7145. =head2 X<plotclip>plotclipC<(w)>
  7146.  
  7147. `clips' the content of rectwindow C<w>, i.e
  7148. remove all parts of the drawing that would not be visible on the screen.
  7149. Together with X<plotcopy>C<plotcopy> this function enables you to draw on a
  7150. scratchpad before commiting the part you're interested in to the final
  7151. picture.
  7152.  
  7153. =head2 X<plotcolor>plotcolorC<(w,c)>
  7154.  
  7155. set default color to C<c> in rectwindow C<w>.
  7156. In present version B<2.2.0>, this is only implemented for X11 window system,
  7157. and you only have the following palette to choose from:
  7158.  
  7159. 1 = black, 2 = blue, 3 = sienna, 4 = red, 5 = cornsilk, 6 = grey, 7 = gainsborough.
  7160.  
  7161. Note that it should be fairly easy for you to hardwire some more colors by
  7162. tweaking the files C<rect.h> and C<plotX.c>. User-defined
  7163. colormaps would be nice, and I<may> be available in future versions.
  7164.  
  7165. =head2 X<plotcopy>plotcopyC<(w1,w2,dx,dy)>
  7166.  
  7167. copy the contents of rectwindow
  7168. C<w1> to rectwindow C<w2>, with offset C<(dx,dy)>.
  7169.  
  7170. =head2 X<plotcursor>plotcursorC<(w)>
  7171.  
  7172. give as a 2-component vector the current
  7173. (scaled) position of the virtual cursor corresponding to the rectwindow C<w>.
  7174.  
  7175. =head2 X<plotdraw>plotdrawC<(list)>
  7176.  
  7177. physically draw the rectwindows given in C<list>
  7178. which must be a vector whose number of components is divisible by 3. If
  7179. C<list = [w1,x1,y1,w2,x2,y2,...]>, the windows C<w1>, C<w2>, etc.S< >are
  7180. physically placed with their upper left corner at physical position
  7181. C<(x1,y1)>, C<(x2,y2)>,...respectively, and are then drawn together.
  7182. Overlapping regions will thus be drawn twice, and the windows are considered
  7183. transparent. Then display the whole drawing in a special window on your
  7184. screen.
  7185.  
  7186. =head2 X<plotfile>plotfileC<(s)>
  7187.  
  7188. set the output file for plotting output. Special
  7189. filename C<-> redirects to the same place as PARI output.
  7190.  
  7191. =head2 X<ploth>plothC<(X = a,b,I<expr>,{I<flag> = 0},{n = 0})>
  7192.  
  7193. high precision
  7194. plot of the function C<y = f(x)> represented by the expression I<expr>, C<x>
  7195. going from C<a> to C<b>. This opens a specific window (which is killed
  7196. whenever you click on it), and returns a four-component vector giving the
  7197. coordinates of the bounding box in the form
  7198. C<[I<xmin>,I<xmax>,I<ymin>,I<ymax>]>.
  7199.  
  7200. B<Important note>: Since this may involve a lot of function calls,
  7201. it is advised to keep the current precision to a minimum (e.g.S< >9) before
  7202. calling this function.
  7203.  
  7204. C<n> specifies the number of reference point on the graph (0 means use the
  7205. hardwired default values, that is: 1000 for general plot, 1500 for
  7206. parametric plot, and 15 for recursive plot).
  7207.  
  7208. If no C<I<flag>> is given, I<expr> is either a scalar expression C<f(X)>, in which
  7209. case the plane curve C<y = f(X)> will be drawn, or a vector
  7210. C<[f_1(X),...,f_k(X)]>, and then all the curves C<y = f_i(X)> will be drawn in
  7211. the same window.
  7212.  
  7213. The binary digits of C<I<flag>> mean:
  7214.  
  7215. C<B<*>> 1: X<parametric plot>I<parametric plot>. Here I<expr> must be a vector with
  7216. an even number of components. Successive pairs are then understood as the
  7217. parametric coordinates of a plane curve. Each of these are then drawn.
  7218.  
  7219. For instance:
  7220.  
  7221. C<ploth(X = 0,2*Pi,[sin(X),cos(X)],1)> will draw a circle.
  7222.  
  7223. C<ploth(X = 0,2*Pi,[sin(X),cos(X)])> will draw two entwined sinusoidal
  7224. curves.
  7225.  
  7226. C<ploth(X = 0,2*Pi,[X,X,sin(X),cos(X)],1)> will draw a circle and the line
  7227. C<y = x>.
  7228.  
  7229. C<B<*>> 2: X<recursive plot>I<recursive plot>. If this flag is set, only I<one>
  7230. curve can be drawn at time, i.e.S< >I<expr> must be either a two-component
  7231. vector (for a single parametric curve, and the parametric flag I<has> to
  7232. be set), or a scalar function. The idea is to choose pairs of successive
  7233. reference points, and if their middle point is not too far away from the
  7234. segment joining them, draw this as a local approximation to the curve.
  7235. Otherwise, add the middle point to the reference points. This is very fast,
  7236. and usually more precise than usual plot. Compare the results of
  7237.  
  7238. S<  >C<ploth(X = -1,1,sin(1/X),2)  and  ploth(X = -1,1,sin(1/X))>
  7239.  
  7240. for instance. But beware that if you are extremely unlucky, or choose too few
  7241. reference points, you may draw some nice polygon bearing little resemblance
  7242. to the original curve. For instance you should I<never> plot recursively 
  7243. an odd function in a symmetric interval around 0. Try
  7244.  
  7245.     ploth(x = -20, 20, sin(x), 2)
  7246.  
  7247. to see why. Hence, it's usually a good idea to try and plot the same
  7248. curve with slightly different parameters.
  7249.  
  7250. The other values toggle various display options:
  7251.  
  7252. C<B<*>> 4: do not rescale plot according to the computed extrema. This is
  7253. meant to be used when graphing multiple functions on a rectwindow (as a
  7254. X<plotrecth>C<plotrecth> call), in conjuction with X<plotscale>C<plotscale>.
  7255.  
  7256. C<B<*>> 8: do not print the C<x>-axis.
  7257.  
  7258. C<B<*>> 16: do not print the C<y>-axis.
  7259.  
  7260. C<B<*>> 32: do not print frame.
  7261.  
  7262. C<B<*>> 64: only plot reference points, do not join them.
  7263.  
  7264. C<B<*>> 256: use splines to interpolate the points.
  7265.  
  7266. C<B<*>> 512: plot no C<x>-ticks.
  7267.  
  7268. C<B<*>> 1024: plot no C<y>-ticks.
  7269.  
  7270. C<B<*>> 2048: plot all ticks with the same length.
  7271.  
  7272. =head2 X<plothraw>plothrawC<(I<listx>,I<listy>,{I<flag> = 0})>
  7273.  
  7274. given
  7275. I<listx> and I<listy> two vectors of equal length, plots (in high
  7276. precision) the points whose C<(x,y)>-coordinates are given in I<listx>
  7277. and I<listy>. Automatic positioning and scaling is done, but with the
  7278. same scaling factor on C<x> and C<y>. If C<I<flag>> is 1, join points, other non-0
  7279. flags toggle display options and should be combinations of bits C<2^k>, C<k
  7280.  E<gt>= 3> as in C<ploth>.
  7281.  
  7282. =head2 X<plothsizes>plothsizesC<()>
  7283.  
  7284. return data corresponding to the output window
  7285. in the form of a 6-component vector: window width and height, sizes for ticks
  7286. in horizontal and vertical directions (this is intended for the C<gnuplot>
  7287. interface and is currently not significant), width and height of characters.
  7288.  
  7289. =head2 X<plotinit>plotinitC<(w,x,y)>
  7290.  
  7291. initialize the rectwindow C<w> to width C<x> and
  7292. height C<y>, and position the virtual cursor at C<(0,0)>. This destroys any rect
  7293. objects you may have already drawn in C<w>. 
  7294.  
  7295. The plotting device imposes an upper bound for C<x> and C<y>, for instance the
  7296. number of pixels for screen output. These bounds are available through the
  7297. X<plothsizes>C<plothsizes> function. The following sequence initializes in a portable way
  7298. (i.e independant of the output device) a window of maximal size, accessed through
  7299. coordinates in the C<[0,1000]  x [0,1000]> rangeS< >:
  7300.  
  7301.   s = plothsizes();
  7302.   plotinit(0, s[1]-1, s[2]-1);
  7303.   plotscale(0, 0,1000, 0,1000);
  7304.  
  7305. =head2 X<plotkill>plotkillC<(w)>
  7306.  
  7307. erase rectwindow C<w> and free the corresponding
  7308. memory. Note that if you want to use the rectwindow C<w> again, you have to
  7309. use C<initrect> first to specify the new size. So it's better in this case
  7310. to use C<initrect> directly as this throws away any previous work in the
  7311. given rectwindow.
  7312.  
  7313. =head2 X<plotlines>plotlinesC<(w,X,Y,{I<flag> = 0})>
  7314.  
  7315. draw on the rectwindow C<w>
  7316. the polygon such that the (x,y)-coordinates of the vertices are in the
  7317. vectors of equal length C<X> and C<Y>. For simplicity, the whole
  7318. polygon is drawn, not only the part of the polygon which is inside the
  7319. rectwindow. If C<I<flag>> is non-zero, close the polygon. In any case, the
  7320. virtual cursor does not move.
  7321.  
  7322. C<X> and C<Y> are allowed to be scalars (in this case, both have to).
  7323. There, a single segment will be drawn, between the virtual cursor current
  7324. position and the point C<(X,Y)>. And only the part thereof which
  7325. actually lies within the boundary of C<w>. Then I<move> the virtual cursor
  7326. to C<(X,Y)>, even if it is outside the window. If you want to draw a
  7327. line from C<(x1,y1)> to C<(x2,y2)> where C<(x1,y1)> is not necessarily the
  7328. position of the virtual cursor, use C<plotmove(w,x1,y1)> before using this
  7329. function.
  7330.  
  7331. =head2 X<plotlinetype>plotlinetypeC<(w,I<type>)>
  7332.  
  7333. change the type of lines
  7334. subsequently plotted in rectwindow C<w>. I<type> C<-2> corresponds to
  7335. frames, C<-1> to axes, larger values may correspond to something else. C<w = 
  7336. -1> changes highlevel plotting. This is only taken into account by the
  7337. C<gnuplot> interface.
  7338.  
  7339. =head2 X<plotmove>plotmoveC<(w,x,y)>
  7340.  
  7341. move the virtual cursor of the rectwindow C<w>
  7342. to position C<(x,y)>.
  7343.  
  7344. =head2 X<plotpoints>plotpointsC<(w,X,Y)>
  7345.  
  7346. draw on the rectwindow C<w> the
  7347. points whose C<(x,y)>-coordinates are in the vectors of equal length C<X> and
  7348. C<Y> and which are inside C<w>. The virtual cursor does I<not> move. This
  7349. is basically the same function as C<plothraw>, but either with no scaling
  7350. factor or with a scale chosen using the function C<plotscale>.
  7351.  
  7352. As was the case with the C<plotlines> function, C<X> and C<Y> are allowed to
  7353. be (simultaneously) scalar. In this case, draw the single point C<(X,Y)> on
  7354. the rectwindow C<w> (if it is actually inside C<w>), and in any case
  7355. I<move> the virtual cursor to position C<(x,y)>.
  7356.  
  7357. =head2 X<plotpointsize>plotpointsizeC<(w,size)>
  7358.  
  7359. changes the ``size'' of following
  7360. points in rectwindow C<w>. If C<w = -1>, change it in all rectwindows.
  7361. This only works in the C<gnuplot> interface.
  7362.  
  7363. =head2 X<plotpointtype>plotpointtypeC<(w,I<type>)>
  7364.  
  7365. change the type of
  7366. points subsequently plotted in rectwindow C<w>. C<I<type> = -1>
  7367. corresponds to a dot, larger values may correspond to something else. C<w = -1>
  7368. changes highlevel plotting. This is only taken into account by the
  7369. C<gnuplot> interface.
  7370.  
  7371. =head2 X<plotrbox>plotrboxC<(w,dx,dy)>
  7372.  
  7373. draw in the rectwindow C<w> the outline of
  7374. the rectangle which is such that the points C<(x1,y1)> and C<(x1+dx,y1+dy)> are
  7375. opposite corners, where C<(x1,y1)> is the current position of the cursor.
  7376. Only the part of the rectangle which is in C<w> is drawn. The virtual cursor
  7377. does I<not> move.
  7378.  
  7379. =head2 X<plotrecth>plotrecthC<(w,X = a,b,I<expr>,{I<flag> = 0},{n = 0})>
  7380.  
  7381. writes to
  7382. rectwindow C<w> the curve output of C<ploth>C<(w,X = a,b,I<expr>,I<flag>,n)>.
  7383.  
  7384. =head2 X<plotrecthraw>plotrecthrawC<(w,I<data>,{I<flag> = 0})>
  7385.  
  7386. plot graph(s) for
  7387. I<data> in rectwindow C<w>. C<I<flag>> has the same significance here as in
  7388. C<ploth>, though recursive plot is no more significant.
  7389.  
  7390. I<data> is a vector of vectors, each corresponding to a list a coordinates.
  7391. If parametric plot is set, there must be an even number of vectors, each
  7392. successive pair corresponding to a curve. Otherwise, the first one containe
  7393. the C<x> coordinates, and the other ones contain the C<y>-coordinates
  7394. of curves to plot.
  7395.  
  7396. =head2 X<plotrline>plotrlineC<(w,dx,dy)>
  7397.  
  7398. draw in the rectwindow C<w> the part of the
  7399. segment C<(x1,y1)-(x1+dx,y1+dy)> which is inside C<w>, where C<(x1,y1)> is the
  7400. current position of the virtual cursor, and move the virtual cursor to
  7401. C<(x1+dx,y1+dy)> (even if it is outside the window).
  7402.  
  7403. =head2 X<plotrmove>plotrmoveC<(w,dx,dy)>
  7404.  
  7405. move the virtual cursor of the rectwindow
  7406. C<w> to position C<(x1+dx,y1+dy)>, where C<(x1,y1)> is the initial position of
  7407. the cursor (i.e.S< >to position C<(dx,dy)> relative to the initial cursor).
  7408.  
  7409. =head2 X<plotrpoint>plotrpointC<(w,dx,dy)>
  7410.  
  7411. draw the point C<(x1+dx,y1+dy)> on the
  7412. rectwindow C<w> (if it is inside C<w>), where C<(x1,y1)> is the current position
  7413. of the cursor, and in any case move the virtual cursor to position
  7414. C<(x1+dx,y1+dy)>.
  7415.  
  7416. =head2 X<plotscale>plotscaleC<(w,x1,x2,y1,y2)>
  7417.  
  7418. scale the local coordinates of the
  7419. rectwindow C<w> so that C<x> goes from C<x1> to C<x2> and C<y> goes from C<y1> to
  7420. C<y2> (C<x2 E<lt> x1> and C<y2 E<lt> y1> being allowed). Initially, after the initialization
  7421. of the rectwindow C<w> using the function C<plotinit>, the default scaling
  7422. is the graphic pixel count, and in particular the C<y> axis is oriented
  7423. downwards since the origin is at the upper left. The function C<plotscale>
  7424. allows to change all these defaults and should be used whenever functions are
  7425. graphed.
  7426.  
  7427. =head2 X<plotstring>plotstringC<(w,x,{I<flag> = 0})>
  7428.  
  7429. draw on the rectwindow C<w> the
  7430. String C<x> (see L<Label se:strings>), at the current position of the cursor.
  7431.  
  7432. I<flag> is used for justification: bits 1 and 2 regulate horizontal alignment:
  7433. left if 0, right if 2, center if 1. Bits 4 and 8 regulate vertical
  7434. alignment: bottom if 0, top if 8, v-center if 4. Can insert additional
  7435. small gap between point and string: horizontal if bit 16 is set, vertical
  7436. if bit 32 is set (see the tutorial for an example).
  7437.  
  7438. =head2 X<plotterm>plottermC<(I<term>)>
  7439.  
  7440. sets terminal where high resolution
  7441. plots go (this is currently only taken into account by the C<gnuplot>
  7442. graphical driver). Using the C<gnuplot> driver, possible terminals are
  7443. the same as in gnuplot. If I<term> is "?", lists possible values. 
  7444.  
  7445. Terminal options can be appended to the terminal name and space; terminal
  7446. size can be put immediately after the name, as in C<"gif = 300,200">.
  7447. Positive return value means success.
  7448.  
  7449. =head2 X<psdraw>psdrawC<(I<list>)>
  7450.  
  7451. same as C<plotdraw>, except that the
  7452. output is a PostScript program appended to the C<psfile>.
  7453.  
  7454. =head2 X<psploth>psplothC<(X = a,b,I<expr>)>
  7455.  
  7456. same as C<ploth>, except that the
  7457. output is a PostScript program appended to the C<psfile>.
  7458.  
  7459. =head2 X<psplothraw>psplothrawC<(I<listx>,I<listy>)>
  7460.  
  7461. same as C<plothraw>,
  7462. except that the output is a PostScript program appended to the C<psfile>.
  7463.  
  7464. =head1 Programming under GP
  7465.  
  7466. X<programming>X<Label se:programming>
  7467. =head2 Control statements.
  7468.  
  7469. A number of control statements are available under GP. They are simpler and
  7470. have a syntax slightly different from their C counterparts, but are quite
  7471. powerful enough to write any kind of program. Some of them are specific to
  7472. GP, since they are made for number theorists. As usual, C<X> will denote any
  7473. simple variable name, and I<seq> will always denote a sequence of
  7474. expressions, including the empty sequence.
  7475.  
  7476. =item X<break>breakC<({n = 1})>
  7477.  
  7478. interrupts execution of current I<seq>, and
  7479. immediately exits from the C<n> innermost enclosing loops, within the
  7480. current function call (or the top level loop). C<n> must be bigger than 1.
  7481. If C<n> is greater than the number of enclosing loops, all enclosing loops
  7482. are exited.
  7483.  
  7484. =item X<for>forC<(X = a,b,I<seq>)>
  7485.  
  7486. the formal variable C<X> going from
  7487. C<a> to C<b>, the I<seq> is evaluated. Nothing is done if C<a E<gt> b>.
  7488. C<a> and C<b> must be in B<I<R>>.
  7489.  
  7490. =item X<fordiv>fordivC<(n,X,I<seq>)>
  7491.  
  7492. the formal variable C<X> ranging
  7493. through the positive divisors of C<n>, the sequence I<seq> is evaluated.
  7494. C<n> must be of type integer.
  7495.  
  7496. =item X<forprime>forprimeC<(X = a,b,I<seq>)>
  7497.  
  7498. the formal variable C<X>
  7499. ranging over the prime numbers between C<a> to C<b> (including C<a> and C<b>
  7500. if they are prime), the I<seq> is evaluated. More precisely, the value
  7501. of C<X> is incremented to the smallest prime strictly larger than C<X> at the
  7502. end of each iteration. Nothing is done if C<a E<gt> b>. Note that C<a> and C<b> must
  7503. be in B<I<R>>.
  7504.  
  7505.   ? { forprime(p = 2, 12,
  7506.         print(p); 
  7507.         if (p == 3, p = 6);
  7508.       )
  7509.     }
  7510.   2
  7511.   3
  7512.   7
  7513.   11
  7514.  
  7515. =item X<forstep>forstepC<(X = a,b,s,I<seq>)>
  7516.  
  7517. the formal variable C<X>
  7518. going from C<a> to C<b>, in increments of C<s>, the I<seq> is evaluated.
  7519. Nothing is done if C<s E<gt> 0> and C<a E<gt> b> or if C<s E<lt> 0> and C<a E<lt> b>. C<s> must be in
  7520. C<B<I<R>>^*> or a vector of steps C<[s_1,...,s_n]>. In the latter case, the
  7521. successive steps are used in the order they appear in C<s>.
  7522.  
  7523.   ? forstep(x=5, 20, [2,4], print(x))
  7524.   5
  7525.   7
  7526.   11
  7527.   13
  7528.   17
  7529.   19
  7530.  
  7531. =item X<forsubgroup>forsubgroupC<(H = G,{B},I<seq>)>
  7532.  
  7533. executes I<seq> for
  7534. each subgroup C<H> of the I<abelian> group C<G> (given in 
  7535. SNFX<Smith normal form> form or as a vector of elementary divisors),
  7536. whose index is bounded by bound. The subgroups are not ordered in any
  7537. obvious way, unless C<G> is a C<p>-group in which case Birkhoff's algorithm
  7538. produces them by decreasing index. A X<subgroup>subgroup is given as a matrix
  7539. whose columns give its generators on the implicit generators of C<G>. For
  7540. example, the following prints all subgroups of index less than 2 in C<G = 
  7541. B<I<Z>>/2B<I<Z>> g_1  x B<I<Z>>/2B<I<Z>> g_2>S< >:
  7542.  
  7543.   ? G = [2,2]; forsubgroup(H=G, 2, print(H))
  7544.   [1; 1]
  7545.   [1; 2]
  7546.   [2; 1]
  7547.   [1, 0; 1, 1]
  7548.  
  7549. The last one, for instance is generated by C<(g_1, g_1 + g_2)>. This
  7550. routine is intended to treat huge groups, when X<subgrouplist>B<subgrouplist> is not an
  7551. option due to the sheer size of the output. 
  7552.  
  7553. For maximal speed the subgroups have been left as produced by the algorithm.
  7554. To print them in canonical form (as left divisors of C<G> in
  7555. HNFX<Hermite normal form> form), one can for instance use
  7556.  
  7557.   ? G = matdiagonal([2,2]); forsubgroup(H=G, 2, print(mathnf(concat(G,H))))
  7558.   [2, 1; 0, 1]
  7559.   [1, 0; 0, 2]
  7560.   [2, 0; 0, 1]
  7561.   [1, 0; 0, 1]
  7562.  
  7563. Note that in this last representation, the index C<[G:H]> is given by the
  7564. determinant.
  7565.  
  7566. =item X<forvec>forvecC<(X = v,I<seq>,{I<flag> = 0})>
  7567.  
  7568. C<v> being an C<n>-component
  7569. vector (where C<n> is arbitrary) of two-component vectors C<[a_i,b_i]>
  7570. for C<1 E<lt>= i E<lt>= n>, the I<seq> is evaluated with the formal variable
  7571. C<X[1]> going from C<a_1> to C<b_1>,...,C<X[n]> going from C<a_n> to C<b_n>.
  7572. The formal variable with the highest index moves the fastest. If C<I<flag> = 1>,
  7573. generate only nondecreasing vectors C<X>, and if C<I<flag> = 2>, generate only
  7574. strictly increasing vectors C<X>.
  7575.  
  7576. =item X<if>ifC<(a,{I<seq1>},{I<seq2>})>
  7577.  
  7578. if C<a> is non-zero,
  7579. the expression sequence I<seq1> is evaluated, otherwise the expression
  7580. I<seq2> is evaluated. Of course, I<seq1> or I<seq2> may be empty,
  7581. so C<if (a,I<seq>)> evaluates I<seq> if C<a> is not equal to zero
  7582. (you don't have to write the second comma), and does nothing otherwise,
  7583. whereas C<if (a,,I<seq>)> evaluates I<seq> if C<a> is equal to
  7584. zero, and does nothing otherwise. You could get the same result using
  7585. the C<!> (C<not>) operator: C<if (!a,I<seq>)>.
  7586.  
  7587. Note that the boolean operators C<&&> and C<||> are evaluated
  7588. according to operator precedence as explained in L<Label se:operators>, but
  7589. that, contrary to other operators, the evaluation of the arguments is
  7590. stopped as soon as the final truth value has been determined. For instance
  7591.  
  7592.   if (reallydoit && longcomplicatedfunction(), ...)%
  7593.  
  7594. is a perfectly safe statement.
  7595.  
  7596. Recall that functions such as C<break> and C<next> operate on
  7597. I<loops> (such as C<forxxx>, C<while>, C<until>). The C<if>
  7598. statement is I<not> a loop (obviously!).
  7599.  
  7600. =item X<next>nextC<({n = 1})>
  7601.  
  7602. interrupts execution of current C<seq>,
  7603. resume the next iteration of the innermost enclosing loop, within the
  7604. current fonction call (or top level loop). If C<n> is specified, resume at
  7605. the C<n>-th enclosing loop. If C<n> is bigger than the number of enclosing
  7606. loops, all enclosing loops are exited.
  7607.  
  7608. =item X<return>returnC<({x = 0})>
  7609.  
  7610. returns from current subroutine, with
  7611. result C<x>.
  7612.  
  7613. =item X<until>untilC<(a,I<seq>)>
  7614.  
  7615. evaluates expression sequence I<seq>
  7616. until C<a> is not equal to 0 (i.e.S< >until C<a> is true). If C<a> is initially
  7617. not equal to 0, I<seq> is evaluated once (more generally, the condition
  7618. on C<a> is tested I<after> execution of the I<seq>, not before as in
  7619. C<while>).
  7620.  
  7621. =item X<while>whileC<(a,I<seq>)>
  7622.  
  7623. while C<a> is non-zero evaluate the
  7624. expression sequence I<seq>. The test is made I<before> evaluating
  7625. the C<seq>, hence in particular if C<a> is initially equal to zero the
  7626. I<seq> will not be evaluated at all.
  7627.  
  7628. =head2 Specific functions used in GP programming
  7629.  
  7630. X<Label se:gp_program>
  7631. In addition to the general PARI functions, it is necessary to have some
  7632. functions which will be of use specifically for GP, though a few of these can
  7633. be accessed under library mode. Before we start describing these, we recall
  7634. the difference between I<strings> and I<keywords> (see
  7635. L<Label se:strings>): the latter don't get expanded at all, and you can type
  7636. them without any enclosing quotes. The former are dynamic objects, where
  7637. everything outside quotes gets immediately expanded.
  7638.  
  7639. We need an additional notation for this chapter. An argument between braces,
  7640. followed by a star, like C<{I<str>}*>, means that any number of such
  7641. arguments (possibly none) can be given.
  7642.  
  7643. =item X<addhelp>addhelpC<(S,I<str>)>
  7644.  
  7645. X<Label se:addhelp> changes the help
  7646. message for the symbol C<S>. The string I<str> is expanded on the spot
  7647. and stored as the online help for C<S>. If C<S> is a function I<you> have
  7648. defined, its definition will still be printed before the message I<str>.
  7649. It is recommended that you document global variables and user functions in
  7650. this way. Of course GP won't protest if you don't do it.
  7651.  
  7652. There's nothing to prevent you from modifying the help of built-in PARI
  7653. functions (but if you do, we'd like to hear why you needed to do it!).
  7654.  
  7655. =item X<alias>aliasC<(I<newkey>,I<key>)>
  7656.  
  7657. defines the keyword
  7658. I<newkey> as an alias for keyword I<key>. I<key> must correspond
  7659. to an existing I<function> name. This is different from the general user
  7660. macros in that alias expansion takes place immediately upon execution,
  7661. without having to look up any function code, and is thus much faster. A
  7662. sample alias file C<misc/gpalias> is provided with the standard
  7663. distribution. Alias commands are meant to be read upon startup from the
  7664. C<.gprc> file, to cope with function names you are dissatisfied with, and
  7665. should be useless in interactive usage.
  7666.  
  7667. =item X<allocatemem>allocatememC<({x = 0})>
  7668.  
  7669. this is a very special operation which
  7670. allows the user to change the stack size I<after> initialization. C<x>
  7671. must be a non-negative integer. If C<x! = 0>, a new stack of size C<16*\lceil
  7672. x/16\rceil> bytes will be allocated, all the PARI data on the old stack will
  7673. be moved to the new one, and the old stack will be discarded. If C<x = 0>, the
  7674. size of the new stack will be twice the size of the old one.
  7675.  
  7676. Although it is a function, this must be the I<last> instruction in any GP
  7677. sequence. The technical reason is that this routine usually moves the stack,
  7678. so objects from the current sequence might not be correct anymore. Hence, to
  7679. prevent such problems, this routine terminates by a C<longjmp> (just as an
  7680. error would) and not by a return.
  7681.  
  7682. X<allocatemoremem>The library syntax is B<allocatemoremem>C<(x)>, where C<x> is an unsigned long, and the return type
  7683. is void. GP uses a variant which ends by a C<longjmp>.
  7684.  
  7685. =item X<default>defaultC<({I<key>},{I<val>},{I<flag>})>
  7686.  
  7687. sets the default
  7688. corresponding to keyword I<key> to value I<val>. I<val> is a string
  7689. (which of course accepts numeric arguments without adverse effects, due to the
  7690. expansion mechanism). See L<Label se:defaults> for a list of available
  7691. defaults, and L<Label se:meta> for some shortcut alternatives. Typing
  7692. C<default()> (or C<\d>) yields the complete default list as well as
  7693. their current values.X<Label se:default>
  7694.  
  7695. If I<val> is omitted, prints the current value of default I<key>.
  7696. If C<I<flag>> is set, returns the result instead of printing it.
  7697.  
  7698. =item X<error>errorC<({I<str>}*)>
  7699.  
  7700. outputs its argument list (each of
  7701. them interpreted as a string), then interrupts the running GP program,
  7702. returning to the input prompt.
  7703.  
  7704. Example: C<error("n = ", n, " is not squarefree !")>.
  7705.  
  7706. Note that, due to the automatic concatenation of strings, you could in fact
  7707. use only one argument, just by suppressing the commas.
  7708.  
  7709. =item X<extern>externC<(I<str>)>
  7710.  
  7711. the string I<str> is the name
  7712. of an external command (i.e.S< >one you would type from your UNIX shell prompt).
  7713. This command is immediately run and its input fed into GP, just as if read
  7714. from a file.
  7715.  
  7716. =item X<getheap>getheapC<()>
  7717.  
  7718. returns a two-component row vector giving the
  7719. number of objects on the heap and the amount of memory they occupy in long
  7720. words. Useful mainly for debugging purposes.
  7721.  
  7722. X<getheap>The library syntax is B<getheap>C<()>.
  7723.  
  7724. =item X<getrand>getrandC<()>
  7725.  
  7726. returns the current value of the random number
  7727. seed. Useful mainly for debugging purposes.
  7728.  
  7729. X<getrand>The library syntax is B<getrand>C<()>, returns a C long.
  7730.  
  7731. =item X<getstack>getstackC<()>
  7732.  
  7733. returns the current value of
  7734. C<top-avma>,
  7735. i.e.S< >the number of bytes used up to now on the stack. Should be equal to 0
  7736. in between commands. Useful mainly for debugging purposes.
  7737.  
  7738. X<getstack>The library syntax is B<getstack>C<()>, returns a C long.
  7739.  
  7740. =item X<gettime>gettimeC<()>
  7741.  
  7742. returns the time (in milliseconds) elapsed since
  7743. either the last call to C<gettime>, or to the beginning of the containing
  7744. GP instruction (if inside GP), whichever came last.
  7745.  
  7746. X<gettime>The library syntax is B<gettime>C<()>, returns a C long.
  7747.  
  7748. =item X<global>globalC<({I<list of variables>})>
  7749.  
  7750. X<Label se:global>
  7751. declares the corresponding variables to be global. From now on, you will be
  7752. forbidden to use them as formal parameters for function definitions or as
  7753. loop indexes. This is especially useful when patching together various
  7754. scripts, possibly written with different naming conventions. For instance the
  7755. following situation is dangerous:
  7756.  
  7757.   p = 3   \\ fix characteristic
  7758.   ...
  7759.   forprime(p = 2, N, ...)
  7760.   f(p) = ...
  7761.  
  7762. since within the loop or within the function's body (even worse: in the
  7763. subroutines called in that scope), the true global value of C<p> will be
  7764. hidden. If the statement C<global(p = 3)> appears at the beginning of
  7765. the script, then both expressions will trigger syntax errors.
  7766.  
  7767. Calling C<global> without arguments prints the list of global variables in
  7768. use. In particular, C<eval(global)> will output the values of all local
  7769. variables.
  7770.  
  7771. =item X<input>inputC<()>
  7772.  
  7773. reads a string, interpreted as a GP expression,
  7774. from the input file, usually standard input (i.e.S< >the keyboard). If a
  7775. sequence of expressions is given, the result is the result of the last
  7776. expression of the sequence. When using this instruction, it is useful to
  7777. prompt for the string by using the C<print1> function. Note that in the
  7778. present version 2.19 of C<pari.el>, when using GP under GNU Emacs (see
  7779. L<Label se:emacs>) one I<must> prompt for the string, with a string
  7780. which ends with the same prompt as any of the previous ones (a C<"? ">
  7781. will do for instance).
  7782.  
  7783. =item X<install>installC<(I<name>,I<code>,{I<gpname>},{I<lib>})>
  7784.  
  7785. loads from dynamic library I<lib> the function I<name>. Assigns to it
  7786. the name I<gpname> in this GP session, with argument code I<code> (see
  7787. L<Label se:gp.interface> for an explanation of those). If I<lib> is
  7788. omitted, uses C<libpari.so>. If I<gpname> is omitted, uses
  7789. I<name>.X<Label se:install>
  7790.  
  7791. This function is useful for adding custom functions to the GP interpreter,
  7792. or picking useful functions from unrelated libraries. For instance, it
  7793. makes the function X<system>C<system> obsolete:
  7794.  
  7795.   ? install(system, vs, sys, "libc.so")
  7796.   ? sys("ls gp*")
  7797.   gp.c            gp.h            gp_rl.c
  7798.  
  7799. But it also gives you access to all (non static) functions defined in the
  7800. PARI library. For instance, the function C<GEN addii(GEN x, GEN y)> adds
  7801. two PARI integers, and is not directly accessible under GP (it's eventually
  7802. called by the C<+> operator of course):
  7803.  
  7804.   ? install("addii", "GG")
  7805.   ? addii(1, 2)
  7806.   %1 = 3
  7807.  
  7808. B<Caution:> This function may not work on all systems, especially
  7809. when GP has been compiled statically. In that case, the first use of an
  7810. installed function will provoke a Segmentation Fault, i.e.S< >a major internal
  7811. blunder (this should never happen with a dynamically linked executable).
  7812. Hence, if you intend to use this function, please check first on some
  7813. harmless example such as the ones above that it works properly on your
  7814. machine.
  7815.  
  7816. =item X<kill>killC<(s)>
  7817.  
  7818. X<Label se:kill> kills the present value of the
  7819. variable, alias or user-defined function C<s>. The corresponding identifier
  7820. can now be used to name any GP object (variable or function). This is the
  7821. only way to replace a variable by a function having the same name (or the
  7822. other way round), as in the following example:
  7823.  
  7824.   ? f = 1
  7825.   %1 = 1
  7826.   ? f(x) = 0
  7827.     ***   unused characters: f(x)=0
  7828.                               ^----
  7829.   ? kill(f)
  7830.   ? f(x) = 0
  7831.   ? f()
  7832.   %2 = 0
  7833.  
  7834. When you kill a variable, all objects that used it become invalid. You
  7835. can still display them, even though the killed variable will be printed in a
  7836. funny way (following the same convention as used by the library function
  7837. C<fetch_var>, seeS< >L<Label se:vars>). For example:
  7838.  
  7839.   ? a^2 + 1
  7840.   %1 = a^2 + 1
  7841.   ? kill(a)
  7842.   ? %1
  7843.   %2 = #<1>^2 + 1
  7844.  
  7845. If you simply want to restore a variable to its ``undefined'' value
  7846. (monomial of degree one), use the X<quote>quote operator: C<a = 'a>.
  7847. Predefined symbols (C<x> and GP function names) cannot be killed.
  7848.  
  7849. =item X<print>printC<({I<str>}*)>
  7850.  
  7851. outputs its (string) arguments in raw
  7852. format, ending with a newline.
  7853.  
  7854. =item X<print1>print1C<({I<str>}*)>
  7855.  
  7856. outputs its (string) arguments in raw
  7857. format, without ending with a newline (note that you can still embed newlines
  7858. within your strings, using the C<\n> notationS< >!).
  7859.  
  7860. =item X<printp>printpC<({I<str>}*)>
  7861.  
  7862. outputs its (string) arguments in
  7863. prettyprint (beautified) format, ending with a newline.
  7864.  
  7865. =item X<printp1>printp1C<({I<str>}*)>
  7866.  
  7867. outputs its (string) arguments in
  7868. prettyprint (beautified) format, without ending with a newline.
  7869.  
  7870. =item X<printtex>printtexC<({I<str>}*)>
  7871.  
  7872. outputs its (string) arguments in
  7873. TeX format. This output can then be used in a TeX manuscript.
  7874. The printing is done on the standard output. If you want to print it to a
  7875. file you should use C<writetex> (see there).
  7876.  
  7877. Another possibility is to enable the X<log>C<log> default
  7878. (seeS< >L<Label se:defaults>).
  7879. You could for instance do:X<logfile>
  7880.  
  7881.   default(logfile, "new.tex");
  7882.   default(log, 1);
  7883.   printtex(result);
  7884.  
  7885. (You can use the automatic string expansion/concatenation process to have
  7886. dynamic file names if you wish).
  7887.  
  7888. =item X<quit>quitC<()>
  7889.  
  7890. exits GP.X<Label se:quit>
  7891.  
  7892. =item X<read>readC<({I<str>})>
  7893.  
  7894. reads in the file whose name results
  7895. from the expansion of the string I<str>. If I<str> is omitted,
  7896. re-reads the last file that was fed into GP. The return value is the result of
  7897. the last expression evaluated.X<Label se:read>
  7898.  
  7899. =item X<reorder>reorderC<({x = []})>
  7900.  
  7901. C<x> must be a vector. If C<x> is the
  7902. empty vector, this gives the vector whose components are the existing
  7903. variables in increasing order (i.e.S< >in decreasing importance). Killed
  7904. variables (see C<kill>) will be shown as C<0>. If C<x> is
  7905. non-empty, it must be a permutation of variable names, and this permutation
  7906. gives a new order of importance of the variables, I<for output only>. For
  7907. example, if the existing order is C<[x,y,z]>, then after
  7908. C<reorder([z,x])> the order of importance of the variables, with respect
  7909. to output, will be C<[z,y,x]>. The internal representation is unaffected.
  7910. X<Label se:reorder>
  7911.  
  7912. =item X<setrand>setrandC<(n)>
  7913.  
  7914. reseeds the random number generator to the value
  7915. C<n>. The initial seed is C<n = 1>.
  7916.  
  7917. X<setrand>The library syntax is B<setrand>C<(n)>, where C<n> is a C<long>. Returns C<n>.
  7918.  
  7919. =item X<system>systemC<(I<str>)>
  7920.  
  7921. I<str> is a string representing
  7922. a system command. This command is executed, its output written to the
  7923. standard output (this won't get into your logfile), and control returns
  7924. to the PARI system. This simply calls the C C<system> command.
  7925.  
  7926. =item X<trap>trapC<({e}, {I<rec>}, {I<seq>})>
  7927.  
  7928. tries to
  7929. execute I<seq>, trapping error C<e>, that is effectively preventing it
  7930. from aborting computations in the usual way; the recovery sequence
  7931. I<rec> is executed if the error occurs and the evaluation of I<rec>
  7932. becomes the result of the command. If C<e> is omitted, all exceptions are
  7933. trapped. Note in particular that hitting C<^C> (Control-C) raises an
  7934. exception.
  7935.  
  7936.   ? \\ trap division by 0
  7937.   ? inv(x) = trap (gdiver2, INFINITY, 1/x)
  7938.   ? inv(2)
  7939.   %1 = 1/2
  7940.   ? inv(0)
  7941.   %2 = INFINITY
  7942.  
  7943. If I<seq> is omitted, defines I<rec> as a default action when
  7944. encountering exception C<e>. The error message is printed, as well as the
  7945. result of the evaluation of I<rec>, and the control is given back to the
  7946. GP prompt. In particular, current computation is then lost.
  7947.  
  7948. The following error handler prints the list of all user variables, then
  7949. stores in a file their name and their values:
  7950.  
  7951.   ? { trap( ,
  7952.         print(reorder);
  7953.         write("crash", reorder);
  7954.         write("crash", eval(reorder))) }
  7955.  
  7956. If no recovery code is given (I<rec> is omitted) a so-called
  7957. I<X<break loop>break loop> will be started. During a break loop, all commands are
  7958. read and evaluated as during the main GP loop (except that no history of
  7959. results is kept).
  7960.  
  7961. To get out of the break loop, you can use X<next>C<next>, X<break>C<break> or
  7962. X<return>C<return>; reading in a file by C<\r> will also terminate the loop once
  7963. the file has been read (C<read> will remain in the break loop). If the
  7964. error is not fatal (C<^C> is the only non-fatal error), C<next>
  7965. will continue the computation as if nothing had happened (except of course,
  7966. you may have changed GP state during the break loop); otherwise control
  7967. will come back to the GP prompt. After a user interrupt (C<^C>),
  7968. entering an empty input line (i.e hitting the return key) has the same
  7969. effect as C<next>.
  7970.  
  7971. Break loops are useful as a debugging tool to inspect the values of GP
  7972. variables to understand why a problem occurred, or to change GP behaviour
  7973. (increase debugging level, start storing results in a logfile, modify
  7974. parameters...) in the middle of a long computation (hit C<^C>, type
  7975. in your modifications, then type C<next>).
  7976.  
  7977. If I<rec> is the empty string C<""> the last default handler is popped
  7978. out, and replaced by the previous one for that error.
  7979.  
  7980. B<Note:> The interface is currently not adequate for trapping
  7981. individual exceptions. In the current version B<2.2.0>, the following keywords
  7982. are recognized, but the name list will be expanded and changed in the
  7983. future (all library mode errors can be trapped: it's a matter of defining
  7984. the keywords to GP, and there are currently far too many useless ones):
  7985.  
  7986. C<accurer>: accuracy problem
  7987.  
  7988. C<gdiver2>: division by 0
  7989.  
  7990. C<archer>: not available on this architecture or operating system
  7991.  
  7992. C<typeer>: wrong type
  7993.  
  7994. C<errpile>: the PARI stack overflows
  7995.  
  7996. =item X<type>typeC<(x,{t})>
  7997.  
  7998. this is useful only under GP. If C<t> is
  7999. not present, returns the internal type number of the PARI object C<x>.
  8000. Otherwise, makes a copy of C<x> and sets its type equal to type C<t>, which
  8001. can be either a number or, preferably since internal codes may eventually
  8002. change, a symbolic name such as C<t_FRACN> (you can skip the C<t_>
  8003. part here, so that C<FRACN> by itself would also be all right). Check out
  8004. existing type names with the metacommand C<\t>.X<Label se:gptype>
  8005.  
  8006. GP won't let you create meaningless objects in this way where the internal
  8007. structure doesn't match the type. This function can be useful to create
  8008. reducible rationals (type C<t_FRACN>) or rational functions (type
  8009. C<t_RFRACN>). In fact it's the only way to do so in GP. In this case, the
  8010. created object, as well as the objects created from it, will not be reduced
  8011. automatically, making some operations a bit faster.
  8012.  
  8013. There is no equivalent library syntax, since the internal functions C<typ>
  8014. and C<settyp> are available. Note that C<settyp> does I<not>
  8015. create a copy of C<x>, contrary to most PARI functions. It also doesn't
  8016. check for consistency. C<settyp> just changes the type in place and
  8017. returns nothing. C<typ> returns a C long integer. Note also the different
  8018. spellings of the internal functions (C<set>)C<typ> and of the GP
  8019. function C<type>, which is due to the fact that C<type> is a reserved
  8020. identifier for some C compilers.
  8021.  
  8022. =item X<whatnow>whatnowC<(I<key>)>
  8023.  
  8024. if keyword I<key> is the name
  8025. of a function that was present in GP version 1.39.15 or lower, outputs
  8026. the new function name and syntax, if it changed at all (C<387> out of C<560>
  8027. did).X<Label se:whatnow>
  8028.  
  8029. =item X<write>writeC<(I<filename>,{I<str>*})>
  8030.  
  8031. writes (appends)
  8032. to I<filename> the remaining arguments, and appends a newline (same output
  8033. as C<print>).X<Label se:write>
  8034.  
  8035. =item X<write1>write1C<(I<filename>,{I<str>*})>
  8036.  
  8037. writes (appends) to
  8038. I<filename> the remaining arguments without a trailing newline
  8039. (same output as C<print1>).
  8040.  
  8041. =item X<writetex>writetexC<(I<filename>,{I<str>*})>
  8042.  
  8043. as C<write>,
  8044. in TeX format.X<Label se:writetex>
  8045.  
  8046.