collect coefficients of like powers - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Algebra : Polynomials : Manipulation : collect

collect - collect coefficients of like powers

Calling Sequence

collect(a, x)

collect(a, x, form, func)

collect(a, x, func)

Parameters

a

-

expression

x

-

indeterminate, or a list or set of indeterminates, or an unevaluated function

form

-

(optional) name; `recursive` (default) or `distributed`

func

-

(optional) procedure

Description

• 

The collect function views a as a general polynomial in x.  It collects all the coefficients with the same rational power of x.  This includes positive and negative powers, and fractional powers.  Note that the resulting expression is not necessarily sorted by powers of x.  To sort a polynomial see the sort function.

• 

There are four main purposes for using collect. Firstly, to "simplify" an expression by factoring out all terms of like powers in some indeterminate. Secondly, to expand a polynomial in a variable before applying the coeff function. Thirdly, to write a multivariate polynomial in different forms. Fourthly, to apply a function to the coefficients of a polynomial. The examples below show each of these uses.

• 

The second argument x can be a single indeterminate (univariate case) or a list or set of indeterminates x1, x2, ..., xn (multivariate case).  Sets can only be used if the distributed form is specified (see below).  The indeterminates can be names or unevaluated function calls but not sums or products or fractional powers.  To collect fractional powers, for example x just collect x.

• 

Two forms for the result are available.  The form is specified by the optional argument form. It may be the name `recursive` (the default) or the name `distributed`.

• 

The recursive form is obtained by first collecting the coefficients in x1, then for each coefficient in x1, collecting the coefficients in x2 and so on. If the indeterminates are specified as a set, their order is controlled by Maple and the results might differ from session to session. The distributed form is the form obtained by collecting the coefficients of x1e1x2e2...xnen.

• 

A function may be specified using the optional argument func. It is applied to the coefficients of the collected result. Often simplify or factor will be used.

• 

The following shorthand is supported:  often one wants to collect all the derivatives in an expression, or all the sine and cosines present in an expression.  If func is a name then collect(expr, func) will collect expr with respect to functions whose name is func.

Examples

Simplifying an expression by regrouping terms

f:=alnxlnxxx

f:=alnxlnxxx

(1)

collectf,lnx

axlnxx

(2)

g:=∫x2ⅇx+ⅇxⅆx

g:=x2ⅇx2xⅇx+2ⅇxx2ⅇx2xⅇx2ⅇx

(3)

collectg,ⅇx

x22x+2ⅇx+x22x2ⅇx

(4)

Expanding a polynomial in one variable before using coeff

f:=xx+1+yx+1

f:=xx+1+yx+1

(5)

coefff,x,1

1+y

(6)

g:=collectf,x

g:=x2+1+yx+y

(7)

coeffg,x,1

1+y

(8)

Writing a multivariate polynomial in different forms

p:=xy+axy+yx2ayx2+x+ax:

collectp,x,y,recursive

a+1yx2+a+1y+a+1x

(9)

collectp,y,x,recursive

a+1x2+a+1xy+a+1x

(10)

Note this returns a result that is order-dependent

collectp,x,y,recursive

a+1yx2+a+1y+a+1x

(11)

But this does not

collectp,x,y,distributed

a+1yx2+a+1xy+a+1x

(12)

collectp,x,y,distributed

a+1yx2+a+1xy+a+1x

(13)

Applying a function to the coefficients

f:=a3xx+a3+a

f:=a3x+a3+ax

(14)

collectf,x

a31x+a3+a

(15)

collectf,x,factor

a1a2+a+1x+aa2+1

(16)

Collect understands positive and negative rational powers

p:=yx+2zx+x13yx13

p:=yx+2zx+x1/3yx1/3

(17)

collectp,x

1yx1/3+y+2zx

(18)

Collect can simplify for general indeterminates (e.g. diff, D, sin).

DE:=ⅆ2ⅆx2yxsinxⅆⅆxyxsinyx+sinxⅆⅆxyx+sinyxⅆ2ⅆx2yx

DE:=ⅆ2ⅆx2yxsinxⅆⅆxyxsinyx+sinxⅆⅆxyx+sinyxⅆ2ⅆx2yx

(19)

collectDE,diff

sinx+sinyxⅆ2ⅆx2yx+sinxsinyxⅆⅆxyx

(20)

collectDE,sin

ⅆ2ⅆx2yx+ⅆⅆxyxsinx+ⅆ2ⅆx2yxⅆⅆxyxsinyx

(21)

Collect does not sort in general

collectx3y+x2y3+x+3,y

x2y3+x3y+x+3

(22)

sort,y

x2y3+x3y+x+3

(23)

See Also

coeff, sort


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam