Code
qcr:2606.82587.1

Quantum Phase Estimation

Quantum Phase Estimation (QPE) is one of the most important subroutines in quantum computing, sitting at the heart of Shor's factoring algorithm, the HHL linear-systems solver, and quantum simulation of chemistry and materials. Given a unitary operator and one of its eigenstates, QPE estimates the corresponding eigenvalue's phase, the angle theta for which the eigenvalue is exp(2*pi*i*theta), to a precision set by the number of ancilla qubits used. This Cirq example builds and simulates a phase-estimator circuit that recovers an unknown phase encoded in a target qubit: it prepares a register of ancilla qubits in superposition, applies a sequence of controlled powers of the unitary so that the phase is kicked back into the ancilla register, and then applies an inverse quantum Fourier transform to convert the accumulated relative phases into a binary readout of theta. Measuring the ancillas yields an estimate of the phase whose accuracy improves with each additional qubit. The script lets you vary the number of estimation qubits to see the precision-versus-resources tradeoff directly. It is a clear, hands-on introduction to the phase-estimation primitive that so many advanced quantum algorithms are built upon.
Qubit
Circuit-based
Uploaded 4 days ago
14
Views
GitHub4990
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

quantumlib/Cirq
49901228
README.md

Quantum Phase Estimation

Quantum Phase Estimation (QPE) is one of the most important subroutines in quantum computing, sitting at the heart of Shor's factoring algorithm, the HHL linear-systems solver, and quantum simulation of chemistry and materials. Given a unitary operator and one of its eigenstates, QPE estimates the corresponding eigenvalue's phase, the angle theta for which the eigenvalue is exp(2pii*theta), to a precision set by the number of ancilla qubits used. This Cirq example builds and simulates a phase-estimator circuit that recovers an unknown phase encoded in a target qubit: it prepares a register of ancilla qubits in superposition, applies a sequence of controlled powers of the unitary so that the phase is kicked back into the ancilla register, and then applies an inverse quantum Fourier transform to convert the accumulated relative phases into a binary readout of theta. Measuring the ancillas yields an estimate of the phase whose accuracy improves with each additional qubit. The script lets you vary the number of estimation qubits to see the precision-versus-resources tradeoff directly. It is a clear, hands-on introduction to the phase-estimation primitive that so many advanced quantum algorithms are built upon.

Run it

pip install -r requirements.txt
python phase_estimator.py

Source and license

Imported from examples/phase_estimator.py in quantumlib/Cirq at v1.6.1, under the Apache License 2.0. Original authors: The Cirq Developers. The upstream LICENSE is included alongside this example.

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Versions

v1 Latest
Jun 15, 2026
qcr:2606.82587.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

Cirq

Keywords

phase-estimation
qpe
eigenvalue
inverse-qft
controlled-unitary

You may also like5