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 on the web: Section 1.4.5 and Section 3.3.1.
See also: Series, CoefficientList, Together, Cases.
Further Examples