NonCommutativeCollect[expr,x,alg]
collects together terms involving the same powers of objects matching x over the noncommutative algebra alg.
NonCommutativeCollect[expr,{x1,x2,…},alg]
successively collects together terms that involve the same powers of objects matching x1 then x2, ….
NonCommutativeCollect[expr,{{x1,s1},{x2,s2},…},alg]
successively collects together terms that involve the same powers of objects matching xi on the side indicated by si, where si is Left, Right or All.
NonCommutativeCollect
NonCommutativeCollect[expr,x,alg]
collects together terms involving the same powers of objects matching x over the noncommutative algebra alg.
NonCommutativeCollect[expr,{x1,x2,…},alg]
successively collects together terms that involve the same powers of objects matching x1 then x2, ….
NonCommutativeCollect[expr,{{x1,s1},{x2,s2},…},alg]
successively collects together terms that involve the same powers of objects matching xi on the side indicated by si, where si is Left, Right or All.
Details
- NonCommutativeCollect is typically used to collect terms in a non-commutative polynomial.
- When collecting with respect to xi on both sides, first terms that involve the same powers of xi on the right are collected, and then terms that involve the same powers of xi on the left are collected. In other words, specifications {…,xi,…}, {…,{xi,All},…} and {…,{xi,Right},{xi,Left},…} are equivalent.
- alg can be a NonCommutativeAlgebra object or any valid NonCommutativeAlgebra specification. If the algebra argument is omitted, NonCommutativeAlgebra with the default property values is used.
- For algebras with relations, NonCommutativeCollect first computes the standard representation and then collects.
- NonCommutativeCollect automatically threads over lists in expr.
Examples
open all close allBasic Examples (3)
Collect terms involving the same powers of x:
NonCommutativeCollect[x**x**y**x + 2x**x**z**x + 3x**y**x**x + 4x**z**x**x, x]Collect terms involving the same powers of x on the right:
NonCommutativeCollect[x**x**y**x + 2x**x**z**x + 3x**y**x**x + 4x**z**x**x, {x, Right}]Collect terms involving the same powers of x on the left:
NonCommutativeCollect[x**x**y**x + 2x**x**z**x + 3x**y**x**x + 4x**z**x**x, {x, Left}]Collect over an algebra with symbolic operation names:
alg = NonCommutativeAlgebra[<|"Multiplication" -> mult, "Addition" -> add|>];NonCommutativeCollect[add[mult[a, x], 2mult[b, x], c], x, alg]Compute the standard representation and collect with respect to x:
alg = WeylAlgebra[{{x, y}, {dx, dy}}];NonCommutativeCollect[dx**dy**x**y**x**y, x, alg]Scope (4)
Collect over the algebra of square matrices with Dot product:
NonCommutativeCollect[a.b + a.c + b.a.a + c.a.a, a, {Dot, n}]Collect over the algebra of linear endomorphisms with Composition:
NonCommutativeCollect[f @* g + f @* h + g @* f @* f + h @* f @* f, f, Composition]Collecting with respect to different variable specifications may yield different results:
expr = x**a**x + x**b**x + x**a**b**x + x**a**x**b**x;NonCommutativeCollect[expr, x]NonCommutativeCollect[expr, {a, b, x}]NonCommutativeCollect[expr, {x, a, b}]NonCommutativeCollect[expr, {{x, Left}, a, b}]NonCommutativeCollect[expr, {{x, Right}, a, b}]NonCommutativeCollect is listable with respect to the first argument:
NonCommutativeCollect[{a**b + a**c, b**a + c**a}, a]Properties & Relations (2)
NonCommutativeCollect collects terms in noncommutative polynomials:
NonCommutativeCollect[x**y + 2x**z, x]Collect collects terms in commutative polynomials:
Collect[x * y + 2x * z, x]NonCommutativeExpand is effectively the inverse of NonCommutativeCollect:
NonCommutativeCollect[x**y**x + 2x**z**x, x]NonCommutativeExpand[%]Tech Notes
Related Guides
Text
Wolfram Research (2025), NonCommutativeCollect, Wolfram Language function, https://reference.wolfram.com/language/ref/NonCommutativeCollect.html (updated 2026).
CMS
Wolfram Language. 2025. "NonCommutativeCollect." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/NonCommutativeCollect.html.
APA
Wolfram Language. (2025). NonCommutativeCollect. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NonCommutativeCollect.html
BibTeX
@misc{reference.wolfram_2026_noncommutativecollect, author="Wolfram Research", title="{NonCommutativeCollect}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/NonCommutativeCollect.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_noncommutativecollect, organization={Wolfram Research}, title={NonCommutativeCollect}, year={2026}, url={https://reference.wolfram.com/language/ref/NonCommutativeCollect.html}, note=[Accessed: 12-June-2026]}