double_commutator¶
- double_commutator(op_a, op_b, op_c, sign)¶
Computes the double-commutator of three operators.
The double-commutator is defined as follows (see also Equation (13.6.18) in [1]):
If
signisFalse, it returns\[[[A, B], C]/2 + [A, [B, C]]/2 = (2ABC + 2CBA - BAC - CAB - ACB - BCA)/2. \]If
signisTrue, it returns\[\{[A, B], C\}/2 + \{A, [B, C]\}/2 = (2ABC - 2CBA - BAC + CAB - ACB + BCA)/2. \]Operators which support this method must implement the
SupportsCommutatorsprotocol.Note
All three inputs must be of the same operator type. This will also determine the output type.
>>> from qiskit_fermions.operators import FermionOperator >>> from qiskit_fermions.operators.library import anti_commutator >>> op1 = FermionOperator.from_dict({((True, 0), (False, 0)): 1}) >>> op2 = FermionOperator.from_dict({((False, 0), (True, 0)): 2}) >>> op3 = FermionOperator.from_dict( ... {((True, 0), (False, 0)): 1, ((False, 0), (True, 0)): 2 + 0.5j} ... ) >>> comm = double_commutator(op1, op2, op3, False) >>> comm = comm.normal_ordered() >>> canon = comm.simplify() >>> assert canon == FermionOperator.zero()
- Parameters:
op_a (SupportsCommutators) – the operator \(A\) above.
op_b (SupportsCommutators) – the operator \(B\) above.
op_c (SupportsCommutators) – the operator \(C\) above.
sign (bool) – the nature of the outer (anti-)commutator as per the definition above.
- Returns:
The double-commutator as per the definition above.
- Return type: