 Coefficients - Maple Help

Physics[Coefficients] - extract all coefficients of a multivariate polynomial involving commutative and anticommutative variables Calling Sequence Coefficients(p, x, N, onlynonzero) Parameters

 p - algebraic expression, or relation between them, or a set or list of them x - variable, can be a name, function, product, power, or a list of them N - optional, default to all, can be an integer, or a range of integers (n..m), or any of the keywords leading, trailing, all; indicates whether to compute all the coefficients or some or only one onlynonzero - optional, can be true or false (default), to receive only the coefficients not equal to zero in the returned sequence Description

 • The Coefficients command extracts the coefficients of x in the polynomial p, where x and p can involve anticommutative variables. Coefficients is a one-command generalization of coeff, coeffs, lcoeff and tcoeff, that works with commutative noncommutative and anticommutative variables in equal footing.
 • The first argument, p, can also be a relation between polynomials, or a set or list of them, in which case Coefficients maps itself over the elements of the relation, set or list. For example, if p is an equation, then Coefficients(p, x) returns the equation obtained by computing Coefficients(lhs(p), x) = Coefficients(rhs(p), x), where lhs(p) and rhs(p) respectively represent the left and right hand sides of p.
 • The second argument, x, can be a name, function, product, power, or a list of them. When x is a power, say as in a^n, Coefficients(p, x) returns the same as Coefficients(p, a, n), that is the coefficient of the nth power.
 • The third argument, N, is optional, and indicates whether to extract all the coefficients (default behavior when N is not given, this is as coeffs) or the one of the Nth power when N is an integer (this is how coeff works), or the leading or trailing coefficient (pass N as the corresponding word, this produces the equivalent of lcoeff and tcoeff results), or a sequence of coefficients when N is a range of integers. The case N = all is then equivalent to the range case N = lower_degree .. higher_degree.
 • Unlike coeff and coeffs, when x is a single variable and more than one coefficient is requested (for example, you call Coefficients with just two arguments, or with a third argument as a range), Coefficients returns the sequence of coefficients in ascending order, including those that are equal to 0. To receive only the non-zero coefficients use the optional argument onlynonzero. When N is omitted it is assumed equal to all.
 • When x is a product, say a * b, Coefficients(p, a * b, N) returns the equivalent of taking a * b as a single variable - say c. Note: when a and b are anticommutative, Coefficients(p, a*b) returns the same as - Coefficients(p, b*a); likely, Coefficients(a*b, a) = - Coefficients(b*a, a).
 • When x is a list, say [a, b], Coefficients(p, [a, b], N) returns the equivalent of recursively computing the coefficients with respect to each of the elements of the list, that is the same as op(map(Coefficients, [Coefficients(p, a, N)], b, N)). Note that when a and b are anticommutative, Coefficients(p, [a, b]) returns the same as - Coefficients(p, [b, a]); likely, Coefficients(a*b, [a, b]) = - Coefficients(b*a, [a, b]).
 • Related to extracting coefficients, to compute the Degree of an expression with respect to anticommutative variables use the Physics:-Library:-Degree command. Examples

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{mathematicalnotation}=\mathrm{true}\right)$
 $\left[{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}\right]$ (1)

First set theta as an identifier to work with type/anticommutative variables (see Setup)

 > $\mathrm{Setup}\left(\mathrm{anticommutativepre}=\mathrm{θ}\right)$
 $\mathrm{* Partial match of \text{'}}\mathrm{anticommutativepre}\mathrm{\text{'} against keyword \text{'}}\mathrm{anticommutativeprefix}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{anticommutativeprefix}}{=}\left\{{\mathrm{\theta }}\right\}\right]$ (2)
 > $a{\mathrm{θ}}_{1}{\mathrm{θ}}_{2}+b$
 ${a}{}{{\mathrm{\theta }}}_{{1}}{}{{\mathrm{\theta }}}_{{2}}{+}{b}$ (3)

The following three input lines have the same meaning, returning a sequence with all the coefficients

 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{1}\right)$
 ${b}{,}{a}{}{{\mathrm{\theta }}}_{{2}}$ (4)
 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{1},\mathrm{all}\right)$
 ${b}{,}{a}{}{{\mathrm{\theta }}}_{{2}}$ (5)
 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{1},0..1\right)$
 ${b}{,}{a}{}{{\mathrm{\theta }}}_{{2}}$ (6)

When the third argument is an integer, Coefficients returns the coefficient of the corresponding power

 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{1},0\right)$
 ${b}$ (7)
 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{1},1\right)$
 ${a}{}{{\mathrm{\theta }}}_{{2}}$ (8)

Computing the coefficient or the 1st power of an anticommutative variable is the same as differentiating with respect to it

 > $\frac{\partial }{\partial {\mathrm{θ}}_{1}}$
 ${a}{}{{\mathrm{\theta }}}_{{2}}$ (9)
 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{2},1\right)$
 ${-}{a}{}{{\mathrm{\theta }}}_{{1}}$ (10)
 > $\frac{\partial }{\partial {\mathrm{θ}}_{2}}$
 ${-}{a}{}{{\mathrm{\theta }}}_{{1}}$ (11)

The coefficient of a product: note the change in sign when you reverse the order of the anticommutative variables in the coefficient product-variable

 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{1}{\mathrm{θ}}_{2}\right)$
 ${b}{,}{a}$ (12)
 > $\mathrm{Coefficients}\left(,{\mathrm{θ}}_{2}{\mathrm{θ}}_{1}\right)$
 ${b}{,}{-}{a}$ (13)

The coefficients of a list of variables - note the zeros in the output

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right]\right)$
 ${b}{,}{0}{,}{0}{,}{a}$ (14)
 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right],\mathrm{all}\right)$
 ${b}{,}{0}{,}{0}{,}{a}$ (15)

To receive only the nonzero coefficients use the onlynonzero optional argument

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right],\mathrm{onlynonzero}\right)$
 ${b}{,}{a}$ (16)

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right],\mathrm{leading}\right)$
 ${a}$ (17)
 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{2},{\mathrm{θ}}_{1}\right],\mathrm{trailing}\right)$
 ${b}$ (18)

When the third argument, N, is an integer, and the second argument is a list, the coefficients are computed recursively;

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right],0\right)$
 ${b}$ (19)

When N is equal to 1, this is also equivalent to differentiation

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right],1\right)$
 ${a}$ (20)
 > $\frac{{\partial }^{2}}{\partial {\mathrm{θ}}_{2}\partial {\mathrm{θ}}_{1}}$
 ${a}$ (21)

Reversing the order of the anticommutative variables in the list,

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{2},{\mathrm{θ}}_{1}\right],1\right)$
 ${-}{a}$ (22)
 > $\frac{{\partial }^{2}}{\partial {\mathrm{θ}}_{1}\partial {\mathrm{θ}}_{2}}$
 ${-}{a}$ (23)

When the variables are anticommutative, their square is zero,

 > ${\mathrm{θ}}_{1}^{2}$
 ${0}$ (24)

Hence,

 > $\mathrm{Coefficients}\left(,\left[{\mathrm{θ}}_{1},{\mathrm{θ}}_{2}\right],2\right)$
 ${0}$ (25) See Also Compatibility

 • The Physics[Coefficients] command was introduced in Maple 16.