# qml.grouping.is_commuting¶

is_commuting(pauli_word_1, pauli_word_2, wire_map=None)[source]

Checks if two Pauli words commute.

To determine if two Pauli words commute, we can check the value of the symplectic inner product of their binary vector representations. For two binary vectors representing Pauli words, $$p_1 = [x_1, z_1]$$ and $$p_2 = [x_2, z_2],$$ the symplectic inner product is defined as $$\langle p_1, p_2 \rangle_{symp} = z_1 x_2^T + z_2 x_1^T$$. If the symplectic product is $$0$$ they commute, while if it is $$1$$, they don’t commute.

Parameters
• pauli_word_1 (Observable) – first Pauli word in commutator

• pauli_word_2 (Observable) – second Pauli word in commutator

• 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

Returns

returns True if the input Pauli commute, False otherwise

Return type

bool

Raises

TypeError – if either of the Pauli words is not valid.

Example

>>> wire_map = {'a' : 0, 'b' : 1, 'c' : 2}
>>> pauli_word_1 = qml.PauliX('a') @ qml.PauliY('b')
>>> pauli_word_2 = qml.PauliZ('a') @ qml.PauliZ('c')
>>> is_commuting(pauli_word_1, pauli_word_2, wire_map=wire_map)
False

Using PennyLane

Development

API