# Grover oracle result: vectors (0,1) & (0,1) => two Hadamards => product of two H results => CZ = (.5, .-5, -.5, -.5)

According to the Grover's algorithm section in the IBM Quantum Experience, if I have two qubits in the "one" state (vectors (0,1) and (0,1)), and I apply a Hadamard gate to each of them, and then input the tensor product output to a CZ gate, my resulting amplitudes should be (.5, .5, .5, and -.5). However, no matter how I fiddle with the matrices, my resulting amplitudes are (.5, -.5, -.5, and -.5) Am I screwing up the product of the results of the two Hadamards?

• What do you mean by "two qubits in the one state"? If you have two qubits in the state $\vert 01\rangle$ then these two qubits together may correspond to binary $1$. It's not clear to me wny you refer to "two qubits in the one state" as vectors $(0,1)$ and $(0,1)$... Jun 9 '20 at 0:52
• I should have said, "... if I have tow qubits each in the "one" state ..." Each (and both) qubits start in the "one" state. Jun 10 '20 at 12:47

## 1 Answer

Could you point to the source? Your calculations seem correct, in Dirac notation:

• start with $$|1\rangle \otimes |1\rangle$$
• apply H to each qubit: $$|-\rangle \otimes |-\rangle = \frac12(|00\rangle - |01\rangle - |10\rangle + |11\rangle)$$
• Apply CZ: the sign of $$|11\rangle$$ changes, for the final result $$\frac12(|00\rangle - |01\rangle - |10\rangle - |11\rangle)$$

Could it be that the source starts with qubits in $$|0\rangle \otimes |0\rangle$$ state? In that case the resulting amplitudes will indeed be $$\frac12(|00\rangle + |01\rangle + |10\rangle - |11\rangle)$$.

• Thank you for responding. This is the source. Scroll down about 3/4 the way to the section "Oracles". medium.com/swlh/… Jun 5 '20 at 23:54
• Do you mean "Oracle for |w⟩=|11⟩"? It doesn't start in |11⟩ state indeed; the whole circuit starts in |00⟩ state. The fact that this oracle marks |11⟩ state doesn't mean that the circuit starts in |00⟩, it means that the oracle CZ, when given a superposition of all possible inputs, flips the phase of just |11⟩. Jun 6 '20 at 0:05
• Thank you for your reply. I appreciate it. I have to give this some additional study because I am frankly missing the point. I thought this oracle would detect an |11> if the |11> lurked among the choices. Jun 6 '20 at 2:21
• It does detect 11, sort of - by means of flipping its phase. To convert this effect into a "detection" that results in the actual 11 state, you need the full Grover's algorithm, the oracle alone doesn't do it. Jun 6 '20 at 2:27
• Grover's search algorithm is not really suited for database search. The examples that use hardcoded values that we search for don't do it justice for the precise reason you pointed out. Tag "grovers-algorithm" on this site has a lot of great questions and answers on this, starting with quantumcomputing.stackexchange.com/questions/6325/… Jun 7 '20 at 0:42