# How to decompose root iswap into root cz and single-qubit gates

Id like to decompose root iswap gate into root cz (not cz or cx) and single-qubit gates.

1)Is it possible to decompose like that?

2)Is there a way to do such a decomposition with qiskit, qutip, etc.?

## 1 Answer

So, you are given the $$\sqrt{iSWAP}$$ gate

from qiskit import QuantumCircuit
from qiskit.circuit.library import iSwapGate

qc = QuantumCircuit(2)
qc.append(iSwapGate().power(1/2), [0, 1])
qc.draw('mpl')


defined by the unitary operator $$\sqrt{iSWAP} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & \tfrac{1}{\sqrt{2}} & \tfrac{1}{\sqrt{2}}i & 0 \\ 0 & \tfrac{1}{\sqrt{2}}i & \tfrac{1}{\sqrt{2}} & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix}$$ and you want to decompose it by using $$\sqrt{CZ}$$ and single-qubit gates ($$U$$ rotations) only. In Qiskit, this is possible by passing the basis_gates argument (optionally including custom gates) to the transpile function.

However, in your case, first you have to define your $$\sqrt{CZ}$$ gate and then add to the Qiskit StandardEquivalenceLibrary the equivalence $$CZ = \sqrt{CZ} \sqrt{CZ}$$, since it is not included by default:

from qiskit.circuit.library import CZGate
from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel

sqrt_cz = QuantumCircuit(2, name='$$\sqrt{CZ}$$')
sqrt_cz.append(CZGate().power(1/2), [0, 1])

cz = QuantumCircuit(2)
cz.append(sqrt_cz, [0, 1])
cz.append(sqrt_cz, [0, 1])
sel.add_equivalence(CZGate(), cz)


Finally, you should be able to transpile your original circuit and draw its decomposition:

from qiskit import transpile

tqc = transpile(qc, basis_gates=['$$\sqrt{CZ}$$', 'u'])
tqc.draw('mpl')


• Is it impossible to create a root iswap with only two root cz and single-qubit gates?
– KTK
Commented Jan 9, 2023 at 13:44
• Yes, I think that is not possible. At least two $CZ$ or two $CX$ gates are needed. Commented Jan 9, 2023 at 17:57