Collect
Usage
• Collect[expr, x]把涉及匹配 x的对象的相同幂的项合并到一起。
• Collect[expr, var, h]把 h 应用到形成获得的每一项的系数的表达式。
Notes
• Collect[expr, x]有效的把expr写为一个 x 的多项式或 x 的分数幂。 • 例如: Collect[x + n x + m, x]  ; Collect[(1+x+y)^3, x]  . • Collect[expr, x, Simplify]可以用于分别简化每个系数。
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]=
|
You can use patterns to collect all the products of powers of x and y in a polynomial that involves other variables.
In[7]:=
|
Out[7]=
|
|