Lecture 1: Elementary quantum algorithms Dominic Berry Macquarie University Quantum simulator All classical computers work in fundamentally the same way. Quantum systems are fundamentally different. The size of the problem goes up exponentially in the size of the system, making them hard to simulate. 1982 Richard Feynman In 1982 this led Feynman to propose quantum computers. A quantum system should be able to efficiently simulate another quantum system. Efficiently means that the resources used (time and size of the system) should scale at most polynomially in the size of the system to be simulated. Polynomially means as 𝑥, 𝑥 2 , 𝑥 3 , etc. Universal quantum computer A classical computer uses bits, e.g. 001100010010011110100001101101110011 Quantum computers replace this with a quantum state 001100010010011110100001101101110011 Each digit is a two-level quantum system – a qubit. 1985 David Deutsch Quantum computers can be in superpositions of these states 𝑁 |𝜓〉 = 𝜓𝑥 |𝑥〉 𝑥=1 Represent the state as a vector: 𝜓1 𝜓2 𝜓 ≡ 𝜓3 ⋮ 𝜓𝑁 Universal quantum computer Operations on the state can be represented as matrices: 𝑈11 ⋯ 𝑈1𝑁 ⋱ ⋮ 𝑈≡ ⋮ 𝑈𝑁1 ⋯ 𝑈𝑁𝑁 The allowed operations on this state are unitary matrices. These satisfy 𝑈†𝑈 = 𝕀 The † indicates the Hermitian conjugate – the transpose and complex conjugate of the matrix. Any allowed operation is reversible. Using 𝑈 † on 𝑈|𝜓〉 will restore the state |𝜓〉. A special case is permutation matrices – a permutation matrix only changes one computational basis state to another. Examples of permutations 1. The NOT operation, also called an 𝑋, acts on a single qubit 0 1 𝑋≡ 1 0 It takes |0〉 to |1〉, and vice versa. 2. The controlled NOT acts on two qubits. It performs an 𝑋 on the target qubit if the control qubit is in the state |1〉. Otherwise it does nothing. 1 0 0 0 3. 0 1 0 0 0 0 0 1 0 0 1 0 The Toffoli gate is a NOT controlled by two qubits. It performs an 𝑋 only if both controls are in the state |1〉. 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 Turning classical into quantum The NAND gate is universal for classical circuits and acts as below. 𝐴 𝐵 𝑄 𝑨 𝑩 𝑸 0 0 1 0 1 1 1 0 1 1 1 0 We can perform the same operation using a Toffoli gate. |𝐴〉 |𝐴〉 |𝐵〉 |𝐵〉 |1〉 |𝑄〉 We can convert any classical algorithm into a quantum algorithm, replacing the NAND gates with Toffolis, and keeping the extra qubits. Turning classical into quantum Any function we could calculate on a classical computer we could also compute on a quantum computer, with the addition of some extra “garbage” registers. 𝑥 0 ↦ 𝑓 𝑥 |extra data(𝑥)〉 This can be turned into a computation that does this: 𝑈𝑓 𝑥 0 = 𝑥 |𝑓 𝑥 〉 Method: Add an ancilla, and perform the program as above to give 𝑓 𝑥 |0〉 extra data(𝑥) . Copy the output of the function into the extra ancilla, to give 𝑓 𝑥 |𝑓(𝑥)〉 extra data(𝑥) . Invert the program above, giving 𝑥 |𝑓 𝑥 〉 0 . 1. 2. 3. For ancillas that are not initially zeroed, we can just perform the XOR. 𝑈𝑓 𝑥 𝑏 = 𝑥 |𝑏 ⊕ 𝑓 𝑥 〉 Part of the story: Superposition Now what if we start the state in a superposition? 1 2𝑛 2𝑛 𝑥 |0〉 ↦ 𝑥=1 1 2𝑛 2𝑛 𝑥 |𝑓(𝑥)〉 𝑥=1 For 𝑛 qubits, we have evaluated an exponential number of different values of the function. But if we measure it, we only ever find one value of the function! The other part: Interference We can’t just calculate many values of a function, we need some way to interfere them to obtain some global property of the function. Just measuring Schrödinger’s cat would never show it in a superposition. If we could do a Hadamard on Schrödinger’s cat, we would turn 1. ( live + |dead〉)/ 2 to live , and 2. ( live − |dead〉)/ 2 to dead We need non-permutation gates: The Hadamard gate has a matrix representation 1 1 1 𝐻≡ 2 1 −1 0 ↔ (|0〉 + |1〉)/ 2 1 ↔ (|0〉 − |1〉)/ 2 showing we have superposition. The other part: Interference We can’t just calculate many values of a function, we need some way to interfere them to obtain some global property of the function. Universal sets of gates: 1. The Hadamard gate 1 1 𝐻≡ 2 1 1 −1 together with the Toffoli gate is universal for real unitaries. 2. The 𝜋/8 or 𝑇 gate 1 0 0 𝑒 𝑖𝜋/4 together with the Hadamard and CNOT is universal. 𝑇≡ The Deutsch algorithm Problem: Given a function 𝑓(𝑥) mapping bits to bits, determine if it is one-to-one [i.e. 𝑓 0 ≠ 𝑓(1)]. Classically we need to evaluate both 𝑓(0) and 𝑓(1). Quantum algorithm: 1. Start with David Deutsch 0 |1〉 2. 3. 4. Perform a Hadamard on both qubits to give 1 0 { 0 − 1 } + 1 { 0 − |1〉} 2 Apply the gate mapping 𝑥 |𝑏〉 ↦ 𝑥 |𝑏 ⊕ 𝑓 𝑥 〉 to give 1 0 { 𝑓 0 − 1 ⊕ 𝑓 0 } + 1 { 𝑓 1 − |1 ⊕ 𝑓(1)〉} 2 Apply Hadamard on qubit 2 to give 1 0 { −1 𝑓 0 } + 1 { −1 2 1985 𝑓 1 } |1〉 The Deutsch algorithm 1. 1985 Start with 0 |1〉 2. Perform a Hadamard on both qubits to give 1 0 { 0 − 1 } + 1 { 0 − |1〉} 2 3. Apply the gate mapping 𝑥 |𝑏〉 ↦ 𝑥 |𝑏 ⊕ 𝑓 𝑥 〉 to give David Deutsch 1 0 { 𝑓 0 − 1 ⊕ 𝑓 0 } + 1 { 𝑓 1 − |1 ⊕ 𝑓 (1)〉} 2 4. Apply Hadamard on qubit 2 to give 1 0 { −1 𝑓 0 } + 1 { −1If𝑓𝑓1 0} |1〉 If 𝑓(0) = 𝑓(1) then we ≠ 𝑓(1) then we 2 only get this part only get this part 5. Apply Hadamard on qubit 1 to give qubit 1 is in state 0 . qubit 1 is in state 1 . 1 0 + 1 −1 𝑓 0 + { 0 − |1〉} −1 𝑓 1 1 2 6. Rearranging gives 1 0 −1 𝑓 0 + −1 𝑓 1 + 1 −1 𝑓 0 − −1 𝑓 1 1 2 The Deutsch algorithm Problem: Given a function 𝑓(𝑥) mapping 1 bit to 1 bit 𝑓 𝑥 : {0,1} → {0,1}, determine if it is either constant or balanced. Classically we need to evaluate both 𝑓(0) and 𝑓(1). 1985 David Deutsch Deutsch quantum algorithm gives result with one function evaluation. Quantum algorithm has two crucial steps: Calculate the function on both input values simultaneously. Interfere the result. 1. 2. The Deutsch algorithm Problem: Given a function 𝑓(𝑥) mapping 1 bit to 1 bit 𝑓 𝑥 : {0,1} → {0,1}, determine if it is either constant or balanced. Classically we need to evaluate both 𝑓(0) and 𝑓(1). 1985 David Deutsch Deutsch quantum algorithm gives result with one function evaluation. Calculate the function on both input values simultaneously. |0〉 Interfere the result. 𝐻 𝐻 𝑈𝑓 |1〉 𝐻 𝐻 measurement The Deutsch-Jozsa algorithm 1992 Problem: Given a function 𝑓(𝑥) mapping 𝑛 bits to 1 bit 𝑓 𝑥 : 0,1 𝑛 → {0,1}, determine if it is either constant or balanced. There is a promise that it is either. Classically we need to evaluate 2𝑛−1 + 1 values of 𝑓(𝑥). David Deutsch Deutsch-Jozsa quantum algorithm gives result with one function evaluation. 0 ⊗𝑛 𝐻 ⊗𝑛 𝐻 ⊗𝑛 𝑈𝑓 |1〉 𝐻 measurement Richard Jozsa Phase oracles We have previously assumed that the unitary for the function acts as 𝑈𝑓 𝑥 𝑏 = 𝑥 |𝑏 ⊕ 𝑓 𝑥 〉 In both cases we have needed to turn this into a phase in order to make the algorithm work, i.e. 1 1 𝑈𝑓 𝑥 (|0〉 − |1〉) = 𝑥 (|𝑓(𝑥)〉 − |1 ⊕ 𝑓(𝑥)〉) 2 2 1 = −1 𝑓 𝑥 |𝑥〉(|0〉 − |1〉) 2 Instead we can just take the oracle to have this form: 𝑈𝑓 𝑥 = −1 𝑓 𝑥 |𝑥〉 The Deutsch-Jozsa algorithm Deutsch algorithm: start with 2 𝑥=0 2𝑛 −1 𝑓 𝑥 1 2𝑛 1 1 −1 𝑓 𝑥 𝑥=0 −1 𝑦=0 The probability of measuring 𝑦 is 1 4 −1 𝑓 𝑥 −1 𝑦⋅𝑥 𝑥=0 2𝑛 −1 −1 𝑓 𝑥 𝑥 𝑥=0 2𝑛 −1 2𝑛 −1 −1 𝑓 𝑥 𝑥=0 −1 𝑦⋅𝑥 |𝑦〉 𝑦=0 The probability of measuring 𝑦 is 2 1 𝑥=0 𝑥 Hadamards give 1 2𝑛 𝑦⋅𝑥 |𝑦〉 2𝑛 −1 The function evaluation yields 𝑥 A Hadamard gives 1 2 1 2 𝑥=0 1 𝑥 The function evaluation yields 1 Deutsch-Jozsa algorithm: start with 1 1 1992 1 22𝑛 2 2𝑛 −1 −1 𝑥=0 𝑓 𝑥 −1 𝑦⋅𝑥 1993 Fourier sampling Bernstein, Vazirani Problem: Given a function 𝑓(𝑥) mapping 1 bit to 1 bit 𝑓 𝑥 : {0,1} → {0,1} such that 𝑓 𝑥 = 𝑠 ⋅ 𝑥, determine 𝑠. The function evaluation yields 2𝑛 −1 1 2𝑛 𝑓 𝑥 𝑥 𝑥=0 Hadamards give 1 2𝑛 −1 2𝑛 −1 2𝑛 −1 −1 𝑓 𝑥 𝑥=0 −1 𝑦⋅𝑥 |𝑦〉 𝑦=0 The probability of measuring 𝑦 is 1 22𝑛 2 2𝑛 −1 −1 𝑥=0 𝑓 𝑥 −1 𝑦⋅𝑥 1 = 2𝑛 2 2 2𝑛 −1 −1 𝑥=0 (𝑦+𝑠)⋅𝑥 = 𝛿𝑦,𝑠 Grover’s search algorithm 1996 Problem: Given a function 𝑓(𝑥) mapping 𝑛 bits to 1 bit 𝑓 𝑥 : 0,1 𝑛 → {0,1}, determine the value of 𝑥 such that 𝑓 𝑥 = 1. We have a promise that the value is unique. Classically we need to evaluate 𝑂 𝑁 values, 𝑁 = 2𝑛 . Lov Grover Grover’s algorithm enables a search with 𝑂 2. Quantum algorithm has two crucial steps: Calculate the function on all values simultaneously. Reflect about the equal superposition state. These steps are repeated 𝑂 1. 𝑁 times. 𝑁 queries. Grover’s search algorithm We start in the state 𝑠 = 1. 2. 1 𝑁 1996 𝑁 𝑥 𝑥=1 We repeat the following ∼ 𝑁 times: Apply the function calculation 𝑈𝑓 . Apply the reflection operation 𝑈𝑠 = 2 𝑠 〈𝑠| − 𝕀. The system will be in the state |𝜔〉 such that 𝑓 𝜔 = 1. But how do we perform 𝑈𝑠 ? Lov Grover Grover’s search algorithm But how do we perform 𝑈𝑠 ? First, invert the operation that prepares |𝑠〉 - just Hadamards on all qubits. Then, reflect about |0〉; i.e. apply 2 0 〈0| − 𝕀. Lastly, repeat the operation that prepares 𝑠 . |1〉 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 𝐻 1996 Lov Grover Grover’s search algorithm What does 𝑈𝑠 do? 𝑁 𝑈𝑠 𝑥=1 𝑁 2 𝜓𝑥 𝑥 = 𝑁 = 𝑁 𝑥 𝑥=1 𝑁 2 𝑁 𝑁 〈𝑦| 𝑦=1 𝑁 𝑥 𝑥=1 𝑁 𝜓𝑧 𝑧 − 𝑧=1 𝑁 𝜓𝑦 − 𝑦=1 = Lov Grover 𝜓𝑥 𝑥 𝑥=1 (2𝜓 − 𝜓𝑥 ) 𝑥 𝑥=1 Each coefficient is reflected about the mean 1 𝜓= 𝑁 𝑁 𝜓𝑦 𝑦=1 𝜓𝑥 𝑥 𝑥=1 𝑁 1996 Grover’s search algorithm 1996 Example: Take 𝑁 = 4, with solution 𝑥 = 3. We start in the state 𝑠 = 12 (|1〉 + 2 + 3 + |4〉) Apply the function calculation 𝑈𝑓 , giving 1 2(|1〉 + 2 − 3 + |4〉) The mean is Lov Grover 𝜓 = 14(12 + 12 − 12 + 12) = 14 Grover’s search algorithm 1996 Example: Take 𝑁 = 4, with solution 𝑥 = 3. We start in the state 𝑠 = 12 (|1〉 + 2 + 3 + |4〉) Apply the function calculation 𝑈𝑓 , giving 1 2(|1〉 + 2 − 3 + |4〉) The mean is Therefore, when we apply the reflection operation 𝑈𝑠 , we get 1 1 (|1〉 + 2 + 3 + |4〉) − (|1〉 + 2 − 3 + |4〉) = |3〉 2 2 Lov Grover 𝜓 = 14(12 + 12 − 12 + 12) = 14 Grover’s search algorithm 1996 Example: Take 𝑁 = 9, with solution 𝑥 = 6. Reflecting target… The mean is 7/27. Lov Grover Grover’s search algorithm Example: Take 𝑁 = 9, with solution 𝑥 = 6. Reflecting target… The mean is 7/27. Reflecting about mean… Reflecting target… The mean is 17/243. 1996 Lov Grover Grover’s search algorithm Example: Take 𝑁 = 9, with solution 𝑥 = 6. Reflecting target… The mean is 7/27. Reflecting about mean… Reflecting target… The mean is 17/243. Reflecting about mean… Solution with high probability. 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations Define the ket perpendicular to 𝜔 . 1 ′ |𝑠 〉 = |𝑥〉 𝑁 − 1 𝑥≠𝜔 1996 Lov Grover Then 𝑠 = cos 𝜙 𝑠′ + sin 𝜙 |𝜔〉 with sin 𝜙 = 1/ 𝑁. The operation 𝑈𝑓 reflects 𝜔 and leaves all orthogonal states unchanged. 𝑈𝑓 = 𝕀 − 2 𝜔 〈𝜔| The action of 𝑈𝑓 on 𝑠′ is 𝑈𝑓 𝑠′ = (𝕀 − 2 𝜔 〈𝜔|) 𝑠′ = 𝑠′ Grover’s search algorithm Another way of looking at it: Rotations The action of 𝑈𝑓 on 𝑠′ is 𝑈𝑓 𝑠′ = 𝑠′ The action of 𝑈𝑠 on 𝜔 is 𝑈𝑠 𝜔 = (2 𝑠 〈𝑠| − 𝕀) 𝜔 =2 𝑠𝜔 𝑠 − 𝜔 = 2 sin 𝜙 𝑠 − 𝜔 Now use 𝑠 = cos 𝜙 𝑠′ + sin 𝜙 |𝜔〉 This gives 𝑈𝑠 𝜔 = 2 sin 𝜙 cos 𝜙 𝑠′ + sin 𝜙 |𝜔〉 − 𝜔 = 2 sin 𝜙 cos 𝜙 𝑠 ′ − 1 − 2 sin2 𝜙 𝜔 = sin 2𝜙 𝑠 ′ − cos 2𝜙 |𝜔〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations The action of 𝑈𝑓 on 𝑠′ is 𝑈𝑓 𝑠′ = 𝑠′ The action of 𝑈𝑠 on 𝜔 is 𝑈𝑠 𝜔 = sin 2𝜙 𝑠 ′ − cos 2𝜙 |𝜔〉 The action of 𝑈𝑠 on 𝑠′ is 𝑈𝑠 𝑠′ = (2 𝑠 〈𝑠| − 𝕀) 𝑠′ = 2 𝑠 𝑠′ 𝑠 − 𝑠 ′ = 2 cos 𝜙 𝑠 − |𝑠 ′ 〉 Now use 𝑠 = cos 𝜙 𝑠′ + sin 𝜙 |𝜔〉 This gives 𝑈𝑠 𝑠′ = 2 cos 𝜙 cos 𝜙 𝑠′ + sin 𝜙 |𝜔〉 − 𝑠 ′ = 2 cos 2 𝜙 − 1 s ′ + 2 sin 𝜙 cos 𝜙 𝜔 = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 1996 Lov Grover 1996 Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 Consider a state written as 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 The action of 𝑈𝑓 on 𝜓 is 𝑈𝑓 𝜓 = cos 𝜃 𝑠′ − sin 𝜃 |𝜔〉 Then applying 𝑈𝑠 gives 𝑈𝑠 𝑈𝑓 𝜓 = cos 𝜃 cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 − sin 𝜃 sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 = cos 𝜃 cos 2𝜙 − sin 𝜃 sin 2𝜙 𝑠 ′ + cos 𝜃 sin 2𝜙 + sin 𝜃 cos 2𝜙 𝜔 = cos(𝜃 + 2𝜙) 𝑠 ′ + sin(𝜃 + 2𝜙) 𝜔 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 The Grover iteration gives 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 ′ |𝜔〉 𝑈𝑠 𝑈𝑓 𝜓 = cos(𝜃 + 2𝜙) 𝑠 + sin(𝜃 + 2𝜙) 𝜔 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 The Grover iteration gives 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 ′ |𝜔〉 𝑈𝑠 𝑈𝑓 𝜓 = cos(𝜃 + 2𝜙) 𝑠 + sin(𝜃 + 2𝜙) 𝜔 𝑈𝑠 𝑈𝑓 |𝑠〉 3𝜙 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 The Grover iteration gives 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 ′ |𝜔〉 𝑈𝑠 𝑈𝑓 𝜓 = cos(𝜃 + 2𝜙) 𝑠 + sin(𝜃 + 2𝜙) 𝜔 2 𝑈𝑠 𝑈𝑓 |𝑠〉 𝑈𝑠 𝑈𝑓 |𝑠〉 5𝜙 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 The Grover iteration gives 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 ′ |𝜔〉 𝑈𝑠 𝑈𝑓 𝜓 = cos(𝜃 + 2𝜙) 𝑠 + sin(𝜃 + 2𝜙) 𝜔 3 𝑈𝑠 𝑈𝑓 |𝑠〉 2 𝑈𝑠 𝑈𝑓 |𝑠〉 𝑈𝑠 𝑈𝑓 |𝑠〉 7𝜙 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 The Grover iteration gives 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 ′ |𝜔〉 𝑈𝑠 𝑈𝑓 𝜓 = cos(𝜃 + 2𝜙) 𝑠 + sin(𝜃 + 2𝜙) 𝜔 3 𝑈𝑠 𝑈𝑓 |𝑠〉 4 𝑈𝑠 𝑈𝑓 |𝑠〉 2 𝑈𝑠 𝑈𝑓 |𝑠〉 𝑈𝑠 𝑈𝑓 |𝑠〉 9𝜙 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations 𝑈𝑓 𝑠′ = 𝑠′ 𝑈𝑠 𝜔 = sin 2𝜙 𝑠′ − cos 2𝜙 |𝜔〉 𝑈𝑠 𝑠′ = cos 2𝜙 𝑠 ′ + sin 2𝜙 |𝜔〉 The Grover iteration gives 𝜓 = cos 𝜃 𝑠′ + sin 𝜃 |𝜔〉 ′ |𝜔〉 𝑈𝑠 𝑈𝑓 𝜓 = cos(𝜃 + 2𝜙) 𝑠 + sin(𝜃 + 2𝜙) 𝜔 3 5 𝑈𝑠 𝑈𝑓 |𝑠〉 𝑈𝑠 𝑈𝑓 |𝑠〉 2 𝑈𝑠 𝑈𝑓 |𝑠〉 11𝜙 𝑈𝑠 𝑈𝑓 |𝑠〉 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 1996 Lov Grover Grover’s search algorithm Another way of looking at it: Rotations In general 𝑈𝑠 𝑈𝑓 1996 𝑘 𝑠 = cos[ 2𝑘 + 1 𝜙] 𝑠 ′ + sin[ 2𝑘 + 1 𝜙] 𝜔 For solution we want 2𝑘 + 1 𝜙 ≈ 𝜋/2 ⇒ 2𝑘 + 1 arcsin 1/ 𝑁 ≈ 𝜋/2 Lov Grover |𝜔〉 3 5 𝑈𝑠 𝑈𝑓 |𝑠〉 𝑈𝑠 𝑈𝑓 |𝑠〉 2 𝑈𝑠 𝑈𝑓 |𝑠〉 11𝜙 𝑘opt 𝜋 1 ≈ 𝑁− 4 2 𝑈𝑠 𝑈𝑓 |𝑠〉 |𝑠〉 𝜙 |𝑠′〉 𝑈𝑓 |𝑠〉 For 𝑁 = 42 𝑘opt ≈ 4.58996 … 1996 Grover’s search algorithm What about multiple targets? In general we have 𝑚 values of 𝑥 such that 𝑓(𝑥) = 1. Let us define 𝑚 1 |𝜔〉 = |𝜔𝑛 〉 𝑚 𝑛=1 where 𝜔𝑛 are the values of 𝑥 such that 𝑓(𝑥) = 1. Define a modified |𝑠 ′ 〉 1 ′ |𝑠 〉 = |𝑥〉 𝑁 − 𝑚 𝑥∉{𝜔 } 𝑛 Then 𝑠 = cos 𝜙 𝑠′ + sin 𝜙 |𝜔〉 Lov Grover Define projector 𝑚 𝑃𝜔 = 𝜔𝑛 〈𝜔𝑛 | 𝑛=1 and reflector 𝑈𝑓 = 𝕀 − 2𝑃𝜔 with sin 𝜙 = 𝑚/𝑁. The analysis is the same, except with the modified value of 𝜙. 𝑘opt 𝜋 ≈ 𝑁 4 becomes 𝑘opt 𝜋 𝑁 ≈ 4 𝑚