The crucial word in PARI is : most types
which are handled are recursive. For example, the basic type
exists. However, the components (i.e. the real and imaginary part)
of
such a ``complex number'' can be of any type. The only sensible ones are
integers
(we are then in
Z[i]), rational numbers (
Q[i]), real numbers
(
R[i] =
C), or even elements of
Z/n
Z
(
(
Z/n
Z)[i] when this makes sense), or p-adic numbers when
p≡3 mod 4 (
Qp[i]).
This feature must of course not be used too rashly: for example you are in principle allowed to create objects which are ``complex numbers of complex numbers'', but don't expect PARI to make sensible use of such objects: you will mainly get nonsense.
On the other hand, one thing which is allowed is to have components of different, but compatible, types. For example, taking again complex numbers, the real part could be of type integer, and the imaginary part of type rational.
By compatible, we mean types which can be freely mixed in operations like + or *. For example if the real part is of type real, the imaginary part cannot be of type integermod (integers modulo a given number n).
Let us now describe the types. As explained above, they are built recursively from basic types which are as follows. We use the letter T to designate any type; the type number corresponds to the internal representation of the type.
xxx&typexxxxxx&xxxxxxxxxxxxxxxxxxx&xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxx
&type 1:& Z&
s (with arbitrary precision)
&type 2:&
R&
s (with arbitrary precision)
&type 3:&
Z/n
Z&
s (integers modulo n)
&type 4:&
Q&
s (in irreducible form)
&type 5:&
Q& Rational numbers (in non necessarily irreducible form)
&type 6:& T[i]&
s
&type 7:&
Qp& p-adicp-adic number numbers
&type 8:& T[w]&
s (where
[
Z[w] :
Z] = 2)
&type 9:&
T[X]/P(X)T[X]&
s (polynomials modulo P)
&type 10:& T[X]&
s
&type 11:& T((X))&
(finite Laurent series)
&type 13:& T(X)&
s (in irreducible form)
&type 14:& T(X)& Rational functions (in non necessarily irreducible
form)
&type 17:& Tn& Row (i.e. horizontal) Row vectorvectors
&type 18:& Tn& Column (i.e. vertical) Column vectorvectors
&type 19:&
Mm, n(T)& Matrices.Matrix
In addition, there exist type 15 for binary quadratic forms of positive discriminant, type 16 for binary quadratic forms of negative discriminant Binary quadratic form which can be used in specific operations, but which may disappear in future versions, hence their use is not documented in this manual.
Let us look closely at these types.
Integers and reals:IntegerReal number they are of arbitrary and varying length (each number having coded internally its own length or precision) with the following mild restrictions: integers must be in absolute value less than 21048480 (i.e. roughly 315623 digits). The precision of real numbers is also at most 315623 significant decimal digits, and the binary exponent must be in absolute value less than 223 = 8388608.
Note that PARI has been optimized so that it works as fast as possible on numbers with 40 to 100 decimal digits. In particular, no fancy multiplication technique is used. Hence, although it is possible to use PARI to do computations with 300000 decimal digits, much better programs can be written for these loooong numbers.
Integers and real numbers are completely non recursive types and are sometimes
called the .
Integermods, rational numbers (irreducible or not), p-adic numbers, polymods, and rational functions:IntegermodRational numberp-adic number Polymod they are recursive, but in a forced manner:
For integermods or polymods, there are two components: the modulus, which must be of type integer (resp. polynomial), and the number (or polynomial).
For rational numbers or rational functions, there are also only two components: the numerator and the denominator, which must both be of type integer (resp. polynomial).
Finally, p-adic numbers have three components: the prime p, the
``modulus'' pk,
and an approximation to the p-adic number. Here Zp is considered as
Z/pk
Z, and
Qp as its field of fractions.
Like real numbers, the codewords contain also the information on the
precision
of the number (which is in fact redundant with pk, but it is apparently more
efficient to keep this redundancy).
Complex numbers (a + bi) and quadratic numbers: Complex number
Quadratic numberquadratic numbers are numbers of the form a + bw,
where w is such that
[Z[w] :
Z] = 2, and more precisely
w =
/2 when
d≡0 mod 4, and
w = (1 +
)/2 when
d≡1 mod 4, where d
is
the discriminant of a quadratic order.
Complex and quadratic numbers are partially recursive: the two components
a and b can be of type integer, real, rational, integermod or p-adic,
and can
be mixed, subject to the limitations mentioned above. For example,
a + bi with a and b p-adic is in
Qp[i], but this is equal to
Qp
when
p≡1 mod 4, hence we must exclude these p when one explicitly
uses
a complex p-adic type.
Polynomials, power series, vectors and matrices: PolynomialPower seriesVectorMatrix they are completely recursive: their components can be of any type, and types can be mixed (however beware when doing operations). Note in particular that a polynomial in two variables is simply a polynomial with polynomial coefficients.
Note that in the present version of PARI, there is a bug in the handling of power series of power series (i.e. power series in several variables). However power series of polynomials (which are power series in several variables of a special type) are OK. The reason for this bug is known, but it is difficult to correct because the mathematical problem itself contains some amount of imprecision.
Exact and imprecise objects: imprecise objectwe have already
said that integers and reals are called the because they are
ultimately
at the end of every branch of a tree representing a PARI object. Another
important notion is that of an
: by definition,
numbers of basic type real, p-adic or power series are imprecise, and we
will
say that a PARI object having one of these imprecise types anywhere in its
tree
is not exact. All other PARI objects will be called exact. This is a very
important notion since no numerical analysis is involved when dealing with
exact objects.
What is ?: this is a crucial question in all computer
systems. The answer we give in PARI is the following. For exact types,
all zeros are equivalent and are exact, so are usually represented as
an integer zero. The problem becomes
nontrivial for imprecise types. For p-adics the answer is as
follows: every p-adic number (including 0) has an exponent e and a
``mantissa'' u which is a p-adic unit, except when the number is zero (in
which case u is zero), the mantissa having a certain ``precision'' k (i.e.
is defined modulo pk). Then this p-adic zero is understood to be
equal to O(pe), i.e. there is an infinite number of zeros. The number k
is thus irrelevant.
For power series the situation is similar, with p replaced by X, i.e. a power series zero will be O(Xe), the number k (here the length of the power series) being also irrelevant.
For real numbers, the precision k is also irrelevant, and a real zero will in fact be O(2e) where e is now usually a negative binary exponent. This of course will be printed as usual for a real number ( 0.0000 ... in f format or 0.Exx in e format) and not with a O() symbol as with p-adics or power series.
Scalar types:scalar type basic types with type number less than or equal to 9 will be called scalar types because they essentially occur as coefficients of some more complicated object. Note that type 9, i.e. polymod, is used to define algebraic extensions of a base ring, and as such is a scalar type.