1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ You should use theta more often, if not why defining it? $\endgroup$
    – Mauricio
    Oct 1 at 14:13
3
$\begingroup$

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]])
$\endgroup$
11
  • $\begingroup$ 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. $\endgroup$
    – Curious
    Oct 1 at 14:38
  • $\begingroup$ Be careful, I guess the Qiskit calculation is right, but the sign should be inverted in your 1st equation. $\endgroup$
    – Mauricio
    Oct 1 at 14:46
  • $\begingroup$ @Mauricio thanks about that! $\endgroup$
    – epelaaez
    Oct 1 at 14:48
  • $\begingroup$ @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. $\endgroup$
    – Curious
    Oct 1 at 14:57
  • 1
    $\begingroup$ @epelaaez sounds fine, at least I think I get the point)) thank you so much for the link! it looks very "tasty" for learning!! $\endgroup$
    – Curious
    Oct 1 at 19:16

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.