I want to be able to applied controlled versions of the $R_y$ gate (rotation around the Y axis) for real devices on the IBM Q Experience. Can this be done? If so, how?
2 Answers
You can make controlled $R_y$ gates from cnots and $R_y$ rotations, so they can be be done on any pair of qubits that allows a cnot.
Two examples of controlled-Ys are shown in the image below. They are on the same circuit, one after the other.
The first has qubit 1 as control and qubit 0 as target, which is easy because the cnots can be directly implemented in the right direction.
In the second example, qubit 0 is control and qubit 1 is target. This is achieved by using four H gates for each cnot to effectively turn it around.
This second example can also be optimized further. There are two adjacent H gates on the top line that can be canceled. And since H anticommutes with Y, $H\,u3(\theta,0,0)\,H$ can always be replaced with $u3(-\theta,0,0)$. (Thanks to @DaftWullie for pointing these out).
The single qubit gates used are $u3(\theta,0,0)$, which are $R_y(\theta)$ rotations. The angles used are pi/2 and -pi/2 in this case. These cancel when the control is $|0\rangle$. This gives the expected effect of the controlled-Y acting trivially in this case.
When the control is $|1\rangle$, the cnots perform an X either side of the $u3(-\pi/2,0,0)$, which has the effect
$X \, u3(\theta,0,0) \, X = u3(-\theta,0,0)$
This means that the $u3(-\pi/2,0,0)$ flips to $u3(\pi/2,0,0)$. The end effect on the control is then
$ u3(\pi/2,0,0) \, u3(\pi/2,0,0) \, = u\, 3(\pi,0,0) \, = \, Y$
which is a $Y$
A more general controlled $R_y$ rotation means that you want to do a fraction of a $Y$. So just reduce both angles by the corresponding fraction.
- 11,700
- 1
- 35
- 74
You can also (very easily) implement a multiple-controlled Y rotation gate using Qiskit. Notice that the number of single and two-qubit gates increases significantly for every extra control qubit. Therefore, the fidelity will decrease.
- 11
- 2

