《量子计算》课程讲义
《量子计算》课程讲义
Fall 2022
Instructor: 李彤阳
September 7, 2022
Basic Information
• Except Lecture 1, we will teach by handwriting on iPad, and notes will be
posted to our course website after each lecture.
• The lecture notes are adopted from several books and lecture notes for
best fitting the course topics. Acknowledgement: Prof. Andrew M. Childs
and Prof. Ronald de Wolf.
Evaluation
Assignments 25% (5 assignments, 5% each)
Project 35% (5% proposal, 20% final report, 10% presentation)
Final exam 40%
Assignments
• Each assignment will be given around two weeks to finish.
• Late assignments will NOT be accepted. After each deadline, there will be a
prompt lecture to post solutions hosted by TAs.
• You are encouraged to discuss assignment problems with your peers, with the
TA, and with the course instructor. However, your solutions should be based on
your own understanding and should be written independently. For each
assignment, if you discussed the problems with other students in the class, you
must include a list of the students' name.
Project
Our course project will:
• Explore a topic in depth, especially considering that quantum computing is a rapidly advancing area;
• Give you experience in reading research literature and identifying possible future research directions;
• Practice your scientific communication skills through both a written report and an in-class presentation.
You may work either on your own or in a group of two students. Project types include:
- An expository paper on a quantum computing topic that is not covered in the course,
- An original research project on a theoretical aspect of quantum computing, or
- An implementation of a quantum algorithm or protocol using online quantum computing platforms.
The project is composed of a proposal (1 page), a final report (no more than 10 pages),
and a presentation (around 20 minutes, depending on the number of groups).
Project
A suggested range of topics will be given around the middle of the semester.
The final report will be required to be written in a given LaTeX template. Reference:
• https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes
• https://texdoc.org/serve/latex2e.pdf/0
The evaluation of the presentation will mainly depend on contents and clarity.
Final Exam
Students are allowed to take one page of A4 paper (with two sides).
No other notes, books, devices, etc. are allowed.
Week 11: Assignment 5 announced; Assignment 4 due on Nov 16 and Solution Lecture 4
Classical bit: 0 or 1.
Fault-tolerant
Current quantum
quantum computers computers
10-100 noisy qubits >106 qubits
??? years
Quantum
supremacy
Quantum supremacy
Current status of quantum computing research
Industry Giants
Start-ups
Academia
Online quantum computing platforms
• IBM Qiskit: https://qiskit.org/
Online quantum computing platforms
• IBM Qiskit: https://qiskit.org/
Online quantum computing platforms
• Tensorflow Quantum: https://www.tensorflow.org/quantum
• Paper: TensorFlow Quantum: A Software Framework for Quantum Machine
Learning, https://arxiv.org/abs/2003.02989
Online quantum computing platforms
• QuTiP: https://qutip.org/. Written in Python, focus on quantum simulation.
• QuTiP: An open-source Python framework for the dynamics of open quantum
systems, https://arxiv.org/abs/1110.0573
• QuTiP 2: A Python framework for the dynamics of open quantum systems,
https://arxiv.org/abs/1211.6518
Online quantum computing platforms
• TensorCircuit: a Quantum Software Framework for the NISQ Era,
https://arxiv.org/abs/2205.10091
Quantum computing by steps
• After all, this is the very original motivation of studying quantum computing.
Lecture 2
1 Classcial gate
We call a set of gates universal if it can compute any f : {0, 1}n → {0, 1}m
• {NAND} is universal.
1
2 Reversible Computing
AND gate is NOT reversible: cannot recover(x,y) pairs with the output:
Toffoli is universal:
2
3 Postulates in quantum computing
3.1 Quantum states
( )
a0 a0 , a 1
Qubit : ∈C |a0 |2 + |a1 |2 = 1
a1 “amplitudes”
( )
1
= |0i
0
Basic vectors :
( )
0
= |1i
1
θ θ
|ψi = eiη cos |0i + eiϕ sin |1i
2 2
Since the global phase is irrelevant, set η = 0 WLOG:
θ θ
|ψi = cos |0i + eiϕ sin |1i
2 2
3
3.2 Quantum dynamics/evolutions
Time evolution in quantum mechanics is linear:
Recall that all quantum states are l2 -norm unit vectors. To keep quantum states being states =⇒ quantum
dynamics must be unitary:
∴ NOT† NOT = I
For example:
d
i |ψ(t)i = H |ψ(t)i
dt
H : the“Hamiltonian” H = H†
(−iHt)2
e−iHt = I + (−iHt) + + ···
2!
4
3.3 Composite systems
The state space of a composite system is the tensor product of the individual space.
( ) ( ) p0 q 0
p q
p0 q0 0 1
Vector : ⊗ =
p1 q1 p1 q0
p1 q 1
( ) ( ) a00 b00 a00 b01 a01 b00 a01 b01
a b a01 b11
a00 a01 b00 b01 00 10 a00 b11 a01 b10
⊗ =
a10 a11 b10 b11 a10 b00 a10 b01 a11 b00 a11 b01
a10 b10 a10 b11 a11 b10 a11 b11
If the first and second subsystem is denoted as |ψi, |ϕi respectively, then the overall state is:
For example:
n qubits C2 ⊗ C2 ⊗ · · · ⊗ C2 ∼
n
= C2
∑
|ψi = ax |xi
x∈{0,1}n
For example:
0, α1 β1 = √1 .α0 β0 α1 β1
2
= 1
2 6= 0 = α0 β1 α1 β0 , a contradiction.
5
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: September 16, 2022
Lecture 3
1 Orthonormal basis
A group of vectors {|φi i} such that:
∑
hφi |φj i = δij and |φi i hφi | = I
i
• Let B = {|φi i} be an orthonormal basis for the state space of a quantum system. Then if the system
∑
is in a state |ψi = i ai |φi i, a quantum measurement with respect to B outputs “i” with probability
|ai |2 , leaving the system in state |φi i.
∑
• If the system is in i ai |φi i ⊗ |ωi i where the states |ωi i is normalized. Then a measurement of the
first subsystem w.r.t. B gives “i” with probability |ai |2 , leaving the system in state |φi i ⊗ |ωi i.
1
We could also realize this by a unitary followed by a computational basis measurement.
( ) ( ) ( √ )
1+√ 3
1 1 1 H |+i 7−→ |0i 1
H=√ H √23 = 1− 2 √2
2 1 −1 H |−i 7−→ |1i 2
√ 3
2 2
2 Partial measurement
For example: |ψi = √1 (|00i
2
+ |11i), measure 1st qubit in computational basis:
1 1
, |ψi 7−→ |00i Pr(1) = , |ψi 7−→ |11i
Pr(0) =
2 2
√ √ √ √
For example: |ψi = 10
1
|00i + 10
2
|01i + 103
|10i + 10
4
|11i, measure 1st qubit in computational basis:
√ √ √ √ √ √
3 1 2 7 3 4
|ψi = |0i ⊗ ( |0i + |1i) + |1i ⊗ ( |0i + |1i)
10 3 3 10 7 7
3 7
Pr(0) = , Pr(1) =
10 10
If we measure both qubits in the computational basis, we get:
1 2 3 4
Pr(00) = , Pr(01) = , Pr(10) = , Pr(11) = .
10 10 10 10
3 Superdense coding
Suppose Alice and Bob share an entangled state √12 (|00i + |11i).(ebit)
( ) ( ) ( ) ( )
1 0 0 1 1 0 0 1
Suppose Alice applies one of I = , X= , Z= , ZX = = iY
0 1 1 0 0 −1 −1 0
1 1
(I ⊗ I) √ (|00i + |11i) = √ (|00i + |11i) = |β00 i
2 2
1 1
(X ⊗ I) √ (|00i + |11i) = √ (|10i + |01i) = |β01 i
2 2
1 1
(Z ⊗ I) √ (|00i + |11i) = √ (|00i − |11i) = |β10 i
2 2
1 1
(ZX ⊗ I) √ (|00i + |11i) = √ (− |10i + |01i) = |β11 i
2 2
{|β00 i , |β01 i , |β10 i , |β11 i} forms an orthonormal basis, the Bell basis.
A procedure that Alice can send two classical bits to Bob:
1. If Alice wants to send ZX ∈ {0, 1}2 to Bob, she performs Z Z X X on √1 (|00i + |11i)
2
and obtains |βZX i.
The procedure requires an ebit, sends a qubit, and Bob can decode two classical bits.
2
4 Teleportation
Now, Alice wants to send Bob a qubit, but she only has a classical channel.
Suppose they also share a Bell pair.
Mathematically, they share |ψi ⊗ |β00 i, where Alice has qubits 1 & 2, Bob has qubit 3.
Procedure:
1. Alice measures qubit 1 & 2 in Bell basis.
|β00 i
00
|β i
10
01
2. If the outcome is , Alice sends XZ = to Bob.
|β10 i
01
|β11 i 11
• Superdense coding: The procedure requires an ebit, sends a qubit, and Bob can decode two classical
bits.
• Teleportation: The procedure requires an ebit, sends two classical bits, and Bob can decode a qubit.
In the following sections, we discuss about chapter of Quantum Circuits, which should have
been scheduled in the next lecture, but was put here corresponding with the lecture’s pace.
3
Common rules:
• for measurements.
5 Single-qubit gates
θ (i θ )2 (i θ )3 (i θ )4
RX (θ) = e−i 2 X = I − i X + 2 X 2 − 2 X 3 + 2 X 4 + · · ·
θ
( 2 2! ) (3! 4! )
θ 2 θ 4 θ 3
(2) (2) θ (2) ( θ2 )5
=I 1− + + · · · − iX − + + ···
2! 4! 2 3! 5!
( )
θ θ cos θ2 −i sin θ2
= cos I − i sin X =
2 2 −i sin θ2 cos θ2
( )
θ θ cos θ2 − sin θ2
RY (θ) = cos I − i sin Y =
2 2 sin θ2 cos θ2
( θ )
θ θ e−i 2 0
RZ (θ) = cos I − i sin Z = θ
2 2 0 ei 2
Fact: Any 1-qubit unitary can be decomposed as eiϕ RZ (θ3 )RX (θ2 )RZ (θ1 ) where ϕ, θ1 , θ2 , θ3 ∈ R
4
6 Controlled-U gates
|xi • |xi •
|yi |x ⊕ yi U
|00i 7−→ |00i , |01i 7−→ |01i |0i |ψi 7−→ |0i |ψi
|10i 7−→ |11i , |11i 7−→ |10i |1i |ψi 7−→ |0i U |ψi
( )
x, y ∈ {0, 1} I 0
|0i h0| ⊗ I + |1i h1| ⊗ U =
0 U
For example:
• • • |+i • |−i
Z
= ⇐⇒
X −I |−i |−i
5
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: September 21, 2022
Lecture 4
1 Universality
We would like to use a finite gate set to quantify complexity an fault tolerance.
This needs approximation and a metric between states.
√
k|ψi − |ϕik := (hψ| − hϕ|)(|ψi − |ϕi)
√
k|ψi − |ψik = 0, k|ψi − |−ψik = 2, hψ|ϕi = 0 ⇒ k|ψi − |ϕik = 2
For example:
kX |−i − I |−ik = 2 ⇒ E(X, I) = 2
Definition: A set of quantum gates is universal if for any positive integer n, any n-qubot unitary U and
any ϵ > 0, we can find gates V1 , V2 , · · · , Vk from the set s.t. E(U, V1 V2 · · · Vk ) ≤ ϵ
For example: {Toffoli} can only map product states to product states: not universal.
For example: {CNOT,X,Y,Z} can only map product states to product states: not universal.
Facts about universality:
• If we can rotate by an angle that is not a rational multiple of π, then we can approximate a rotation
about that axis by any angle arbitrarily closely.
• If we can rotate about two non-parallel axes by arbitrary angles, we can perform an arbitrary rotation.
• For multi-qubit gates, universal set must include an entangling gate (can map product state to entangled
state).
1
• In fact, universal 1-qubit gate set + any entangling gate gives universality.
( )
π 1 0
Common universal set: {CNOT,H,T}, where T = RZ ( 4 ) = π
0 ei 4
HT HT, T HT H → irrational angle.
Efficiency: NOT every unitary on n qubits has a cricuit of poly(n) gates by a counting argument.
Classically:
2 Phase kickback
Simplest query problem:
x f1 (x) f2 (x) f3 (x) f4 (x)
|xi |xi 0 0 1 0 1
Uf
|yi |y ⊕ f (x)i 1 0 1 1 0
constant balanced
Put |−i = √1 (|0i − |1i) in the second register.
2
|xi |−i = √1 (|xi |0i − |xi |1i) 7−→ √1 |xi (|f (x)i − |f (x)i)
2 2
|−i f (x) = 0
√1 |xi (|f (x)i − |f (x)i) = |xi = (−1)f (x) |xi |−i
2 − |−i f (x) = 1
Hence, |xi |−i 7−→ (−1)f (x) |xi |−i. This is formally known as phase kickback.
3 Deustsch’s problem
Given black box for f : {0, 1} −→ {0, 1}. Problem: Is f constant or balanced?(Or the parity of f (0) ⊕ f (1))
Quantumly, query in superposition:
|0i H H⊗I Uf
Uf |0i |0i 7−→ |+i |0i 7−→ √1
2
(|0, f (0)i + |1, f (1)i)
|1i
Not so helpful... cannot get the information of both f (0) and f (1) at the same time.
Instead, we use phase kick:
|0i H H⊗I Uf ( )
Uf |0i |−i 7−→ |+i |−i 7−→ √1
2
(−1)f (0) |0i + (−1)f (1) |1i |−i
|−i
2
( ) ( ) |+i |−i f (0) ⊕ f (1) = 0
(−1)f (0)
√1 (−1)f (0) |0i + (−1)f (1) |1i |−i = √ |0i + (−1)f (0)⊕f (1) |1i |−i ∝
2 2 |−i |−i f (0) ⊕ f (1) = 1
4 Deustch-Jozsa problem
• Given: f : {0, 1}n 7−→ 0, 1(by a black box)
|x1 i |x1 i
.. ··· ··· ..
. Uf .
|xn i |xn i
|−i (−1)f (x) |−i
Algorithm:
|0i H H
.. ··· ··· ..
. Uf .
|0i H H
|−i |−i
⊗n ⊗n
∑ 1 Uf 1 ∑
(H |0i ) |−i = |+i |−i = √ |xi |−i 7−→ √ (−1)f (x) |xi |−i (*)
2 n 2n
x∈{0,1}n x∈{0,1}n
⊗n
|0i + (−1)xj |1i 1 ∑ ∏
n
1 ∑
H ⊗n |xi = √ =√ (−1)xj yj |yi = √ (−1)x·y |yi
j=1
2 2n y∈{0,1}n j=1
2n y∈{0,1}n
∑ f ∑
Where ay = 21n {0,1}n (−1)f (x)+x·y . If f is a constant, then ay = (−1) 2n x∈{0,1}n (−1)
x·y
3
if y = 0 . . . 0, output ”constant”. If y 6= 0 . . . 0, output “balanced”.
Conclusion: after we measure,
Classically, 2n−1 + 1 (determinisic) queries
Succeed with probability 1:
Quantumly, 1 query
( )
But with classical randomized algorithm. O log 1ϵ queries with success probability ≥ 1 − ϵ:
( )
Take O log 1ϵ samples. If all same, output “constant”. Otherwise output “balanced”.
4
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: September 23, 2022
Lecture 5
1 Simon’s problem
• Given: a function f : {0, 1}n → X where |X| ≥ 2n−1 .“A structured 2-to-1 function”
• Promise: ∃ some s ∈ {0, 1}n , s 6= 0n such that f (x) = f (y), if and only if x = y or x = y ⊕ s.
• Find s.
X
|0i H H ⊗n ⊗m H
⊗n ⊗m
I 1
|xi |0i |0i 7−→ √ |xi |0m i
.. ··· ··· .. 2n x∈{0,1}n
. .
Uf 1 X
|0i H H 7−→ √ |xi |f (x)i
Uf 2n x∈{0,1}n
|0i X |xi + |x ⊕ si
|yi = √
1
√ |f (x)i
.. ··· ··· ..
. . 2n−1 2
x∈R
|0i |R| = 2n−1 , coset representation of f
H ⊗n P
Recall the effect of H ⊗n (Hadamard transformation), |xi 7−→ √12n y∈{0,1}n (−1)x·y |yi
Recall: x · y means bit-wise product x · y = x1 y1 + · · · xn yn (mod 2)
1
Plugging this into above:
1 X |xi + |x ⊕ si H (⊗n I ⊗m 1 1 X X h i
√ √ |f (x)i −→ √ √ (−1)x·y + (−1)(x⊕s)·y |yi|f (x)i
2n−1 x∈R
2 2n−1 2n+1 x∈R y∈{0,1}n
1 X X
= n (−1)x·y [1 + (−1)s·y ] |yi|f (x)i
2 n
x∈R y∈{0,1}
Yn Y∞
2n − 1 2n − 2 2n − 2n−1 1 1 1
Pr[linearly independent] = n
· n
······ · n
= 1− i ≥ 1 − i ≈ 0.289 · · · >
2 2 2 i=1
2 i=1
2 4
These states form an orthonormal basis, the Fourier basis: hx̃ | x̃′ i = δx,x′ .
When do we need the quantum Fourier transform?
2
2.2 Hadamard test H⊗I 1 1
controlled-U
|0i|ψi 7−→ √ (|0i + |1i)|ψi √ (|0i|ψi + |1iU |ψi)
7−→
2 2
|0i H • H 1
= √ |0i + eiθ |1i |ψi
|ψi U |ψi 2
H⊗I 1 1 + eiθ 1 − eiθ
7−→ (|0i + |1i) + e (|0i − |1i) |ψi =
iθ
|0i + |1i |ψi
2 2 2
2 2
1 + eiθ1 1 − eiθ θ
Pr(0) = (1 + cos θ)2 + sin2 θ
= Pr(1) = = sin2 .
2 4 2 2
1 θ
= [2 + 2 cos θ] = cos2
4 2
If θ = 0 or θ = π, we learn θ perfectly. If 0 < θ < π. learn the probability distribution by samples to get
information of θ.
n bits
Pn x z }| {
Next, suppose θ = 2π · j=1 2jj . i.e., θ = 2π · 0. x1 . . . xn
k
Consider what happens if we apply U 2 .
k k
U 2 |ψi = ei2 θ |ψi = e2πi·x1 ...xk .xk+1 ...xn |ψi = e2πi·0.xk+1 ...xn |ψi
n−1
In particular, U 2 |ψi = e2πi·0.xn |ψi.
n−1
|ψi xn = 0 |0i H • H xn
In other words, U 2 |ψi =
− |ψi xn = 1
|ψi U2
n−1
.. .. .. ...
. . .
|0i H • ··· √1
2
|0i + e2πi·0.x2 ...xn |1i
|0i H • ··· √1
2
|0i + e2πi·0.x1 ...xn |1i
|ψi U U2 ··· U2
n−2
U2
n−1
|ψi
The output state is:
On
1
√ |0i + e2πi·0.xn+1−i ...xn |1i
i=1
2
2 −1
1 X 2πi·2n−1n xyn−1
n
2πi·2n−2 xyn−2 2πixy0
=√ e 2 |yn−1 i e 2n |yn−2 i · · · e 2n |y0 i
n
2 y=0
1 X 2πixy
n−1
2
=√ e 2n |yi = |x̃i
2n y=0
3
Ideally, for phase estimation, we want to have x1 , · · · , xn directly as outputs.
P2n −1 2πixy
Note: QF T : |xi −→ |x̃i = √12n y=0 e 2n |yi x ∈ {0, 1, · · · , 2n − 1}
So the transformation sending |x̃i 7→ |xi is exactly QF T −1 .
How do we implement this?
The first qubit is |0⟩+e √2 |1⟩ = H |xn i. So applying H reveals xn .
2πi·0.xn
n−k+1 n+12x xn x
Move generally, since e2πi·0·xn−k+1 ...xn = e2πi( 21 + 22 +···+ 2k )
x x
the k th qubit is √12 |0i + e2πi·0.xn−k+1 ...xn |1i = Rkxn · · · R3 n−k+3 R2 n−k+2 H |xn−k+1 i.
−1
As a result, the QF T circuit is:
√1
2
|0i + e2πi·0.xn |1i H • ··· • ··· • ··· |xn i
√1
2
|0i + e2πi·0.xn−1 xn |1i R2† H ··· • ··· • ··· |xn−1 i
.. • ..
. .
† †
√1
2
|0i + e2πi·0.x2 ...xn |1i ··· Rn−1 Rn−2 ··· R2† H ··· • |x2 i
†
√1
2
|0i + e2πi·0.x1 ...xn |1i ··· ··· Rn† Rn−1 ··· R2† H |x1 i
4
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: September 30, 2022
Lecture 6
1 Phase Estimation
Big picture of phase estimation:
.. .. .. QF T −1
. . .
|ψi U U2 ··· U2
n−2
U2
n−1
|ψi
If U |ψi = e2πi·0.x1 ...xn |ψi, this works. How about e2πiφ for general φ ∈ [0, 1) ?
2X −1 i−1
n
⊗n 1 Xn
2 |xi i if xi = 0
|0i⊗n 7−→ √
H c−U
|xi x= xi · 2n−i |xi i 7−→
n
2 x=0 eiφ2i−1 |xi i if xi = 1
i=1
2X
n
−1
c−Us 1 Y
n
7−→ √ eiφx |xi
i−1
n
|x1 . . . xn i 7−→ eiφxi 2 |xi i
2 x=0
−1
P2n −1 P2n −1 2πixy
i=1
The QF T is x=0 |xi hx̃| = √12n x,y=0 e− 2n |xi hy|.
P2n −1 iφx QF T −1 P2n −1 P2n −1 P2n −1 i(φ− 2πy
2n ) x .
2πixy
√1
2n x=0 e |xi 7−→ 21n x,y=0 eiφx e− 2n |yi = y=0 αy |yi, αy := 1
2n x=0 e
αy is a geometric series. Denote φ̃ = φ − 2πy
2n
2
e−iφ̃2
n−1 n−1 n−1
2X −1 − eiφ̃2 2X
n n−1
e n
1 − eiφ2 eiφ̃2 e n−1
sin2 φ2
e iφ̃x
= = ⇒ eiφ̃x =
x=0
1 − eiφ̃ eiφ̃/2 e−iφ̃/2 − eiφ̃/2 x=0
sin2 (φ̃/2)
1
2πy
1 sin ((φ− 2n )·2
2 n−1
2 )
Therefore: Pr(y) = |αy | = 22n 2πy
sin (φ− 2 )· 12 )
2
. sin mx
sin x → m when x → 0.
2n ≈ φ.
This distribution is tightly peaked around those y for which 2πy
2π(k+1)
Claim. Let 2n ⩽ φ ⩽ 2n . Then the probebility of outputting either k or k + 1 is at least
2πk 8
π2 .
1 1
= ·
22n−1 sin2 2n+1
π
1 1 8
⩾ 2n−1 · 2 = 2 .
2 π
n+1
π
2
Summary. Given |ψi with U |ψi = eiφ |ψi. we can produce an estimate of φ thet differs from the true value by
−1
at most ε 2π 8
2n with probability at π 2 . This use QF T with gate complexity O n2 and O(1/ε) controlled−
Us (2n ).
2 Order finding
Order definition: The order of an integer a modulo N is the smallest integer such that:
ar ≡ 1 (mod N )
Problems:
2
1. We don’t know r, and as a result, how can we make |uk i ?
k
2. We only get an approximation of r; which precise fraction it is?
3. What if k and r have common factors? Since we don’t know r, can confuse with factor cancellation.
k
2.1 Estimate r
in superposition
2πi −1 n
For any n ⩾ 2, if w = e n , 1 + w + · · · + wn−1 = ww−1 = 0.
P r−1 P r−1 2πikx
Consider r k=0 |uk i = r k,x=0 e
1
√ 1 r | a mod N i = |1i
x
Phase estimation:
Pr−1 phase estimation 1 Pr−1 f
|0i ⊗ |1i = √1r k=0 |0i ⊗ |uk i 7−→ √
r k=0 |k|ri ⊗ |uk i
Measuring the first register gives an estimate of kr , where k is chosen uniformly at random.
n
Note: c − U 2 can be implenented in tine poly (n) by square-and-multiply.
k
2.2 Reconstructing r
from the approximation
n 2n
n
Main idea: We can have an integer y close to k · 2r (either k · r or k · 2r with probability ⩾ 8
π2 ).
Compute the continuous fraction expansion (CF E) : 2yn = a 1
1 a1 , a 2 ∈ N
1 + a +···
2
5 1 1 1 1 1 1
For example: 8 = 1·6 = 1+0.6 = 1
1+ 5/3
= 1
1+ 1+2/3
= 1+ 1 = 1+ 1
1+ 1 1+ 1
1+ 1 1+ 1
2 1+1
1 1 2 3 5
Each time, deleting the term in (0, 1], get: 1, 2, 3, 5, 8.
End when we reach 1 .
1 1
Consider the sequence a1 , a + 1 , . . . (truncate the CF E ).
1 a2
Since 2yn is rational, this must ends finally. Denote the sequence of fractions we get ane p1 p2
q1 , q2 , . . .
Can prove: qi+2 ⩾ 2qi ∀i ∈ [n]. This implies that the length ⩽ 2n.
Furthermove, CF E has very strong convengence property:
Fact. If we estimate x by CF E, then x − pqii < q12 .
i
n
In our case, we know y − k · 2r ≤ 1 ⇔ 2yn − kr ≤ 21n .
Taking 2n > 2r2 and using CF E theory, we can prove that kr must appear in the CF E. Also due to
the CF E hos O(n) terms and whether ar ≡ 1 (mod N ) or not can be verified in poly (log N ) time using
square-and-multiply, taking n = C · log N for a large enough C, 2n > 2r2 can be satisfied the overall cost is
poly (log N ).
1− 1
··· 1 − 1
N is the number of integers in [N] that has gcd = 1 with N .
p1
pN
ϕ(r) 1
Fact: r = Ω log(log r) .
Therefore, O(log log r) repititions suffice.
Finally, it comes to Shor’s algorithm:
3
3 Shor’s algorithm
3.1 Factorization(N)
1. If N is even, return factor 2 ;
2. If N = pα for a prime p and α ⩾ 2, compute the 2nd (square) root, 3rd, · · · , dlog2 N e root, and return
one of them being an integer;
3. Uniformly randomly choose x in {1, 2, . . . , N − 1}. If gcd(x, N ) > 1, then return factor gcd(x, N );
3.2 Observations
1. Primality testing, i.e., testing whether N is a prime or not, can be done in Õ (log N )6 time on a
classical computer. (Õ omits poly-logarithmic factors, i.e., Õ(f ) = O(f · poly (log f )).)
This is called the Agrawal-Kayal-Saxena (AKS) primality test, won Gödel Prize and Fulkerson Prize
in 2006.
Therefore, the above algorithm is written as factoring a composite number, as we can run AKS as a
preprocessing step. Nevertheless, we can also run Shor’s algorithm for poly(log N ) rounds and return
“prime” if it cannot find a factor.
2. Steps 1 and 2 has O(log n) iterations, and each root computation takes poly(log N ) cost on a classical
computer. In the rest of the algorithm, we can assume that N is an odd integer with more than one
primer factor.
3. gcd(x, N) can be computed classically using Euclid’s algorithm. This takes cost O log2 N .
4. If gcd(x, N ) = 1 and r is the order of x mod N , and the condition in step 5 holds, then N ∤ xr/2 + 1, N ∤
xr/2 − 1 (r/2 is not the other) but N | xr/2 + 1 xr/2 − 1 = xr − 1 ⇒ both gcd xr/2 − 1 ,
gcd xr/2 + 1 6= 1, and the factorization problem is solved.
∗
uniformly at random from ZN := {x ∈ ZN | gcd(x, N ) = 1}, and let r be the order of x mod N . Then
h i 1
Pr r is even and xr/2 6= −1 (mod N ) ⩾ 1 −
2l−1
.
We first prove a lemma:
Lemma. Let p be an odd prime. Let 2d be the largest power of 2 dividing φ (pα ), i.e., 2d kφ (pα ): 2d ∤ φ(pα )
but 2d+1 ∤ φ(pα ).
Then with probability exactly 21 , 2d divides the order mod pα of a uniformly random chosen element of
Z∗pα .
Proof of lemma. Note that φ (pα ) = pα−1 (p − 1). Therefore 2d kp − 1 and d ⩾ 1.
4
It is known in elementary number theory that there exists primitive roots mod pα , i.e., ∃g ∈ Z∗pα s.t.
g, g 2 , · · · , g φ(p ) = Z∗pα .
α
If r is odd, because vj | r for j ∈ [l], it implies that all rj are odd, hence dj = d = 0 ∀j ∈ [l].
α α α
If xr/2 ≡ −1 (mod N ), N xr/2 + 1 ⇒ pj j xr/2 +1 ∀j ∈ [l] ⇒ rj ∤ r/2 (otherwise pj j | xr/2 −1 ⇒ pj j | 2,
but pj is odd)
However, rj | r ∀j ∈ [l], hence dj = d ∀j ∈ [l].
Therefore: When the event in (*) holds, all dj must take the same valse for all j ∈ [l].
α
Each chunk represents the largest power of 2 dividing the order of xj mod pj j , and by the corollary, each
chunk has probability ≤ 2 . It directly follows that this occurs with probability ⩽ 2l−1
1 1
.
Problem: Given g ∈ Zp and a ∈ Z where g is a primitive root. Find x so that g x ≡ a (mod p) (i.e.,
x = logg a )
Interesting fact: Historically, Peter W. Shor first found an efficient quantum algorithm for the discrete
logarithm problem, and then found the factorization algorithm.
5
Example 2. Hidden subgroup problem
Given a group G and a black-box function satisfying f (x) = f (y) iff(if and only if) y = xh for some x ∈ H,
a subgroup of G.
Problem: Find H (say, find the generating set).
This can be done efficiently on quantum computers for any Abelian group G.
Reference.
Childs and van Dam. Quantum algorithms for algebraic problens. Rev. Mod. Physics 2010, arxiv: 0812.0380
Example 3.
Deeper in number theory: Can solve the Pell’s equation Input: d ∈ N not a square, and denote the smallest
√ √ n
nontrivial solution of x −dy = 1 as (x1 , y1 ). All the solutions can be written as xn +yn d = x1 + y1 d
2 2
for n ∈ N. There exists an algorithm for finding (x1 , y1 ) in time poly (log d).
Reference.
Hallgren. Polynomial-time quantum algorithms for Pell’s equation and the prinpical ideal problem. JACM
2007, earlier version at STOC 2002.
Eisentraeger. Hallgren, Kitaev, Song, A quantum algorithm for computing the unit group of an
arbitrary degree number field.
poly(log N, deg). STOC 2014.
6
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: October 5, 2022
Lecture 7
Shor’s Algorithm
- Order finding
- Shor’s algorithm
1 Order finding
Order definition: The order of an integer a modulo N is the smallest integer such that:
ar ≡ 1 (mod N )
Problems:
3. What if k and r have common factors? Since we don’t know r, can confuse with factor cancellation.
1
k
1.1 Estimate r
in superposition
2πi −1 n
For any n ⩾ 2, if w = e n , 1 + w + · · · + wn−1 = ww−1 = 0.
P r−1 P r−1 2πikx
Consider √r k=0 |uk i = r k,x=0 e r | a mod N i = |1i
1 1 x
Phase estimation:
Pr−1 phase estimation 1 Pr−1 f
|0i ⊗ |1i = √1r k=0 |0i ⊗ |uk i 7−→ √
r k=0 |k|ri ⊗ |uk i
k
Measuring the first register gives an estimate of r , where k is chosen uniformly at random.
n
Note: c − U 2 can be implenented in tine poly (n) by square-and-multiply.
k
1.2 Reconstructing r
from the approximation
n 2n
n
Main idea: We can have an integer y close to k · 2r (either k · r or k · 2r with probability ⩾ 8
π2 ).
Compute the continuous fraction expansion (CF E) : 2yn = a 1
1 a1 , a 2 ∈ N
1 + a +···
2
5 1 1 1 1 1 1
For example: 8 = 1·6 = 1+0.6 = 1
1+ 5/3
= 1
1+ 1+2/3
= 1+ 1 = 1+ 1
1+ 1 1+ 1
1+ 1 1+ 1
2 1+1
Each time, deleting the term in (0, 1], get: 11 , 12 , 23 , 35 , 58 . End when we reach 1 .
Consider the sequence a11 , a +1 1 , . . . (truncate the CF E ).
1 a2
Since 2yn is rational, this must ends finally. Denote the sequence of fractions we get ane p1 p2
q1 , q2 , . . .
Can prove: qi+2 ⩾ 2qi ∀i ∈ [n]. This implies that the length ⩽ 2n.
Furthermove, CF E has very strong convengence property:
Fact. If we estimate x by CF E, then x − pqii < q12 .
i
n
In our case, we know y − k · 2r ≤ 1 ⇔ 2yn − kr ≤ 21n .
Taking 2n > 2r2 and using CF E theory, we can prove that kr must appear in the CF E. Also due to
the CF E hos O(n) terms and whether ar ≡ 1 (mod N ) or not can be verified in poly (log N ) time using
square-and-multiply, taking n = C · log N for a large enough C, 2n > 2r2 can be satisfied the overall cost is
poly (log N ).
1− 1
··· 1 − 1
N is the number of integers in [N] that has gcd = 1 with N .
p1
pN
Fact: ϕ(r)
r = Ω 1
log(log r) .
Therefore, O(log log r) repititions suffice.
Finally, it comes to Shor’s algorithm:
2 Shor’s algorithm
2.1 Factorization(N)
1. If N is even, return factor 2 ;
2. If N = pα for a prime p and α ⩾ 2, compute the 2nd (square) root, 3rd, · · · , dlog2 N e root, and return
one of them being an integer;
2
3. Uniformly randomly choose x in {1, 2, . . . , N − 1}. If gcd(x, N ) > 1, then return factor gcd(x, N );
2.2 Observations
1. Primality testing, i.e., testing whether N is a prime or not, can be done in Õ (log N )6 time on a
classical computer. (Õ omits poly-logarithmic factors, i.e., Õ(f ) = O(f · poly (log f )).)
This is called the Agrawal-Kayal-Saxena (AKS) primality test, won Gödel Prize and Fulkerson Prize
in 2006.
Therefore, the above algorithm is written as factoring a composite number, as we can run AKS as a
preprocessing step. Nevertheless, we can also run Shor’s algorithm for poly(log N ) rounds and return
“prime” if it cannot find a factor.
2. Steps 1 and 2 has O(log n) iterations, and each root computation takes poly(log N ) cost on a classical
computer. In the rest of the algorithm, we can assume that N is an odd integer with more than one
primer factor.
3. gcd(x, N) can be computed classically using Euclid’s algorithm. This takes cost O log2 N .
4. If gcd(x, N ) = 1 and r is the order of x mod N , and the condition in step 5 holds, then N ∤ xr/2 + 1, N ∤
xr/2 − 1 (r/2 is not the other) but N | xr/2 + 1 xr/2 − 1 = xr − 1 ⇒ both gcd xr/2 − 1 ,
gcd xr/2 + 1 6= 1, and the factorization problem is solved.
uniformly at random from Z∗N := {x ∈ ZN | gcd(x, N ) = 1}, and let r be the order of x mod N . Then
h i 1
Pr r is even and xr/2 6= −1 (mod N ) ⩾ 1 −
2l−1
.
We first prove a lemma:
Lemma. Let p be an odd prime. Let 2d be the largest power of 2 dividing φ (pα ), i.e., 2d kφ (pα ): 2d ∤ φ(pα )
but 2d+1 ∤ φ(pα ).
Then with probability exactly 21 , 2d divides the order mod pα of a uniformly random chosen element of
Z∗pα .
Proof of lemma. Note that φ (pα ) = pα−1 (p − 1). Therefore 2d kp − 1 and d ⩾ 1.
It is known in elementary number theory that there exists primitive roots mod pα , i.e., ∃g ∈ Z∗pα s.t.
2
g, g , · · · , g φ(p ) = Z∗pα .
α
3
In summary. Z∗p2 may be partitioned into two sets of equal size: those which may be written as g k with
k odd. for which 2d | rk , and those which may ke written as g k with k even, for which 2d ∤ r. Thus with
probability 1/2 the integer 2d divides the order r of a randomly chosen element of Zp∗α . and with probability
1/2 it does not.
Corollary. Let x be a uniformly random chosen element of Z∗pα . Then for any nonegative integer dx =
0, 1, . . ., the probability that 2dx is the largest pover of 2 dividing the order of x mod pα is ⩽ 1/2. (The
lemma is Pr[dx ≥ d] = 21 ).
Proof of theorem. Note that choosing x uniformly at random from Z∗N is equivalent to choosing xj
α
independently and uniformly at random from Z∗αj , and requiring that x ≡ xj med pj j for each j ∈ [l].
pj
To prove the theorem. it suffices to prove: Pr [r is odd or xr/2 ≡ −1 (mod N ) ⩽ 2l−1 1
. (*)
αj
Let rj ke the order of xj modulo pj . Let 2 krj (the largest power of 2 that divides rj ). and let 2d kr.
dj
If r is odd, because vj | r for j ∈ [l], it implies that all rj are odd, hence dj = d = 0 ∀j ∈ [l].
α α α
If xr/2 ≡ −1 (mod N ), N xr/2 + 1 ⇒ pj j xr/2 +1 ∀j ∈ [l] ⇒ rj ∤ r/2 (otherwise pj j | xr/2 −1 ⇒ pj j | 2,
but pj is odd)
However, rj | r ∀j ∈ [l], hence dj = d ∀j ∈ [l].
Therefore: When the event in (*) holds, all dj must take the same valse for all j ∈ [l].
α
Each chunk represents the largest power of 2 dividing the order of xj mod pj j , and by the corollary, each
chunk has probability ≤ 12 . It directly follows that this occurs with probability ⩽ 2l−1 1
.
Problem: Given g ∈ Zp and a ∈ Z where g is a primitive root. Find x so that g x ≡ a (mod p) (i.e.,
x = logg a )
Interesting fact: Historically, Peter W. Shor first found an efficient quantum algorithm for the discrete
logarithm problem, and then found the factorization algorithm.
Given a group G and a black-box function satisfying f (x) = f (y) iff(if and only if) y = xh for some x ∈ H,
a subgroup of G.
Problem: Find H (say, find the generating set).
This can be done efficiently on quantum computers for any Abelian group G.
4
Reference.
Childs and van Dam. Quantum algorithms for algebraic problens. Rev. Mod. Physics 2010, arxiv: 0812.0380
Example 3.
Deeper in number theory: Can solve the Pell’s equation Input: d ∈ N not a square, and denote the smallest
√ √ n
nontrivial solution of x −dy = 1 as (x1 , y1 ). All the solutions can be written as xn +yn d = x1 + y1 d
2 2
for n ∈ N. There exists an algorithm for finding (x1 , y1 ) in time poly (log d).
Reference.
Hallgren. Polynomial-time quantum algorithms for Pell’s equation and the prinpical ideal problem. JACM
2007, earlier version at STOC 2002.
Eisentraeger. Hallgren, Kitaev, Song, A quantum algorithm for computing the unit group of an
arbitrary degree number field.
poly(log N, deg). STOC 2014.
5
Introduction to Quantum Computing Lecturer: Tongyang Li, scribed by Yecheng Xue
Fall 2022, Peking University Date: November 16, 2022
Lecture 8
Find conclusion: Quantum computer can solve order finding with cost poly(log N ) (with high probability).
1) If N is even, return 2;
√ √
2) If N = pα for a prime p and α ≥ 2, compute N, 3
N , · · · , ⌈log3 N ⌉ root, and return one of them being
an integer;
5) If r is even and ar/2 ̸≡ −1( mod N ), compute gcd(ar/2 − 1, N ) and gcd(ar/2 + 1, N ), If one of them > 1,
return that.
Otherwise, start over.
uniformly at random from Z∗N = {x ∈ ZN | gcd(x, N ) = 1}, and let r be the order of x mod N . Then
1
Pr{r is even and xr/2 ̸≡ −1( mod N )} ≥ 1 −
2l−1
Remark. Not required for understanding qunatum computing – only for the completeness of Shor’s algorithm.
1
Then with probability 12 , 2d divides the order mod pα of a uniformly random chosen element of Z∗pα .
α
{g, g 2 , · · · , g p (p−1)
} = Z∗pα
1) k is odd. Since g is a primitive root, by the definition of rk , (gk )rk ≡ 1( mod pα ) ⇒ φ(pα ) | krk . Here
(g k )rk ≡ 1( mod pα ) ⇒ g krk ≡ 1( mod pα ), φ(pα ) | krk ⇒ 2d | rk .
α α α
2) k is even. (g k )φ(p )/2 = g kφ(p )/2 = (g φ(p ) )k/2 ≡ 1k/2 ≡ 1( mod pα )
⇒ rk | φ(pα )/2. However 2d ∥ φ(pα ) ⇒ 2d ∤ rk .
In summary, Z∗pα may be partitioned into two sets of equal size: those may be written as g k where k is
odd, for which sd | rk , and those which may be writeen as g k with k is even, for which 2d ∤ rk . Thus with
probability 12 , 2d divides the order r of a randomly chosen element of Z∗pα . □
Corollary. Let x be a uniformly random chosen element of Z∗pα . Then for any nonnegative integer dx =
0, 1, · · · , the probability that 2dx is the largest power of 2 dividing the order x mod pα ≤ 12 .
αl
Proof of theorem. Recall N = pα 1 · · · pl l ≥ 2.
1
Z∗N
Note that choosing x at random Z∗N is equivalent to choosing xj independently and uniformly at random
α
from Z∗αj , and requiring that x ≡ xj ( mod pj j ) for each j ∈ [l].
pj
1
To prove the theorem, it suffices to prove: Pr[r is odd or xr/2 ≡ −1( mod N )] ≤ 2l−1
(∗).
α
Let rj be the order of xj modulo pj j . Let 2dj ∥ rj (the largest power of 2 that divides rj ). And let
2d ∥ r, where r is the order of x modulo N .
α
xr ≡ 1( mod N ) ⇒ xr ≡ 1( mod pj j )
2
If r is odd, because rj | r for all j ∈ [l] ⇒ all rj are odd.
⇒ dj = d = 0∀j ∈ [l].
α
If xr/2 ≡ −1( mod N ) ⇒ N | xr/2 + 1 ⇒ pj j | (xr/2 + 1)∀j ∈ [l]
α α
This means rj ∤ r/2. (Otherwise, pj j | xr/2 − 1) ⇒ pj j | 2, but pj is odd).
But otherhand rj | r∀j ∈ [l] ⇒ dj = d∀j ∈ [l].
Therefore: When the event in (∗) holds, all dj must take the same value for j ∈ [l].
□ □ ··· □
□ □ ··· □
□ □ ··· □
p1 p2 ··· pl
α
Each chunk represents the largest power of 2 dividing the order xj mod pj j , and by our corollary, each
chunk has probability ≤ 12 .
1
⇒ It directly follows that (∗) holds with probability ≤ 2l−1 . □
2
Remark 1. Shor’s algorithm can factorize integers with constant probability (say ≥ 3) in poly(log N )
time on quantum computer, the best-known classical algorithm takes time
r
3 64 1 2
exp[( + o(1))(log n) 3 (log log n) 3 ]
9
Shor’s algroithm gives super-polynomial quantum speedup.
Interesting fact: Peter W. Shor first found an efficient quantum alrgotihm for the discrete logarithm, and
then found the factorization algorithm.
Reference. Childs and van Dam. Quantum algorithms for algebraic problems. Rev.Med.Physics. arXiv:0812.0380
3
(quadratic field)
Eisenfraeger, Hallen, Kifaev, Song STOC14 ⇒ arbitrary constant degree number field.
So far:
• Deutsch-Jozsa
f : {0, 1}n → {0, 1}
constant or balanced
”structure”
↓ less requirement, but still structured
• Simon’s problem
f : {0, 1}n → X
f (x) = f (y) iff x = y or x = y ⊕ s
• phase estimation
U |φ⟩ = eiθ |φ⟩, find θ
A genuinely quantum problem, O( 1ε ) queries, w.p. ≥ π82
Note: Going beyound Hadamard. QFT from Z2 ⊗ · · · ⊗ Z2 to Z2n
Application: Order finding ⇒ Shor’s algorithm
Total function. A function F : {0, 1}N → {0, 1} which has definition on all 2N inputs.
n
Deutsch-Jozsa: N = 2n f : {0, 1}2 → {0, 1}, definition domain is {s = s1 · · · s2n |# of 1 is 0, 2n−1 , 2n }
Note: Deutsch-Jozsa is NOT a total function.
If a function is defined on a proper set of {0, 1}N , it’s called a partial function.
Classically: With string s and the ability ot query si for some i ∈ [n], need Θ(n) queries to output the value
f for any input s.
Uf
Quantumly: |i, z⟩ −−→ |i, z ⊗ si ⟩ ∀i ∈ [n], z ∈ {0, 1} (∗)
4
This is also called the unstructured search problem.
Uf
Black-box:|x, z⟩ −−→ |x, f (x) ⊗ z⟩ x ∈ [n], z ∈ {0, 1}.
Here Uf Equivalent to the oracle above: f (x) = sx ∀x ∈ [n] in (∗)
5
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: November 13, 2022
Lecture 9
Unstructured Search
- Grover’s algorithm
- Amplitude amplification
1 Fundamental Subroutines
1.1 Unstructured search problem:
Given a black-box function f : {1, 2, · · · , n} → {0, 1},
decide whether there is an x such that f (x) = 1. (Or find such an x)
Call such an x (f (x) = 1) a marked item.
Uf
Black-box: |x, zi 7−→ |x, f (x) ⊕ zi x ∈ [n], z ∈ {0, 1}.
1
V is independent of queries. In the following discussion. WLOG, assume n = 2m . (Otherwise, there
exists m ∈ N s.t. 2m−1 ⩽ n ⩽ 2m . Can consider n = 2m where f (n + 1) = f (n + 2) = · · · = f (2m ) = 0).
How to apply V? H ⊗m |0i = |ψi ⇒ V = H ⊗m R0 H ⊗m (similar to Deutsch-Jozsa), where R0 = 2 |0m i h0m |−I
|0m i |0i 7−→ − |0m i |0i 7−→ |0m i |0i
..
. |0m i |1i 7−→ − |0m i |1i 7−→ |0m i |1i
Circuit: 2 |0m i h0m |−I
|xi|0i 7−→ −|xi|0i 7−→ −|xi|0i(x 6= 0m )
−I −I
|xi|1i 7−→ −|xi|1i 7−→ −|xi|1i(x 6= 0m )
span{|ωi, |ω ⊥ i} ⊥ : perpendicular
|ψi − hω|ψi |ωi
hω|ω ⊥ i = hω|ψi − hω|ψi hω|ωi = 0 |ω ⊥ i = hω ⊥ |ω ⊥ i = 1
√ normalization
( )
1 1 ⊥ ⊥ 1
|ψi = √ |ωi + 1 − |ω i = sin θ|ωi + cos θ |ω i θ = arcsin √ .
n n n
( )
sin θ
V = 2 |ψi hψ| − I = 2 (sin θ cos θ) − I
cos θ
( ) ( )
2 sin2 θ − 1 2 sin θ cos θ − cos 2θ sin 2θ
= =
2 sin θ cos θ 2 cos2 θ − 1 sin 2θ cos 2θ
( )( ) ( )
− cos 2θ sin 2θ −1 0 cos 2θ sin 2θ
VU = = .
sin 2θ cos 2θ 0 1 − sin 2θ cos 2θ
( )
t cos 2tθ sin 2tθ
(V U ) = This can be proved by induction.
− sin 2tθ cos 2tθ
( )( ) ( ) ( )
cos 2tθ sin 2tθ sin θ cos 2tθ sin θ + sin 2tθ cos θ sin(2t + 1)θ
(V U ) |ψi =
t
= =
− sin 2tθ cos 2tθ cos θ − sin 2tθ sin θ + cos 2tθ cos θ cos(2t + 1)θ
2
When is Pr(ω) close to 1?
1 1
sin θ ≈ θ when θ is small, ∴ θ = arcsin √ ≈ √ usually n is large
n n
π π 1 π√
=⇒ t ≈
(2t + 1)θ ≈ − ≈ n
2 4θ 2 4
√
This means that we alternate between U and V for O( n) times.
where |ψ1 i and |ψ0 i are normalized (l − 1) - qubit quantum states, We can think of |1i |ψ1 i as the “good
state” and |0i |ψ0 i as the “bad state”.
Similar to Grover, we could apply:
1. This is basically putting a ”-” in front of |1i |ψ1 i and leaving |0i |ψ0 i alone
Solution: Put Z on the first quit. Z |0i = |0i , Z |1i = − |1i.
3
2. Apply U R0 U −1
4
Introduction to Quantum Computing Lecturer: Tongyang, scribed by Shuo Zhou
Fall 2022, Peking University Date: November 11, 2022
Lecture 15
Hamiltonian Simulation
- Efficient simulation
- Product formulas
1 Efficient simulation
d
One of the most well-known results in quantum mechanics: the Schrödinger equation, iℏ dt |ψ(t)i = H(t) |ψ(t)i
where H(t) is a Hamiltonian, and ℏ is Planck’s constant.
For convenience, it’s typical to choose units in which ℏ = 1.
Goal: Can we efficiently simulate the evolution of Schrödinger’s equation? In other words, given an initial
wave function |ψ(0)i, determine |ψ(t)i at any time t.
Actually, this was the first application of quantum computing when Richard Feynman initiated the field
in the 1980s.
For H independent of time, the solution of the Schrödinger equation is
1
• Simply take the original Hamiltonian and rescale t.
• This holds even if c < 0 : just take t for the quantum circuit.
n
×2n
Observation 3. If H can be efficiently simulated, and U ∈ C2 can be efficiently implemented, then
U HU † can be efficiently simulated.
† †
U HU † = U† H † U † = U HU †
† k
This is because e−iU HU t
= U e−iHt U † . U HU † = U HU † U HU † · · · U HU † = U H k U † .
2
−iU HU † t −iU HU + t −iU HU † t −iHt (−iHt)2
e =I+ + + ··· = U I+ + + ··· U † = U e−iHt U † .
1! 2! 1! 2!
Observation 4. If H ∈ C 2 ×2 is diagonal in the computational basis and any diagonal element d(k) =
n n
hk|H|ki can be computed efficiently for each k ∈ [n], then H can be efficiently simulated.
d(1) e−id(1)t
.. ..
H= . e−iHt = .
e−id(2 )t
n
d (2n )
H† = H d(k) = d(k) ⇒ d(k) ∈ R
compute uncompute
|k, 0i 7−→ |k, d(k)i 7−→ e−itd(k) |k, d(k)i 7−→ e−itd(k) |k, 0i = e−iHt |ki|0i
Uf Uf†
2 Product formula
Many natural Hamiltonians have the form of a sum of terms, each of which can be efficiently simulated (by
the observations above).
For example: Hamiltonian of an n-quit spin system:
X X
H= hi X i + Ji,j Zi Zj .
i i,j
where hi , Ji,j ∈ C, and Xi is Pauli-X acting on the ith qubit, and Zi is Pauli-Z acting on the ith quit.
Definition. A Hamiltonian H is k-local if H is a sun of Hamiltonians that each acts on at most k qubits.
Product formula: In general, if H1 and H2 can be efficiently simulated, then H1 + H2 can be efficiently
simulated.
If H1 and H2 commute ([H1 , H2 ] = H1 H2 − H2 H1 = 0), then this is trivial.
In general, for matrices, H1 and H2 don’t commute, i.e., [H1 , H2 ] 6= 0. In this case, e−i(H1 +H2 )t 6=
−iH1 t −iH2 t
e e in general. What can we do?
2
m
Lie product formula: e(−iH1 +H2 )t = limm→∞ e−iH1 t/m e−iH2 t/m .
For more quantitive versions, we truncate this expression to a finite number of times:
m m
e−iH1 t/m e−iH2 t/m − e−i(H1 +H2 )t/m ⩽ ε. (∗)
a2 kak2
kea k ≤ e∥a∥ : kea k = I + a + + ······ ≤ 1 + kak + + · · · = e∥a∥ .
2! 2!
Taking a = eA/m eB/m and b = e(A+B)/m , we have:
m m n om−1
eA/m eB/m − e(A+B)/m ⩽ m · eA/m eB/m − eA+B/m · max eA/m eB/m · e(A+B)/m
In our case, eA/m eB/m = e−iH1 t/m e−iH2 t /m is a multiplication of two unitaries, so eA/m eB/m = 1.
Similarly. e(A+B)/m = e−i(H1 +H2 )t/m is a unitary, so e(A+B)/m = 1, kA + Bk ≤ 2 max{kAk, kBk}.
A kAk2 B kBk2 A+B kA + Bk2
eA/m eB/m − eA+B/m = I + +O I + + O − I + + O
m m2 m m2 m m2
A B AB max{kAk, kBk}2 A+B max{kAk, kBk}2
= I+ + + 2 +O − I + + O
m m m m2 m m2
max{kAk, kBk} 2
=O (∆)
m2
In all, we have
m m 1
max{kAk, kBk}2 ?
e A/m B/m
e − e (A+B)/m
= m
⩽ε
X
m
Suppose kH1 k , kH2 k = O(1). Then kAk, kBk = O(t). Cost of simulation: Apply e−iH1 t/m e−iH2 t/m ,
in other words, e−iH2 t/m and e−iH1 t/m alternatively, for m = O t2 /ε times.
Can we improve further on the bound for m ?
In other words, can we make the error to 3rd power?
m
Consider eA/2m eB/m eA/2m . eA/2m eB/m eA/2m eA+B
(WLOG, kAk, kBk ≤ 1 for better presentation.)
3
m
eA/m eB/m : Trotter formula
1
t1+ k
Higher-order Trotter formula: m = O ε1/k
∀k ∈ N Trotter-Suzuki: formula
Research paper. Berry, Ahokas. Cleve, Sanders. Efficient quantum algorithms for simulates sparse
Hamiltonians. CMP 2007. arxiv: quant-ph/0508139.
Similarly, for move terms we have
m
e−i(H1 +···+Hl )t = lim e−iH1 ,/m · · · e−iHt t/m ,
m→∞
1
t1+ k
and the product formulas still apply and give algorithms with cost O ε1/k
, ∀k ∈ N
Corollary: O(1)-local Hamiltonians can! be efficiently simulated.
n
For k-local Hamiltonians, at most = poly(n) terms when k = O(1).
k