3
$\begingroup$

I have come across most of the quantum circuit which contains gate such as controlled $V$ and $V^{\dagger}$ but I dont know how to code it in Qiskit.

The above image is the zplg gate circuit

$\endgroup$
5
  • $\begingroup$ What's the V gate again? :) $\endgroup$
    – Cryoris
    Jun 23 at 11:23
  • $\begingroup$ @Cryoris I think $V$ gate in this case should be $Rx(\pi/2)$. Look at section 1.2 here: arxiv.org/pdf/1509.03962.pdf But hopefully the OP can clarify. $\endgroup$
    – KAJ226
    Jun 23 at 15:05
  • $\begingroup$ Illustration seems to come from this paper. I do not have access to it, could someone check it and verify it is really a $Rx(\pi /2)$ ? $\endgroup$ Jun 23 at 15:47
  • $\begingroup$ @BrockenDuck The image is indeed coming from that paper. It is Figure 21 to be specific. On page 5, section 1.2 of the paper, it is stated that " $V$ is a square root of the NOT gate". And $R_X^2(pi/2)$ is indeed equivalent to $X$ up to an overall phase.... $\endgroup$
    – KAJ226
    Jun 23 at 16:13
  • $\begingroup$ But overall phase does matter in controlled gate.... that is $Controlled-U$ is not the same as $Controlled-e^{i\theta}U$. $\endgroup$
    – KAJ226
    Jun 23 at 16:17
3
$\begingroup$

$V$ is the square root of $X$. That is,

\begin{align*} V = \sqrt X = \frac{1}{2}\left( {\begin{array}{*{20}{c}} {1 + i}&{1 - i}\\ {1 - i}&{1 + i} \end{array}} \right) \end{align*}

It is implemented in Qiskit with the name $SX$. So, the circuit in your question is easy to implement:

from qiskit import QuantumCircuit
from qiskit.circuit.library import SXdgGate

qc = QuantumCircuit(4)

qc.cx(2, 3)
qc.cx(0, 3)

qc.csx(1, 2)
qc.cx(0, 1)

csxdg_gate = SXdgGate().control()
qc.append(csxdg_gate, [1, 2])

qc.csx(0, 2)
qc.cx(2, 0)

qc.draw('mpl')

enter image description here

$\endgroup$
1
2
$\begingroup$

I don't remember what is the V-gate, sorry, but I created something that you can easily change so you can put any gate you like.

The idea is to create the gate and then use the ControlledGate to create the control you like. I also put on there an example of how to create a control from an already existing gate, notice you can put more than 1 control.

from qiskit.circuit import Gate
from qiskit.circuit.library import HGate
from qiskit.quantum_info import Operator
from qiskit import QuantumCircuit

my_control_gate = Operator([[1.,0],[0,-1]]).to_instruction().control(1)
circuit = QuantumCircuit(3)
circuit.append(my_control_gate, [0,1])
circuit.barrier()
H_control = HGate().control(2)
circuit.append(H_control, [0,2,1])
circuit.draw()

This code will give you this :

Controlled Gates

Hope it helps, tell me if you need precision :)

$\endgroup$

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.