qrisp.operators.qubit.QubitOperator.to_pauli#

QubitOperator.to_pauli()[source]#

Returns an equivalent operator, which however only contains Pauli factors.

Returns:
QubitOperator

An operator that contains only Pauli-Factor.

Examples

We create a QubitOperator containing A and C terms and convert it to a Pauli based representation.

>>> from qrisp.operators import A,C,Z
>>> H = A(0)*C(1)*Z(2)
>>> print(H.to_pauli())
0.25*X_0*X_1*Z_2 + 0.25*I*X_0*Y_1*Z_2 - 0.25*I*Y_0*X_1*Z_2 + 0.25*Y_0*Y_1*Z_2