1
$\begingroup$

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 !

$\endgroup$
  • 1
    $\begingroup$ Controlled 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. $\endgroup$ – Mark S Jul 5 '19 at 13:31
  • $\begingroup$ 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 $\endgroup$ – user1319236 Jul 5 '19 at 13:55
  • $\begingroup$ 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. $\endgroup$ – Mark S Jul 5 '19 at 17:53
  • $\begingroup$ Yes it was a double phased question but i commented on your previous answer with an additional question about what your wrote ! $\endgroup$ – user1319236 Jul 5 '19 at 18:45
1
$\begingroup$

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$.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Algorithmically speaking, how is it useful the CRx CRy CRz ? in initializing any state qubit for another operation maybe etc... $\endgroup$ – user1319236 Jul 5 '19 at 16:01
  • $\begingroup$ I edited my question pls check it $\endgroup$ – user1319236 Jul 5 '19 at 16:51
  • $\begingroup$ In the last CRz expression you mean a state of \alpha |00>-|10> right ? $\endgroup$ – user1319236 Jul 5 '19 at 17:23
  • $\begingroup$ 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. $\endgroup$ – Mark S Jul 5 '19 at 23:23
  • $\begingroup$ Well because it's a 1 as control bit in the |10⟩ component $\endgroup$ – user1319236 Jul 6 '19 at 0:00

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.