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$$
Asked
Active
Viewed 3,879 times
1 Answers
17
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.
Adrien Suau
- 5,172
- 22
- 58