For a electrical switch that periodically reverses the current see Commutator (electric)

In mathematics the commutator of two elements g and h of a group G is the element g-1 h-1 gh, often denoted by [g,h]. It is equal to 1 if and only if g and h commute, i.e., if and only if gh = hg. The subgroup generated by all commutators is called the derived group or the commutator subgroup of G: we consider the subgroup generated by the set of commutators because in general the set of commutators is not closed under the group operation. Commutators are used to define nilpotent groups.

Commutators are also defined for rings and associative algebras. Here, the commutator [a,b] of two elements a and b is also called the Lie bracket and is defined by [a,b] = ab - ba. It is zero if and only if a and b commute. By using the Lie bracket, every associative algebra can be turned into a Lie algebra. The commutator of two operators defined on a Hilbert space is an important concept in quantum mechanics since it measures how well the two observables described by the operators can be measured simultaneously. The Uncertainty Principle is ultimately a theorem about these commutators.