qml.pauli.pauli_mult_with_phase

pauli_mult_with_phase(pauli_1, pauli_2, wire_map=None)[source]

Multiply two Pauli words together, and return both their product as a Pauli word and the global phase.

Warning

pauli_mult_with_phase is deprecated. Instead, you can multiply two Pauli words together with qml.simplify(qml.prod(pauli_1, pauli_2)). Note that if there is a phase, this will be in result.scalar, and the base will be available in result.base.

Two Pauli operations can be multiplied together by taking the additive OR of their binary symplectic representations. The phase is computed by looking at the number of times we have the products \(XY, YZ\), or \(ZX\) (adds a phase of \(i\)), or \(YX, ZY, XZ\) (adds a phase of \(-i\)).

Parameters
  • pauli_1 (Operation) – A Pauli word.

  • pauli_2 (Operation) – A Pauli word to multiply with the first one.

  • wire_map (dict[Union[str, int], int]) – dictionary containing all wire labels used in the Pauli word as keys, and unique integer labels as their values. If no wire map is provided, the map will be constructed from the set of wires acted on by the input Pauli words.

Returns

The product of pauli_1 and pauli_2, and the global phase.

Return type

tuple[Operation, complex]

Example

This function works the same as pauli_mult() but also returns the global phase accumulated as a result of the ordering of Paulis in the product (e.g., \(XY = iZ\), and \(YX = -iZ\)).

>>> from pennylane.pauli import pauli_mult_with_phase
>>> pauli_1 = qml.X(0) @ qml.Z(1)
>>> pauli_2 = qml.Y(0) @ qml.Z(1)
>>> product, phase = pauli_mult_with_phase(pauli_1, pauli_2)
>>> product
Z(0)
>>> phase
1j