# pyquil.paulis¶

Module for working with Pauli algebras.

pyquil.paulis.ID = <pyquil.paulis.PauliTerm object>

The identity Pauli operator on the 0th qubit.

class pyquil.paulis.PauliSum(terms)[source]

Bases: object

A sum of one or more PauliTerms.

get_qubits()[source]

The support of all the operators in the PauliSum object.

Returns: A list of all the qubits in the sum of terms. list
simplify()[source]

Simplifies the sum of Pauli operators according to Pauli algebra rules.

class pyquil.paulis.PauliTerm(op, index, coefficient=1.0)[source]

Bases: object

A term is a product of Pauli operators operating on different qubits.

get_qubits()[source]

Gets all the qubits that this PauliTerm operates on.

id()[source]

Returns the unique identifier string for the PauliTerm. Used in the simplify method of PauliSum.

Returns: The unique identifier for this term. string
pyquil.paulis.check_commutation(pauli_list, pauli_two)[source]

Check if commuting a PauliTerm commutes with a list of other terms by natural calculation. Derivation similar to arXiv:1405.5749v2 fo the check_commutation step in the Raesi, Wiebe, Sanders algorithm (arXiv:1108.4318, 2011).

Parameters: pauli_list (list) – A list of PauliTerm objects pauli_two_term (PauliTerm) – A PauliTerm object True if pauli_two object commutes with pauli_list, False otherwise bool
pyquil.paulis.commuting_sets(pauli_terms, nqubits)[source]

Gather the Pauli terms of pauli_terms variable into commuting sets

Uses algorithm defined in (Raeisi, Wiebe, Sanders, arXiv:1108.4318, 2011) to find commuting sets. Except uses commutation check from arXiv:1405.5749v2

Parameters: pauli_terms (PauliSum) – A PauliSum object List of lists where each list contains a commuting set list
pyquil.paulis.exponential_map(term)[source]

Creates map alpha -> exp(-1j*alpha*term) represented as a Program.

Parameters: term (PauliTerm) – Tests is a PauliTerm is the identity operator Program Program
pyquil.paulis.exponentiate(term)[source]

Creates a pyQuil program that simulates the unitary evolution exp(-1j * term)

Parameters: term (PauliTerm) – Tests is a PauliTerm is the identity operator A Program object Program
pyquil.paulis.is_identity(term)[source]

Check if Pauli Term is a scalar multiple of identity

Parameters: term (PauliTerm) – A PauliTerm object True if the PauliTerm is a scalar multiple of identity, false otherwise bool
pyquil.paulis.is_zero(pauli_object)[source]

Tests to see if a PauliTerm or PauliSum is zero.

Parameters: pauli_object – Either a PauliTerm or PauliSum True if PauliTerm is zero, False otherwise bool
pyquil.paulis.sI(q)

A function that returns the identity operator on a particular qubit.

Parameters: qubit_index (int) – The index of the qubit A PauliTerm object PauliTerm
pyquil.paulis.sX(q)

A function that returns the sigma_X operator on a particular qubit.

Parameters: qubit_index (int) – The index of the qubit A PauliTerm object PauliTerm
pyquil.paulis.sY(q)

A function that returns the sigma_Y operator on a particular qubit.

Parameters: qubit_index (int) – The index of the qubit A PauliTerm object PauliTerm
pyquil.paulis.sZ(q)

A function that returns the sigma_Z operator on a particular qubit.

Parameters: qubit_index (int) – The index of the qubit A PauliTerm object PauliTerm
pyquil.paulis.suzuki_trotter(trotter_order, trotter_steps)[source]

Generate trotterization coefficients for a given number of Trotter steps.

U = exp(A + B) is approximated as exp(w1*o1)exp(w2*o2)... This method returns a list [(w1, o1), (w2, o2), ... , (wm, om)] of tuples where o=0 corresponds to the A operator, o=1 corresponds to the B operator, and w is the coefficient in the exponential. For example, a second order Suzuki-Trotter approximation to exp(A + B) results in the following [(0.5/trotter_steps, 0), (1/trotteri_steps, 1), (0.5/trotter_steps, 0)] * trotter_steps.

Parameters: trotter_order (int) – order of Suzuki-Trotter approximation trotter_steps (int) – number of steps in the approximation List of tuples corresponding to the coefficient and operator type: o=0 is A and o=1 is B. list
pyquil.paulis.term_with_coeff(term, coeff)[source]

Change the coefficient of a PauliTerm.

Parameters: term (PauliTerm) – A PauliTerm object coeff (float) – The coefficient to set on the PauliTerm A new PauliTerm that duplicates term but sets coeff PauliTerm
pyquil.paulis.trotterize(first_pauli_term, second_pauli_term, trotter_order=1, trotter_steps=1)[source]

Create a Quil program that approximates exp( (A + B)t) where A and B are PauliTerm operators.

Parameters: first_pauli_term (PauliTerm) – PauliTerm denoted A second_pauli_term (PauliTerm) – PauliTerm denoted B trotter_order (int) – Optional argument indicating the Suzuki-Trotter approximation order–only accepts orders 1, 2, 3, 4. trotter_steps (int) – Optional argument indicating the number of products to decompose the exponential into. Quil program Program