MQC_Notes___3
MQC_Notes___3
Dr. Venugopal K.
June 2, 2025
1 Deutsch Algorithm
1.1 Introduction
The Deutsch algorithm, proposed by David Deutsch in 1985, is the first quantum algorithm
demonstrating quantum advantage. It solves a toy problem that illustrates the power of
quantum parallelism.
1
1.4 Circuit 1 DEUTSCH ALGORITHM
1.4 Circuit
1.5 Analysis
Initial State Preparation:
|ψ0 ⟩ = |0⟩ ⊗ |1⟩
• First qubit: Input register
• Second qubit: Ancilla prepared in |1⟩ for phase kickback
Step 1: Hadamard Transformation Apply H to both qubits:
1 1
H |0⟩ = √ (|0⟩ + |1⟩), H |1⟩ = √ (|0⟩ − |1⟩)
2 2
1
|ψ1 ⟩ = (H ⊗ H) |ψ0 ⟩ = (|0⟩ + |1⟩)(|0⟩ − |1⟩)
2
This creates superposition of all possible inputs with phase difference.
Step 2: Oracle Application The oracle Uf implements:
Uf |x⟩ |y⟩ = |x⟩ |y ⊕ f (x)⟩
Applying to |ψ1 ⟩:
1
|ψ2 ⟩ = [|0⟩ (|0 ⊕ f (0)⟩ − |1 ⊕ f (0)⟩) + |1⟩ (|0 ⊕ f (1)⟩ − |1 ⊕ f (1)⟩)]
2
1
H |ψ3 ⟩ = √ (H |0⟩ + (−1)s H |1⟩)
2
1 1 s 1
" #
= √ √ (|0⟩ + |1⟩) + (−1) √ (|0⟩ − |1⟩)
2 2 2
1
H |ψ3 ⟩ = [(1 + (−1)s ) |0⟩ + (1 − (−1)s ) |1⟩]
2
Measurement Outcomes:
2 1
1 + (−1)s if s = 0 (constant)
Probability of |0⟩ : =
2 0 if s = 1 (balanced)
s 2 0
1 − (−1) if s = 0 (constant)
Probability of |1⟩ : =
2 1 if s = 1 (balanced)
1.6 Conclusion
The measurement outcome deterministically reveals:
• |0⟩ → Constant function
• |1⟩ → Balanced function
with only one quantum query to the oracle, compared to two classical queries required in
the worst case.
1.7 Exercises
1. Verify the final state for all four 1-bit functions:
(a) f (x) = 0
(b) f (x) = 1
(c) f (x) = x
(d) f (x) = 1 ⊕ x
2. Show that measuring the second qubit gives no information about f .
3. Design a 2-qubit Deutsch-like algorithm that determines whether a function f : {0, 1}2 →
{0, 1} is constant or balanced.
2 Deutsch-Jozsa Algorithm
2.1 Introduction
The Deutsch-Jozsa algorithm generalizes the Deutsch algorithm to n-bit functions, providing
an exponential speedup over classical algorithms for a promise problem.
2.3 Circuit
Creates uniform superposition over all n-bit strings with phase difference.
Step 2: Oracle Application The oracle Uf implements:
Applying to |ψ1 ⟩:
1 X
|ψ2 ⟩ = √ n |x⟩ (|0 ⊕ f (x)⟩ − |1 ⊕ f (x)⟩)
2 x
Thus:
1 X 1
|ψ2 ⟩ = √ n (−1)f (x) |x⟩ ⊗ √ (|0⟩ − |1⟩)
2 x 2
(−1)c X
|ψ4 ⟩ = (−1)x·z |z⟩ = (−1)c |0⟩⊗n
2n x,z
since x (−1)
x·z
= 2n δz,0
P
• Balanced case:
2
⊗n 2 1 X
⟨0| |ψ4 ⟩ = n (−1)f (x)
=0
2 x
by definition of balanced functions
Measurement Outcomes:
• Measure |0⟩⊗n : Constant function (probability 1)
• Measure any other state: Balanced function (probability 1)
Key Features
• Quantum Parallelism: Evaluating f (0) and f (1) simultaneously
• Interference: Hadamard gates create constructive/destructive interference
• Measurement: Extracting global information about f from a single measurement
• Requires only one quantum query vs. Ω(2n−1 + 1) classical queries
• Perfect discrimination between constant/balanced classes
• Generalizes Deutsch’s algorithm (n = 1 case)
• Demonstrates exponential quantum advantage for oracle problems
2.5 Exercises
1. Show that for balanced functions, the amplitude of |0⟩⊗n vanishes.
2. Construct the oracle Uf for the case when f (x) is the AND of all input bits.
3. Analyze the algorithm’s behavior when the promise is violated (i.e., f is neither con-
stant nor perfectly balanced).
4. How would you modify the algorithm if f is promised to be either constant or satisfy
f (x) = s · x for some secret string s?
3 Bernstein-Vazirani Algorithm
Problem Statement: Given a function f : {0, 1}n → {0, 1} defined as:
n
f (x) = s · x mod 2 =
M
s i xi
i=1
3.1 Circuit
Applying to |ψ1 ⟩:
1 X
|ψ2 ⟩ = √ n |x⟩ (|0 ⊕ (s · x)⟩ − |1 ⊕ (s · x)⟩)
2 x
Thus:
1 X 1
|ψ2 ⟩ = √ n (−1)s·x |x⟩ ⊗ √ (|0⟩ − |1⟩)
2 x 2
where x · z = xi zi .
Ln
i=1
Measurement Analysis:
1 X
⟨z|ψ4 ⟩ = (−1)s·x+x·z
2 x
n
1 X
= n (−1)x·(s⊕z)
2 x
= δz,s (since (−1)x·w = 2n δw,0 )
X
Measurement Outcome:
Key Features
• Single Query: Determines s with one oracle call
• Classical Comparison: Requires n classical queries
• Phase Encoding: Oracle encodes s in relative phases
• Perfect Reconstruction: Hadamard transform perfectly extracts s
Complexity Comparison
Quantum 1 query
Classical Ω(n) queries
Conceptual Importance
• Exponential Speedup: Solves a specific oracle problem exponentially faster than
any classical algorithm.
• Quantum Paradigm Shift: Showcases the power of quantum parallelism and inter-
ference.
• Foundational Elements: Utilizes superposition, unitary operations, and measure-
ment to extract global structure from a function.
|0⟩⊗n |0⟩⊗n .
Step 4: Apply Hadamard Transform Again Apply Hadamard to the first register:
1 h i
|ψ4 ⟩ = √ (−1)x0 ·y + (−1)(x0 ⊕s)·y |y⟩ .
X
2n+1 y∈{0,1}n
1 X
=√ (−1)x0 ·y [1 + (−1)s·y ] |y⟩ .
2n+1 y
Only those y for which s · y = 0 (mod 2) will have non-zero amplitude.
Step 5: Measure and Collect Equations Measure to get a bit string y such that:
4.6 Conclusion
Simon’s algorithm solves the problem of finding a hidden XOR mask in a 2-to-1 function
using quantum superposition, interference, and measurement. It highlights the contrast
between classical and quantum capabilities and remains a foundational example in quantum
algorithm studies.
Goal: Transform a quantum state |x⟩ into a superposition state where the amplitudes encode
frequency (or phase) information.
1 NX
−1
x̃k = √ xj e2πijk/N , for k = 0, 1, . . . , N − 1.
N j=0
1 NX−1
QFT |x⟩ = √ e2πixy/N |y⟩
N y=0
Note: - This is a unitary transformation. - It maps computational basis states |x⟩ into
phase-encoded superpositions.
This means the QFT maps each |x⟩ to a superposition whose amplitudes carry phases that
depend on x.
1 0
" #
Rk =
0 e2πi/2
k
• This step introduces a phase based on the values of the later qubits.
2. Finally, reverse the order of the qubits.
5.5 Circuit
5.6 QFT on a General State
Let the input be a general state:
n −1
2X
|ψ⟩ = αx |x⟩
x=0
Then:
n −1 n −1 n −1
2X 2X
1 2X n
QFT |ψ⟩ = αx · QFT |x⟩ = αx · √ n
e2πixy/2 |y⟩
x=0 x=0 2 y=0
1 X 7
QFT |x⟩ → √ ω xk |k⟩ ,
8 k=0
8
where ω = ω8 = e( 8 ) is an eighth root of unity satisfying ω 8 = e( 8 )
2πi 2πi
= 1.
1 1 1 1 1 1 1 1
1 ω ω2 ω3 ω4 ω5 ω6 ω7
1 ω2 ω4 ω6 1 ω2 ω4 ω6
1 1
ω3 ω6 ω ω4 ω7 ω2 ω5
F8 = √
.
8 1 ω4 1 ω4 1 ω4 1 4
ω
1
ω5 ω2 ω7 ω4 ω ω6 ω3
1 ω6 ω4 ω2 1 ω6 ω4 ω2
1 ω7 ω6 ω5 ω4 ω3 ω2 ω
For example:
• Row 0: ω 0·k = 1 for all k, so it’s:
1 1 X 7
√ [1, 1, 1, 1, 1, 1, 1, 1] ⇒ QFT |0⟩ = √ |k⟩
8 8 k=0
1 1 X 7
√ [1, ω, ω 2 , ω 3 , ω 4 , ω 5 , ω 6 , ω 7 ] ⇒ QFT |1⟩ = √ ω k |k⟩
8 8 k=0
1 1 X 7
√ [1, ω j , ω 2j , . . . , ω 7j ] ⇒ QFT |j⟩ = √ ω jk |k⟩
8 8 k=0
1
QFT |0⟩ = (|0⟩ + |1⟩ + |2⟩ + |3⟩)
2
1
QFT |1⟩ = (|0⟩ + i |1⟩ − |2⟩ − i |3⟩)
2
1
QFT |2⟩ = (|0⟩ − |1⟩ + |2⟩ − |3⟩)
2
1
QFT |3⟩ = (|0⟩ − i |1⟩ − |2⟩ + i |3⟩)
2
Important: The number of gates grows quadratically (O(n2 )), but can be approximated
efficiently by ignoring very small rotations.
8. Applications
• Quantum Phase Estimation: Extracts eigenvalues (phases) using inverse QFT.
• Shor’s Algorithm: Finds the period of modular functions using QFT.
• Quantum signal processing and chemistry: Exploit phase structure of quantum
states.
5.10 Summary
• QFT transforms computational basis states into phase-encoded superpositions.
• The inverse QFT decodes this phase back into binary form.
• QFT is central to many powerful quantum algorithms.
QPE is a core subroutine in many quantum algorithms, including Shor’s algorithm, Hamil-
tonian simulation, and the HHL algorithm for solving linear systems.
Applications
• Shor’s factoring algorithm.
• Estimating eigenvalues of Hermitian operators.
• Quantum simulation of physical systems.
6.1.1 Circuit
After applying the Hadamard gates in Step 1, the quantum state is:
m −1
1 2X
√ |k⟩ ⊗ |u⟩
2m k=0
This is a uniform superposition over all possible m-bit binary values k, tensored with the
eigenvector |u⟩.
Now, we apply a sequence of controlled-unitary operations. Specifically, we apply the unitary
U raised to increasing powers of 2, controlled by each qubit in the control register:
0 1 m−1
Apply controlled-U 2 , controlled-U 2 , . . . , controlled-U 2 .
This means that for each basis state |k⟩, the unitary U k is applied to |u⟩. Because |u⟩ is an
eigenvector of U , we have:
U k |u⟩ = e2πiϕk |u⟩ .
Key Insight: The phase e2πiϕk is now associated with each basis state |k⟩ in the control
register. The information about ϕ is thus encoded into the relative phases of the amplitudes
of the control register. The target register |u⟩ remains unchanged.
This phenomenon is known as phase kickback: the controlled application of U causes the
eigenvalue (a complex phase) to “kick back” into the control qubits.
Let us now ignore the target register (which remains |u⟩), and focus on the control register,
which is in the state: m −1
1 2X
√ e2πiϕk |k⟩ .
2 k=0
m
This is a Fourier-like state: the phases vary linearly with k. In fact, this is exactly the
quantum Fourier transform of the number ϕ · 2m .
Therefore, applying the inverse quantum Fourier transform (QFT−1 ) to this state gives:
|ϕ̃⟩ ,
ϕ̃ 1
ϕ− ≤ m+1 ,
2 m 2
with high probability (at least ≈ 0.405, and higher with amplitude amplification).
Why This Works: The inverse QFT decodes the phase information encoded in the su-
perposition. It maps the complex exponential phases e2πiϕk into a binary representation of
ϕ.
Result: After applying QFT−1 , the control register collapses (upon measurement) to a
bitstring approximating ϕ, accurate to m bits.
Step 4: Measurement
Measure the control register to obtain a binary approximation of ϕ.
6.5 Applications
• Shor’s algorithm: Used for period finding in modular arithmetic.
• Quantum simulations: Estimating eigenvalues of Hamiltonians.
• Linear systems (HHL): QPE encodes eigenvalues into amplitudes.
• Quantum metrology and phase estimation.
6.6 Conclusion
Quantum Phase Estimation (QPE) is a fundamental algorithm that demonstrates the true
power of quantum computation. Its ability to extract eigenvalues efficiently is critical for
solving various important problems, making it a cornerstone of quantum algorithm design.