Is it possible to perform $z$ rotation in Qiskit with just $x$ and $y$ rotations?

Is it possible to perform $$z$$ rotation in Qiskit with just $$x$$ and $$y$$ rotations?

I tried the following:

from qiskit import *
qc = QuantumCircuit(1)

theta = 0.5*np.pi
qc.ry(np.pi/2,0)
qc.rx(-np.pi/2,0)

qc.ry(theta,0)

qc.rx(np.pi/2,0)
qc.ry(-np.pi/2,0)


The code is based on (Realization of High-Fidelity CZ and ZZ-Free iSWAP Gates with a Tunable Coupler) (page 26), but it seems that I do something wrong.

• You should use theta more often, if not why defining it? Oct 1, 2021 at 14:13

The decomposition they give is the following:

$$R_z(\theta) = R_x\left(\pi / 2\right) R_y(\theta) R_x\left(-\pi / 2\right)$$

Therefore, the Qiskit code would look like:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Operator
import numpy as np

theta = np.pi / 4

qc = QuantumCircuit(1)
qc.rx(-np.pi / 2, 0)
qc.ry(theta, 0)
qc.rx(np.pi / 2, 0)

Operator(qc).data


Which gives output:

array([[0.92387953-0.38268343j, 0.        +0.j        ],
[0.        +0.j        , 0.92387953+0.38268343j]])


And we can see it is equivalent to $$R_z(\theta)$$:

qc = QuantumCircuit(1)
qc.rz(theta, 0)

Operator(qc).data

array([[0.92387953-0.38268343j, 0.        +0.j        ],
[0.        +0.j        , 0.92387953+0.38268343j]])

• Thank you! Operator data can really persuade that it is reall Z-gate. But how to visualize it, like population vs rotation angle in paper? If I remove -Y/2 and Y/2 in qiskit the result will be always |0> on the Bloch sphere. Oct 1, 2021 at 14:38
• Be careful, I guess the Qiskit calculation is right, but the sign should be inverted in your 1st equation. Oct 1, 2021 at 14:46
• @Mauricio thanks about that! Oct 1, 2021 at 14:48
• @epelaaez is it possible to visualize the result of such rotation on the Bloch sphere? without Y/2 and -Y/2 the final result always 0. Oct 1, 2021 at 14:57
• @epelaaez sounds fine, at least I think I get the point)) thank you so much for the link! it looks very "tasty" for learning!! Oct 1, 2021 at 19:16