# Wavefunction Methods¶

class pyquil.api.WavefunctionSimulator(connection=None, random_seed=None)[source]

A simulator that propagates a wavefunction representation of a quantum state.

Parameters

Methods

 wavefunction(quil_program[, memory_map]) Simulate a Quil program and return the wavefunction. expectation(prep_prog, pauli_terms[, memory_map]) Calculate the expectation value of Pauli operators given a state prepared by prep_program. run_and_measure(quil_program[, qubits, …]) Run a Quil program once to determine the final wavefunction, and measure multiple times.
class pyquil.wavefunction.Wavefunction(amplitude_vector)[source]

Encapsulate a wavefunction representing a quantum state as returned by WavefunctionSimulator.

Note

The elements of the wavefunction are ordered by bitstring. E.g., for two qubits the order is 00, 01, 10, 11, where the the bits are ordered in reverse by the qubit index, i.e., for qubits 0 and 1 the bitstring 01 indicates that qubit 0 is in the state 1. See also the related documentation section in the WavefunctionSimulator Overview.

Initializes a wavefunction

Parameters

amplitude_vector (ndarray) – A numpy array of complex amplitudes

Attributes and Methods

 Returns an array of probabilities in lexicographical order pretty_print([decimal_digits]) Returns a string repr of the wavefunction, ignoring all outcomes with approximately zero amplitude (up to a certain number of decimal digits) and rounding the amplitudes to decimal_digits. pretty_print_probabilities([decimal_digits]) TODO: This doesn’t seem like it is named correctly… sample_bitstrings(n_samples) Sample bitstrings from the distribution defined by the wavefunction. zeros(qubit_num) Constructs the groundstate wavefunction for a given number of qubits.