5
$\begingroup$

I know how Grover's diffusion operator works ($U_s = 2|s\rangle\langle s|-I$) with the inversion around the mean. However, I want to implement it in simpler gates, to use the algorithm. How can I do this ?

$\endgroup$

1 Answer 1

8
$\begingroup$

Grover's diffusion operator can be implemented with H, X and a controlled Z gate. I will show this mathematically. Since $|s\rangle = |+\rangle^{\otimes n} $ : $$ U_s = 2|s\rangle\langle s|-I = H^{\otimes n}(2|0\rangle\langle0|-I)H^{\otimes n} $$ We know have the H gate which appeared. We now know that we will have to apply the Hadamard gate to every qubit at the beginning and the end of Grover's diffusion operator. We will only work with $2|0\rangle\langle 0|-I$. $|0\rangle\langle0|$ is the outer product of the first basic state. It is a matrix filled with 0s only (0, 0) is filled with a 1. $I$ Is the identity matrix. $$ 2|0\rangle\langle 0|-I = 2 \begin {bmatrix} 1 & 0 & \cdots & 0 \\ 0 & 0 & \cdots & 0 \\ \vdots & \vdots & \ddots & 0\\ 0 & 0 & 0 & 0 \end {bmatrix} - I = \begin {bmatrix} 2 & 0 & \cdots & 0 \\ 0 & 0 & \cdots & 0 \\ \vdots & \vdots & \ddots & 0\\ 0 & 0 & 0 & 0 \end {bmatrix} - \begin {bmatrix} 1 & 0 & \cdots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & 0\\ 0 & 0 & 0 & 1 \end {bmatrix} = \begin {bmatrix} 1 & 0 & \cdots & 0 \\ 0 & -1 & \cdots & 0 \\ \vdots & \vdots & \ddots & 0\\ 0 & 0 & 0 & -1 \end {bmatrix} $$ We now have the matrix which represents $2|0\rangle\langle 0|-I$. It flips the phase of every state apart from $|0\cdots0\rangle$. If we apply a global phase of $-1$ (which can be ignored), we only have to flip the phase of $|0\cdots0\rangle$. $$ \begin {bmatrix} 1 & 0 & \cdots & 0 \\ 0 & -1 & \cdots & 0 \\ \vdots & \vdots & \ddots & 0\\ 0 & 0 & 0 & -1 \end {bmatrix} = -1 \begin {bmatrix} -1 & 0 & \cdots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & 0\\ 0 & 0 & 0 & 1 \end {bmatrix} = -1 X^{\otimes n} \begin {bmatrix} 1 & 0 & \cdots & 0 & 0 \\ 0 & 1 & \cdots & 0 & 0 \\ \vdots & \vdots & \ddots & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & -1 \\ \end {bmatrix} X^{\otimes n} $$ We can transform the matrix by applying the X gate to every qubit to only have to flip the phase of $|1\cdots1\rangle$ state. However, this matrix is only a controlled Z operation with all the qubits except the last one as control.

There we have it : Grover's diffusion operator with only H gates , X gates and a controlled Z gate. This paper describes a slightly different way to do it with a toffoli (CCNOT) gate but the method has the same complexity (I think). I hope this answered your question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.