Lec08 Algorithm
Lec08 Algorithm
Quantum Computing
#8: Examples of Quantum Algorithms
송기원
2022
Time Complexity Deutsch-Jozsa Algorithm Simon’s Problem Bounded-error time complexity
Outline
1 Time Complexity
2 Deutsch-Jozsa Algorithm
3 Simon’s Problem
Simple definition of P
A complexity class P is a class of problems that can be solved in
polynomial time step.
NP
Definition(Certifier)
For some T/F problem P : X → { T , F } (its input is from X ),
a function V : X × C → { T , F } is a certifier if:
∃c ∈ C ; V (x, c) = T =⇒ P(x) = T
Simple definition of NP
A complexity class NP is a class of T/F problems that has a
certifier working in polynomial time step.
P vs. NP
Query complexity
Definition(Query complexity)
Query complexity ignores all the time step took in calculation,
but only counts the number of inputs done to a given function.
Outline
1 Time Complexity
2 Deutsch-Jozsa Algorithm
3 Simon’s Problem
Oracle
Definition(Boolean oracle)
A boolean oracle Uf of f : { 0, 1 }m → { 0, 1 }n maps |x⟩ ⊗ |y ⟩
where x is m-qubits and y is n-qubits, to |x⟩ ⊗ |y ⊕ f (x)⟩
Definition(Phase oracle)
A phase oracle Pf of f : { 0, 1 }m → { 0, 1 } maps |x⟩ where x is
m-qubits , to (−1)f (x) |x⟩.
Deutsch’s Problem
Definition(Balanced function)
A function f : { 0, 1 }n → { 0, 1 } is balanced when the number of
inputs that gives 0 and 1 are equal.
|0⟩ H H
Uf
|1⟩ H
|0⟩ H H
Uf
|1⟩ H
|0⟩ H H
Uf
|1⟩ H
√1 √1
The last H: 2
|0⟩ + |1⟩ to |0⟩ and 2
|0⟩ − |1⟩ to |1⟩
▶ f (0) = f (1) then ± |0⟩ and otherwise ± |1⟩
Thus if measurement gives 0 then constant, 1 then balanced
Time Complexity Deutsch-Jozsa Algorithm Simon’s Problem Bounded-error time complexity
Kronecker product
Definition(Kronecker Product)
For matrices A and B, the kronecker product of A and B is
A B A12 B · · · A1n B
11
A21 B A22 B · · · A2n B
A⊗B = .
.. .. .. ..
. . .
Am1 B Am2 B · · · Amn B
Deutsch-Jozsa Problem
Deutsch-Jozsa Problem
For given f : { 0, 1 }n → { 0, 1 }, is it balanced or constant?
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
|1⟩ H
n X 1
1 Y 1
After H: √ n |xi ⟩ ⊗ √ (|0⟩ − |1⟩)
2 i=1 xi =0 2
1 X
After Uf : √ n+1 |x⟩ ⊗ (|f (x)⟩ − |f (x) ⊕ 1⟩)
2 x∈{ 0,1 }n
▶ In the same way : (|f (x)⟩ − |f (x) ⊕ 1⟩) = (−1)f (x) (|0⟩ − |1⟩)
1 X 1
Thus after Uf : √ n (−1)f (x) |x⟩ ⊗ √ (|0⟩ − |1⟩)
2 x∈{ 0,1 }n
2
Time Complexity Deutsch-Jozsa Algorithm Simon’s Problem Bounded-error time complexity
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
|1⟩ H
1 X
Focusing on the upper qubits √ n (−1)f (x) |x⟩
2 x∈{ 0,1 }n
√ n
Consider the first row of H ⊗n whose entries are all 1/ 2 .
⊗n
▶ The first row the gate yields is the amplitude of |0⟩ .
1 X
(−1)f (x)
2n n
x∈{ 0,1 }
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
|1⟩ H
Outline
1 Time Complexity
2 Deutsch-Jozsa Algorithm
3 Simon’s Problem
Definition(Bitwise XOR)
For n-bits x = a0 a1 a2 · · · an and y = b0 b1 b2 · · · bn , the bitwise XOR
x ⊕ y = c0 c1 c2 · · · cn satisfies ai ⊕ bi = ci for all i ∈ { 0, 1, · · · , n }.
Proof
Prove x × (y ⊕ z) = (x × y ) ⊕ (x × z) for all x, y , z ∈ { 0, 1 }.
We can take all 8 cases and verify it.
Using the result, by the definition of the dot product:
a · (b ⊕ c) = a0 × (b ⊕ c)0 ⊕ a1 × (b ⊕ c)1 ⊕ · · · ⊕ an × (b ⊕ c)n
= a0 × (b0 ⊕ c0 ) ⊕ a1 × (b1 ⊕ c1 ) ⊕ · · · ⊕ an × (bn ⊕ cn )
= (a0 × b0 ) ⊕ (a0 × c0 ) ⊕ · · · ⊕ (an × bn ) ⊕ (an × cn )
= (a0 × b0 ) ⊕ · · · ⊕ (a0 × bn ) ⊕ (a0 × c0 ) ⊕ · · · ⊕ (an × cn )
=a·b⊕a·c
Time Complexity Deutsch-Jozsa Algorithm Simon’s Problem Bounded-error time complexity
Simon’s problem
Simon’s problem
For given f : { 0, 1 }n → { 0, 1 }n , it satisfies f (x) = f (y ) if and
only if x = y or x = y ⊕ s, for some nonzero constant s. Find s.
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
|0⟩⊗n
n X 1
1
|xi ⟩ ⊗ |0⟩⊗n
Y
After H: √ n
2 i=1 xi =0
1 X
After Uf : √ n |x⟩ ⊗ |f (x)⟩
2 x∈{ 0,1 }n
1 X
After H: |ψ⟩ = √ n H ⊗n |x⟩ ⊗ |f (x)⟩
2 x∈{ 0,1 }n
Time Complexity Deutsch-Jozsa Algorithm Simon’s Problem Bounded-error time complexity
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
⊗n
|0⟩
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
⊗n
|0⟩
1 X
As H ⊗n |x⟩ = √ n (−1)x·y |y ⟩:
2 y ∈{ 0,1 }n
1 X 1 X
|ψ⟩ = √ n √ n (−1)x·y + (−1)(x⊕s)·y |y ⟩ ⊗ |f (x)⟩
2 x∈A 2 y ∈{ 0,1 }n
n n n n
|0⟩⊗n H⊗n H⊗n
Uf
⊗n
|0⟩
Outline
1 Time Complexity
2 Deutsch-Jozsa Algorithm
3 Simon’s Problem
Definition(BPP)
BPP is a complexity class for problems that can be solved in a
polynomial time, allowing at most 1/3 giving the wrong answer.
BPP ⊊ BQP
Conclusion: Practicality?