1
$\begingroup$

I was trying to implement the 2-qubit Grover algorithm without the auxiliary bit. Before finding the gate symbol for the controlled $\mathrm{Z}$, I worked with the controlled $\mathrm{Rz}$. The gate glossary states: " $\mathrm{Z}$ is equivalent to $\mathrm{Rz}$ for the angle $\pi$". So I thought the controlled $\mathrm{Rz}$ with angle $\pi$ should be equal with the controlled $\mathrm{Z}$ gate. However, I get very different results in the browser state-vector representation.

So my question is, should they be equivalent?

Here are my circuits: 2-Qubit Grover with cRz 2-Qubit Grover with cZ

$\endgroup$
1
$\begingroup$

I realized that $\mathrm{Rz}(\lambda)$ is implemented in following way on IBM Q:

gate crz(lambda) a,b
{
  u1(lambda/2) b;
  cx a,b;
  u1(-lambda/2) b;
  cx a,b;
}

Setting $\lambda =\pi$, a matrix describing construction above is following: $$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & -i & 0 \\ 0 & 0 & 0 & i \\ \end{pmatrix} $$

This is not problem when the gate is not controlled as $i$ is a global phase, however, it matters for controlled gates.

I also checked that these values are really returned for computation basis states in state vector visualization on IBM Q.

Conclusion is that controlled $\mathrm{Rz}(\pi)$ is not equivalent to controlled $\mathrm{Z}$ on IBM Q.

Note that application of single qubit $\mathrm{Rz}(\pi)$ returns same results as single qubit $\mathrm{Z}$.


Solution:

To make controlled $\mathrm{Rz}(\pi)$ behave as expected, you have to put controlled global phase gate before $\mathrm{Rz}(\pi)$. You can do that by application single-qubit gate $\mathrm{U1}(\pi/2)$ on controlling qubit of $\mathrm{Rz}(\pi)$, i.e. $q_0$ in your case.

|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ You say this is a bug, but I wouldn't call it so. The definition follows very naturally from the single-qubit definitions. The bug is the expectation that they should be the same. They shouldn't because of the difference between global and relative phase. $\endgroup$ – DaftWullie Feb 28 at 12:10
  • $\begingroup$ @DaftWullie: I would expect that controlled version of single qubit gate $\mathrm{U}$ is described by matrix $\begin{pmatrix} I & O \\ O & U\end{pmatrix}$ as e.g. in case of controlled $\mathrm{X}$, $\mathrm{Z}$ or $\mathrm{H}$. $\endgroup$ – Martin Vesely Feb 28 at 12:45
  • $\begingroup$ It is, i's just the $U$ that you're talking about is equivalent to $Z$ up to a global phase, but it is not $Z$. $\endgroup$ – DaftWullie Feb 28 at 12:53
  • 1
    $\begingroup$ No, because $R_z$ is not $Z$. $R_z=-iZ$. $\endgroup$ – DaftWullie Feb 28 at 13:29
  • 1
    $\begingroup$ This, I can agree with. $\endgroup$ – DaftWullie Feb 28 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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