# pyquil.paulis¶

Module for working with Pauli algebras.

pyquil.paulis.ID()

The identity Pauli Term.

class pyquil.paulis.PauliSum(terms)

Bases: object

A sum of one or more PauliTerms.

get_programs()

Get a Pyquil Program corresponding to each term in the PauliSum and a coefficient for each program

Returns: (programs, coefficients)
get_qubits()

The support of all the operators in the PauliSum object.

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

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

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

Bases: object

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

copy()

Properly creates a new PauliTerm, with a completely new dictionary of operators

classmethod from_list(terms_list, coefficient=1.0)

Allocates a Pauli Term from a list of operators and indices. This is more efficient than multiplying together individual terms.

Parameters: terms_list (list) – A list of tuples, e.g. [(“X”, 0), (“Y”, 1)] PauliTerm
get_qubits()

Gets all the qubits that this PauliTerm operates on.

id()
Returns the unique identifier string for the PauliTerm (ignoring the coefficient).
Used in the simplify method of PauliSum.
Returns: The unique identifier for this term. string
program
exception pyquil.paulis.UnequalLengthWarning(*args, **kwargs)
pyquil.paulis.ZERO()

The zero Pauli Term.

pyquil.paulis.check_commutation(pauli_list, pauli_two)

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)

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)

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)

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.exponentiate_commuting_pauli_sum(pauli_sum)

Returns a function that maps all substituent PauliTerms and sums them into a program. NOTE: Use this function with care. Substituent PauliTerms should commute.

Parameters: pauli_sum (PauliSum) – PauliSum to exponentiate. A function that parametrizes the exponential. function
pyquil.paulis.is_identity(term)

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)

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)

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)

Change the coefficient of a PauliTerm.

Parameters: term (PauliTerm) – A PauliTerm object coeff (Number) – 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)

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