Pauli Operators¶
Quantum operators can be expressed as combinations of Pauli operators I, X, Y, Z:
>>> operator = sZ(0)*sZ(1) + sX(2)*sY(3)
>>> print(operator)
(1+0j)*Z0*Z1 + (1+0j)*X2*Y3
Construction functions¶
sX (q) |
A function that returns the sigma_X operator on a particular qubit. |
sY (q) |
A function that returns the sigma_Y operator on a particular qubit. |
sZ (q) |
A function that returns the sigma_Z operator on a particular qubit. |
sI ([q]) |
A function that returns the identity operator, optionally on a particular qubit. |
ID () |
The identity operator. |
ZERO () |
The zero operator. |
Working with operators¶
simplify_pauli_sum (pauli_sum) |
Simplify the sum of Pauli operators according to Pauli algebra rules. |
check_commutation (pauli_list, pauli_two) |
Check if commuting a PauliTerm commutes with a list of other terms by natural calculation. |
commuting_sets (pauli_terms) |
Gather the Pauli terms of pauli_terms variable into commuting sets |
is_identity (term) |
Tests to see if a PauliTerm or PauliSum is a scalar multiple of identity |
is_zero (pauli_object) |
Tests to see if a PauliTerm or PauliSum is zero. |
exponentiate (term) |
Creates a pyQuil program that simulates the unitary evolution exp(-1j * term) |
exponential_map (term) |
Returns a function f(alpha) that constructs the Program corresponding to exp(-1j*alpha*term). |
exponentiate_commuting_pauli_sum (pauli_sum) |
Returns a function that maps all substituent PauliTerms and sums them into a program. |
suzuki_trotter (trotter_order, trotter_steps) |
Generate trotterization coefficients for a given number of Trotter steps. |
trotterize (first_pauli_term, second_pauli_term) |
Create a Quil program that approximates exp( (A + B)t) where A and B are PauliTerm operators. |
Classes¶
-
class
pyquil.paulis.
PauliSum
(terms)[source]¶ A sum of one or more PauliTerms.
Parameters: terms (Sequence) – A Sequence of PauliTerms. Methods
get_qubits
()The support of all the operators in the PauliSum object. simplify
()Simplifies the sum of Pauli operators according to Pauli algebra rules. get_programs
()Get a Pyquil Program corresponding to each term in the PauliSum and a coefficient for each program from_compact_str
(str_pauli_sum)Construct a PauliSum from the result of str(pauli_sum)
-
class
pyquil.paulis.
PauliTerm
(op, index, coefficient=1.0)[source]¶ A term is a product of Pauli operators operating on different qubits.
Create a new Pauli Term with a Pauli operator at a particular index and a leading coefficient.
Parameters: Methods
id
([sort_ops])Returns an identifier string for the PauliTerm (ignoring the coefficient). operations_as_set
()Return a frozenset of operations in this term. copy
()Properly creates a new PauliTerm, with a completely new dictionary of operators program
rtype: Program
from_list
(terms_list[, coefficient])Allocates a Pauli Term from a list of operators and indices. pauli_string
([qubits])Return a string representation of this PauliTerm without its coefficient and with implicit qubit indices.