Skip to Content
Quantum Computation

Quantum Algorithm

2019-09-05Original-language archivelegacy assets may be incomplete

Query value of function

  • Uf:x,yx,yf(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: UfHn0n=12nxx,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: Ofx=(1)f(x)xO_f|x\rangle=(-1)^{f(x)}|x\rangle
    • Ufx,=(1)f(x)xU_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)
    • 0HOfHM(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(f1(0)=f1(1)=2n1|f^{-1}(0)|=|f^{-1}(1)|=2^{n-1}).
    • 0nHnOfHnM(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=(ia)mod2x_i=(i\cdot a)\bmod 2. The goal is to find aa
  • Algorithm
    1. Prepare the state: H0nH|0^n\rangle
    2. Make a query OfO_f: 12ni{0,1}n(1)xii=12ni{0,1}n(1)iai=Hna\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 HnH^{\otimes n}: a|a\rangle

Simon's Algorithm

  • Simon's Problem(Hidden Shift): N=2n,x(x0,,xN1),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=jsi=j\oplus s. The goal is to find ss
  • Algorithm
    1. Prepare the state: Hn0n0n=12ni{0,1}ni0nH^{\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: 12ni{0,1}nixi\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+is)\frac{1}{\sqrt{2}}(|i\rangle+|i\otimes s\rangle)
    4. Apply HnH^{\otimes n}
    5. Measure the register.
      • Output a random element from {j:ss=0(mod2)}\{j:s\cdot s=0\pmod 2\}
    6. Repeat this procedure until we have obtained n1n-1 independent linear equations involving ss
    7. Gaussian elimination modulo 22
  • Lower bound
    • decision version
      • Given: N=2n,x=(x0,,xN1),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=jsi=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)23Pxμ,r(Πr(x) is correct)23P_{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
        • μ(s0)=12:s\mu(s\not=0)=\frac{1}{2}:s is picked from a nonzero string at random. For each pair {i,is}\{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(1xi)1ixi\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
    • PNPPSPACE\text{P}\subseteq \text{NP}\subseteq \text{PSPACE}
    • PBPPBQPPSPACE\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: FN0nφ=12nj=0N1jφ,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φjUjφ|j\rangle|\varphi\rangle\rightarrow |j\rangle U^j|\varphi\rangle
    • Apply FN1F_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,pN1<p<N,p|N
  • Period-Finding: Given f:NZN,f(a)=xamodNf:\mathbb{N}\rightarrow Z_{N},f(a)=x^a\bmod N with the property for unknown rZN,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(loglogN)O(\log\log N) evaluations of ff and O(loglogN)O(\log\log N) quantum Fourier transforms.
    • time complextity of each evaluation

period find algorithm

  • Algorithm
    • Find q=2l,N2<q2N2q=2^l,N^2<q\leq 2N^2
    • Prepare the state: 1qa=0q1a0q\frac{1}{\sqrt{q}}\sum_{a=0}^{q-1}|a\rangle|0^q\rangle
    • Make a query: 1qa=0q1af(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 1mj=0m1jr+s\frac{1}{\sqrt{m}}\sum_{j=0}^{m-1}|jr+s\rangle

φ3=1mj=0m11qb=0q1e2πi(jr+s)bqb=1mqb=0q1=1mqb=0q1e2πisbq(j=0m1e2π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=0m1e2πijrbq={me2πirbq=11e2πirbq1e2π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: rqr|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     qrb\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,r1][1,r-1], with probability Ω(1loglogr),c\Omega(\frac{1}{\log\log r}),c coprime with rr
    • Repeat algorithm O(loglogN)O(\log\log N) times
  • Case 2: r∤qr\not|q
    • 1e2πimrbq1e2π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, bqcr12q|\frac{b}{q}-\frac{c}{r}|\leq\frac{1}{2q}
    • rr,r,r<Nr\not=r',r,r'<N then crcr>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 1xN1\leq x\leq N. Then at least one of gcd(x1,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
    • 找模NN11 的非平凡平方剩余
  • Lemma: pp is an odd prime, 2d2^d be the largest power of 22 dividing φ(pα)\varphi(p^\alpha), then PxU[Zpα](2dord(xmodpα))=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, xU[ZN]x\sim U[Z^*_N] and r=ord(xmodN)r=\text{ord}(x\bmod{N}), then P(2rxr21(modN))12mP(2|r\wedge x^{\frac{r}{2}}\not=-1\pmod{N})\geq 1-2^{-m}
  • Algorithm
    • if 2N2|N, return 22
    • Determine whether N=abN=a^b for a1,b2a\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(xmodN)r=\text{ord}(x\bmod N)
    • if 2r,xx21(modN)2|r,x^{\frac{x}{2}}\not=1\pmod{N} then compute gcd(xr21)\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:GSf:G\rightarrow S where SS is some finite set. Suppose ff has the property that there exists a subgroup HGH\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: 00|0\rangle|0\rangle of dimensions G|G| and S|S|
    • Prepare: 1GgGg0\frac{1}{\sqrt{G}}\sum_{g\in G}|g\rangle|0\rangle
    • Query: 1ggGgf(g)\frac{1}{\sqrt{g}}\sum_{g\in G}|g\rangle|f(g)\rangle
    • Mesure the second registerm yielding f(s)f(s) for sGs\in G: 1HhHs+h\frac{1}{\sqrt{H}}\sum_{h\in H}|s+h\rangle
    • Apply QFT: 1HhHχs+h\frac{1}{\sqrt{H}}\sum_{h\in H}|\chi_{s+h}\rangle
    • Measure and output gg
      • uniform random gg satisfying χgH={χk(hH)χ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)iji,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(logG)\text{poly}(\log|G|)
    • solvable groups: poly(logG)\text{poly}(\log|G|)
    • nil-2 groups: poly(logG)\text{poly}(\log|G|)
    • dihedral groups: 2O(logG)2^{O(\sqrt{\log|G|})}
  • Query complexity of HSP
    • The quantum query complexity of HSP on any group GG is O(log2G)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: Oxi=(1)xixiO|x\rangle|i\rangle=(-1)^{x_i}|x\rangle|i\rangle (Oxi=(1)xiiO_x|i\rangle=(-1)^{x_i}|i\rangle)
  • φ|\varphi\rangle 为对称轴反转矩阵:U=2φφIU=2|\varphi\rangle\langle\varphi|-I
  • Grover iterate: G=HnRHnOx,R=20n0nIG=H^{\otimes n}RH^{\otimes n}O_x,R=2|0^n\rangle\langle0^n|-I
    • Ox=(2i0i0I)O_x=-(2|i_0\rangle\langle i_0|-I) (只有 i0=0i_0=0)
    • HnRHn=2φφIH^{\otimes n}RH^{\otimes n}=2|\varphi\rangle\langle\varphi|-I
  • Algorithm
    • Initiate: U=Hn0n|U\rangle=H^{\otimes n}|0^n\rangle
    • Repeat following k=O(1ϵ)k=O(\frac{1}{\sqrt{\epsilon}}) times
      • Apply OxO_x
      • Apply HnRHH^{\otimes n}RH^{\otimes}
    • Measure the first register and check that the resulting ii is a solution
  • G=1ti:xi=1i|G\rangle=\frac{1}{\sqrt{t}}\sum_{i:x_i=1}|i\rangle
  • B=1ti:xi=0i|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
    • GkU=sin(2k+1)θG+cos(2k+1)θBG^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}}),txi=1x_i=1 的个数
  • If tt is unknown
    • tN/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=UkOxUk1OxU1Oxψ|\psi_k^x\rangle=U_kO_xU_{k-1}O_x\cdots U_1O_x|\psi\rangle
    • ψk=UkU1U1ψ|\psi_k\rangle=U_kU_{-1}\cdots U_1|\psi\rangle
    • Dk=xψkxψk2D_k=\sum_x\||\psi_k^x\rangle-|\psi_k\rangle\|^2
    • Dk4k2D_k\leq 4k^2
    • DkcND_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=A0|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=VN=|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=1Nxxpx|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=1NMx∉Mxpx|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