qrisp.operators.qubit.QubitOperator.commutator#
- QubitOperator.commutator(other)[source]#
Computes the commutator.
\[[A,B] = AB - BA\]- Parameters:
- otherQubitOperator
The second argument of the commutator.
- Returns:
- commutatorQubitOperator
The commutator operator.
Examples
We compute the commutator of a ladder operator with a Pauli string.
>>> from qrisp.operators import A,C,X,Z >>> O_0 = A(0)*C(1)*A(2) >>> O_1 = Z(0)*X(1)*X(1) >>> print(O_0.commutator(O_1)) 2*A_0*C_1*A_2