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.
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.
- Collect takes the following options:
-
Modulus 0 modulus to assume for integers Trig False whether to do trigonometric as well as algebraic transformations
Examples
open all close allBasic Examples (4)
Combine like terms involving
:
Collect[b x ^ 2 + 5x + 7x ^ 2 + 9a x + 2, x]Collect[a x + b y + c x + d y, x]Collect[a x + b y + c x + d y, y]Collect[(1 + a + x) ^ 3, x]Collect[(1 + a + x) ^ 3, x, Simplify]Scope (6)
Basic Uses (3)
Collect[a x ^ 4 + b x ^ 4 + 2a ^ 2x - 3b x + x - 7, x]Collect[a Sqrt[x] + Sqrt[x] + x ^ (2 / 3) - c x + 3x - 2b x ^ (2 / 3) + 5, x]Collect with respect to
first, then collect with respect to
:
Collect[(x y + x z + y z + x + y) ^ 3, {x, y}]Advanced Uses (3)
Collect with respect to a pattern:
D[f[Sqrt[x ^ 2 + 1]], {x, 3}]Collect[%, Derivative[_][f][_], Together]Factor each coefficient after collection of terms:
Collect[(1 + a + x) ^ 4, x, Factor]Collect terms over the integers modulo
:
Collect[(4 + 2a + x) ^ 2, x, Modulus -> 3]Options (1)
Applications (1)
When a polynomial has many variables, it can be put into many different forms. Here is a polynomial in three variables:
Expand[(y + 2x + 3x y + 4x z + 5y z) ^ 3]Collect reorganizes the polynomial so that
is the dominant variable:
Collect[%, x]If
is specified as the parameter, the terms are organized with
as the leading variable:
Collect[%, y]When two variables are specified, the function will collect with respect to
first, then collect with respect to
:
Collect[%, {x, y}]Or collect with respect to
first, then collect with respect to
:
Collect[%, {y, x}]Properties & Relations (3)
Expand is effectively the inverse of Collect:
f = Expand[(x + y + 1) ^ 5];Collect[f, x]Expand[%] === fThe order of variables matters:
Collect[(1 + x + y + z) ^ 2, {x, y}, Simplify]Collect[(1 + x + y + z) ^ 2, {y, x}, Simplify]Use NonCommutativeCollect to collect terms in a noncommutative polynomial:
NonCommutativeCollect[x**x**y**x + 2x**x**z**x + 3x**y**x**x + 4x**z**x**x, x]Related Guides
Related Links
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 2007 (6.0)
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_2026_collect, author="Wolfram Research", title="{Collect}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Collect.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_collect, organization={Wolfram Research}, title={Collect}, year={2007}, url={https://reference.wolfram.com/language/ref/Collect.html}, note=[Accessed: 12-June-2026]}