How to implement the phase shift gate in qiskit or ibmq? Phase Shift Gate : $$\begin{pmatrix}e^{ia} && 0 \\ 0 && e^{ia}\end{pmatrix} = e^{ia}I$$
-
4$\begingroup$ Why would you want to? Such a phase is a global phase, and therefore irrelevant to further computation. $\endgroup$– DaftWullieJun 26, 2018 at 17:21
-
$\begingroup$ Maybe it's kind of what would you like to see theoretically. I am working in a problem where a two qubit gate is real (i.e. $\operatorname{SO}(4)$. After applying the decomposition of Kraus and Cirac, the one qubit gates are $\operatorname{SU}(2)$ matrices. Of course these complex phases have to cancel out in order to give $\operatorname{SO}(4)$, but if one wants to implement the gate directly this phase gate is needed. $\endgroup$– user2820579Apr 6, 2021 at 12:02
1 Answer
You can implement the phase shift gate
$$P_h(\theta) = \begin{pmatrix}e^{i\theta} & 0\\0 & e^{i\theta}\end{pmatrix}$$
with the X
and u1
gate from the IBM Q chips:
$$ \begin{align}
P_h(\theta) &= U_1(\theta)\ X\ U_1(\theta)\ X \\
&= \begin{pmatrix}1 & 0\\0 & e^{i\theta}\end{pmatrix} \begin{pmatrix}0 & 1\\1 & 0\end{pmatrix} \begin{pmatrix}1 & 0\\0 & e^{i\theta}\end{pmatrix} \begin{pmatrix}0 & 1\\1 & 0\end{pmatrix} \\
&= \begin{pmatrix}0 & 1\\e^{i\theta} & 0\end{pmatrix}\begin{pmatrix}0 & 1\\e^{i\theta} & 0\end{pmatrix} \\
&= \begin{pmatrix}e^{i\theta} & 0\\0 & e^{i\theta}\end{pmatrix}
\end{align}$$
So:
def Ph(quantum_circuit, theta, qubit):
quantum_circuit.u1(theta, qubit)
quantum_circuit.x(qubit)
quantum_circuit.u1(theta, qubit)
quantum_circuit.x(qubit)
implements the $P_h$ gate on Qiskit.
-
$\begingroup$ I'm wondering if $Ph(\theta)$ would be a better name for this based on "Elementary gates for quantum computation" 1995 paper from Barenco et al. $R_{zz}$ seems to be used for a two-qubit ZZ rotation. $\endgroup$ Jun 28, 2019 at 17:10
-
$\begingroup$ For me, $Ph(\theta)$ stands for $\begin{pmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{pmatrix}$. Moreover, I named this gate $R_{zz}$ because I have already seen this notation somewhere. I don't have references right now though, and you might be right. I'll check when possible. $\endgroup$ Jun 28, 2019 at 17:57
-
$\begingroup$ I see, please link the paper that uses it. $\begin{pmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{pmatrix}$ in my knowledge is $R_z(\theta)$ $\endgroup$ Jun 29, 2019 at 20:27
-
$\begingroup$ My sources are from a closed-source library, which is clearly not the best source I agree. I didn't search extensively in papers yet. After thinking about it, I think you are right, $Ph$ is probably a better name even though it is not the one I am used to. Let me edit, and thank you for the remark! $\endgroup$ Jul 2, 2019 at 12:21