 |
Collect
Collect[
expr
,
x
] collects together terms involving the same powers of objects matching x. Collect[
expr
,
,
, ...
] collects together terms that involve the same powers of objects matching , , ... . Collect[
expr
,
var
,
h
] applies h to the expression that forms the coefficient of each term obtained.
Collect[
expr
,
x
] effectively writes expr as a polynomial in x or a fractional power of x. Examples: Collect[x + n x + m, x] ; Collect[(1+x+y)^3, x] . Collect[
expr
,
x
,
Simplify] can be used to simplify each coefficient separately. See the Mathematica book: Section 1.4.5, Section 3.3.1. See also: Series, CoefficientList, Together, Cases.
Further Examples
These two inputs collect terms first in the variable x and then in the variable y.
In[1]:= 
Out[1]= 
In[2]:= 
Out[2]= 
This first collects with respect to x, then collects coefficients with respect to y inside of each of the x coefficients.
In[3]:= 
Out[3]= 
In this example we use Collect to rewrite an expression by pulling out factors common only to certain parts.
In[4]:= 
Out[4]= 
This example has the usual two arguments.
In[5]:= 
Out[5]= 
Collect applies an optional third argument to the innermost coefficients of the collected terms.
In[6]:= 
Out[6]= 
Suppose you want to collect all the products of powers of x and y in a polynomial that involves other variables. One way is to use patterns.
In[7]:= 
Out[7]= 
Another way is to use MonomialList.
In[8]:= 
Out[8]= 
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION. | | | |
 | |
|