Collect2

Description

Collect2[expr, x] collects together terms which are not free of any occurrence of x. Collect2[expr, {x1, x2, ...}] (or also Collect2[expr, x1, x2, ...]) collects together terms which are not free of any occurrence of x1, x2, .... The coefficients are put over a common denominator. If expr is expanded before collecting depends on the option Factoring, which may be set to Factor, Factor2, or any other function, which is applied to the coefficients. If expr is already expanded with respect to x (x1,x2, ...), the option Expanding can be set to False.

Options[Collect2]

See also:  Isolate.

Examples

Collect2[t1 = a + r a + (k^2) f[a] - k f[a] + (x/2) - (y/w), 
      a]

Collect2[t1, a, Factoring -> False]

Collect2[t1, a, Factoring -> Factor]

Collect2[
      2 a (b - a) (h - 1) - (b^2) (e a - c) + (b^2), {a, 
        b}]

Collect2[Expand[(((a - b - c - d))^5)], a, 
      IsolateNames -> L]

ReleaseHold[%]

Clear[t1, L]

Collect2[Expand[(((a - b - c))^3)], a, 
      Factoring -> fun]

%  /.  fun -> FactorTerms