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 sign is False, it returns

\[[[A, B], C]/2 + [A, [B, C]]/2 = (2ABC + 2CBA - BAC - CAB - ACB - BCA)/2. \]

If sign is True, 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 SupportsCommutators protocol.

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:
Returns:

The double-commutator as per the definition above.

Return type:

SupportsCommutators