In Quantum Mechanics, what is a commutator?
Definition
For the given two operators $A, B$, $AB - BA$ is defined as the commutator of $A, B$ and is denoted as follows:
$$ [A,B]=AB-BA $$
Explanation
Upon first encountering the definition of a commutator, one might wonder if it is not $AB - BA = 0$. However, since operators are expressed as matrices and the product of two matrices does not satisfy the commutative law, different results can be produced depending on the order of multiplication.
To study quantum mechanics, a generalization of vectors, matrices, and inner products is required. Operators can also be represented as matrices (vectors). When two operators have a commutator $0$, they are said to commute with each other. The reason for using a commutator is to expedite calculations. For instance, let $P$ be the momentum operator and $X$ be the position operator. Given a wave function $\psi$, suppose the following equation is given:
$$ PX \psi - XP\psi = [P, X]\psi $$
If one does not know the value of $[P, X]$, one must solve it as seen on the left side. This would require applying $X$ to $\psi$ and then applying $P$ (first term), and then subtracting the result of applying $P$ to $\psi$ and then $X$ (second term), making the calculation lengthy. However, knowing the value of $[P, X]$, the cumbersome calculation process is reduced as shown on the right side. Since the commutator of these two is $[P, X] = -\i\hbar$, one can immediately know the answer is $-\i\hbar \psi$.
Anticommutator
Meanwhile, the anticommutator is defined as follows:
$$ \left\{A,B\right\}=AB+BA $$