Interactive Calculator · Algorithms and Advantage
Phase Estimation Precision Calculator
Choose an eigenphase and a number of counting qubits, and see exactly which binary results quantum phase estimation returns and how often.
The eigenvalue of U is e^(2πiφ). φ is between 0 and 1.
How many binary digits of φ you want to be right.
Most likely output
011
Estimate φ ≈ 0.37500; error 0.04167
Chance of that output
68.78%
φ falls between grid points
Best output ± one step
90.97%
Resolution 1/2^t = 0.12500
Controlled-U applications
7
2^t − 1 in the largest block
Most likely outputs (binary, decimal fraction)
Counting qubits for your target
To get 8 correct bits with failure probability 1.0%, the textbook rule adds ⌈log₂(2 + 1/(2ε))⌉ = 6 extra counting qubits, so t ≈ 14, which needs about 16,383 controlled-U applications.
About the extra-bits rule
The extra-qubits formula is a standard textbook bound that I quote from memory and did not re-open a source for. The output probabilities above are exact: they come from the closed-form amplitude sin(πTδ) ÷ (T sin(πδ)), where δ = φ − m/T.Compute the exact output distribution of quantum phase estimation for any phase and register size, see why phases that do not fit in the register produce a spread of results, and find how many counting qubits a target precision needs.
What this calculator does
Quantum phase estimation reads an eigenvalue of a unitary operator U. If U acts on an eigenstate and gives a phase e^(2πiφ), the algorithm uses t counting qubits to produce a t-bit binary approximation of φ, a number between 0 and 1. It is the core of Shor's algorithm and of fault-tolerant quantum chemistry, and it is the algorithm where reading the output distribution carefully matters most.
This tool computes the distribution exactly. You set the true phase φ and the number of counting qubits t. It lists the most likely outputs as binary strings together with their decimal fractions, the probability of the most likely output, the probability of landing within one step of it, the error of the best estimate, and the number of controlled-U applications the circuit needs.
The probabilities come from a closed-form expression. For a measured integer m out of T = 2^t outcomes, the probability is [sin(πTδ) ÷ (T sin(πδ))]², where δ = φ − m/T. When δ is zero the phase fits exactly and the probability is one. I checked the numbers against the browser circuit simulator used in the lessons on this site, and they agree.
How to use it
Choose the preset φ = 1/8 with t = 3. The phase fits exactly in three bits, the output is 001 with probability 100 percent, and the tool marks it as exact. Now choose φ = 1/3 with t = 3. The phase 1/3 has no exact binary form, so the output spreads: 011 (0.375) appears 68.78 percent of the time and 010 (0.25) appears 17.49 percent, with a few percent on the other outcomes. The probability of the best output or its two neighbours is 90.97 percent.
Next raise t while keeping φ = 1/3. The probability of the single best output barely changes: 68.78 percent at t = 3 and 68.40 percent at t = 6. What improves is the precision. The best output's error falls from 0.0417 at t = 3 to 0.0052 at t = 6. A common misunderstanding is that more counting qubits make the best outcome certain. They do not, unless the phase is exactly representable. They make the answer closer to the truth.
The halfway case is instructive. Choose φ = 5/16 with t = 3. The phase sits exactly between two grid points, so 010 and 011 each get 41.05 percent. With t = 4 the phase fits exactly and the answer is certain. A phase halfway between grid points is the worst case for a given register size.
How many counting qubits do you need?
The calculator also answers the planning question. Enter how many binary digits of φ you want to be correct and how large a failure probability you accept. The tool applies a standard textbook rule: use t = n + ⌈log₂(2 + 1/(2ε))⌉ counting qubits, where n is the target precision in bits and ε is the allowed failure probability. I quote this rule from memory and did not re-open a source for it here, so check it against a textbook before relying on it for a published claim.
For eight bits of precision with a 1 percent failure probability, the rule adds six extra qubits, so t = 14, and the circuit needs 2¹⁴ − 1 = 16,383 applications of controlled-U in its largest block. The cost doubles with each added counting qubit, which is why phase estimation needs deep circuits and, for useful problem sizes, error correction.
What the calculator leaves out
The calculator assumes the input register holds an exact eigenstate of U. If the input is a mixture of eigenstates, such as an approximate ground state in chemistry, the output is a mixture of several phase distributions weighted by the overlaps, and the chance of reading the ground-state energy equals the squared overlap. It also assumes a noiseless machine. Real circuits accumulate gate errors, and the controlled-U powers dominate the cost. Treat the tool as a way to understand the ideal behaviour.
The formulas behind it
Output probability
P(m) = [ sin(πTδ) ÷ (T · sin(πδ)) ]², δ = φ − m/T, T = 2^t
Exact probability of reading the integer m from t counting qubits. If δ = 0, P(m) = 1.
Resolution
step = 1 ÷ 2^t
Spacing of the binary fractions the register can represent.
Controlled-U applications
2^t − 1
Number of applications of U in the largest controlled block, from the powers U, U², U⁴ and so on.
Extra counting qubits (textbook rule)
t = n + ⌈ log₂( 2 + 1/(2ε) ) ⌉
Counting qubits for n correct bits with failure probability ε. Quoted from memory.
Worked examples
A phase that does not fit
- φ = 1/3 with t = 3. The grid has steps of 1/8.
- Nearest grid point: 3/8 = 0.375, error 0.0417.
- P(011) = 0.6878, P(010) = 0.1749, P(100) = 0.0469.
ResultAbout 91% of runs land on 010, 011 or 100, and the best guess is off by about 0.04.
A phase halfway between grid points
- φ = 5/16 with t = 3. The grid points 2/8 and 3/8 are equally close.
- P(010) = P(011) = 0.4105.
- With t = 4, 5/16 is exactly 0101 in binary, so P = 1.
ResultOne extra counting qubit turns an ambiguous result into a certain one.
Planning a precision target
- Target: 8 correct bits, failure probability 1%.
- Extra qubits: ⌈log₂(2 + 50)⌉ = 6, so t = 14.
- Controlled-U applications: 2¹⁴ − 1 = 16,383.
ResultFourteen counting qubits and about sixteen thousand applications of the operator.
Frequently asked questions
Why is the best output not certain when φ does not fit the register?
The register can only represent multiples of 1/2^t. A phase in between is represented by a superposition of nearby values, so measurement returns one of them at random, with the closest ones most likely.
Does adding counting qubits make the answer exact?
No. It makes the best estimate closer to the truth, but the probability of the single best output stays near the same value unless the phase is exactly representable.
What does this have to do with Shor's algorithm?
Shor's algorithm finds the period of a function by estimating a phase, and the same distribution of nearby outputs appears there. A continued-fraction step then recovers the exact fraction.
Is this the same as running the circuit?
For an ideal eigenstate and a noiseless machine, yes: the probabilities are those of the circuit. Real devices add noise.
References
- Kitaev, A. Yu. (1995). Quantum measurements and the Abelian stabilizer problem. arXiv:quant-ph/9511026. (Cited from memory; I did not open it for this page.)
- Cleve, R., Ekert, A., Macchiavello, C., & Mosca, M. (1998). Quantum algorithms revisited. Proceedings of the Royal Society A, 454, 339-354. (Cited from memory.)
- The closed-form probabilities are my own derivation from the standard amplitude sum, checked against the in-browser circuit simulator on this site.
Keep exploring
- Lesson: Quantum Phase Estimation
- Algorithm: Quantum Phase Estimation
- Algorithm: Quantum Fourier Transform
- Paper: Quantum Measurements and the Abelian Stabilizer Problem
- Term: Quantum Phase Estimation
- Lesson: Practice Set 2, Quantum Algorithms
These calculators use simplified, published models for education and planning. Real devices and systems differ, so treat results as estimates. They are not engineering, investment, legal, or security advice.