# coefficients -- monomials and their coefficients

## Synopsis

• Usage:
(M,C) = coefficients f
• Inputs:
• f, a one-row Matrix with n columns, say, or a RingElement, to be interpreted as a one-by-one matrix. (A future implementation will handle matrices with more than one row.)
• Optional inputs:
• Variables => a list, default value null, a list v of variables. If a value for this option is not specified, all of the (top-level) variables are used.
• Monomials => ..., default value null, a list or one-row matrix of monomials, each of which is formed using just variables in v.
• Outputs:
• M, , either the value of the Monomials option, if specified (converted to a one-row matrix, if necessary), or a one-row matrix of those monomials appearing in f that involve just variables in v, in descending order. Let m denote the number of columns it has.
• C, , the m by n matrix C such that C_(i,j) is the coefficient in f_(0,j) of the monomial M_(0,i). In other words, C is the unique matrix not involving the (specified) variables such that M*C == f, unless a value was specified for the Monomials option that did not include all the monomials in the variables v used by f

## Description

 i1 : R = QQ[a,b,c,d,e,f][x,y]; i2 : F = a*x^2+b*x*y+c*y^2 2 2 o2 = a*x + b*x*y + c*y o2 : R i3 : (M,C) = coefficients F o3 = (| x2 xy y2 |, {2, 0} | a |) {2, 0} | b | {2, 0} | c | o3 : Sequence
The resulting matrices have the following property.
 i4 : M*C === matrix F o4 = true
The Sylvester matrix of two generic quadratic forms:
 i5 : G = d*x^2+e*x*y+f*y^2 2 2 o5 = d*x + e*x*y + f*y o5 : R i6 : P = matrix{{x*F,y*F,x*G,y*G}} o6 = | ax3+bx2y+cxy2 ax2y+bxy2+cy3 dx3+ex2y+fxy2 dx2y+exy2+fy3 | 1 4 o6 : Matrix R <--- R i7 : (M,C) = coefficients P o7 = (| x3 x2y xy2 y3 |, {3, 0} | a 0 d 0 |) {3, 0} | b a e d | {3, 0} | c b f e | {3, 0} | 0 c 0 f | o7 : Sequence i8 : M*C === P o8 = true
We may give the monomials directly. This is useful if we are taking coefficients of several elements or matrices, and need a consistent choice of monomials.
 i9 : (M,C) = coefficients(P, Monomials=>{x^3,y^3,x^2*y,x*y^2}) o9 = (| x3 y3 x2y xy2 |, {3, 0} | a 0 d 0 |) {3, 0} | 0 c 0 f | {3, 0} | b a e d | {3, 0} | c b f e | o9 : Sequence
If not all of the monomials are used, no error is signaled, but M*C == P no longer holds.
 i10 : (M,C) = coefficients(P, Monomials=>{x^3,y^3}) o10 = (| x3 y3 |, {3, 0} | a 0 d 0 |) {3, 0} | 0 c 0 f | o10 : Sequence i11 : M*C == P o11 = false