commutator
commutator(op_a, op_b)
Computes the commutator of two operators.
The commutator is defined as:
Operators which support this method must implement the SupportsCommutators protocol.
Note
Both inputs must be of the same operator type. This will also determine the output type.
>>> from qiskit_bosons.operators import BosonOperator, ann, cre
>>> from qiskit_bosons.operators.library import commutator
>>> b = BosonOperator.from_dict({(ann(0),): 1.0})
>>> b_dag = BosonOperator.from_dict({(cre(0),): 1.0})
>>> commutator(b, b_dag).equiv(BosonOperator.one())
True
>>> n = BosonOperator.from_dict({(cre(0), ann(0)): 1.0})
>>> commutator(n, b_dag).equiv(b_dag)
True
>>> b1_dag = BosonOperator.from_dict({(cre(1),): 1.0})
>>> commutator(b_dag, b1_dag).equiv(BosonOperator.zero())
True
Parameters
- op_a (T) – the operator above.
- op_b (T) – the operator above.
Returns
The commutator .
Return type
T
Was this page helpful?
Report a bug, typo, or request content on GitHub.