Collect

Collect[expr,x]

collects together terms involving the same powers of objects matching x.

Collect[expr,{x1,x2,}]

successively collects together terms that involve the same powers of objects matching x1, then x2, .

Collect[expr,var,h]

applies h to the expression that forms the coefficient of each term obtained.

Details and Options

  • Collect[expr,x] effectively writes expr as a polynomial in x or a fractional power of x.
  • Collect[expr,x,Simplify] can be used to simplify each coefficient separately.
  • Collect automatically threads over lists in expr, as well as equations, inequalities and logic functions.

Examples

open allclose all

Basic Examples  (4)

Combine like terms involving :

Collect terms involving :

Collect terms involving :

Collect each power of :

Simplify each coefficient:

Scope  (6)

Basic Uses  (3)

A polynomial:

A Puiseux polynomial:

Collect with respect to first, then collect with respect to :

Advanced Uses  (3)

Collect with respect to a pattern:

Collect derivative terms:

Factor each coefficient after collection of terms:

Collect terms over the integers modulo :

Options  (1)

Modulus  (1)

Collect over the integers modulo 2:

Applications  (1)

When a polynomial has many variables, it can be put into many different forms. Here is a polynomial in three variables:

Collect reorganizes the polynomial so that is the dominant variable:

If is specified as the parameter, the terms are organized with as the leading variable:

When two variables are specified, the function will collect with respect to first, then collect with respect to :

Or collect with respect to first, then collect with respect to :

Properties & Relations  (2)

Expand is effectively the inverse of Collect:

The order of variables matters:

Wolfram Research (1988), Collect, Wolfram Language function, https://reference.wolfram.com/language/ref/Collect.html (updated 2007).

Text

Wolfram Research (1988), Collect, Wolfram Language function, https://reference.wolfram.com/language/ref/Collect.html (updated 2007).

CMS

Wolfram Language. 1988. "Collect." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/Collect.html.

APA

Wolfram Language. (1988). Collect. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Collect.html

BibTeX

@misc{reference.wolfram_2024_collect, author="Wolfram Research", title="{Collect}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Collect.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_collect, organization={Wolfram Research}, title={Collect}, year={2007}, url={https://reference.wolfram.com/language/ref/Collect.html}, note=[Accessed: 21-November-2024 ]}