CoefficientList - Maple Help

PolynomialTools

 CoefficientVector
 return a Vector of coefficients from a polynomial
 CoefficientList
 return a list of coefficients from a polynomial

 Calling Sequence CoefficientVector(p, vars, vectoropts, orderopts) CoefficientList(p, vars, orderopts)

Parameters

 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

Description

 • 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={a}_{0}+{a}_{1}x+...+{a}_{n}{x}^{n}$, the k-th element of the Vector or list returned corresponds to ${a}_{k-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.

Examples

 > $\mathrm{with}\left(\mathrm{PolynomialTools}\right):$
 > $p≔1-13x+{x}^{5}$
 ${p}{≔}{{x}}^{{5}}{-}{13}{}{x}{+}{1}$ (1)
 > $\mathrm{CoefficientVector}\left(p,x\right)$
 $\left[\begin{array}{c}{1}\\ {-13}\\ {0}\\ {0}\\ {0}\\ {1}\end{array}\right]$ (2)
 > $\mathrm{CoefficientVector}\left(p,x,'\mathrm{termorder}'='\mathrm{reverse}'\right)$
 $\left[\begin{array}{c}{1}\\ {0}\\ {0}\\ {0}\\ {-13}\\ {1}\end{array}\right]$ (3)
 > $\mathrm{CoefficientList}\left(\mathrm{expand}\left({p}^{2}\right),x\right)$
 $\left[{1}{,}{-26}{,}{169}{,}{0}{,}{0}{,}{2}{,}{-26}{,}{0}{,}{0}{,}{0}{,}{1}\right]$ (4)
 > $\mathrm{CoefficientVector}\left(1+5{x}^{1000000000},x,\mathrm{storage}=\mathrm{sparse}\right)$
 $\begin{array}{c}\left[\begin{array}{c}{1}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {⋮}\end{array}\right]\\ \hfill {\text{1000000001 element Vector[column]}}\end{array}$ (5)
 > $\mathrm{CoefficientVector}\left(1+5{x}^{1000000000},x,\mathrm{storage}=\mathrm{sparse},\mathrm{termorder}=\mathrm{reverse}\right)$
 $\begin{array}{c}\left[\begin{array}{c}{5}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {0}\\ {⋮}\end{array}\right]\\ \hfill {\text{1000000001 element Vector[column]}}\end{array}$ (6)
 • For the zero polynomial, the CoefficientVector command returns a zero-dimensional Vector and the CoefficientList command returns an empty list.
 > $\mathrm{CoefficientVector}\left(0,x\right)$
 $\left[\begin{array}{}\end{array}\right]$ (7)
 > $\mathrm{CoefficientList}\left(0.,x\right)$
 $\left[\right]$ (8)
 • Non-expanded polynomials will also work but since collect will be called on them, this could be inefficient.
 > $q≔\left(x-1\right)\left(x-25\right)\left({x}^{2}-x\right):$
 > $\mathrm{CoefficientList}\left(q,x\right)$
 $\left[{0}{,}{-25}{,}{51}{,}{-27}{,}{1}\right]$ (9)
 • The coefficients of the polynomial do not have to be numbers.
 > $\mathrm{CoefficientList}\left({y}^{3}-{y}^{2}x+\left(y-2\right){x}^{2}+{x}^{3},x\right)$
 $\left[{{y}}^{{3}}{,}{-}{{y}}^{{2}}{,}{y}{-}{2}{,}{1}\right]$ (10)
 > $\mathrm{CoefficientList}\left({y}^{3}-{y}^{2}x+\left(y-2\right){x}^{2}+{x}^{3},\left[x,y\right]\right)$
 $\left[{0}{,}{0}{,}{0}{,}{-2}{,}{0}{,}{0}{,}{1}{,}{1}{,}{-1}{,}{1}\right]$ (11)

Compatibility

 • The PolynomialTools[CoefficientVector] and PolynomialTools[CoefficientList] commands were updated in Maple 2021.
 • The p parameter was updated in Maple 2021.