PolynomialTools
CoefficientVector
return a Vector of coefficients from a polynomial
CoefficientList
return a list of coefficients from a polynomial
Calling Sequence
Parameters
Description
Examples
Compatibility
CoefficientVector(p, vars, vectoropts, orderopts)
CoefficientList(p, vars, orderopts)
p
-
polynom(anything, vars)
vars
name,list of main variable(s)
vectoropt
(optional) a sequence of Vector constructor options; see Vector
orderopts
(optional) equation of the form termorder=reverse or termorder=forward
The CoefficientVector(p, vars) calling sequence returns a Vector of coefficients from a polynomial p in vars.
The CoefficientList(p, x) calling sequence returns a list of coefficients from a polynomial p in vars.
If the term order is not specified or termorder=forward, for p=a0+a1⁢x+...+an⁢xn, the k-th element of the Vector or list returned corresponds to ak−1.
These commands now support polynomials in many variables. For polynomials with more the one variable, the terms are sorted in total degree order, with terms of the same total degree sorted lexically.
If termorder=reverse is specified, then the coefficients will be stored in the reverse of the above order. That is, the leading coefficient will be stored first.
These commands are useful because the Maple command coeff is of linear complexity in the degree of the polynomial. Thus, a naive implementation of CoefficientVector would be of quadratic complexity. The actual implementation is of linear complexity. In fact, for CoefficientVector, if sparse storage is specified as an option, the complexity is linear in the actual number of terms.
The inverse commands are FromCoefficientVector and FromCoefficientList.
with⁡PolynomialTools:
p≔1−13⁢x+x5
p≔x5−13⁢x+1
CoefficientVector⁡p,x
1−130001
CoefficientVector⁡p,x,termorder=reverse
1000−131
CoefficientList⁡expand⁡p2,x
1,−26,169,0,0,2,−26,0,0,0,1
CoefficientVector⁡1+5⁢x1000000000,x,storage=sparse
CoefficientVector⁡1+5⁢x1000000000,x,storage=sparse,termorder=reverse
For the zero polynomial, the CoefficientVector command returns a zero-dimensional Vector and the CoefficientList command returns an empty list.
CoefficientVector⁡0,x
CoefficientList⁡0.,x
Non-expanded polynomials will also work but since collect will be called on them, this could be inefficient.
q≔x−1⁢x−25⁢x2−x:
CoefficientList⁡q,x
0,−25,51,−27,1
The coefficients of the polynomial do not have to be numbers.
CoefficientList⁡y3−y2⁢x+y−2⁢x2+x3,x
y3,−y2,y−2,1
CoefficientList⁡y3−y2⁢x+y−2⁢x2+x3,x,y
0,0,0,−2,0,0,1,1,−1,1
The PolynomialTools[CoefficientVector] and PolynomialTools[CoefficientList] commands were updated in Maple 2021.
The p parameter was updated in Maple 2021.
See Also
coeff
coeffs
expand
FromCoefficientList
Vector
Download Help Document