Quic03 Phase Estimation
Quic03 Phase Estimation
Contents
4.1 Why “Phase Estimation?” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Action of Controlling an Operator on its Eigenstate . . . . . . . . . . . . . . . . 28
4.3 Controlling Higher Powers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4 General Phase Estimation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.5 Closing Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
The phase estimation algorithm is used to determine the eigenvalues of a unitary operator. Convention-
ally, it is presented after the quantum Fourier Transform (QFT), a subroutine used in phase estimation.
Our presentation will use one result from the QFT, which we will derive in a future seminar. The QFT
is interesting in that it can perform a basis transformation analogous to a Fourier transform exponentially
faster than the best known classical algorithm. We will discuss this result more in the second semester when
we introduce (quantum) computational complexity.
For now we want to provide an introduction to the utility of quantum algorithms, which is why we focus
on the phase estimation algorithm first. Computing eigenvalues has an enormous number of applications in
an enormous number of fields. As such, the phase estimation algorithm is used in a large number of other
quantum algorithms from solving linear systems of equations in linear algebra (search for the HHL algorithm)
to minimizing the number of features required in machine learning applications (search for quantum principal
component analysis).
Ax = λx (4.1)
where A ∈ C 2m ×2m
, x ∈ C , and λ ∈ C. Note that we write the dimension as 2 for convenience, since
2m m
m qubits imply a state space of size 2m as we have previously seen. (We’re using m instead of the standard
n because we’ll introduce another n qubits later in the algorithm.)
In the quantum case, we’re only going to be concerned with unitary operators, which we normally write
as U . Since these operators satisfy U † U = I, any eigenvalue has magnitude one.
27
QUIC SEMINAR 4. THE PHASE ESTIMATION ALGORITHM 28
Solution 5: Since U |x⟩ = λ|x⟩, we have ⟨x|λ∗ λ|x⟩ = ⟨x|U † U |x⟩, hence |λ|2 ⟨x|x⟩ = ⟨x|x⟩, from which
the result follows immediately. (Recall eigenvectors are nonzero by definition.)
Since |λ| = 1, we can write it without loss of generality as
λ = e2πiϕ (4.2)
where 0 ≤ ϕ ≤ 1 is called the phase. Hence the term “phase” in “phase estimation.” The term “estimation”
comes about not from the fact that quantum computation is probabilistic, but rather in the degree of precision
that we are going to compute, or estimate, the phase to. The most general case of phase estimation is when
the phase cannot be written exactly using n bits of precision. In this lecture, we’ll only cover the case where
ϕ can be written exactly using n bits.
Before we going about estimating the phase, let’s introduce some useful notation that is common in
quantum algorithms. The phase ϕ is going to be between zero and one, so we can write it as a decimal in
binary notation as follows:
ϕ = 0.ϕ1 ϕ2 · · · ϕn (4.3)
where each ϕi is either zero or one. What does this mean exactly? The same thing we mean when we
always write decimals, except here we’re using binary notation.
Exercise 33: What is the value of the infinitely repeating binary decimal 0.1111111...?
(If it needed to be proved, the above exercise proves that 0 ≤ 0.ϕ1 ϕ2 · · · ≤ 1.)
|0⟩ H •
0
|ψ⟩ U2
Here we let U be a unitary operator and |ψ⟩ an eigenstate1 with eigenvalue λ = e2πi0.ϕ1 . We first perform
a Hadamard gate on the first qubit to get the state
what it’s effect was. Answer: here, we’re just using the eigenstate for pedagogical purposes. As we’ll see, the general phase
estimation algorithm does not require this.
28
QUIC SEMINAR 4. THE PHASE ESTIMATION ALGORITHM 29
|0⟩ H • H ✌✌✌
|0⟩ H X
Figure 4.2: Example of using the phase estimation algorithm to compute the eigenvalues of Pauli-X.
√
where we have intentionally omitted the normalization factor of 1/ 2 for clarity2 . We then perform a
controlled U operation, which we have written as U 2 for reasons that will become clear shortly. The action
0
Note what happened: The second qubit register containing |ψ⟩ hasn’t changed. We shouldn’t expect it
to, since |ψ⟩ is an eigenstate of U . Thus, no matter how many times we apply U to this register, nothing
happens to |ψ⟩.
That’s rather odd though—what’s the point of applying U then? The effect was that it wrote some
information about the eigenvalue into the relative phase of the first qubit. Namely, the entire effect was to
map
|0⟩ + |1⟩ 7→ |0⟩ + e2πi0.ϕ1 |1⟩ (4.8)
How can we read out this information from the quantum state? Consider the effect of applying another
Hadamard transformation on the first qubit, which will produce
Exercise 35: Prove that the RHS of (4.9) becomes exactly |1⟩ up to global phase. (Recall again that
(4.9) omits the normalization factor of 1/2.)
Thus, we measure with certainty (i.e., not probabilistically) a state that tells us exactly what the phase,
and hence the eigenvalue, is.
Example 2: Phase estimation on Pauli-X.
First, prove that the eigenvalues of X are −1 and 1 with eigenvectors |−⟩ and |+⟩ respectively.
Now, let’s see how we can do this using the phase estimation algorithm. The first thing we need to do
is prepare an eigenstate, which we can do by performing the Hadamard gate on the |0⟩ state in the second
register to get the plus state. Then, we control on the first qubit in uniform superposition to implement
a controlled-X gate, otherwise known as CNOT. Finally, we implement H again on the top qubit, then
measure. The complete circuit for this state is shown in Fig. 4.2.
The complete state after applying both Hadamard gates to both qubits is given by the uniform super-
position
|+⟩ ⊗ |+⟩ = |00⟩ + |01⟩ + |10⟩ + |11⟩. (4.10)
Note that this state remains unchanged under the CNOT. After performing the second Hadamard on the
top qubit, the top qubit is in the state |0⟩. Hence, measurement always returns the outcome ϕ1 = 0, and
so we conclude that the corresponding eigenvalue is λ = e2πi·0 = 1, as we must.
29
QUIC SEMINAR 4. THE PHASE ESTIMATION ALGORITHM 30
Exercise 36: Repeat the above example but for the |−⟩ eigenstate and verify that measuring the top
qubit always yields ϕ1 = 1, thus λ = −1. (Hint: How can the circuit in Fig. 4.2 be modified to produce the
|−⟩ state?)
n = 2.
The complete circuit for the n = 2 case is shown below. (Note that, although we’re only writing one
wire for the bottom register, this really consists of m qubits. That is, |ψ⟩ is an m-qubit state and U is an
m-qubit unitary.)
|0⟩ H •
|0⟩ H •
0 1
|ψ⟩ U2 U2
We’ve already computed what the first control does to the top register. The wavefunction at this point
in the circuit is
(|0⟩ + e2πi0.ϕ1 ϕ2 |1⟩ ⊗ (|0⟩ + |1⟩) ⊗ |ψ⟩. (4.11)
Note that the relative phase in the first qubit now has two digits because we assumed that ϕ = 0.ϕ1 ϕ2
consists of two digits.
The same exact operation now happens on the second qubit, except for one key difference: the power of
U . In particular, U is now squared. What effect does this have?
The effect is that the decimal moves one place to the right. (This should not be too surprising based
on common arithmetic in base ten.) What’s interesting and convenient, however, is what happens in the
exponent:
e2πi(2ϕ) = e2πi(ϕ1 +0.ϕ2 ) = e2πiϕ1 e2πi0.ϕ2 = e2πi0.ϕ2 . (4.14)
The last inequality follows because ϕ1 is an integer and so the exponential is unity.
(4.15)
k
e2πi(2 ϕ)
= e2πi0.ϕk ϕk+1 ··· .
Thus, we have proven that the state after applying the C(U 2 ) to the wavefunction (4.11) is
2 This is a common, though probably not great, convention that many authors follow.
30
QUIC SEMINAR 4. THE PHASE ESTIMATION ALGORITHM 31
Definition 4.2 (Quantum Fourier transform action.). The quantum Fourier transform is a unitary change
of basis with the following effect:
QFT (|ϕ1 ⟩|ϕ2 ⟩ · · · |ϕn ⟩) = 2−n/2 (|0⟩ + e2πi0.ϕ1 |1⟩) ⊗ (|0⟩ + e2πi0.ϕ1 ϕ2 |1⟩) ⊗ · · · ⊗ (|0⟩ + e2πi0.ϕ1 ϕ2 ···ϕn |1⟩).
(4.17)
The state on the right looks exactly like what we end up with from phase estimation! (Except with
the order of the bits reversed, but this is not problem.) So, what we need to apply then to read out the
information is the inverse Fourier transform QFT† . (The QFT is unitary, as every quantum algorithm must
be, therefore it has an inverse).
Thus, if we apply QFT† to the state in (4.16), we get a product state containing the information we want
about the phase:
QFT† (|0⟩ + e2πi0.ϕ1 ϕ2 |1⟩ ⊗ (|0⟩ + e2πi0.ϕ2 |1⟩) ⊗ |ψ⟩ = |ϕ2 ⟩ ⊗ |ϕ1 ⟩ ⊗ |ψ⟩. (4.18)
|0⟩ H • ✌✌✌
|0⟩ H • ✌✌✌
.. QFT† ..
. .
|0⟩ H • ✌✌✌
n
|ψ⟩ U2
0
U2
1
··· U2
Figure 4.4: Full algorithm for quantum phase estimation. If the phase ϕ can be written exactly in n bits,
this circuit computes ϕ exactly. If it requires more bits, this circuit computes a “good” approximation to ϕ.
The general calculation is also an immediate generalization of our previous work. Namely, the action of
the circuit, ignoring the |ψ⟩ register that never changes, is
1
|0⟩⊗n 7−→ (|0⟩ + |1⟩) ⊗ (|0⟩ + |1⟩) ⊗ · · · ⊗ (|0⟩ + |1⟩) (after the Hadamards)
2n/2
1
7−→ (|0⟩ + e2πi0.ϕ1 ϕ2 ···ϕn |1⟩) ⊗ (|0⟩ + e2πi0.ϕ2 ϕ3 ···ϕn |1⟩) ⊗ · · · ⊗ (|0⟩ + e2πi0.ϕn |1⟩) (after the C(U )’s)
2n/2
By measuring the final state, we obtain a description of the phase, and hence the eigenvalue, exactly.
31
QUIC SEMINAR 4. THE PHASE ESTIMATION ALGORITHM 32
|0� H • H
|ψ� Q
Figure 4.5: Hadamard test algorithm. This circuit can be used to compute Re [⟨ψ|Q|ψ⟩] as described in
Example 4.5.
Exercise 39: Prove that the phase estimation algorithm works even if we don’t know an eigenstate |u⟩
of U by inputting an arbitrary state |ψ⟩ and writing it as a linear combination of the eigenstates of U ,
∑
|ψ⟩ = cu |u⟩. (4.19)
u
Exercise 40: Prove that implementing an S gate before the final Hadmard on the first qubit allows
one to compute the imaginary part of the expectation value Im [⟨ψ|Q|ψ⟩]. Recall, S|0⟩ = |0⟩ and S|1⟩ = i|1⟩.
32