represents the special non-commutative algebra alg.
NonCommutativeAlgebra[spec]
represents the general non-commutative algebra given by the specification spec.
NonCommutativeAlgebra
represents the special non-commutative algebra alg.
NonCommutativeAlgebra[spec]
represents the general non-commutative algebra given by the specification spec.
Details
- NonCommutativeAlgebra is used to represent a non-commutative algebra.
- NonCommutativeAlgebra objects are used to specify the underlying algebra in functions like NonCommutativeExpand, NonCommutativeCollect, NonCommutativeGroebnerBasis, etc.
- Possible special algebras alg include:
-
{Dot,n}
matricesNonCommutativeMultiply non-commutative polynomials Composition linear endomorphisms with composition TensorProduct infinite direct sum of tensor powers - All special algebras are essentially free algebras that differ only in operation names. No relations between symbolic variables are assumed.
- The specification spec is an association with the following keys and their default values:
-
"Multiplication" NonCommutativeMultiply non-commutative multiplication 
"Addition" Plus addition 
"Unity" 1 one for multiplication
and 
"Zero" 0 zero for addition
and 
"CommutativeVariables" {} variables that commute with all elements "ScalarVariables" Automatic scalar variables "Generators" Automatic generators of the algebra "Relations" Automatic relations satisfied by the generators "CommutationRelations" Automatic relations for commuting the generators "Structure" Automatic named algebra structure "VariableOrder" "Increasing" ordering of variables "WordOrder" "Lexicographic" ordering of monomials that differ only in the order of variables - A valid algebra specification may be an association or a list of rules giving values for some of the above keys or a single rule.
- The value associated with a given key in a NonCommutativeAlgebra object ncalg can be extracted with ncalg["key"].
- A NonCommutativeAlgebra object represents a unitary algebra. An algebra is a vector space equipped with a bilinear product operation. An algebra is unitary if its product operation has a neutral element.
- "Addition" is assumed to be a commutative operation with "Zero" acting as the zero.
- "Multiplication" is assumed to be bilinear, which means
and
where
and
are scalars. Furthermore, "Unity" is acting as the one. - "ScalarVariables" are assumed to be scalars. The default Automatic setting means that when "Generators" are specified, then all symbolic variables that are not in "Generators" or "CommutativeVariables" are assumed to be scalars; otherwise, no symbolic variables are assumed to be scalars. Scalar addition and multiplication are represented by Plus and Times.
- "Generators" can be Automatic or {gs1,…,gsk}, where gsi are disjoint lists of variables. gsi=x, where x is a variable, is equivalent to gsi={x}.
- "VariableOrder" can be either "Increasing" or "Decreasing". With the default "Increasing" setting, variables that appear earlier in variable lists are considered to be smaller. Elements of "Generators" are always considered to be larger than elements of "CommutativeVariables".
- When "Generators" is {gs1,…,gsk}, all algebra elements are represented as polynomials in elements of the gsi and "CommutativeVariables". The standard representation of algebra elements, given by NonCommutativeExpand, is the result of reducing the polynomials modulo the Gröbner basis of the algebra relations.
- The monomial order, used in polynomial reduction and Gröbner basis computation, is the multi-graded order defined as follows. Monomials are ordered first on the number of occurrences of variables from generator lists gsi, starting with the list that contains the largest variables, then on the number of occurrences of "CommutativeVariables". If all numbers of occurrences are the same, monomials are ordered using "WordOrder", which can be one of "Lexicographic" (default), "ReverseLexicographic", "NegativeLexicographic" and "NegativeReverseLexicographic".
- "Relations" can be Automatic or a list of relations satisfied by the algebra generators.
- "CommutationRelations" can be Automatic or a list of commutation relations for the algebra generators. Specifying a list of commutation relations requires "Generators" to be specified. If the generators are
, then for
,
in the monomial order and the commutation relation for
and
needs to have the form
, where
are nonzero scalars, and
is a polynomial in
all of whose monomials are less than
in the monomial order. Moreover, for all
, polynomials
should reduce to zero modulo the commutation relations. »These conditions guarantee that the commutation relations form a Gröbner basis. Generator pairs for which commutation relations are not listed are assumed to commute. » - When "CommutationRelations" are given, all algebra elements can be uniquely represented as linear combinations of standard monomials
, where the exponents denote repeated application of the algebra multiplication. The definition of Gröbner basis is different for algebras with and without commutation relations. - "Structure" can be Automatic or one of the following named algebra structures:
-
{"Weyl",{vars,dvars}} Weyl algebra in variables vars and derivatives dvars {"Clifford",{pvars,nvars,zvars}} Clifford algebra with generators pvars that square to
, nvars that square to
and zvars that square to 
{"Grassmann",vars} Grassmann algebra with generators vars {"Dirac",{γ0,γ1,γ2,γ3}} Dirac algebra with generators {γ0,γ1,γ2,γ3} {"Anticommutative",{x1,x2,…}} algebra with generators {x1,x2,…} and commutation relations
for 
- Named algebra structures specify algebra generators and their relations, hence if "Structure" is not Automatic, then "Relations" and "CommutationRelations" need to be Automatic. "Generators" can be used to specify the variable order but needs to contain the same generators as specified by "Structure".
- When "Relations", "CommutationRelations" and "Structure" are all Automatic, the algebra is a free algebra.
- The detailed specifications spec for the special algebras alg are given below:
-
{Dot,n} <|"Multiplication"Dot, "Unity"SymbolicIdentityArray[{n}],"Zero"SymbolicZerosArray[{n,n}]|> NonCommutativeMultiply <||> Composition <|"Multiplication"Composition, "Unity"Identity|> TensorProduct <|"Multiplication"TensorProduct|>
Examples
open all close allBasic Examples (2)
A NonCommutativeAlgebra object with default properties:
alg = NonCommutativeAlgebra[]Specify the underlying algebra in NonCommutativeExpand:
NonCommutativeExpand[(a + 2b)**(3a + 4b), alg]Specify multiplication, addition and scalar variables:
alg = NonCommutativeAlgebra[<|"Multiplication" -> mult, "Addition" -> add, "ScalarVariables" -> {s, t}|>]Specify the underlying algebra in NonCommutativeExpand:
NonCommutativeExpand[mult[add[s a, t b], (s - t)c], alg]Scope (16)
Basic Uses (6)
Specify that the variable c commutes with all algebra elements:
alg = NonCommutativeAlgebra[<|"CommutativeVariables" -> {c}|>];NonCommutativeExpand[(a + b)**(c + d) + (c + d)**(a + b), alg]Square matrices with Dot product form an algebra:
alg = NonCommutativeAlgebra[{Dot, n}]NonCommutativeExpand[a.(b + c).(2a + 3d), alg]Linear endomorphisms with Composition form an algebra:
alg = NonCommutativeAlgebra[Composition]NonCommutativeExpand[Composition[f + g, g + h, h + f], alg]Compute with polynomials over an abstract algebra with symbolic property names:
alg = NonCommutativeAlgebra[<|"Multiplication" -> mult, "Addition" -> add, "Unity" -> one, "Zero" -> zero|>];NonCommutativeExpand[mult[add[x, y], add[2x, 3y], add[4x, 5y]], alg]NonCommutativeExpand[add[mult[add[x, y], add[2x, 3y], add[4x, 5y]], -%], alg]NonCommutativeCollect[add[mult[x, y], 2x, 3mult[x, y, x, y]], x, alg]Scalar arguments to algebra operations are interpreted as scalar multiples of the multiplicative unity:
alg = NonCommutativeAlgebra[];NonCommutativeExpand[(x + 1)**(y + 2), alg]alg = NonCommutativeAlgebra[<|"Multiplication" -> mult, "Addition" -> add, "Unity" -> one, "Zero" -> zero|>];NonCommutativeExpand[mult[add[x, 1], add[y, 2]], alg]Interpretation of unknown symbolic variables depends on the algebra settings:
alg = NonCommutativeAlgebra[]When algebra generators are not specified, symbolic variables are treated as algebra elements:
NonCommutativeExpand[(x + 2u + 3z)**(y + 4v + 5w), alg]Otherwise, when "ScalarVariables"Automatic, symbolic variables are treated as scalars:
alg = NonCommutativeAlgebra[<|"Generators" -> {{x, y, z}}, "CommutativeVariables" -> {w}|>]Symbolic variables that are not generators or commutative variables are scalars:
NonCommutativeExpand[(x + 2u + 3z)**(y + 4v + 5w), alg]When both algebra generators and scalar variables are specified, there should be no other variables:
alg = NonCommutativeAlgebra[<|"Generators" -> {{x, y, z}}, "ScalarVariables" -> {u, v}|>]Expressions that contain unknown symbolic variables are not elements of the algebra:
NonCommutativeExpand[(x + 2u + 3z)**(y + 4v + 5w), alg]
Algebras Given by Generators and Relations (4)
Define an algebra with generators
satisfying the relation
:
alg = NonCommutativeAlgebra[<|"Generators" -> {{x, y}}, "Relations" -> {y**y - 2x}|>]NonCommutativeExpand automatically reduces modulo the relation:
NonCommutativeExpand[GeneralizedPower[NonCommutativeMultiply, (x + y), 5], alg]Define an algebra with "CommutationRelations" specified:
crels = {y**x - 2x**y + x, z**y - 2y**z + z, z**x - 2x**z + y};alg = NonCommutativeAlgebra[<|"Generators" -> {{x, y, z}}, "CommutationRelations" -> crels|>]Algebra elements can be uniquely represented in terms of standard monomials
:
NonCommutativeExpand[z**y**x**x**y**z, alg]Uniqueness is guaranteed by the requirement that commutation relations form a Gröbner basis:
NonCommutativeGroebnerBasis[crels, {{x, y, z}}]Here "CommutationRelations" do not satisfy the required conditions:
crels = {y**x - 2x**y - x, z**y - 2y**z + z, z**x - 2x**z + y};NonCommutativeAlgebra[<|"Generators" -> {{x, y, z}}, "CommutationRelations" -> crels|>]crels do not form a Gröbner basis:
NonCommutativeGroebnerBasis[crels, {{x, y, z}}]Algebra with relations crels is, in fact, isomorphic to the coefficient field:
alg = NonCommutativeAlgebra[<|"Generators" -> {{x, y, z}}, "Relations" -> crels|>]NonCommutativeExpand[GeneralizedPower[NonCommutativeMultiply, (x + 2y + 3z + 4), 5], alg]Define an algebra with both "Relations" and "CommutationRelations" specified:
alg = NonCommutativeAlgebra[<|"Generators" -> {{x, y}}, "CommutationRelations" -> {y**x + x**y}, "Relations" -> {x**x, y**y}|>]Compute the standard representation of an element:
NonCommutativeExpand[(x + 2y + 3)**(4x + 5y + 6)**(7x + 8y + 9), alg]The algebra is isomorphic to a Grassmann algebra:
alg1 = NonCommutativeAlgebra[<|"Structure" -> {"Grassmann", {x, y}}|>]NonCommutativeExpand[(x + 2y + 3)**(4x + 5y + 6)**(7x + 8y + 9), alg1]Algebras with Named Structure (3)
alg = NonCommutativeAlgebra[<|"Structure" -> {"Weyl", {{x, y}, {dx, dy}}}|>]Compute the standard representation of an element:
NonCommutativeExpand[dx**x**dy**x**y, alg]Since algebra generators are specified, symbolic variables that are not generators are treated as scalars:
NonCommutativeExpand[a**dx**b**x**c**y, alg]Use WeylAlgebra to specify the algebra:
WeylAlgebra[{{x, y}, {dx, dy}}]% === algalg = NonCommutativeAlgebra[<|"Structure" -> {"Clifford", {{x}, {y}, {z}}}|>]Compute the standard representation of an element:
NonCommutativeExpand[(x + 2y + 3z + 4)**(5x + 6y + 7z + 8), alg]Use CliffordAlgebra to specify the algebra:
CliffordAlgebra[{{x}, {y}, {z}}]% === algalg = NonCommutativeAlgebra[<|"Multiplication" -> Wedge, "Structure" -> {"Grassmann", {x, y, z}}|>]Compute the standard representation of an element:
NonCommutativeExpand[(x + 2y + 3z + 4)⋀(5x + 6y + 7z + 8), alg]Use GrassmannAlgebra to specify the algebra:
GrassmannAlgebra[{x, y, z}]% === algMonomial Ordering (3)
The order and grouping of generators determines the multi-graded monomial ordering:
poly = Range[8].NonCommutativeMultiply@@@Tuples[{x, y}, 3]{alg1, alg2, alg3, alg4} = NonCommutativeAlgebra[<|"Generators" -> #|>]& /@ {{{x}, {y}}, {{x, y}}, {{y}, {x}}, {{y, x}}};NonCommutativeMonomialList lists monomials in decreasing order:
NonCommutativeMonomialList[poly, alg1]NonCommutativeMonomialList[poly, alg2]NonCommutativeMonomialList[poly, alg3]NonCommutativeMonomialList[poly, alg4]"WordOrdering" determines the ordering of monomials that differ only in variable order:
poly = Range[6].NonCommutativeMultiply@@@Permutations[{x, y, z}]{lex, rlex, nlex, nrlex} = NonCommutativeAlgebra[<|"Generators" -> {x, y, z}, "WordOrder" -> #|>]& /@ {"Lexicographic", "ReverseLexicographic", "NegativeLexicographic", "NegativeReverseLexicographic"};NonCommutativeMonomialList lists monomials in decreasing order:
NonCommutativeMonomialList[poly, lex]NonCommutativeMonomialList[poly, rlex]NonCommutativeMonomialList[poly, nlex]NonCommutativeMonomialList[poly, nrlex]By default, variables listed first are considered to be smaller:
alg1 = NonCommutativeAlgebra[<|"Generators" -> {x, y}|>];NonCommutativeMonomialList lists monomials in decreasing order:
NonCommutativeMonomialList[1 + x + y, alg1]alg2 = NonCommutativeAlgebra[<|"Generators" -> {x, y}, "VariableOrder" -> "Decreasing"|>];NonCommutativeMonomialList[1 + x + y, alg2]The setting also affects variables given as a function argument when "Generators" is not specified:
alg1 = NonCommutativeAlgebra[];NonCommutativePolynomialReduce[x**y, {x**y - y**x}, {x, y}, alg1]alg2 = NonCommutativeAlgebra["VariableOrder" -> "Decreasing"];NonCommutativePolynomialReduce[x**y, {x**y - y**x}, {x, y}, alg2]Applications (6)
Simplification (2)
Check whether two noncommutative polynomials are equal:
p = a**(b**c + c**b) + (b**c + c**b)**a + b**(a**c - c**a)q = (a**c - c**a)**b + c**(a**b + b**a) + (a**b + b**a)**cExpand the difference of the polynomials:
NonCommutativeExpand[p - q]Simplify an expression involving
matrices
and
:
expr = (Inverse[a] + Inverse[b]).a.Inverse[a + b].bFind the inverses in the expression:
inv = Union[Cases[expr, _Inverse, Infinity]]Generate the relations satisfied by the inverses:
rel = Join@@({#1.First[#1] - SymbolicIdentityArray[{n}], First[#1].#1 - SymbolicIdentityArray[{n}]}& /@ inv)Pick a variable order that makes the most complicated variables largest:
vars = Join[{a, b}, inv]Compute the Gröbner basis of the ideal generated by the relations over the algebra of
matrices:
alg = NonCommutativeAlgebra[{Dot, n}];gb = NonCommutativeGroebnerBasis[rel, vars, alg]Reducing the expression modulo the Gröbner basis shows that it is equal to the identity matrix:
NonCommutativePolynomialReduction[expr, gb, vars, alg]Use ArraySimplify to do the above simplification steps automatically:
ArraySimplify[expr, Element[a | b, Matrices[{n, n}]]]Proving Identities (1)
Prove the Woodbury matrix identity:
In the standard formulation,
is an
matrix,
is a
matrix, with
,
is an
matrix, and
is a
matrix. However, by replacing
,
and
with the block matrices
,
and
, one may assume that all matrices belong to the algebra of
matrices. It will be shown that the difference of the sides of the identity reduces to zero modulo the Gröbner basis of the ideal generated by relations implied by the properties of the matrix inverse.
Compute the difference
of the sides of the Woodbury matrix identity:
d = Subtract@@(Inverse[(a + u.c.v)] == Inverse[a] - Inverse[a].u.Inverse[(v.Inverse[a].u + Inverse[c])].v.Inverse[a])inv = Union[Cases[d, _Inverse, Infinity]]Generate the relations satisfied by the inverses:
rel = Join@@({#1.First[#1] - SymbolicIdentityArray[{n}], First[#1].#1 - SymbolicIdentityArray[{n}]}& /@ inv)Pick a variable order that makes the most complicated variables largest:
vars = Join[{a, c, u, v}, inv]Compute the Gröbner basis of the ideal generated by the relations over the algebra of
matrices:
alg = NonCommutativeAlgebra[{Dot, n}];gb = NonCommutativeGroebnerBasis[rel, vars, alg]Reduce
modulo the Gröbner basis. The result is a zero matrix, which proves the identity:
NonCommutativePolynomialReduction[d, gb, vars, alg]Use ArraySimplify to do the above simplification steps automatically:
ArraySimplify[d, Element[a | c | u | v, Matrices[{n, n}]]]Group Presentations (1)
Construct a finitely presented group. The dicyclic group
is given by generators
and relations
. The group algebra of
is given by four generators:
gens = {a, x, inv[a], inv[x]};The generators satisfy the following relations:
rel = {GeneralizedPower[NonCommutativeMultiply, a, 6] - 1, GeneralizedPower[NonCommutativeMultiply, x, 2] - GeneralizedPower[NonCommutativeMultiply, a, 3], inv[x]**a**x - inv[a], a**inv[a] - 1, inv[a]**a - 1, x**inv[x] - 1, inv[x]**x - 1};Compute the Gröbner basis of the ideal generated by the relations:
vars = {{a, x}, {inv[a], inv[x]}};gb = NonCommutativeGroebnerBasis[rel, vars]Note that reducing an arbitrary monomial modulo the Gröbner basis gives a monomial that does not contain
and
. This shows that reducing an arbitrary monomial in
and
of total degree
yields a monomial of a total degree at most
:
NonCommutativePolynomialReduction[#, gb, vars]& /@ NonCommutativeMultiply@@@Tuples[{a, x}, 5]Hence, all elements of the group can be represented as reduced monomials of degree at most
:
gg = Union[NonCommutativePolynomialReduction[#, gb, vars]& /@ Join@@Table[NonCommutativeMultiply@@@Tuples[{a, x}, i], {i, 0, 4}]]It has been proven that
is a finite group of order
:
Length[gg]Special Algebras (2)
Compute in the Clifford algebra
:
cl33 = NonCommutativeAlgebra["Structure" -> {"Clifford", {{e1, e2, e3}, {e4, e5, e6}}}]Compute the standard representation of
:
f = NonCommutativeExpand[1 / 8(1 + e1**e4)**(1 + e2**e5)**(1 + e3**e6), cl33]NonCommutativeExpand[f**f, cl33] === fCompute the standard representation of
:
g = NonCommutativeExpand[e1**e2**e3**f, cl33]NonCommutativeExpand[g**g, cl33]Compute in the Weyl algebra associated to the differential ring of bivariate polynomials:
wa2 = NonCommutativeAlgebra["Structure" -> {"Weyl", {{x, y}, {dx, dy}}}]Compute the standard representation of
and
:
f = NonCommutativeExpand[(dx + dy)**x**y, wa2]g = NonCommutativeExpand[dx**(x + y)**(dx - dy), wa2]Compute the standard representation of
:
h = NonCommutativeExpand[f**g, wa2]Elements of the Weyl algebra correspond to differential operators with product representing composition:
diff[x][p_] := x p
diff[y][p_] := y p
diff[dx][p_] := D[p, x]
diff[dy][p_] := D[p, y]
diff[a_ ? NumericQ][p_] := a p
diff[a_ ? NumericQ f_][p_] := a diff[f][p]
diff[f_Plus][p_] := diff[#][p]& /@ f
diff[f_NonCommutativeMultiply][p_] := (Composition@@(diff /@ f))[p]
diff[GeneralizedPower[NonCommutativeMultiply, f_, k_]][p_] := Nest[diff[f], p, k]Verify that the operator corresponding to
is the composition of the operators corresponding to
and
:
diff[f][diff[g][(2x + 3y) ^ 3]]diff[h][(2x + 3y) ^ 3]Expand[%% - %]Properties & Relations (3)
CliffordAlgebra gives a NonCommutativeAlgebra with Clifford algebra structure:
CliffordAlgebra[{{x, y}, {z, t}, {}}]% === NonCommutativeAlgebra["Structure" -> {"Clifford", {{x, y}, {z, t}, {}}}]GrassmannAlgebra gives a NonCommutativeAlgebra with Grassmann algebra structure:
GrassmannAlgebra[{x, y, z}]% === NonCommutativeAlgebra[{"Multiplication" -> Wedge, "Structure" -> {"Grassmann", {x, y, z}}}]WeylAlgebra gives a NonCommutativeAlgebra with Weyl algebra structure:
WeylAlgebra[{{x, y}, {dx, dy}}]% === NonCommutativeAlgebra["Structure" -> {"Weyl", {{x, y}, {dx, dy}}}]Possible Issues (1)
When "Structure" is specified, some properties are implied and their settings are ignored:
a = NonCommutativeAlgebra[<|"Structure" -> {"Grassmann", {x, y, z}}, "Relations" -> {x - y}, "CommutationRelations" -> {}|>]a[{"Relations", "CommutationRelations"}]Tech Notes
Related Guides
Text
Wolfram Research (2025), NonCommutativeAlgebra, Wolfram Language function, https://reference.wolfram.com/language/ref/NonCommutativeAlgebra.html (updated 2026).
CMS
Wolfram Language. 2025. "NonCommutativeAlgebra." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/NonCommutativeAlgebra.html.
APA
Wolfram Language. (2025). NonCommutativeAlgebra. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NonCommutativeAlgebra.html
BibTeX
@misc{reference.wolfram_2026_noncommutativealgebra, author="Wolfram Research", title="{NonCommutativeAlgebra}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/NonCommutativeAlgebra.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_noncommutativealgebra, organization={Wolfram Research}, title={NonCommutativeAlgebra}, year={2026}, url={https://reference.wolfram.com/language/ref/NonCommutativeAlgebra.html}, note=[Accessed: 12-June-2026]}