[Quantum Information] Shor's Algorithm
Shor's Algorithm
Notes from RWTH Aachen University course
“Quantum Information” Summer semester 2020
professor: Müller, Markus
Shor’s Algorithm
- factor a number
Fourier Transform
classical Fourier transform
- input: x0,x1...,xn−1
- output: y0,y1...,yn−1
- Definition:
yk=1√NN−1∑j=0xje2πij⋅k/N=1√NN−1∑j=0ωjkNxj
cost?
- naive: O(N2) for N-vector
- more efficient: Fast Fourier Transform (FFT): O(nlogn)
Quantum Fourier transform (QFT)
- acts on orthonormal basis |0⟩,|1⟩,...,|N−1⟩
|yk⟩=1√NN−1∑k=0e2πij⋅k/N|k⟩ - If start at a basis state, no entanglement will be created (results in a product state)
- Resources of n-qubit QFT gate:
- O(n) hadamard gates
- O(n2) single qubit rotation gates (2 CNOT each)
- at most n/2 swap gate: O(n) (3 CNOT each)
O(n2) Quantum Algorithm
- classical FFT: O(n2n)
- QFT provdes an exponential speed up
- acts on orthonormal basis |0⟩,|1⟩,...,|N−1⟩
QFT is not an algorithm to speed up classical transformation
Problem: No way known to access the amplitude in quantum computer.
No way known to prepare efficiently original state to be transformed.
an ingredient of other quantum algorithm
Phase Estimation
- make use of QFT
- Setting:
- U: unitary
- eigenvector |u⟩ with eigenvalues e2πiφ, where φ is unknown
- Goal: to estimate φ,φ∈[0,1]
- Assumption:
- can prepare |u⟩
- can perform controlled-U2j
- Algorithm:
1-st register prepare t qubits |0⟩, where t depends on
- precision
- success probability
2-nd register begin in |u⟩, contains as many qubits as needed to store |u⟩
|0⟩|u⟩Hadamard gates to 1-st register
|0⟩|u⟩H→1√2(|0⟩+|1⟩)|u⟩Controlled-U2j on 2-nd register
1√2(|0⟩+|1⟩)|u⟩c−U2j→1√2|0⟩|u⟩+1√2U2j|1⟩|u⟩=1√2|0⟩|u⟩+1√2e2πi2jφ|1⟩|u⟩=1√2(|0⟩+e2πi2jφ|1⟩)|u⟩- t-qubit
1√2t2t−1∑k=0e2πiφk|k⟩ - suppose φ=0.φ1...φt
1√2t(|0⟩+e2πi⋅0.φt|1⟩)(|0⟩+e2πi⋅0.φtφt−1|1⟩)...(|0⟩+e2πi⋅0.φt...φ1|1⟩)
The Fourier transform of |φ⟩=|φ1⟩|φ2⟩...|φt⟩
- t-qubit
apply inverse QFT to the 1-st register
1√2t2t−1∑k=0e2πiφk|k⟩|u⟩FT†→|e⟩|u⟩measure the qubits of first register in computational basis
- Discuss:
- To achieve accuracy 2−n with probability (1−ε)
t=n+⌈log(2+12ε)⌉ - What if we cannot prepare the eigenstates |u⟩?
|ψ⟩=∑uCu|u⟩
After the estimation, we get
∑uCu|~φu⟩|u⟩
where ~φu is a good approximation to the eigenvalue φu
with probability |Cu|2 we get ~φu
If we do it many times, we can avoid the requirement of preparing |u⟩
- To achieve accuracy 2−n with probability (1−ε)
Order Finding
output r where xr=1 mod N
is a hard problem in classical computer (no polynomial time algorithm)
in quantum computer, it is the phase estimation algorithm applied to the unitary
U|y⟩=|xy ( mod N)⟩
y is an b-qubit stateconstruct
|us⟩=1√rr∑k=0exp(−2πiskr)|xk mod N⟩
For integer s, |us⟩ are eigenstates of U.
U|us⟩=exp(2πisr)|us⟩
so exp(2πisr) is the eigenvalue of |us⟩
This allows us to estimate sr=φ
⇒ with the addition work to access order r- Problem: not allowed to use r, we cannot prepare |us⟩
- ⇒
1√rr−1∑s=0|us⟩=|x0( mod N)⟩=|1⟩
|1⟩ is trivial to prepare
Algorithm:
- prepare 1-st register with t qubits |0⟩
prepare 2-nd regester with |1⟩ - run phase estimation
- measuring the first registers
- for each s in the range of 1 to r, this will lead to an estimation of the phase φ=s/r
- accuracy: 2L+1 bits
- probability (1−ε)/r
- “/r” because don’t know which |us⟩ 1√rr−1∑s=0|us⟩
entangled with the second register when measuring.
- “/r” because don’t know which |us⟩ 1√rr−1∑s=0|us⟩
- moduler exponentiation
- speed up exponentiation |z⟩|xz⟩
- use the third temporary registers
- reversible computing
- O(L) spanning operations
O(L2) standard multiplication for each operation
⇒ total O(L3) operations
- How to get r from the output φ
- run continued function algorithm (on a classical computer)
- Continued Fraction Algorithm
- a rational number s/r such that
|sr−φ|≤12r2
then s/r is a convergence of the continued fraction for φ, and can be calculated in O(L3) steps - idea: express the number as
[a0,a1,...,aM]=a0+1a1+1a2+1...+1aM - check [a0],[a0,a1],...[a0,...aM] which satisfies s/r
- the algorithm provides efficiently s′/r′
- a rational number s/r such that
- Continued Fraction Algorithm
- complexity
- Hadamard gates: O(L)
- Inverse FT: O(L2)
- Modular exponentiation: O(L3)
- classical continued fraction algorithm: O(L3)
- If order finding fails, one has to repeat only for a constant number to obtain r with high probability: O(1)
⇒ overall cost: O(L3)
can be reduced to almost O(L2) by square-and-multiply
Shor’s Algorithm
- Factoring N to two prime numbers
- reduce factoring to order finding
- If we have
y2=1 mod N(y−1)(y+1)=0 mod N=k⋅N
If y≠±1 mod N, then
gcd(y+1,N)gcd(y−1,N)
must each be a proper divisor of N, i.e. prime factors. - How can we find a non-trivial square root y?
- choose a random 1<x≤N−1
- run the order finding algorithm to find r, xr=1 mod N
- If r is even:
xr=1 mod N(xr/2+1)(xr/2−1)=0 mod N=k⋅N
then y=xr/2 is a square root of 1
and if xr/2≠±1, then compute gcd
success probability to find a “good” x?
“good”: order r is even and xr/2≠1
Theorem: If N is divisible by l distinct odd primes, then at least 1−12l−1elements are “good”.
l=2⇒1/2 probability to have “good” x
O(1) trials- If r is not even:
- If r is even:
- Complexity:
- O(1) for order finding
- overall: O(L3)
- classical factoring: exp(O(L1/3))
- exponential speedup
RSA Algorithm
- pick random two primes p,q, and n=p⋅q
- pick random public key by e∈ϕ(n), where ϕ(n)=(p−1)(q−1)
- choose private key d such that e⋅d=1 mod ϕ(n)
- public key: (n,e)
private key: (n,d)
- Encryption:
E(m)=me mod n - Decryption:
D(c)=cd mod n=me⋅d mod n=m1 mod ϕ(n) mod n=m mod n
Shor’s Algorithm allows us to factor efficiently on a quantum computer
RSA public key scheme is broken, as soon as sufficiently large quantum computer exists.
留言
張貼留言