# Implement a square root of Swap gate in using qiskit [closed]

Does the √SWAP gate have a ready-to-use function on the Qiskit circuit library?

If not, how to implement it?

I don't think √SWAP gate has a ready-to-use function in Qiskit. But it is easy to implement.

√SWAP unitary is: $$\sqrt{swap} = \left( {\begin{array}{*{20}{c}} 1&0&0&0 \\ 0&\frac{1}{2}(1 + i)&\frac{1}{2}(1 - i)&0 \\ 0&\frac{1}{2}(1 - i)&\frac{1}{2}(1 + i)&0 \\ 0&0&0&1 \end{array}} \right)$$

It is equivalent to:

So, it can be implemented as follows:

from qiskit import QuantumCircuit

circ = QuantumCircuit(2)
circ.cx(0, 1)
circ.csx(1, 0)
circ.cx(0, 1)


To verify:

from qiskit.quantum_info.operators import Operator
from qiskit.visualization import array_to_latex

op = Operator(circ)
array_to_latex(op)


And to use it as a gate:

sr_swap = circ.to_gate(label = '√SWAP')

qc = QuantumCircuit(2)
qc.append(sr_swap, [0, 1])

• Thanks for this comprehensive answer. Is there a command that prints out the truth table for this circuit? Oct 29 '21 at 11:43