Quantum Algorithms
Total Page:16
File Type:pdf, Size:1020Kb
Quantum algorithms Andrew Childs Pawel Wocjan University of Waterloo University of Central Florida 10th Canadian Summer School on Quantum Information 17{19 July 2010 Outline I. Quantum circuits II. Elementary quantum algorithms III. The QFT and phase estimation IV. Factoring V. Quantum search VI. Quantum walk Part I Quantum circuits Quantum circuit model Quantum circuits are generalizations of Boolean circuits input transformation output (probabilistic) 1 U1 0 j i U3 U6 1 U5 1 j i U2 NM 0 0 j i U6 NM 1 U4 1 j i U3 U7 NM 0 1 j i NM NM Classical bit Classical bit (bit): B := 0; 1 f g I Basis state: either 0 or 1 I General state: a probability distribution p = (p0; p1) on B Classical register n Classical register: B := B B ::: B × × × | {zn } n I Basis state: a binary string x B 2 n I General state: a probability distribution p = (px : x B ) on n 2 B (written as a column vector) Remark: Note that p is a vector with positive entries that is normalized with respect to the `1-norm (the sum of the absolute values of the entries) Classical transformation Transformations on the classical register B are described by stochastic matrices Stochastic matrices preserve the `1-norm, i.e., probability distributions are mapped on probability distributions Let p be the state of the register. The state after the transformation P is given by the matrix-vector-product Pp Qubit 2 Quantum bit (qubit): two-dimensional complex Hilbert space C I Computational basis states (classical states): 1 0 0 := and 1 := j i 0 j i 1 I General states: superpositions α0 2 2 = = α0 0 + α1 1 ; α0 + α1 = 1 j i α1 j i j i j j j j the coefficients α0; α1 C are called probability amplitudes 2 Quantum register n 2 ⊗n Quantum register: 2 -dimensional complex Hilbert space (C ) with tensor product structure 2 ⊗n 2 2 2 (C ) := C C C ⊗ ⊗ · · · ⊗ | {zn } I Computational basis states (classical states): n x = x1 x2 xn ; x B j i j i ⊗ j i ⊗ · · · ⊗ j i 2 I General state: X X 2 = αx x ; αx = 1 j i j i j j x2Bn x Remark: Note that is a column vector (ket) that is j i normalized with respect to the `2-norm (Euclidean norm) Quantum transformations 2 ⊗n Transformations on the quantum register := (C ) are described by unitary matrices U ( ) H 2 U H Unitary matrices preserve the `2-norm Let be the state of the quantum register; the state after the transformationj i 2 H U is given by the matrix-vector product U j i Quantum circuit Each transformations U has to be implemented by a quantum circuit, i.e., a sequence of elementary gates Quantum circuit model = Quantum mechanics + Notion of complexity Single qubit gate on two qubits U single-qubit gate U on first qubit 0 0 (U 0 ) 0 j i ⊗ j i 7! j i ⊗ j i 2 2 0 1 (U 0 ) 1 action on basis states of C C j i ⊗ j i 7! j i ⊗ j i ⊗ 1 0 (U 1 ) 0 j1i ⊗ j1i 7! (Uj1i) ⊗ j1i j i ⊗ j i 7! j i ⊗ j i corresponding matrix 0 1 u00 0 u01 0 u00 I u01 I B 0 u00 0 u01 C U I = · · = B C ⊗ u10 I u11 I @ u10 0 u11 0 A · · 0 u10 0 u11 Single qubit gate on two qubits single-qubit gate U on second qubit U 0 0 0 U 0 j i ⊗ j i 7! j i ⊗ j i 2 2 0 1 0 U 1 action on basis states of C C j i ⊗ j i 7! j i ⊗ j i ⊗ 1 0 1 U 0 j1i ⊗ j1i 7! j1i ⊗ Uj1i j i ⊗ j i 7! j i ⊗ j i corresponding matrix 0 1 u00 u01 0 0 1 U 0 U B u10 u11 0 0 C I U = · · = B C ⊗ 0 U 1 U @ 0 0 u00 u01 A · · 0 0 u10 u11 Controlled-NOT gate control: first qubit; target: second qubit • 2 2 action on basis states of C C ⊗ c t c c t j i ⊗ j i 7! j i ⊗ j ⊕ i corresponding matrix 0 1 0 0 0 1 B 0 1 0 0 C B C = 0 0 I2 + 1 1 X @ 0 0 01 A j ih j ⊗ j ih j ⊗ 0 0 10 where I2 = 0 0 + 1 1 and X = 0 1 + 1 0 j ih j j ih j j ih j j ih j Controlled U gate control: qubit; target: m-qubit register • = U let U be a unitary acting on the m-qubit register 2 2 ⊗m action on basis states of C (C ) ⊗ c m c t c U t where b B; t B j i ⊗ j i 7! j i ⊗ j i 2 2 corresponding matrix I 0 = 0 0 I + 1 1 U 0 U j ih j ⊗ j ih j ⊗ Toffoli gate control: first and second qubits; target: third qubit • • 2 2 2 action on basis states of C C C ⊗ ⊗ c1 c2 t c1 c2 (c1 c2) t j i ⊗ j i ⊗ j i 7! j i ⊗ j i ⊗ j ^ ⊕ i corresponding matrix 0 1 0 0 0 0 0 0 0 1 B 0 1 0 0 0 0 0 0 C B C B 0 0 1 0 0 0 0 0 C B C B 0 0 0 1 0 0 0 0 C B C = (I4 11 11 ) I2 + 11 11 X B 0 0 0 0 1 0 0 0 C −j ih j ⊗ j ih j⊗ B C B 0 0 0 0 0 1 0 0 C B C @ 0 0 0 0 0 0 01 A 0 0 0 0 0 0 10 Simulating irreversible gates with Toffoli gate The classical AND gate is irreversible because if the output is 0 then we cannot determine which of the three possible pairs was the actual input x1 x2 x1 x2 ^ 0 0 0 0 1 0 1 0 0 1 1 1 But it is easy to simulate the AND gate with one Toffoli gate x1 x1 jx2i • jx2i j i • j i 0 x1 x2 j i j ^ i Problem of garbage To simulate irreversible circuits with Toffoli gates, we keep the input and intermediary results to make everything reversible Consider the function y = x1 x2 x3 ^ ^ x1 x1 jx2i • jx2i jx3i • jx3i j i • j i 0 x1 x2 x3 j i j ^ ^ i 0 x1 x2 garbage j i • j ^ i It is important to not leave any garbage; otherwise, we could not make use of quantum parallelism and constructive interference effects Reversible garbage removal It is always possible to reversibly remove (uncompute) the garbage In the case y = x1 x2 x3, this can be done with the circuit ^ ^ x1 x1 jx2i • • jx2i jx3i • • jx3i j i • j i 0 x1 x2 x3 j i j ^ ^ i 0 0 garbage uncomputed j i • j i Simulating irreversible circuits with Toffoli gates Let f : 0; 1 n 0; 1 be any boolean function f g ! f g Assume this function can be computed classically using only t classical elementary gates such as AND, OR, NAND 2 ⊗n 2 2 ⊗w We can implement a unitary Uf on (C ) C (C ) such that ⊗ ⊗ ⊗w ⊗w Uf x in y out 0 = x y f (x) 0 j i ⊗ j i ⊗ j iwork j i ⊗ j ⊕ i ⊗ j i Uf is built from polynomially many in t Toffoli gates and the size w of the workspace register is polynomial in t During the computation the qubits of the workspace register are changed, but at the end they reversibly reset to 0 ⊗w j i Universal gate set { exact implementation Each unitary U ( ) can be implemented exactly by quantum circuits using only:2 U H I CNOT gates (acting on adjacent qubits) I arbitrary single qubit gates Gate complexity of unitaries { exact implementation The gate complexity κ(U) of a unitary U ( ) is minimal number of elementary gates needed to implement2 U H U For example, quantum Fourier Transform has complexity O(n2) = Shor's factorization algorithm ) Universal gate set { approximate implementation For each (0; 1) and each unitary U ( ), there is a unitary V such that2 2 U H U V where U V = sup (U V ) k − k ≤ k − k j i k − j ik and V is implemented by quantum circuits using only: I CNOT gates (acting on adjacent qubits) I the single qubit gates 1 1 1 1 0 π H = R(θ) = ; with θ = p2 1 1 0 eiθ 4 − There are other universal gate sets Gate complexity of unitaries { approximate implementation The gate complexity κ(U) of a unitary U is the minimal number of gates (from a universal gate set) need to implement a unitary V with U V k − k ≤ The Solovay-Kitaev theorem implies that c κ(U) = O κ(U) log κ(U)/ · for some small constant c Counting arguments show that most n-qubit unitaries have gate complexity exponential in n. Quantum measurement A general measurement is described by a collection P0,. ,Pm−1 of orthogonal projectors such that m−1 X Pi = IH where denotes the identity on H H i=0 Let be the state of the quantum register. The probability of obtainingj i the outcome i is given by 2 Pr(i) = Pi k j ik The post-measurement state (collapse of the wavefunction) is Pi j i Pi k j ik Elementary quantum measurements A measurement has to be realized by first applying a suitable quantum circuit followed by an elementary measurement An elementary measurement on the n-qubit quantum register consists of measuring the first (w.l.o.g.) m qubits (m n) withH respect to the computational basis ≤ m The 2 orthogonal projectors Pb are labeled by m-bit strings m b B and are defined by 2 Pb = b1 b1 b2 b2 bm bm I n−m j ih j ⊗ j ih j ⊗ · · · ⊗ j ih j ⊗ 2 The probability of obtaining outcome b is given by 2 X 2 Pr(b) = Pb = αb ;:::;b ;x ;:::;x k j ik j 1 m m+1 n j xm+1;:::;xn2B Structure of quantum algorithms A quantum algorithm consists of n I preparing the initial state x with x B , j i 2 I applying a quantum circuit of polynomially many in n gates from some universal gate set, and I performing an elementary measurement These steps are repeated polynomially many times to collect enough samples and followed by classical post-processing = solution of the problem ) Hadamard test 0 H H j i • = U j i NM The probabilities of obtaining the outcomes 0 and 1 are: 1 1 Pr(0) = (1 + Re U ) Pr(1) = (1 Re U ) 2 h j j i 2 − h j j i Hadamard test 0 H H j i • = U j i NM 0 j i ⊗ j i 1 ( 0 + 1 ) 7! p2 j i j i ⊗ j i 1 1 = 0 + 1 p2j i ⊗ j i p2j i ⊗ j i 1 1 0 + 1 U 7! p2j i ⊗ j i p2j i ⊗ j i 1 1 ( 0 + 1 ) + ( 0 1 ) U 7! 2 j i j i ⊗ j i 2 j i − j i ⊗ j i 1 1 = 0 ( + U ) + 1 ( U ) 2j i ⊗ j i j i 2j i ⊗ j i − j i =: Φ j i Hadamard test Pr(0) = P Φ 2 with P = 0 0 I k j ik j ih j ⊗ 1 1 = 0 0 I 0 ( + U ) + 1 ( U ) 2 k j ih j⊗ 2j i⊗ j i j i 2j i⊗ j i − j i k 1 = 0 ( + U ) 2 k2j i ⊗ j i j i k 1 = 0 2 + U 2 4 kj ik · kj i j ik 1 = + Uy + U 4 h j h j j i j i 1 = + U + Uy + UyU 4 h j i h j j i h j j i h j j i 1 = 2 + U + U 4 h j j i h j j i 1 = 1 + Re U 2 h j j i Hadamard test { Figure it out yourself How can you estimate the imaginary part of U ? h j j i Hint: Add a simple gate on the control register before the measurement.