A list of ring elements can be interpreted as a row vector or the list of coefficients of a polynomial. There are a couple of functions that implement arithmetic operations based on these interpretations. GAP contains proper support for polynomials (see Polynomials and Rational Functions), the operations described in this section are on a lower level.
The following operations all perform arithmetic on univariate polynomials given by their coefficient lists. These lists can have different lengths but must be dense homogeneous lists containing elements of a commutative ring. Not all input lists may be empty.
In the following descriptions we will always assume that list1 is the coefficient list of the polynomial pol1 and so forth. If length parameter leni is not given, it is set to the length of listi by default.
ValuePol( coeff, x ) F
Let coeff be the coefficients list of a univariate polynomial f,
and x a ring element. Then
ValuePol returns the value f(x ).
The coefficient of xi is assumed to be stored at position i+1 in the coefficients list.
gap> ValuePol([1,2,3],4); 57
ProductCoeffs( list1, [len1, ]list2[, len2] ) O
Let pol1 (and pol2) be polynomials given by the first len1 (len2) entries of the coefficient list list2 (list2). If len1 and len2 are omitted, they default to the lengths of list1 and list2. This operation returns the coefficient list of the product of pol1 and pol2.
gap> l:=[1,2,3,4];;m:=[5,6,7];;ProductCoeffs(l,m); [ 5, 16, 34, 52, 45, 28 ]
ReduceCoeffs( list1[, len1], list2[, len2] ) O
changes list1 to the coefficient list of the remainder when dividing pol1 by pol2. This operation changes list1 which therefore must be a mutable list. The operations returns the position of the last non-zero entry of the result but is not guaranteed to remove trailing zeroes.
gap> l:=[1,2,3,4];;m:=[5,6,7];;ReduceCoeffs(l,m); 2 gap> l; [ 64/49, -24/49, 0, 0 ]
ReduceCoeffsMod( list1, [len1, ]list2, [len2, ]mod ) O
changes list1 to the coefficient list of the remainder when dividing pol1 by pol2 modulo mod. mod must be a positive integer. This operation changes list1 which therefore must be a mutable list. The operations returns the position of the last non-zero entry of the result but is not guaranteed to remove trailing zeroes.
gap> l:=[1,2,3,4];;m:=[5,6,7];;ReduceCoeffsMod(l,m,3); 1 gap> l; [ 1, 0, 0, 0 ]
PowerModCoeffs( list1, [len1, ]exp, list2[, len2] ) O
Let pol1 (and pol2) be polynomials given by the first len1 (len2)
entries of the coefficient list list3 (list2).
If len1 and len2 are omitted, they default to the lengths of list1
and list2.
This operation returns the coefficient list of the remainder when dividing
pol1^exp by pol2. The operation reduces coefficients already
while computing powers and therefore avoids an explosion in list length.
gap> l:=[1,2,3,4];;m:=[5,6,7];;PowerModCoeffs(l,5,m); [ -839462813696/678223072849, -7807439437824/678223072849, 0 ]
ShiftedCoeffs( list, shift ) O
produces a new coefficient list new obtained by the rule
new[i+shift]:=list[i] and filling initial holes by the
appropriate zero.
gap> l:=[1,2,3];;ShiftedCoeffs(l,2);ShiftedCoeffs(l,-2); [ 0, 0, 1, 2, 3 ] [ 3 ]
ShrinkCoeffs( list ) O
removes trailing zeroes from list. It returns the position of the last non-zero entry, that is the length of list after the operation.
gap> l:=[1,0,0];;ShrinkCoeffs(l);l; 1 [ 1 ]
GAP 4 manual