A polynomial in GAP is defined over a certain type
of ring (or field) that GAP understands. For example,
GAP knows the ring of integers,
.
A variable (such as
) cannot be typed into GAP
without first being defined.
x:= Indeterminate( Integers, "x" );;.
Now a polynomial such as f:=x^2-1;. To multiply polynomials,
use a g:=(x^2-1)*(x-1); and
GAP will return the (expanded) product.
To evaluate a polynomial at a ring element, use the
Value command: for example,
Value(f,2); returns
x:= Indeterminate( GF(4), "x" );;,
y:= Indeterminate( GF(4), "y" );;.
Now a polynomial such as f:=x^2-y^2;. To multiply polynomials,
use a g:=(x^2-y^2)*(y-1); and
GAP will return the (expanded) product.
To evaluate a polynomial at a ring element, use the
Value command: for example,
Value(f,[x,y],[2,-1]); returns Z(2)^0.
Type x:= Indeterminate( Rationals, "x" );;
and GcdRepresentation( f, g ); for the extended
Euclidean algorithm applied to the polynomials
in
.
For example,
GcdRepresentation( x^2+1, x^3+1 );returns
[ 1/2-1/2*x-1/2*x^2, 1/2+1/2*x ].To double check this: note
(1/2-1/2*x-1/2*x^2)*(x^2+1)+(1/2+1/2*x )*(x^3+1);returns
Gcd(x^2+1,x^3+1);returns
Type
R:= PolynomialRing( Rationals, 1 );,
x:= IndeterminatesOfPolynomialRing( R )[1];
and Factors( R, f ); to obtain the
factorization of
in
.
For example, Factors( R, x^2-1 );
gives the factorization
[ -1+x_1, 1+x_1 ].
R:=PolynomialRing(Integers,[``x'']);
and the command C:=CompanionMat(p); gives,
for a monic polynomial
of degree
over a ring
,
the companion matrix
for
as an element of
.
PowerMod.)
Find a primitive element of
.
PowerMod.)
Find a primitive element of
.