Level 3 · Algorithms

Quantum Phase Estimation: Reading a Hidden Phase Out of a Quantum Circuit

About 5,377 words · roughly 24 minute read · sources checked December 2, 2026

Quantum phase estimation, usually shortened to QPE, is the subroutine at the centre of the most famous quantum algorithms. Shor’s factoring algorithm is phase estimation applied to a modular-multiplication operation. Many proposals for quantum chemistry on fault-tolerant machines use it to read out an energy. Even the Fourier transform lesson on this site was really preparation for it.

The task sounds abstract, and it is worth stating plainly. A quantum operation U, applied to a special state |u⟩, does nothing to the state except multiply it by a phase, a complex number of size 1. That phase is written e^(2πiφ), and the number φ between 0 and 1 is the thing we want. QPE gives us φ to as many binary digits as we are willing to pay for.

This lesson builds the algorithm from the ground up. We start with the circuit, follow the state through it by hand, check the results with exact calculations, work out how many qubits you need for a given accuracy, look at a cheaper one-qubit variant, and then connect it to Shor’s algorithm with real numbers for factoring 15 and 21. Every number printed here was computed with my own NumPy simulation, and I flag clearly which code I could not run.

A note on honesty. Qiskit was not installed in my environment, so the code listings are written from the library’s documented behaviour and were not run. The probabilities and tables come from my own simulation of the same gates. The source papers I opened are listed in the references, and I say exactly what each was used for.

What you will learn

  • What an eigenvalue and an eigenphase are, in plain terms.
  • How the QPE circuit works, with the state written out after every step.
  • Why the answer is exact when the phase has a short binary expansion, and what happens when it does not.
  • How many counting qubits give a chosen accuracy and success probability.
  • How iterative (Kitaev-style) phase estimation gets the same digits with one ancilla qubit.
  • How QPE finds the order r in Shor’s algorithm, including the cases where one run fails.
  • Why phase estimation needs long, deep circuits, and what that means for near-term hardware.

Helpful first: The Quantum Fourier Transform in Qiskit, Quantum Algorithms.

What problem does phase estimation solve?

Start with the idea of an eigenstate. Take a quantum operation U, written as a unitary matrix, and apply it to a state |u⟩. For most states the result is a different state. For a special few, the result is the same state multiplied by a number: U|u⟩ = λ|u⟩. Such a state is an eigenstate of U, and λ is its eigenvalue. Because U never changes the length of a state, λ must have size 1, so it can be written as a point on the unit circle:

U |u⟩  =  e^(2πiφ) |u⟩        with  0 ≤ φ < 1
The eigenvalue equation. The number φ is the phase we want to estimate, written as a fraction of a full turn.

We write φ as a fraction of a full turn because it makes the binary digits natural. A phase of 0.25 is a quarter turn, 0.5 is a half turn, and 0.125 is an eighth of a turn. The goal of QPE is to find the binary expansion of φ, as in φ = 0.b₁b₂b₃…, to as many digits as needed.

Worked example

Three phases you already know

  1. The Z gate leaves |0⟩ alone and multiplies |1⟩ by −1. So |1⟩ is an eigenstate of Z with eigenvalue −1 = e^(2πi·0.5), and φ = 0.5 = 0.1 in binary.
  2. The S gate multiplies |1⟩ by i = e^(2πi·0.25). So φ = 0.25 = 0.01 in binary.
  3. The T gate multiplies |1⟩ by e^(iπ/4) = e^(2πi·0.125). So φ = 0.125 = 0.001 in binary.
  4. In each case |1⟩ is the eigenstate, and the gate is a phase gate. These are the simplest test cases, and we will use them throughout.

Why would anyone want φ?

Because many hard problems can be disguised as “find the eigenphase of some unitary.” The three most important disguises are:

  • Order finding. The unitary multiplies a number by a modulo some N, and its eigenphases are fractions s/r, where r is the order. Reading them off is the quantum core of Shor’s algorithm.
  • Energy of a quantum system. If U = e^(−iHt) evolves a system for time t under its energy operator H, the eigenphase of U encodes an energy. Reading it out gives the energy of a molecule or material.
  • Linear algebra problems. Some quantum algorithms for solving equations first use phase estimation to read the eigenvalues of a matrix into a register.

Cleve, Ekert, Macchiavello and Mosca’s 1997 paper, whose arXiv abstract I opened, makes this point for the early algorithms: it shows that several known quantum algorithms are different instances of quantum phase estimation, and it describes the common pattern as multi-particle interference that favours the correct outcome and cancels the others. That is a good way to hold the whole subject in your head. Phase estimation is the pattern, and many algorithms are particular uses of it.

One input you must supply

QPE needs the eigenstate |u⟩ as input, or a state that overlaps with it. If you do not have the eigenstate, you can feed in a superposition of eigenstates and you will read out one of their phases at random, with probabilities set by the overlaps. Shor’s algorithm uses this fact cleverly, as we will see at the end of the lesson.

The circuit, piece by piece

The circuit uses two registers. The counting register has t qubits, and it will end up holding the binary digits of φ. The target register holds the eigenstate |u⟩, and it is not changed by the algorithm. The steps are:

  1. Prepare the counting qubits in |0⟩ and the target in |u⟩.
  2. Apply a Hadamard gate to every counting qubit, making an equal superposition of all 2ᵗ counting values.
  3. For each counting qubit j (counting from 0), apply U raised to the power 2ʲ to the target, controlled by qubit j. Qubit 0 controls U, qubit 1 controls U², qubit 2 controls U⁴, and so on.
  4. Apply the inverse quantum Fourier transform to the counting register.
  5. Measure the counting register. The result, read as an integer m, gives φ ≈ m / 2ᵗ.

That is the whole algorithm. Two of the steps deserve a closer look because they are where the idea lives.

Step 3 and phase kickback

A controlled-U applies U to the target only when the control qubit is |1⟩. Since the target is an eigenstate, U just multiplies it by e^(2πiφ). That phase belongs to the whole joint state, so it can be attributed to the control qubit: the control picks up the phase when it is 1, and nothing when it is 0. The target is left unchanged. This is the same phase kickback you met in the Deutsch–Jozsa lesson, now with a general phase instead of a sign of ±1.

For control qubit j, which applies U to the power 2ʲ, the eigenvalue is raised to the same power, so the phase kicked back is e^(2πi·φ·2ʲ). Putting that together, a control qubit in the state (|0⟩ + |1⟩)/√2 becomes (|0⟩ + e^(2πiφ2ʲ)|1⟩)/√2.

counting qubit j:   (|0⟩ + e^(2πi · φ · 2ʲ) |1⟩) / √2
all t qubits together:  (1/√N) Σₖ e^(2πi · φ · k) |k⟩,    N = 2ᵗ
The state of the counting register after step 3. The second line comes from multiplying the t single-qubit states together: the phases add up to 2πφ times the integer k whose binary digits are the qubit values.

This is the heart of it. After step 3 the counting register holds a state in which the integer k carries the phase e^(2πiφk). It is a wave with frequency φ, spread across all the counting values.

Step 4 and the inverse QFT

In the Fourier transform lesson you saw that the QFT maps the basis state |m⟩ to (1/√N) Σₖ e^(2πi·mk/N)|k⟩. Compare this with the state above. If φ = m/N exactly, the two are identical. So the state we built is the QFT of |m⟩, and applying the inverse QFT returns |m⟩ exactly. Measuring then gives m with certainty, and φ = m/N.

In one sentence

Phase kickback writes the unknown phase into the counting register as a frequency, and the inverse QFT converts that frequency into a number you can read.

When the phase has a short binary expansion

If φ can be written exactly with t binary digits, the algorithm gives it exactly, with probability 1. I confirmed this by simulating the full circuit, including the target qubit, for several cases.

Gate / phaseφCounting qubits tResult (counting register, qubit 0 on the right)ProbabilityReading
Z gate on |1⟩0.5111.01 ÷ 2 = 0.5
S gate on |1⟩0.252011.01 ÷ 4 = 0.25
T gate on |1⟩0.12530011.01 ÷ 8 = 0.125
Phase gate, φ = 3/80.37530111.03 ÷ 8 = 0.375
Phase gate, φ = 5/160.3125401011.05 ÷ 16 = 0.3125

My simulation of the full circuit, including the target qubit. In every row the counting register shows the integer m = φ × 2ᵗ with probability 1.

Worked example

Following the T gate by hand

  1. U is the T gate and |u⟩ = |1⟩, so φ = 1/8. Take t = 3 counting qubits, so N = 8.
  2. After the Hadamards and controlled powers, the counting qubits are in the state (1/√8) Σₖ e^(2πi·k/8)|k⟩ for k = 0 to 7. The phases, in turns, go 0, 1/8, 2/8, … 7/8.
  3. This is exactly the QFT of |1⟩, because QFT|1⟩ = (1/√8) Σₖ e^(2πi·1·k/8)|k⟩.
  4. The inverse QFT turns it back into |1⟩ = |001⟩. Measuring gives 001, and 1 ÷ 8 = 0.125 = φ.

A useful way to see it: the controlled-T gate applies one eighth of a turn, the controlled-T² applies a quarter turn, and the controlled-T⁴ applies a half turn, each kicking its phase into its own counting qubit. The binary digits of 1/8 = 0.001 are exactly the three rotations you apply. The circuit is reading the digits of the angle.

When the phase does not fit: probabilities, not certainty

Most phases are not a tidy fraction of a power of two. The phase 1/3 is 0.010101… in binary, forever. With t counting qubits the circuit can only output multiples of 1/2ᵗ, so it cannot hit 1/3 exactly. What it does instead is output integers near 2ᵗ·φ, with a probability that peaks at the closest one and falls off quickly.

I simulated φ = 1/3 with t = 5 counting qubits. The nearest multiple of 1/32 is 11/32 = 0.34375, and the circuit returned 01011 (that is 11) with probability 0.6842. The runners-up were 01010 (10) at 0.1712, 01100 (12) at 0.043 and 01001 (9) at 0.0276. The rest of the probability is spread thinly over the other outcomes.

tBest outcome mm / 2ᵗError vs 1/3P(best)P(within 1 bin)
210.250.08330.69980.8873
330.3750.04170.68780.8628
450.31250.02080.68490.8569
5110.343750.01040.68420.8554
6210.328120.00520.68400.8550
7430.335940.00260.68390.8549
8850.332030.00130.68390.8549
91710.333980.000650.68390.8549
103410.333010.000330.68390.8549

My simulation for φ = 1/3. “Within 1 bin” means the outcome is the best one or its immediate neighbour on either side. The error halves with every extra counting qubit, but the success probability stays near 0.68.

Two lessons come out of this table. First, the error shrinks by a factor of two for each added counting qubit, exactly as you would expect from adding one more binary digit. Second, the probability of getting the single best outcome does not improve with t. It settles near 0.684, because the leftover fractional part of 2ᵗφ stays the same size relative to one bin. Textbook analysis gives guaranteed lower bounds of 4/π² ≈ 0.405 for the best outcome and 8/π² ≈ 0.811 for landing within one bin; my numbers (0.684 and 0.855) sit comfortably above them, as they should.

Reading the table honestly

These bounds are the standard ones from textbooks. I did not open a source for them in this session, so treat them as “consistent with my simulation,” not as something I verified from a paper.

A second example: φ = 0.3

With t = 3 counting qubits and φ = 0.3, I got these probabilities for outcomes 0 to 7: 0.0216, 0.0518, 0.5775, 0.2593, 0.0409, 0.0194, 0.0145, 0.0149. The best outcome is 2, which reads as 0.25, with probability 0.5775. The second best is 3, which reads as 0.375, with 0.2593. The true value 0.3 lies between those two, a little closer to 0.25, and the probabilities reflect that. With t = 4, the best outcome is 0101 (5/16 = 0.3125) with probability 0.8756.

The pattern is a bump centred on 2ᵗφ. If 2ᵗφ is an integer, the bump collapses to a single spike. If it falls between two integers, the probability splits between the neighbours in proportion to how close each is.

How many counting qubits do you need?

Two knobs decide the size of the counting register. One is the number of correct bits n you want. The other is how sure you want to be that all n bits are right. The standard textbook recipe says: to get φ correct to n bits with probability at least 1 − ε, use

t  =  n + ⌈ log₂( 2 + 1 / (2ε) ) ⌉
The textbook sizing formula for the counting register. The extra qubits beyond n are a safety margin that pushes the failure probability below ε.
Bits wanted nε = 0.1ε = 0.01ε = 0.001
3t = 6t = 9t = 12
8t = 11t = 14t = 17
16t = 19t = 22t = 25

Values of t from the formula above. The failure margin costs only a few extra qubits, not many.

I checked the idea numerically for n = 3, meaning the result should land within 1/8 of the true phase. Using the worst case over phases I tested, the success probability was 0.9059 at t = 4, 0.9522 at t = 5, 0.976 at t = 6 and 0.988 at t = 7. Each extra qubit roughly halves the failure probability. That matches the shape of the formula, though the formula is more conservative than the numbers I measured.

What to take from the formula

The accuracy you want sets most of t. The confidence you want adds only a handful of qubits, because each extra counting qubit cuts the failure rate roughly in half.

The real cost is not the qubits

Counting qubits are cheap. The expensive part is the controlled powers of U. To get t bits, qubit j needs U applied 2ʲ times, so the total number of applications of U is 1 + 2 + 4 + … + 2ᵗ⁻¹ = 2ᵗ − 1. Each extra bit of accuracy doubles the number of times U must be applied.

Counting qubits tApplications of U (2ᵗ − 1)Controlled-phase gates in inverse QFTHadamard gates (2t)Swaps
37361
415682
53110102
66315123
712721143
825528164
951136184
10102345205
11204755225
12409566246

Gate counts for the circuit. The inverse QFT uses t(t−1)/2 controlled-phase gates and ⌊t/2⌋ swaps, and it is the small part. The applications of U dominate.

In these counts, the Hadamard column includes the t Hadamards at the start and the t inside the inverse QFT. For a phase gate, applying U 4095 times is trivial, because U² is just a phase gate with doubled angle, and you can build it directly. For a real operation such as a molecular time evolution, U^(2ʲ) has no shortcut, and the circuit gets very deep. This is why QPE is considered a fault-tolerant-era algorithm: it needs long coherent evolution, which today’s noisy machines cannot provide.

Peruzzo and colleagues make the same contrast on the first page of their 2013 paper. The arXiv abstract I opened says the variational method they introduce requires much less coherent evolution than phase estimation. That is the motivation for the next lesson on the variational quantum eigensolver.

Qiskit code: phase estimation of a phase gate

Here is a complete QPE circuit for a phase gate with a chosen φ. The eigenstate is |1⟩, so we flip the target qubit with an X gate first. The code reuses the qft helper from the Quantum Fourier Transform lesson, the version that includes the final swaps. I could not run this code in my environment, since Qiskit was not installed, so treat it as a careful draft and check it on your own machine.

import math
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler

def qpe_phase_gate(phi, t):
    qc = QuantumCircuit(t + 1, t)
    qc.x(t)                          # target qubit = eigenstate |1>
    qc.h(range(t))                   # counting register in superposition
    for j in range(t):
        qc.cp(2 * math.pi * phi * 2**j, j, t)   # controlled-U^(2^j)
    qc.compose(qft(t).inverse(), qubits=range(t), inplace=True)
    qc.measure(range(t), range(t))
    return qc

qc = qpe_phase_gate(1/8, 3)
result = StatevectorSampler().run([qc], shots=1000).result()
print(result[0].data.c.get_counts())
QPE for a phase gate. Not run here. The classical register is named c because the circuit was created with an integer number of classical bits.

Three details are worth checking when you run it.

  • The controlled-U^(2ʲ) for a phase gate is simply a controlled-phase gate with the angle multiplied by 2ʲ. That is why the loop uses cp with 2π·φ·2ʲ. For a general U you cannot do this shortcut.
  • The inverse QFT must include the swaps, so that the counting register reads in the usual order. If your answers come out with the bits reversed, a missing or doubled swap is the likely cause.
  • Qiskit prints bit strings with qubit 0 on the right. For φ = 1/8 and t = 3 the expected output is 001 with all 1000 shots.

My own simulation of the same gates, using the same bit order, gave these results: φ = 1/8 with t = 3 gives 001 with probability 1, and φ = 5/16 with t = 4 gives 0101 with probability 1. If your run disagrees, compare the order of your gates with the list above.

Build the QFT from gates

I did not verify the name or the deprecation status of Qiskit’s own QFT class, which has changed between versions. Building the QFT from basic gates, as in the earlier lesson, avoids that problem.

Iterative phase estimation: the same digits with one qubit

The standard circuit uses t counting qubits and one big inverse QFT. There is a cheaper variant that needs only a single counting qubit, reused again and again. It is usually credited to Kitaev, whose 1995 paper on the Abelian stabilizer problem, which I opened on arXiv, describes a procedure for measuring an eigenvalue of a unitary operator. The version below is the commonly taught one-ancilla form, and I verified it by simulation rather than from the paper’s text.

The idea is to read the digits of φ from the last one to the first. The last digit shows up when you apply U^(2ᵗ⁻¹): that power turns φ into 2ᵗ⁻¹φ, whose fractional part is determined by just the final bit. So you measure that bit first. Then you use what you learned to cancel its influence and move on to the next bit, which now sits in the position the previous one occupied.

  1. Pick the number of digits t. Set a feedback angle f = 0.
  2. For k from t − 1 down to 0: put the ancilla in |+⟩, apply controlled-U^(2ᵏ), apply a phase rotation by −2π·f to the ancilla, apply a Hadamard, and measure. Call the result b.
  3. Update the feedback with f = f/2 + b/4. Then move to the next k.
  4. After all rounds, the bits were found from least significant to most significant, so assemble them in that order.
φDigits tBits found (last to first)Result
0.812541, 0, 1, 11101 = 13/16 (deterministic)
0.62531, 0, 1101 = 5/8
0.3437551, 1, 0, 1, 001011 = 11/32

My simulation of the one-ancilla version. For phases that are exact binary fractions, every measurement is deterministic.

The trade-off is clear. Iterative estimation uses far fewer qubits and no big Fourier transform, but it needs t separate circuit runs one after another, with a classical computer feeding the previous result into the next rotation. On hardware that supports mid-circuit measurement and fast classical feedback this is an excellent choice. For an inexact phase, each round is probabilistic, and practical versions repeat rounds to boost confidence. I did not analyse that noisy case here.

One bug I hit while testing

My first attempt printed the bits in the wrong order. The fix was the update f = f/2 + b/4, which keeps the older bits in the right place as new ones arrive. If your own implementation produces a reversed string, check this update first.

The link to Shor’s algorithm: finding an order

Shor’s algorithm factors a number N by first finding the order r of some a modulo N, meaning the smallest r > 0 with aʳ mod N = 1. The quantum part is exactly QPE on the operation U|y⟩ = |a·y mod N⟩.

This U has eigenstates whose phases are s/r for s = 0, 1, …, r − 1. You do not have to build any of those eigenstates. The state |1⟩ is an equal-weight superposition of all of them, so feeding |1⟩ into QPE gives a random one of the phases s/r, each with probability 1/r. The measured number, divided by 2ᵗ, is then an approximation of some s/r. A classical step called continued fractions turns it into a fraction and reads off the denominator.

Factoring 15 with a = 7

The order of 7 modulo 15 is r = 4, since 7⁴ = 2401 = 160·15 + 1. With t = 4 counting qubits, my simulation gave probability 0.25 each on outcomes 0, 4, 8 and 12. Dividing by 16 gives phases 0, 1/4, 1/2 and 3/4.

  • Outcome 0 (phase 0) tells us nothing. The fraction 0/1 has denominator 1. This is a failed run, and we must repeat.
  • Outcomes 4 and 12 (phases 1/4 and 3/4) give denominator 4. This is the order, and the run succeeds.
  • Outcome 8 (phase 1/2) gives denominator 2. That is a factor of r, not r itself. It is a partial failure that can sometimes still be rescued by trying multiples.

So the chance that the denominator equals r in one run is 0.5. Not every run works, and that is expected; you simply repeat. Once r = 4 is known, the classical step finishes the job: a^(r/2) = 7² = 49, and gcd(49 − 1, 15) = gcd(48, 15) = 3 and gcd(49 + 1, 15) = gcd(50, 15) = 5. So 15 = 3 × 5.

a, NOrder rtOutcome probabilitiesP(denominator = r)
7, 15440.25 each on 0, 4, 8, 120.5
2, 1544same as above0.5
4, 15240.5 on 0 and 80.5
11, 1524same as above0.5
2, 2165cannot resolve the peaks (t too small)0
2, 21680 and 128 at 0.1667; 85, 43, 171, 213 at 0.114 each0.285

My simulation of order finding. For N = 21 the phases are multiples of 1/6, which are not powers-of-two fractions, so the peaks spread out and t must be larger.

Why N = 21 needs more qubits

For N = 15 every phase is a multiple of 1/4, which fits neatly into 16 bins. For N = 21 with a = 2, the order is 6 and the phases are multiples of 1/6. These do not fit into a power of two, so with t = 5 the peaks overlap and I measured no useful chance of recovering r. With t = 8 the circuit works, though only 28.5% of runs give the exact order directly. The standard advice is to use about 2·log₂N counting qubits for Shor, so that the peaks of neighbouring fractions s/r can always be told apart. I state that as the textbook rule and have not opened a source for it here.

For N = 21 and a = 2, the order is 6 because 2⁶ = 64 = 3·21 + 1. Taking r = 6 gives a³ = 8, with gcd(8 − 1, 21) = 7 and gcd(8 + 1, 21) = 3. So 21 = 3 × 7.

The key point

Shor’s algorithm is not a separate idea from phase estimation. It is QPE, plus the observation that the eigenphases of modular multiplication encode the order, plus a classical continued-fraction step. If you understand this lesson, you understand the quantum engine inside Shor.

Run phase estimation in your browser

Phase estimation is easier to believe once you have watched it work. The circuits below use three counting qubits and one target qubit prepared in |1⟩, which is an eigenstate of the phase gate. The counting qubits control powers of the gate, and an inverse quantum Fourier transform reads out the phase. The result strings follow Qiskit's bit order, with qubit 0 as the rightmost bit.

An exact case: the T gate

Run this circuit

Phase estimation of the T gate (exact case)

q0q1q2q3XHHHP0.79P1.57P3.14HP-1.57HP-0.79P-1.57H

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: The T gate multiplies |1⟩ by e^(iπ/4) = e^(2πi·φ) with φ = 1/8. With 3 counting qubits we can write φ exactly as 001 in binary (1/8). What do the counting qubits read?

Press Run to simulate. Results appear here with a short explanation.

The T gate multiplies |1⟩ by e^(iπ/4), which is e^(2πiφ) with φ = 1/8. In binary, 1/8 is 0.001, which needs exactly three bits. The counting register reads 001, with probability one, and the answer is exact.

An inexact case: a phase of 1/3

Run this circuit

Phase estimation when the phase does not fit (φ = 1/3)

q0q1q2q3XHHHP2.09P4.19P8.38HP-1.57HP-0.79P-1.57H

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: Now φ = 1/3, which has no exact 3-bit binary form (0.0101…). The best 3-bit guesses are 3/8 = 0.375 and 2/8 = 0.25. What do you expect?

Press Run to simulate. Results appear here with a short explanation.

A phase of one third has the binary expansion 0.010101…, which never terminates. With three bits the nearest values are 3/8 = 0.375 and 2/8 = 0.25. The circuit returns 011 (that is 3/8) about 69 percent of the time, 010 (2/8) about 17 percent of the time, and other values with small probabilities. This is the standard behaviour when the phase does not fit exactly.

How the answer sharpens with more counting qubits

To see the effect of adding counting qubits, I computed the exact output distribution of phase estimation for φ = 1/3 using the closed-form amplitude, with NumPy. For each number of counting qubits t, the table gives the most likely estimate, the probability of that estimate, and the probability that the result is within one step of it.

Counting qubits tMost likely estimateProbability of that estimateProbability within one step (±1/2^t)
33/8 = 0.37500.68780.9097
45/16 = 0.31250.68490.9006
511/32 = 0.34380.68420.8984
621/64 = 0.32810.68400.8978
885/256 = 0.33200.68390.8977

Phase estimation for φ = 1/3 with different numbers of counting qubits. My own NumPy calculation from the exact amplitudes. The true value is 0.3333…

Two things stand out. First, the estimate gets closer to 1/3 as t grows: the error is 0.0417 at t = 3, 0.0208 at t = 4, 0.0104 at t = 5, 0.0052 at t = 6 and 0.0013 at t = 8, halving with each extra qubit as the theory says. Second, the probability of the single best estimate does not rise towards one. It settles near 0.684, which is the signature of an inexact phase: the nearest grid value is never perfectly aligned with the truth, and the measurement lands on it about 68 percent of the time, with most of the rest on its two neighbours.

error at t = 3:  |3/8 − 1/3| = 0.0417
error at t = 4:  |5/16 − 1/3| = 0.0208
error at t = 8:  |85/256 − 1/3| = 0.0013
My own arithmetic. Each extra counting qubit halves the grid spacing.

The practical consequence is that you choose the number of counting qubits for the precision you want, and you add a few extra to push the failure probability down. The textbook rule is that to get the phase to n bits of accuracy with a high success probability you need n plus a small number of extra qubits, and the cost in controlled-U applications doubles with every added qubit. That doubling is the main expense of the algorithm, which is why the iterative variants in this lesson matter.

Two different knobs

More counting qubits improve the precision of the estimate. They do not make an inexact phase come out exact. To raise the chance of landing on the nearest grid value you repeat the experiment and take the most common result, or you use extra qubits and round.

Common mistakes and misunderstandings

  • Forgetting the eigenstate. The target register must hold an eigenstate, or a superposition of eigenstates you are happy to sample from. A random input state gives a random eigenphase.
  • Mixing up bit order. Qiskit prints qubit 0 on the right. A reversed answer usually means a bit-order or swap mistake, not an algorithmic error.
  • Thinking more counting qubits raises the single-outcome probability. It does not. It improves the accuracy. The probability of the best outcome stays near 0.68 for a phase that does not fit, as the table showed.
  • Ignoring the cost of controlled-U^(2ʲ). On paper it is one box. In practice it is the whole expense, and for a physical problem it can need an enormous number of gates.
  • Treating the output as exact. For a general phase, QPE returns a good approximation with high probability, not a guaranteed exact value.
  • Expecting it to run on today’s hardware at useful sizes. Preskill’s 2018 NISQ paper, whose abstract I opened, describes the near-term era as machines of roughly 50 to 100 qubits where noise limits the size of circuits. Deep QPE circuits are beyond that.

Frequently asked questions

Is phase estimation the same as the Fourier transform?

No. The QFT is a building block. QPE uses it at the end to convert a frequency stored in the phases into a binary number. The new ingredient is the controlled powers of U that write the phase in.

Does QPE give a speed-up on its own?

The speed-up lives in the problem it is applied to. For order finding it leads to Shor’s algorithm, which is believed to beat the best known classical factoring methods. For other uses the advantage depends on whether you can prepare a good eigenstate and implement U efficiently, and those are real obstacles.

What happens if I only have a rough eigenstate?

You get a spread of phases. If your state overlaps with the true ground state by an amount c, you read out the ground-state phase with probability about |c|². That is why state preparation matters so much in quantum chemistry proposals.

Why not just measure the target qubit?

Because an eigenstate gives no outcome that depends on φ. The phase is global to the state, so a direct measurement cannot see it. Phase kickback transfers it into a relative phase on the control qubits, where interference can reveal it.

Practice questions

Check yourself

A T gate has φ = 1/8. How many counting qubits are needed to read it exactly, and what bit string do you expect?

Three counting qubits, since 1/8 = 0.001 in binary. The expected result is 001 with probability 1.

How many applications of U does a t = 6 circuit use?

2⁶ − 1 = 63.

Why does the error halve with each extra counting qubit?

Each added qubit adds one more binary digit, so the grid of readable values becomes twice as fine.

In the N = 15, a = 7 example, why does outcome 8 not give the order?

8/16 = 1/2 has denominator 2, and the true order is 4. The phase 2/4 reduced to 1/2 loses information.

Why does iterative phase estimation need classical feedback?

Each round’s rotation depends on the bits already measured, so a classical computer must feed that result into the next round.

Summary

  • QPE estimates the phase φ in U|u⟩ = e^(2πiφ)|u⟩ by writing it into a counting register as a frequency and reading it with an inverse QFT.
  • If φ has a t-bit binary expansion, the result is exact with probability 1. Otherwise you get the nearest values with high probability.
  • Accuracy doubles with each counting qubit, but the number of applications of U also doubles: it is 2ᵗ − 1 in total.
  • A one-ancilla iterative version trades qubits for sequential rounds and classical feedback.
  • Shor’s algorithm is QPE on modular multiplication, plus continued fractions.
  • The long coherent circuits make QPE a fault-tolerant-era tool, which is why variational methods such as VQE were invented for today’s machines.

References and further reading

I opened the arXiv pages for Kitaev’s 1995 paper (the one-ancilla measurement procedure), for Cleve, Ekert, Macchiavello and Mosca’s 1997 paper (phase estimation as the common pattern behind several algorithms) and for Peruzzo et al. (the statement that a variational method needs much less coherent evolution than phase estimation). I opened the Cambridge page for Nielsen and Chuang only to confirm that it covers quantum algorithms. The accuracy formula for the number of counting qubits is the standard textbook result; I did not open a source for it in this session, and I checked it numerically instead. I could not run Qiskit, so none of the code was executed. Every probability and table is from my own NumPy simulation of the same circuits.

  1. Quantum measurements and the Abelian Stabilizer Problem (arXiv (A. Yu. Kitaev, 1995)) Opened the abstract page. Describes a procedure for measuring an eigenvalue of a unitary operator; the basis of the one-ancilla iterative version.
  2. Quantum Algorithms Revisited (arXiv (Cleve, Ekert, Macchiavello, Mosca, 1997)) Opened the abstract page. Shows several quantum algorithms as instances of phase estimation.
  3. A variational eigenvalue solver on a quantum processor (arXiv (Peruzzo et al., 2013)) Opened the abstract page. Used only for the statement that the variational method needs much less coherent evolution than phase estimation.
  4. Quantum Computing in the NISQ era and beyond (arXiv (J. Preskill, 2018)) Opened the abstract page. Used for the description of near-term machines of about 50 to 100 qubits limited by noise.