# PhaseEstimation¶

class PhaseEstimation(num_evaluation_qubits, unitary, iqft=None, name='QPE')[source]

Phase Estimation circuit.

In the Quantum Phase Estimation (QPE) algorithm [1, 2, 3], the Phase Estimation circuit is used to estimate the phase $$\phi$$ of an eigenvalue $$e^{2\pi i\phi}$$ of a unitary operator $$U$$, provided with the corresponding eigenstate $$|psi\rangle$$. That is

$U|\psi\rangle = e^{2\pi i\phi} |\psi\rangle$

This estimation (and thereby this circuit) is a central routine to several well-known algorithms, such as Shor’s algorithm or Quantum Amplitude Estimation.

References:

: Kitaev, A. Y. (1995). Quantum measurements and the Abelian Stabilizer Problem. 1–22.

quant-ph/9511026

: Michael A. Nielsen and Isaac L. Chuang. 2011.

Quantum Computation and Quantum Information: 10th Anniversary Edition (10th ed.). Cambridge University Press, New York, NY, USA.

: Qiskit

textbook

Parameters
• num_evaluation_qubits (int) – The number of evaluation qubits.

• unitary (QuantumCircuit) – The unitary operation $$U$$ which will be repeated and controlled.

• iqft (Optional[QuantumCircuit]) – A inverse Quantum Fourier Transform, per default the inverse of QFT is used. Note that the QFT should not include the usual swaps!

• name (str) – The name of the circuit.

Note

The inverse QFT should not include a swap of the qubit order.

Reference Circuit:

Attributes

 PhaseEstimation.ancillas Returns a list of ancilla bits in the order that the registers were added. PhaseEstimation.clbits Returns a list of classical bits in the order that the registers were added. PhaseEstimation.data Return the circuit data (instructions and context). PhaseEstimation.extension_lib PhaseEstimation.global_phase Return the global phase of the circuit in radians. PhaseEstimation.header PhaseEstimation.instances PhaseEstimation.n_qubits Deprecated, use num_qubits instead. PhaseEstimation.num_ancillas Return the number of ancilla qubits. PhaseEstimation.num_clbits Return number of classical bits. PhaseEstimation.num_parameters Convenience function to get the number of parameter objects in the circuit. PhaseEstimation.num_qubits Return number of qubits. PhaseEstimation.parameters Convenience function to get the parameters defined in the parameter table. PhaseEstimation.prefix PhaseEstimation.qubits Returns a list of quantum bits in the order that the registers were added.

Methods

 PhaseEstimation.AND(qr_variables, qb_target, …) Build a collective conjunction (AND) circuit in place using mct. PhaseEstimation.OR(qr_variables, qb_target, …) Build a collective disjunction (OR) circuit in place using mct. Return indexed operation. Return number of operations in circuit. Add registers. PhaseEstimation.append(instruction[, qargs, …]) Append one or more instructions to the end of the circuit, modifying the circuit in place. PhaseEstimation.assign_parameters(param_dict) Assign parameters to new parameters or values. Apply Barrier. PhaseEstimation.bind_parameters(value_dict) Assign numeric parameters to values yielding a new circuit. PhaseEstimation.cast(value, _type) Best effort to cast value to type. Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits. PhaseEstimation.ccx(control_qubit1, …[, …]) Apply CCXGate. PhaseEstimation.ch(control_qubit, …[, …]) Apply CHGate. Return the current number of instances of this class, useful for auto naming. Return the prefix to use for auto naming. PhaseEstimation.cnot(control_qubit, …[, …]) Apply CXGate. Append rhs to self if self contains compatible registers. PhaseEstimation.compose(other[, qubits, …]) Compose circuit with other circuit or instruction, optionally permuting wires. PhaseEstimation.control([num_ctrl_qubits, …]) Control this circuit on num_ctrl_qubits qubits. PhaseEstimation.copy([name]) Copy the circuit. Count each operation kind in the circuit. PhaseEstimation.cp(theta, control_qubit, …) Apply CPhaseGate. PhaseEstimation.crx(theta, control_qubit, …) Apply CRXGate. PhaseEstimation.cry(theta, control_qubit, …) Apply CRYGate. PhaseEstimation.crz(theta, control_qubit, …) Apply CRZGate. PhaseEstimation.cswap(control_qubit, …[, …]) Apply CSwapGate. PhaseEstimation.csx(control_qubit, target_qubit) Apply CSXGate. PhaseEstimation.cu(theta, phi, lam, gamma, …) Apply CUGate. PhaseEstimation.cu1(theta, control_qubit, …) Apply CU1Gate. PhaseEstimation.cu3(theta, phi, lam, …[, …]) Apply CU3Gate. PhaseEstimation.cx(control_qubit, …[, …]) Apply CXGate. PhaseEstimation.cy(control_qubit, …[, …]) Apply CYGate. PhaseEstimation.cz(control_qubit, …[, …]) Apply CZGate. PhaseEstimation.dcx(qubit1, qubit2) Apply DCXGate. Call a decomposition pass on this circuit, to decompose one level (shallow decompose). Return circuit depth (i.e., length of critical path). PhaseEstimation.diag_gate(diag, qubit) Deprecated version of QuantumCircuit.diagonal. PhaseEstimation.diagonal(diag, qubit) Attach a diagonal gate to a circuit. PhaseEstimation.draw([output, scale, …]) Draw the quantum circuit. Append QuantumCircuit to the right hand side if it contains compatible registers. PhaseEstimation.fredkin(control_qubit, …) Apply CSwapGate. Take in a QASM file and generate a QuantumCircuit object. PhaseEstimation.from_qasm_str(qasm_str) Take in a QASM string and generate a QuantumCircuit object. PhaseEstimation.h(qubit, *[, q]) Apply HGate. PhaseEstimation.hamiltonian(operator, time, …) Apply hamiltonian evolution to to qubits. PhaseEstimation.has_register(register) Test if this circuit has the register r. PhaseEstimation.i(qubit, *[, q]) Apply IGate. PhaseEstimation.id(qubit, *[, q]) Apply IGate. PhaseEstimation.iden(qubit, *[, q]) Deprecated identity gate. PhaseEstimation.initialize(params, qubits) Apply initialize to circuit. Invert (take adjoint of) this circuit. PhaseEstimation.iso(isometry, q_input, …) Attach an arbitrary isometry from m to n qubits to a circuit. PhaseEstimation.isometry(isometry, q_input, …) Attach an arbitrary isometry from m to n qubits to a circuit. PhaseEstimation.iswap(qubit1, qubit2) Apply iSwapGate. PhaseEstimation.mcmt(gate, control_qubits, …) Apply a multi-control, multi-target using a generic gate. PhaseEstimation.mcrx(theta, q_controls, q_target) Apply Multiple-Controlled X rotation gate PhaseEstimation.mcry(theta, q_controls, …) Apply Multiple-Controlled Y rotation gate PhaseEstimation.mcrz(lam, q_controls, q_target) Apply Multiple-Controlled Z rotation gate PhaseEstimation.mct(control_qubits, target_qubit) Apply MCXGate. PhaseEstimation.mcu1(lam, control_qubits, …) Apply MCU1Gate. PhaseEstimation.mcx(control_qubits, target_qubit) Apply MCXGate. PhaseEstimation.measure(qubit, cbit) Measure quantum bit into classical bit (tuples). PhaseEstimation.measure_active([inplace]) Adds measurement to all non-idle qubits. PhaseEstimation.measure_all([inplace]) Adds measurement to all qubits. DEPRECATED: use circuit.reverse_ops(). PhaseEstimation.ms(theta, qubits) Apply MSGate. How many non-entangled subcircuits can the circuit be factored to. Return number of non-local gates (i.e. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. PhaseEstimation.p(theta, qubit) Apply PhaseGate. PhaseEstimation.power(power[, matrix_power]) Raise this circuit to the power of power. PhaseEstimation.qasm([formatted, filename]) Return OpenQASM string. Converts several qubit representations (such as indexes, range, etc.) into a list of qubits. PhaseEstimation.r(theta, phi, qubit, *[, q]) Apply RGate. PhaseEstimation.rcccx(control_qubit1, …) Apply RC3XGate. PhaseEstimation.rccx(control_qubit1, …) Apply RCCXGate. Removes final measurement on all qubits if they are present. Repeat this circuit reps times. Reset q. Return a circuit with the opposite order of wires. Reverse the circuit by reversing the order of instructions. PhaseEstimation.rx(theta, qubit, *[, label, q]) Apply RXGate. PhaseEstimation.rxx(theta, qubit1, qubit2) Apply RXXGate. PhaseEstimation.ry(theta, qubit, *[, label, q]) Apply RYGate. PhaseEstimation.ryy(theta, qubit1, qubit2) Apply RYYGate. PhaseEstimation.rz(phi, qubit, *[, q]) Apply RZGate. PhaseEstimation.rzx(theta, qubit1, qubit2) Apply RZXGate. PhaseEstimation.rzz(theta, qubit1, qubit2) Apply RZZGate. PhaseEstimation.s(qubit, *[, q]) Apply SGate. PhaseEstimation.sdg(qubit, *[, q]) Apply SdgGate. Returns total number of gate operations in circuit. PhaseEstimation.snapshot(label[, …]) Take a statevector snapshot of the internal simulator representation. Take a density matrix snapshot of simulator state. Take a snapshot of expectation value of an Operator. Take a probability snapshot of the simulator state. Take a stabilizer snapshot of the simulator state. Take a statevector snapshot of the simulator state. PhaseEstimation.squ(unitary_matrix, qubit[, …]) Decompose an arbitrary 2*2 unitary into three rotation gates. PhaseEstimation.swap(qubit1, qubit2) Apply SwapGate. PhaseEstimation.sx(qubit) Apply SXGate. Apply SXdgGate. PhaseEstimation.t(qubit, *[, q]) Apply TGate. PhaseEstimation.tdg(qubit, *[, q]) Apply TdgGate. PhaseEstimation.to_gate([parameter_map, label]) Create a Gate out of this circuit. PhaseEstimation.to_instruction([parameter_map]) Create an Instruction out of this circuit. PhaseEstimation.toffoli(control_qubit1, …) Apply CCXGate. PhaseEstimation.u(theta, phi, lam, qubit) Apply UGate. PhaseEstimation.u1(theta, qubit, *[, q]) Apply U1Gate. PhaseEstimation.u2(phi, lam, qubit, *[, q]) Apply U2Gate. PhaseEstimation.u3(theta, phi, lam, qubit, *) Apply U3Gate. PhaseEstimation.uc(gate_list, q_controls, …) Attach a uniformly controlled gates (also called multiplexed gates) to a circuit. PhaseEstimation.ucg(angle_list, q_controls, …) Deprecated version of uc. PhaseEstimation.ucrx(angle_list, q_controls, …) Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit. PhaseEstimation.ucry(angle_list, q_controls, …) Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit. PhaseEstimation.ucrz(angle_list, q_controls, …) Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit. PhaseEstimation.ucx(angle_list, q_controls, …) Deprecated version of ucrx. PhaseEstimation.ucy(angle_list, q_controls, …) Deprecated version of ucry. PhaseEstimation.ucz(angle_list, q_controls, …) Deprecated version of ucrz. PhaseEstimation.unitary(obj, qubits[, label]) Apply unitary gate to q. Return number of qubits plus clbits in circuit. PhaseEstimation.x(qubit, *[, label, …]) Apply XGate. PhaseEstimation.y(qubit, *[, q]) Apply YGate. PhaseEstimation.z(qubit, *[, q]) Apply ZGate. Return indexed operation. Return number of operations in circuit.