qiskit-documentation/docs/api/qiskit/0.44/qiskit.algorithms.Iterative...

87 lines
5.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: IterativePhaseEstimation
description: API reference for qiskit.algorithms.IterativePhaseEstimation
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.algorithms.IterativePhaseEstimation
---
# IterativePhaseEstimation
<Class id="qiskit.algorithms.IterativePhaseEstimation" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.25/qiskit/algorithms/phase_estimators/ipe.py" signature="qiskit.algorithms.IterativePhaseEstimation(num_iterations, quantum_instance=None, sampler=None)" modifiers="class">
Bases: `PhaseEstimator`
Run the Iterative quantum phase estimation (QPE) algorithm.
Given a unitary circuit and a circuit preparing an eigenstate, return the phase of the eigenvalue as a number in $[0,1)$ using the iterative phase estimation algorithm.
**\[1]: Dobsicek et al. (2006), Arbitrary accuracy iterative phase estimation algorithm as a two**
qubit benchmark, [arxiv/quant-ph/0610214](https://arxiv.org/abs/quant-ph/0610214)
<Admonition title="Deprecated since version 0.24.0" type="danger">
`qiskit.algorithms.phase_estimators.ipe.IterativePhaseEstimation.__init__()`s argument `quantum_instance` is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Instead, use the `sampler` argument. See [https://qisk.it/algo\_migration](https://qisk.it/algo_migration) for a migration guide.
</Admonition>
**Parameters**
* **num\_iterations** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) The number of iterations (rounds) of the phase estimation to run.
* **quantum\_instance** ([*QuantumInstance*](qiskit.utils.QuantumInstance "qiskit.utils.QuantumInstance") *|*[*Backend*](qiskit.providers.Backend "qiskit.providers.Backend") *| None*) Deprecated: The quantum instance on which the circuit will be run.
* **sampler** ([*BaseSampler*](qiskit.primitives.BaseSampler "qiskit.primitives.BaseSampler") *| None*) The sampler primitive on which the circuit will be sampled.
**Raises**
* [**ValueError**](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.12)") if num\_iterations is not greater than zero.
* [**AlgorithmError**](algorithms#qiskit.algorithms.AlgorithmError "qiskit.algorithms.AlgorithmError") If neither sampler nor quantum instance is provided.
## Methods
### construct\_circuit
<Function id="qiskit.algorithms.IterativePhaseEstimation.construct_circuit" signature="construct_circuit(unitary, state_preparation, k, omega=0.0, measurement=False)">
Construct the kth iteration Quantum Phase Estimation circuit.
For details of parameters, see Fig. 2 in [https://arxiv.org/pdf/quant-ph/0610214.pdf](https://arxiv.org/pdf/quant-ph/0610214.pdf).
**Parameters**
* **unitary** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")) The circuit representing the unitary operator whose eigenvalue (via phase) will be measured.
* **state\_preparation** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")) The circuit that prepares the state whose eigenphase will be measured. If this parameter is omitted, no preparation circuit will be run and input state will be the all-zero state in the computational basis.
* **k** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) the iteration idx.
* **omega** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")) the feedback angle.
* **measurement** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.12)")) Boolean flag to indicate if measurement should be included in the circuit.
**Returns**
the quantum circuit per iteration
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### estimate
<Function id="qiskit.algorithms.IterativePhaseEstimation.estimate" signature="estimate(unitary, state_preparation)">
Estimate the eigenphase of the input unitary and initial-state pair.
**Parameters**
* **unitary** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")) The circuit representing the unitary operator whose eigenvalue (via phase) will be measured.
* **state\_preparation** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")) The circuit that prepares the state whose eigenphase will be measured. If this parameter is omitted, no preparation circuit will be run and input state will be the all-zero state in the computational basis.
**Returns**
Estimated phase in an IterativePhaseEstimationResult object.
**Raises**
[**AlgorithmError**](algorithms#qiskit.algorithms.AlgorithmError "qiskit.algorithms.AlgorithmError") If neither sampler nor quantum instance is provided.
**Return type**
*IterativePhaseEstimationResult*
</Function>
</Class>