CRZ and CRY Gates

1

1

I am trying to understand the CRZ and CRY gates functions : what do they actually used for ? why we require a certain angle rotation around z or y Axis on a Qubit ? and what does it yield ?

Application : performing a CNX with Qiskit.

def cnx(qc, *qubits):
  if len(qubits) >= 3:
    last = qubits[-1]
    #What's the goal of the next two lines ?
    qc.crz(np.pi/2, qubits[-2], qubits[-1])
    qc.cry(np.pi/2, 0, 0, qubits[-2],qubits[-1])

    #Is this a recursive call to cnx ?
    cnx(qc,*qubits[:-2],qubits[-1])

    #what there's this flip too ?
    qc.cry(-np.pi/2, 0, 0, qubits[-2], qubits[-1])

    #what about this line ?
    cnx(qc,*qubits[:-2],qubits[-1])

    #what about this line too?
    qc.crz(-np.pi/2,qubits[-2],qubits[-1])

Please explain inline questions, in the context of the initial question.

Thanks !

user1319236

Posted 2019-07-05T02:47:36.373

Reputation: 357

1Controlled rotations of a qubit around axes are workhorses in quantum algorithms; for example, consider the controlled rotation of the marked state in Grover's algorithm. Unlike, say, the $\mathsf{CNOT}$ or $\mathsf{CSWAP}$ gates, there is no classical analog of a controlled rotation. Can you provide more clarity in what you know and what you are looking to learn? Otherwise it's a little broad - like asking what the purpose of a $\mathsf{NAND}$ gate is in classical computing. – Mark S – 2019-07-05T13:31:36.500

What i know is that it performs a certain angle flip of the target Qubit on the Bloch sphere following the Z -axis for the CRZ and Y - axis for the CRY if the control bit is at state 1. Now why we want to do this, in the first place ? what is it useful in, a flip ? and how the target qubit will look like (e.g an example) at the end ? how could CRZ be more useful in some calculations ? thx – user1319236 – 2019-07-05T13:55:26.690

It seems like you are having specific questions about a snippet of code in Qiskit, and not so much about how controlled Pauli operations are used. It's hard to answer such "moving-target" questions and I don't know how to help further. Maybe someone else can; however, in the future refrain from changing the context of a question and asking XY questions.

– Mark S – 2019-07-05T17:53:01.757

Yes it was a double phased question but i commented on your previous answer with an additional question about what your wrote ! – user1319236 – 2019-07-05T18:45:13.120

Answers

1

Quantum algorithms provide a computational speedup by orchestrating constructive and destructive interference of the amplitudes. It is as if there must be a "minus" sign somewhere in the matrices - otherwise we merely work in the classical world, and would not see a computational speedup.

Let's consider the following gates as controlled Pauli matrices:

\begin{align} CR_x&= \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&0&1\\ 0&0&1&0 \end{pmatrix} \\ \\ CR_y&= \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&0&-i\\ 0&0&i&0 \end{pmatrix} \\\ \\ CR_z&= \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&-1 \end{pmatrix} \,. \end{align}

Clearly $CR_x$ does not have a minus sign - nothing gets inverted. $CR_x$ corresponds to the $\mathsf{CNOT}$ gate; oOperating only with $\mathsf{CNOT}$ gates does not provide any quantum speedup - $\mathsf{CNOT}$ gates can be implemented classically.

Not so, however, with $CR_y$ and $CR_z$. For example, $CR_z$ can be used to "invert" the probability amplitude of the marked states in Grover's algorithm. The marked states, being inverted, will destructively interfere with the unmarked states during the diffusion operation.


As a simple example, consider qubits $|\psi\rangle=\frac{1}{\sqrt{2}}|(|00\rangle+|11\rangle)$. The "target" qubit is $1$ only when the "control" qubit is $1$.

We have:

$$CR_x|\psi\rangle=\frac{1}{\sqrt{2}}(|00\rangle+|10\rangle)$$ $$CR_y|\psi\rangle=\frac{1}{\sqrt{2}}(|00\rangle-i|10\rangle)$$ $$CR_z|\psi\rangle=\frac{1}{\sqrt{2}}|(|00\rangle-|11\rangle)$$

When the "control" qubit is $1$, the "target" qubit may have a phase of $-1$ or $-i$.

Mark S

Posted 2019-07-05T02:47:36.373

Reputation: 4 273

Algorithmically speaking, how is it useful the CRx CRy CRz ? in initializing any state qubit for another operation maybe etc... – user1319236 – 2019-07-05T16:01:51.950

I edited my question pls check it – user1319236 – 2019-07-05T16:51:26.910

In the last CRz expression you mean a state of \alpha |00>-|10> right ? – user1319236 – 2019-07-05T17:23:28.250

I could have gotten it wrong but why do you think it's $|00\rangle-|10\rangle$? It's all $1$'s and $-1$'s on the diagonal - that means it doesn't change states on the diagonal, only phases. – Mark S – 2019-07-05T23:23:17.163

Well because it's a 1 as control bit in the |10⟩ component – user1319236 – 2019-07-06T00:00:52.510

The $4\times 4$ matrix is read $00,01,10,11$ in both the column and row direction. The state $|11\rangle$ corresponds to the bottom row and the far-right column. Reading over to the column we find that it $CR_z$ maps this to $-|11\rangle$. – Mark S – 2019-07-06T02:53:39.380