next | previous | forward | backward | up | top | index | toc | home

coefficients -- monomials and their coefficients

Synopsis

Description

If the optional argument Variables=>v is given, then the monomials will only involve these variables, and the coefficients will involve only the other variables.

If the optional argument Monomials=>m is not given, then the set of monomials appearing in f is calculated using monomials.

i1 : R = QQ[x,y,a,b,c,d,e,f];
i2 : F = a*x^2+b*x*y+c*y^2

      2             2
o2 = x a + x*y*b + y c

o2 : R
i3 : (M,C) = coefficients(F, Variables=>{x,y})

o3 = (| x2 xy y2 |, {2} | a |)
                    {2} | b |
                    {2} | 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 = x d + x*y*e + y f

o5 : R
i6 : P = matrix{{x*F,y*F,x*G,y*G}}

o6 = | x3a+x2yb+xy2c x2ya+xy2b+y3c x3d+x2ye+xy2f x2yd+xy2e+y3f |

             1       4
o6 : Matrix R  <--- R
i7 : (M,C) = coefficients(P, Variables=>{x,y})

o7 = (| x3 x2y xy2 y3 |, {3} | a 0 d 0 |)
                         {3} | b a e d |
                         {3} | c b f e |
                         {3} | 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, Variables=>{x,y}, Monomials=>{x^3,y^3,x^2*y,x*y^2})

o9 = (| x3 y3 x2y xy2 |, {3} | a 0 d 0 |)
                         {3} | 0 c 0 f |
                         {3} | b a e d |
                         {3} | c b f e |

o9 : Sequence
If not all of the monomials are used, then M*C == P no longer holds.
i10 : (M,C) = coefficients(P, Variables=>{x,y}, Monomials=>{x^3,y^3})

o10 = (| x3 y3 |, {3} | a 0 d 0 |)
                  {3} | 0 c 0 f |

o10 : Sequence
i11 : M*C == P

o11 = false

Caveat

Currently, the matrix f must have only one row. This restriction will hopefully be lifted in the future.

See also

Ways to use coefficients :