qrunch.quantum.operators.pauli

Module that contains the abstract Pauli operators \(X\), \(Y\), \(Z\), and \(I\).

These operators correspond to Pauli matrices acting on specified qubits.

A general Hermitian operator can be expressed as a combination of these fundamental operators through addition and multiplication, applied to specific qubits.

Example
from qrunch.quantum.operators.pauli import X, Y, Z

Obs = 0.5 * X(1) * X(2) + 1.2 * Y(3) * Y(4) - 0.7 * Z(1) * Z(2) * Z(3) * Z(4)

A Hermitian operator like this can be used as input for various tools, such as estimators, which calculate the expectation value of the operator for a given quantum state represented by a quantum circuit.

Classes

I

Pauli identity operator.

X

Pauli \(X\) operator.

Y

Pauli \(Y\) operator.

Z

Pauli \(Z\) operator.

class I

Bases: PauliOperator

Pauli identity operator.

__init__(qubit: AbstractIndex | int) None

Initialize Pauli operator that operates on the specified qubit.

The index can be a concrete integer or an AbstractIndex. When an abstract index is used it can be set using with_indices(), returning a new instance of the operator with the index set to the concrete value.

Parameters:

qubit (AbstractIndex | int) – The qubit to operate on.

Return type:

None

get_indices() tuple[AbstractIndex | int]

Get index of the operator (abstract or concrete).

Return type:

tuple[AbstractIndex | int]

property qubit: AbstractIndex | int

The qubit the operator acts on.

with_indices(index_value_pairs: IndexValuePairs) PauliOperator

Create a new copy of the operator with the AbstractIndex set to the given value.

Parameters:

index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.

Return type:

PauliOperator

class X

Bases: PauliOperator

Pauli \(X\) operator.

__init__(qubit: AbstractIndex | int) None

Initialize Pauli operator that operates on the specified qubit.

The index can be a concrete integer or an AbstractIndex. When an abstract index is used it can be set using with_indices(), returning a new instance of the operator with the index set to the concrete value.

Parameters:

qubit (AbstractIndex | int) – The qubit to operate on.

Return type:

None

get_indices() tuple[AbstractIndex | int]

Get index of the operator (abstract or concrete).

Return type:

tuple[AbstractIndex | int]

property qubit: AbstractIndex | int

The qubit the operator acts on.

with_indices(index_value_pairs: IndexValuePairs) PauliOperator

Create a new copy of the operator with the AbstractIndex set to the given value.

Parameters:

index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.

Return type:

PauliOperator

class Y

Bases: PauliOperator

Pauli \(Y\) operator.

__init__(qubit: AbstractIndex | int) None

Initialize Pauli operator that operates on the specified qubit.

The index can be a concrete integer or an AbstractIndex. When an abstract index is used it can be set using with_indices(), returning a new instance of the operator with the index set to the concrete value.

Parameters:

qubit (AbstractIndex | int) – The qubit to operate on.

Return type:

None

get_indices() tuple[AbstractIndex | int]

Get index of the operator (abstract or concrete).

Return type:

tuple[AbstractIndex | int]

property qubit: AbstractIndex | int

The qubit the operator acts on.

with_indices(index_value_pairs: IndexValuePairs) PauliOperator

Create a new copy of the operator with the AbstractIndex set to the given value.

Parameters:

index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.

Return type:

PauliOperator

class Z

Bases: PauliOperator

Pauli \(Z\) operator.

__init__(qubit: AbstractIndex | int) None

Initialize Pauli operator that operates on the specified qubit.

The index can be a concrete integer or an AbstractIndex. When an abstract index is used it can be set using with_indices(), returning a new instance of the operator with the index set to the concrete value.

Parameters:

qubit (AbstractIndex | int) – The qubit to operate on.

Return type:

None

get_indices() tuple[AbstractIndex | int]

Get index of the operator (abstract or concrete).

Return type:

tuple[AbstractIndex | int]

property qubit: AbstractIndex | int

The qubit the operator acts on.

with_indices(index_value_pairs: IndexValuePairs) PauliOperator

Create a new copy of the operator with the AbstractIndex set to the given value.

Parameters:

index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.

Return type:

PauliOperator

Modules

operator_base

Base class for all Pauli operators, which define internal logic and enables simplification of Pauli expressions.

strings

Efficient representation of a Pauli string.

sums

Efficient representation of a Pauli sum.