In mathematics, the **commutator** gives an indication of the extent to which a certain binary operation fails to be commutative. There are different definitions used in group theory and ring theory.

The **commutator** of two elements, g and h, of a group G, is the element

- [
*g*,*h*] =*g*^{−1}*h*^{−1}*gh*.

This element is equal to the group's identity if and only if g and h commute (from the definition *gh* = *hg* [*g*, *h*], being [*g*, *h*] equal to the identity if and only if *gh* = *hg*).

The set of all commutators of a group is not in general closed under the group operation, but the subgroup of *G* generated by all commutators is closed and is called the *derived group* or the *commutator subgroup* of *G*. Commutators are used to define nilpotent and solvable groups and the largest abelian quotient group.

The definition of the commutator above is used throughout this article, but many other group theorists define the commutator as

- [
*g*,*h*] =*ghg*^{−1}*h*^{−1}.^{[1]}^{[2]}

Commutator identities are an important tool in group theory.^{[3]} The expression *a ^{x}* denotes the conjugate of a by x, defined as

- and
- and
- and

Identity (5) is also known as the *Hall–Witt identity*, after Philip Hall and Ernst Witt. It is a group-theoretic analogue of the Jacobi identity for the ring-theoretic commutator (see next section).

N.B., the above definition of the conjugate of a by x is used by some group theorists.^{[4]} Many other group theorists define the conjugate of a by x as *xax*^{−1}.^{[5]} This is often written . Similar identities hold for these conventions.

Many identities are used that are true modulo certain subgroups. These can be particularly useful in the study of solvable groups and nilpotent groups. For instance, in any group, second powers behave well:

If the derived subgroup is central, then

Rings often do not support division. Thus, the **commutator** of two elements *a* and *b* of a ring (or any associative algebra) is defined differently by

The commutator is zero if and only if *a* and *b* commute. In linear algebra, if two endomorphisms of a space are represented by commuting matrices in terms of one basis, then they are so represented in terms of every basis. By using the commutator as a Lie bracket, every associative algebra can be turned into a Lie algebra.

The **anticommutator** of two elements a and b of a ring or associative algebra is defined by

Sometimes is used to denote anticommutator, while is then used for commutator.^{[6]} The anticommutator is used less often, but can be used to define Clifford algebras and Jordan algebras and in the derivation of the Dirac equation in particle physics.

The commutator of two operators acting on a Hilbert space is a central concept in quantum mechanics, since it quantifies how well the two observables described by these operators can be measured simultaneously. The uncertainty principle is ultimately a theorem about such commutators, by virtue of the Robertson–Schrödinger relation.^{[7]} In phase space, equivalent commutators of function star-products are called Moyal brackets and are completely isomorphic to the Hilbert space commutator structures mentioned.

The commutator has the following properties:

Relation (3) is called anticommutativity, while (4) is the Jacobi identity.

If A is a fixed element of a ring *R*, identity (1) can be interpreted as a Leibniz rule for the map given by . In other words, the map ad_{A} defines a derivation on the ring *R*. Identities (2), (3) represent Leibniz rules for more than two factors, and are valid for any derivation. Identities (4)–(6) can also be interpreted as Leibniz rules. Identities (7), (8) express **Z**-bilinearity.

From identity (9), one finds that the commutator of integer powers of ring elements is:

Some of the above identities can be extended to the anticommutator using the above ± subscript notation.^{[8]}
For example:

Consider a ring or algebra in which the exponential can be meaningfully defined, such as a Banach algebra or a ring of formal power series.

In such a ring, Hadamard's lemma applied to nested commutators gives: (For the last expression, see *Adjoint derivation* below.) This formula underlies the Baker–Campbell–Hausdorff expansion of log(exp(*A*) exp(*B*)).

A similar expansion expresses the group commutator of expressions (analogous to elements of a Lie group) in terms of a series of nested commutators (Lie brackets),

When dealing with graded algebras, the commutator is usually replaced by the **graded commutator**, defined in homogeneous components as

Especially if one deals with multiple commutators in a ring *R*, another notation turns out to be useful. For an element , we define the adjoint mapping by:

This mapping is a derivation on the ring *R*:

By the Jacobi identity, it is also a derivation over the commutation operation:

Composing such mappings, we get for example and

We may consider itself as a mapping, , where is the ring of mappings from

By contrast, it is **not** always a ring homomorphism: usually .

The general Leibniz rule, expanding repeated derivatives of a product, can be written abstractly using the adjoint representation:

Replacing *x* by the differentiation operator , and *y* by the multiplication operator , we get , and applying both sides to a function *g*, the identity becomes the usual Leibniz rule for the *n*-th derivative .