up previous next
coefficients    --    list of coefficients of a polynomial


Syntax
coefficients(F: RINGELEM): LIST
coefficients(F: RINGELEM, S: LIST): LIST

Description
This function returns a list of coefficients of F which are elements of CoeffRing(RingOf(F)).

Called with one argument F it returns the list of all non-zero coefficients; the order being decreasing on the terms in F as determined by the term-ordering of RingOf(F).

Called with two arguments F,S it returns the coefficients of the list of specified terms S; their order is determined by the list S. If a terms does not appear in F then the corresponding coefficient is 0.

The old form (CoCoA-4) Coefficients(F,x) for the coefficients of F with respect to (WRT) an indeterminate x is now replaced by the functions CoefficientsWRT and CoeffListWRT .

Example
/**/  use R ::= QQ[x,y,z];
/**/  F := 3*x^2*y + 5*y^2 - x*y;
/**/  Coeffs := coefficients(F);  Coeffs;  -- with one argument
[3, -1, 5]
/**/  phi := CoeffEmbeddingHom(RingOf(F));
/**/  F = ScalarProduct(phi(Coeffs), support(F));
true

/**/  Skeleton := [1, x, y, z, x^2, x*y, y^2, y*z, z^2];
/**/  Coeffs := coefficients(F, Skeleton);  Coeffs;  -- with two arguments
[0, 0, 0, 0, 0, -1, 5, 0, 0]
/**/  ScalarProduct(phi(Coeffs), Skeleton);
-x*y +5*y^2

/**/  L := CoefficientsWRT(F,[x,y,z]);  indent(L);  -- similar function
[
  record[PP := y^3, coeff := 5],
  record[PP := x^2*y, coeff := 3],
  record[PP := x*y^5, coeff := -1]
]
/**/  F = sum([X.coeff * X.PP | X in L]);
true

/**/  L := CoeffListWRT(F, y);  L;  -- similar function
[0,  3*x^2 -x,  5]
/**/  F = sum([L[d+1]*y^d | d in 0..(len(L)-1)]);
true

/**/  R3 := NewFreeModule(R,3);
/**/  V := ModuleElem(R3, [3*x^2+y, x-5*z^3, x+2*y]);
/**/  ConcatLists([coefficients(V[i]) | i in 1..NumCompts(V)]);
[3, 1, -5, 1, 1, 2]

See Also