Skip to Content

Quantum Algorithm

2019-09-05·Quantum Computation

Query value of function

  • Uf:∣x,y⟩→∣x,y⊕f(x)⟩U_f:|x,y\rangle\rightarrow|x,y\oplus f(x)\rangle
    • f:{0,1}n→{0,1}f:\{0,1\}^n\rightarrow\{0,1\}
    • 对应的矩阵为置换阵 2n×2n2^n\times 2^n
  • Quantum Parallelism: UfH⊕n∣0n⟩=12n∑x∣x,f(x)⟩U_f H^{\oplus n}|0^n\rangle=\frac{1}{\sqrt{2^n}}\sum_x|x,f(x)\rangle
  • Store the query in phase: Of∣x⟩=(−1)f(x)∣x⟩O_f|x\rangle=(-1)^{f(x)}|x\rangle
    • Uf∣x,−⟩=(−1)f(x)∣x⟩∣−⟩U_f|x,-\rangle=(-1)^{f(x)}|x\rangle|-\rangle
  • Deutsch Algorithm
    • Question: Given a function f:{0,1}→{0,1}f:\{0,1\}\rightarrow\{0,1\}, decide whether f(0)=f(1)f(0)=f(1)
    • ∣0⟩→H→Of→H→M(∣0⟩,∣1⟩)|0\rangle \rightarrow H \rightarrow O_f \rightarrow H \rightarrow M(|0\rangle,|1\rangle)
  • Deutsch-Joszsa Algorithm
    • Question: Given a function f:{0,1}n→{0,1}f:\{0,1\}^n\rightarrow\{0,1\}, it is either constant or balanced(∣f−1(0)∣=∣f−1(1)∣=2n−1|f^{-1}(0)|=|f^{-1}(1)|=2^{n-1}).
    • ∣0⟩⊗n→H⊗n→Of→H⊗n→M(∣0n⟩)|0\rangle^{\otimes n}\rightarrow H^{\otimes n}\rightarrow O_f\rightarrow H^{\otimes n}\rightarrow M(|0^n\rangle)

Quantum Teleportation

Archived figure unavailable in this copy of the notes: Quantum Teleportation.

Super-dense Coding

one qubit encode two bits (tight)

  • share EPR state
  • 00:I,01:Z,10:X,11:iY00:I,01:Z,10:X,11:iY

Bernstein-Vazirani Algorithm

  • For N=2nN=2^n, given x∈{0,1}Nx\in\{0,1\}^N, there is some unknown a∈{0,1}na\in\{0,1\}^n such that xi=(i⋅a) mod 2x_i=(i\cdot a)\bmod 2. The goal is to find aa
  • Algorithm
    1. Prepare the state: H∣0n⟩H|0^n\rangle
    2. Make a query OfO_f: 12n∑i∈{0,1}n(−1)xi∣i⟩=12n∑i∈{0,1}n(−1)i⋅a∣i⟩=H⊗n∣a⟩\frac{1}{\sqrt{2^n}}\sum_{i\in\{0,1\}^n}(-1)^{x_i}|i\rangle=\frac{1}{\sqrt{2^n}}\sum_{i\in\{0,1\}^n}(-1)^{i\cdot a}|i\rangle=H^{\otimes n}|a\rangle
    3. Apply H⊗nH^{\otimes n}: ∣a⟩|a\rangle

Simon's Algorithm

  • Simon's Problem(Hidden Shift): N=2n,x−(x0,⋯ ,xN−1),xi={0,1}nN=2^n,x-(x_0,\cdots,x_{N-1}),x_i=\{0,1\}^n, there is some unknown nonzero s∈{0,1}ns\in\{0,1\}^n such that xi=xjx_i=x_j iff i=ji=j or i=j⊕si=j\oplus s. The goal is to find ss
  • Algorithm
    1. Prepare the state: H⊕n∣0n⟩∣0n⟩=12n∑i∈{0,1}n∣i⟩∣0n⟩H^{\oplus n}|0^n\rangle|0^n\rangle=\frac{1}{\sqrt{2^n}}\sum_{i\in\{0,1\}^n}|i\rangle|0^n\rangle
    2. Make a query: 12n∑i∈{0,1}n∣i⟩∣xi⟩\frac{1}{\sqrt{2^n}}\sum_{i\in\{0,1\}^n}|i\rangle|x_i\rangle
    3. Measure the second register.
      • Output xix_i w.p. 12n\frac{1}{2^n}.
      • Post-measurement state: 12(∣i⟩+∣i⊗s⟩)\frac{1}{\sqrt{2}}(|i\rangle+|i\otimes s\rangle)
    4. Apply H⊗nH^{\otimes n}
    5. Measure the register.
      • Output a random element from {j:s⋅s=0(mod2)}\{j:s\cdot s=0\pmod 2\}
    6. Repeat this procedure until we have obtained n−1n-1 independent linear equations involving ss
    7. Gaussian elimination modulo 22
  • Lower bound
    • decision version
      • Given: N=2n,x=(x0,⋯ ,xN−1),xi∈{0,1}nN=2^n,x=(x_0,\cdots,x_{N-1}),x_i\in\{0,1\}^n
      • Promise: ∃s∈{0,1}n\exists s\in\{0,1\}^n such that xi=xjx_i=x_j iff i=ji=j or i=j⊕si=j\oplus s
      • Task: decide whether s=0ns=0^n
    • Proof
      • Let Π\Pi be a TT-query randomized algorithm that solve the problem w.p. ≥23\geq\frac{2}{3}
      • Let rr be internal randomness of PiPi (Πr\Pi_r is a determininistic algorithm)
      • Let μ\mu be a distribution on the inputs
      • Px∼μ(Π(x) is correct)≥23⇒Px∼μ,r(Πr(x) is correct)≥23⇒∃P_{x\sim\mu}(\Pi(x)\text{ is correct})\geq\frac{2}{3}\Rightarrow P_{x\sim\mu,r}(\Pi_r(x)\text{ is correct})\geq\frac{2}{3}\Rightarrow\exists a deterministic TT-query algorithm that solve the problem with probability ≥23\geq\frac{2}{3} under μ\mu (在一个概率分布下随机化为确定)
      • Find a "hard distribution" μ\mu:
        • μ(s=0)=12:x\mu(s=0)=\frac{1}{2}:x is a uniform random permutation of {0,1}n\{0,1\}^n
        • μ(s≠0)=12:s\mu(s\not=0)=\frac{1}{2}:s is picked from a nonzero string at random. For each pair {i,i⊕s}\{i,i\oplus s\} in a lexicographic order, we pick xix_i at random without replacement
      • Let i1,⋯ ,iTi_1,\cdots,i_T be queries made by algorithm, P(i1,⋯ ,ik is bad)P(i_1,\cdots,i_k\text{ is bad}) should ≤13\leq\frac{1}{3}
        • ∏i(1−xi)≥1−∑ixi\prod_i(1-x_i)\geq 1-\sum_i x_i
      • T=Ω(2n)T=\Omega(\sqrt{2^n})

Complexity

  • BPP: probabilistically polynomial-time computable by a classical computer
  • BQP: probabilistically polynomial-time computable by a classical computer
  • Theorem
    • P⊆NP⊆PSPACE\text{P}\subseteq \text{NP}\subseteq \text{PSPACE}
    • P⊆BPP⊆BQP⊆PSPACE\text{P}\subseteq \text{BPP}\subseteq\text{BQP}\subseteq\text{PSPACE}

Phase estimation

  • Given a unitary gate UU and an eigenvector ∣φ⟩|\varphi\rangle of UU, U∣φ⟩=λ∣φU|\varphi\rangle=\lambda|\varphi, estimate ∣φ⟩|\varphi\rangle (λ=eiϕ\lambda=e^{i\phi}, estimate ϕ∈[0,2π)\phi\in [0,2\pi))
  • Algorithm
    • Prepare the state: FN∣0n⟩∣φ⟩=12n∑j=0N−1∣j⟩∣φ⟩,N=2nF_N|0^n\rangle|\varphi\rangle=\frac{1}{\sqrt{2^n}}\sum_{j=0}^{N-1}|j\rangle|\varphi\rangle,N=2^n
    • Make a query: ∣j⟩∣φ⟩→∣j⟩Uj∣φ⟩|j\rangle|\varphi\rangle\rightarrow |j\rangle U^j|\varphi\rangle
    • Apply FN−1F_N^{-1} to first nn qubits
    • Get ∣ϕ1ϕ2⋯ϕn⟩,ϕ=2π∗0.ϕ1ϕ2⋯ϕn|\phi_1\phi_2\cdots\phi_n\rangle,\phi=2\pi * 0.\phi_1\phi_2\cdots\phi_n

Shor's Factoring Algorithm

  • Factoring: Given a composite NN, find an integer 1<p<N,p∣N1<p<N,p|N
  • Period-Finding: Given f:N→ZN,f(a)=xa mod Nf:\mathbb{N}\rightarrow Z_{N},f(a)=x^a\bmod N with the property for unknown r∈ZN,f(a)=f(b)r\in Z_N,f(a)=f(b) iff a=b(modr)a=b\pmod{r}
  • Theorem (Shor): There exists a quantum algortihm solving Period-find algorithm using O(log⁡log⁡N)O(\log\log N) evaluations of ff and O(log⁡log⁡N)O(\log\log N) quantum Fourier transforms.
    • time complextity of each evaluation

period find algorithm

  • Algorithm
    • Find q=2l,N2<q≤2N2q=2^l,N^2<q\leq 2N^2
    • Prepare the state: 1q∑a=0q−1∣a⟩∣0q⟩\frac{1}{\sqrt{q}}\sum_{a=0}^{q-1}|a\rangle|0^q\rangle
    • Make a query: 1q∑a=0q−1∣a⟩∣f(a)⟩\frac{1}{\sqrt{q}}\sum_{a=0}^{q-1}|a\rangle|f(a)\rangle
    • Apply FqF_q
      • Condition the second register is f(s)f(s), the first register is 1m∑j=0m−1∣jr+s⟩\frac{1}{\sqrt{m}}\sum_{j=0}^{m-1}|jr+s\rangle

∣φ3⟩=1m∑j=0m−11q∑b=0q−1e2πi(jr+s)bq∣b⟩=1mq∑b=0q−1=1mq∑b=0q−1e2πisbq(∑j=0m−1e2πijrbq)∣b⟩|\varphi_3\rangle=\frac{1}{\sqrt{m}}\sum_{j=0}^{m-1}\frac{1}{\sqrt{q}}\sum_{b=0}^{q-1}e^{\frac{2\pi i(jr+s)b}{q}}|b\rangle=\frac{1}{\sqrt{mq}}\sum_{b=0}^{q-1}=\frac{1}{\sqrt{mq}}\sum_{b=0}^{q-1}e^{2\pi i\frac{sb}{q}}(\sum_{j=0}^{m-1}e^{2\pi i\frac{jrb}{q}})|b\rangle ∑j=0m−1e2πijrbq={me2πirbq=11−e2πirbq1−e2πirbqo.w.\sum_{j=0}^{m-1}e^{2\pi i\frac{jrb}{q}}=\begin{cases}m & e^{2\pi i\frac{rb}{q}}=1\newline \frac{1-e^{2\pi i\frac{rb}{q}}}{1-e^{2\pi i\frac{rb}{q}}} & o.w.\end{cases}

  • Case 1: r∣qr|q
    • m=qr,e2πirbq=1  ⟺  rbqm=\frac{q}{r},e^{2\pi i\frac{rb}{q}}=1\iff \frac{rb}{q} is an integer   ⟺  qr∣b\iff\frac{q}{r}|b
    • exactly rr such bb with amplitudes 1r\frac{1}{r}
    • Get bb, bq=cr\frac{b}{q}=\frac{c}{r}
    • cc uniformly random in [1,r−1][1,r-1], with probability Ω(1log⁡log⁡r),c\Omega(\frac{1}{\log\log r}),c coprime with rr
    • Repeat algorithm O(log⁡log⁡N)O(\log\log N) times
  • Case 2: r∤qr\not|q
    • ∣1−e2πimrbq1−e2πirbq∣=∣sin⁡(πmrb/q)sin⁡(πrb/q)∣|\frac{1-e^{2\pi i\frac{mrb}{q}}}{1-e^{2\pi i\frac{rb}{q}}}|=|\frac{\sin(\pi mrb/q)}{\sin(\pi rb/q)}|
    • w.h.p, ∣bq−cr∣≤12q|\frac{b}{q}-\frac{c}{r}|\leq\frac{1}{2q}
    • r≠r′,r,r′<Nr\not=r',r,r'<N then ∣cr−c′r′∣>1N2|\frac{c}{r}-\frac{c'}{r'}|>\frac{1}{N^2}
    • use continued fraction find the fraction with denominator ≤N\leq N that is closest to bq\frac{b}{q}, which is cr\frac{c}{r}

Reduction of Factoring to period-finding

  • Theorem: NN is composite number LL bits long and xx is non-trival solution to equation x2=1(modN)x^2=1\pmod{N} in range 1≤x≤N1\leq x\leq N. Then at least one of gcd⁡(x−1,N)\gcd(x-1,N) and gcd⁡(x+1,N)\gcd(x+1,N) is a non-trivial factor of nn that can be computed using O(L3)O(L^3) operation
    • 找模NN下 11 的非平凡平方剩余
  • Lemma: pp is an odd prime, 2d2^d be the largest power of 22 dividing φ(pα)\varphi(p^\alpha), then Px∼U[Zpα∗](2d∣ord(x mod pα))=12P_{x\sim U[Z^*_{p^\alpha}]}(2^d|\text{ord}(x\bmod p^\alpha))=\frac{1}{2}
  • Theorem: Suppose N>0N>0 is an odd composite, x∼U[ZN∗]x\sim U[Z^*_N] and r=ord(x mod N)r=\text{ord}(x\bmod{N}), then P(2∣r∧xr2≠−1(modN))≥1−2−mP(2|r\wedge x^{\frac{r}{2}}\not=-1\pmod{N})\geq 1-2^{-m}
  • Algorithm
    • if 2∣N2|N, return 22
    • Determine whether N=abN=a^b for a≥1,b≥2a\geq 1,b\geq 2
    • Randomly choose xx in ZNZ_N, if gcd⁡(x,N)>1\gcd(x,N)>1 return gcd⁡(x,N)\gcd(x,N)
    • Use period-finding subroutine find the r=ord(x mod N)r=\text{ord}(x\bmod N)
    • if 2∣r,xx2≠1(modN)2|r,x^{\frac{x}{2}}\not=1\pmod{N} then compute gcd⁡(xr2−1)\gcd(x^{\frac{r}{2}-1}) and gcd⁡(xr2+1,N)\gcd(x^{\frac{r}{2}+1},N), return the non-trivial factor. Otherwise, the algorithm fails.

Hidden Subgroup Algorithm

  • Problem: Given a known group GG and a map f:G→Sf:G\rightarrow S where SS is some finite set. Suppose ff has the property that there exists a subgroup H≤GH\leq G such that ff is constant within each coset and distinct on different cosets.
    • Goal: find HH
  • Discrete logarithm: find α,A=γα\alpha,A=\gamma^\alpha
  • Algorithm for Abelian HSP
    • Initiate: ∣0⟩∣0⟩|0\rangle|0\rangle of dimensions ∣G∣|G| and ∣S∣|S|
    • Prepare: 1G∑g∈G∣g⟩∣0⟩\frac{1}{\sqrt{G}}\sum_{g\in G}|g\rangle|0\rangle
    • Query: 1g∑g∈G∣g⟩∣f(g)⟩\frac{1}{\sqrt{g}}\sum_{g\in G}|g\rangle|f(g)\rangle
    • Mesure the second registerm yielding f(s)f(s) for s∈Gs\in G: 1H∑h∈H∣s+h⟩\frac{1}{\sqrt{H}}\sum_{h\in H}|s+h\rangle
    • Apply QFT: 1H∑h∈H∣χs+h⟩\frac{1}{\sqrt{H}}\sum_{h\in H}|\chi_{s+h}\rangle
    • Measure and output gg
      • uniform random gg satisfying χg∈H⊥={χk∣(∀h∈H)χk(h)=1}\chi_g\in H^{\perp}=\{\chi_k|(\forall h\in H)\chi_k(h)=1\}
      • output: g1,⋯ ,gtg_1,\cdots,g_t
  • Graph isomorphism
  • Algorithm for Abelian HSP
    • ∣g⟩→∑ρ∈G^dimρ∣G∣∣ρ⟩∑i,j=1dim(ρ)ρ(g)ij∣i,j⟩|g\rangle\rightarrow\sum_{\rho\in\hat G}\sqrt{\text{dim}\frac{\rho}{|G|}}|\rho\rangle\sum_{i,j=1}^{\text{dim}(\rho)}\rho(g)_{ij}|i,j\rangle
    • Heisenberg group: poly(log⁡∣G∣)\text{poly}(\log|G|)
    • solvable groups: poly(log⁡∣G∣)\text{poly}(\log|G|)
    • nil-2 groups: poly(log⁡∣G∣)\text{poly}(\log|G|)
    • dihedral groups: 2O(log⁡∣G∣)2^{O(\sqrt{\log|G|})}
  • Query complexity of HSP
    • The quantum query complexity of HSP on any group GG is O(log⁡2∣G∣)O(\log^2|G|)

Grover's Search Algorithm

  • Problem: N=2nN=2^n, given an arbitrary x∈{0,1}Nx\in\{0,1\}^N. The goal is to find ii such that xi=1x_i=1.
  • Oracle query: O∣x⟩∣i⟩=(−1)xi∣x⟩∣i⟩O|x\rangle|i\rangle=(-1)^{x_i}|x\rangle|i\rangle (Ox∣i⟩=(−1)xi∣i⟩O_x|i\rangle=(-1)^{x_i}|i\rangle)
  • 以 ∣φ⟩|\varphi\rangle 为对称轴反转矩阵:U=2∣φ⟩⟨φ∣−IU=2|\varphi\rangle\langle\varphi|-I
  • Grover iterate: G=H⊗nRH⊗nOx,R=2∣0n⟩⟨0n∣−IG=H^{\otimes n}RH^{\otimes n}O_x,R=2|0^n\rangle\langle0^n|-I
    • Ox=−(2∣i0⟩⟨i0∣−I)O_x=-(2|i_0\rangle\langle i_0|-I) (只有 i0=0i_0=0)
    • H⊗nRH⊗n=2∣φ⟩⟨φ∣−IH^{\otimes n}RH^{\otimes n}=2|\varphi\rangle\langle\varphi|-I
  • Algorithm
    • Initiate: ∣U⟩=H⊗n∣0n⟩|U\rangle=H^{\otimes n}|0^n\rangle
    • Repeat following k=O(1ϵ)k=O(\frac{1}{\sqrt{\epsilon}}) times
      • Apply OxO_x
      • Apply H⊗nRH⊗H^{\otimes n}RH^{\otimes}
    • Measure the first register and check that the resulting ii is a solution
  • ∣G⟩=1t∑i:xi=1∣i⟩|G\rangle=\frac{1}{\sqrt{t}}\sum_{i:x_i=1}|i\rangle
  • ∣B⟩=1t∑i:xi=0∣i⟩|B\rangle=\frac{1}{\sqrt{t}}\sum_{i:x_i=0}|i\rangle
  • OxO_x: 在 ∣B⟩|B\rangle 上翻转
    • sin⁡θ=tN\sin\theta=\sqrt{\frac{t}{N}}
    • ∣U⟩=sin⁡θ∣G⟩+cos⁡θ∣B⟩|U\rangle=\sin\theta|G\rangle+\cos\theta|B\rangle
    • Gk∣U⟩=sin⁡(2k+1)θ∣G⟩+cos⁡(2k+1)θ∣B⟩G^k|U\rangle=\sin(2k+1)\theta|G\rangle+\cos(2k+1)\theta|B\rangle
    • k′=π4θ−12=O(1θ)=O(Nt),tk'=\frac{\pi}{4\theta}-\frac{1}{2}=O(\frac{1}{\theta})=O(\sqrt{\frac{N}{t}}),t 为 xi=1x_i=1 的个数
  • If tt is unknown
    • t≤N/2t\leq N/2 then the eigenvalues are eiθe^{i\theta} and ei(2π−θ)e^{i(2\pi-\theta)}

Optimality of Grover's algorithm

  • Adversary Method
    • ∣ψkx⟩=UkOxUk−1Ox⋯U1Ox∣ψ⟩|\psi_k^x\rangle=U_kO_xU_{k-1}O_x\cdots U_1O_x|\psi\rangle
    • ∣ψk⟩=UkU−1⋯U1∣ψ⟩|\psi_k\rangle=U_kU_{-1}\cdots U_1|\psi\rangle
    • Dk=∑x∥∣ψkx⟩−∣ψk⟩∥2D_k=\sum_x\||\psi_k^x\rangle-|\psi_k\rangle\|^2
    • Dk≤4k2D_k\leq 4k^2
    • Dk≥cND_k\geq cN
  • Polynomial method

Amplitude amplification

  • χ:Z→{0,1}\chi:\mathbb{Z}\rightarrow\{0,1\} be any Boolean function, suppose we have a quantum algorithm AA that uses no intermediate measurements and finds a solution z∈χ−1(1)z\in\chi^{-1}(1) with probability pp
  • Suppose we have an algorithm check whether zz is a solution.
  • Algorithm
    • Initiate: ∣U⟩=A∣0⟩|U\rangle=A|0\rangle
    • Repeat k=O(1p)k=O(\frac{1}{\sqrt{p}})
      • Apply OxO_x
      • Apply
  • Application
    • TSP: O(n!)O(\sqrt{n!})
    • Satisfiability: O(2npoly(n))O(\sqrt{2^n}\text{poly}(n))

Random walk

  • Problem: Given a d-regular simple graph G=(V,E)G=(V,E) with mm marked vertices, find one of the marked vertex.
  • Normalized adjacency matrix PP: ∣V∣×∣V∣|V|\times|V| matrix P(x,y)=1d,(x,y)∈EP(x,y)=\frac{1}{d},(x,y)\in E else 00
  • Pkv(x,y)P^kv(x,y): vv is 11 at the starting position
  • Stationary distribution: G(V,E)G(V,E) is dd-regular connected non-bipartite simple graph, then for any vv, PkvP^kv will converge to a uniform distribution over all vertices
    • Spectral gap: δ=1−λ2\delta=1-\lambda_2
  • Problem: G=(V,E)G=(V,E) with ϵN\epsilon N marked vertices where N=∣V∣N=|V|
    • SS: set up an initial state vv
    • UU: update the current vertex
    • CC: check whether the given vertex is marked
    • expected cost: S+1ϵ(C+1δU)S+\frac{1}{\epsilon}(C+\frac{1}{\delta}U)
  • Quantum walk
    • Prepare: ∣U⟩=1N∑x∣x⟩∣px⟩|U\rangle=\frac{1}{\sqrt{N}}\sum_x|x\rangle|p_x\rangle
    • Repeat the following O(1ϵ)O(\frac{1}{\sqrt{\epsilon}}) times
      • Reflect through ∣B⟩=1N−∣M∣∑x∉M∣x⟩∣px⟩|B\rangle=\frac{1}{\sqrt{N-|M|}}\sum_{x\not\in M}|x\rangle|p_x\rangle
      • Reflect through ∣U⟩|U\rangle
    • Measure the first register and check the xx is marked
    • Time complexity: S+1ϵ(C+1δU)S+\frac{1}{\sqrt{\epsilon}}(C+\frac{1}{\sqrt{\delta}}U)
  • Application
    • Grover Search
    • Collision Problem (03,tight)
    • Triangle finding problem