TransWikia.com

How can we construct a square root of NOT gate in Qiskit and IBMQ circuit composer using universal gates?

Quantum Computing Asked by jayanti singh on August 8, 2021

I have tried it with decomposing controlled S then conjugating with H gate. But I want to construct it using a minimum number of gates.

3 Answers

Use u3 function and rotate by an angle of 90 degrees.

Answered by Aman on August 8, 2021

To form a RNOT gate , the basic gate operations HAD and PHASE() can be used.

         ┌───┐┌───────────┐┌───┐ 
        ─┤ H ├┤ U1(-pi/2) ├┤ H ├─ 
         └───┘└───────────┘└───┘ 

Qiskit code

qc.h(reg)
qc.u1(math.radians(-90), reg)
qc.h(reg)

Answered by kalle olumets on August 8, 2021

Since the NOT gate from the question is the X gate in IBMQ/Qiskit, hereinafter we will call it only the X gate and, accordingly, the square root of the X gate or SqrtX.

How to construct SqrtX using the minimum number of gates, it depends on your purposes.

If the phase is not important for your purposes (e.g. you just looking for how to split the X gate into 2 equal gates assuming that their squares may differ from X by the global phase), then it may be constructed e.g. as:

 ┌──────────┐
 ┤ RX(pi/2) ├
 └──────────┘

in Qiskit:

qc.rx(np.pi/2, reg)

If the phase is important for your purposes (e.g. in cases as adding control to an unitary gate), then it may be constructed from the previous one by phase shift:

 ┌──────────┐┌───┐┌───────────────────┐
 ┤ RX(pi/2) ├┤ X ├┤ U3(pi,pi/4,5pi/4) ├
 └──────────┘└───┘└───────────────────┘

in Qiskit:

qc.rx(np.pi/2, reg)
qc.x(reg)
qc.u3(np.pi, np.pi/4, 5*np.pi/4, reg)

or like this (without RX):

 ┌────────────────┐┌───┐┌────────────────┐
 ┤ U2(-pi/4,pi/2) ├┤ X ├┤ U3(pi,0,5pi/4) ├
 └────────────────┘└───┘└────────────────┘

in Qiskit:

qc.u2(-np.pi / 4, np.pi / 2, reg)
qc.x(reg)
qc.u3(np.pi, 0, 5 * np.pi / 4, reg)

or as in my edition of the answer. As you see, this circuit is almost same as in the original of the answer but in my edition it uses u1 instead of rz.

Also SqrtX may be constucted by using the Qiskit's power method:

qc.append(XGate().power(1/2), reg)

or by using one of unitary matrices corresponding to the square roots of the X gate:

qc.unitary([[0.5 + 0.5j, 0.5 - 0.5j], [0.5 - 0.5j, 0.5 + 0.5j]], reg)

or by using Operator:

qc.append(Operator([[0.5 - 0.5j, 0.5 + 0.5j], [0.5 + 0.5j, 0.5 - 0.5j]]), reg)

or similarly, using UnitaryGate, squ/iso methods, qasm, etc (but be careful, Qiskit does not always accurately process the phase!).

PS. I already mentioned in another answer about my Qiskit program for small investigating of the various cases of the roots of X and Y, look if you are interested.

UPD: In new version of Qiskit 0.20.0 there are new gates, such as: SXGate, SXdgGate and CSXGate (i.e. SqrtX, SqrtX$^dagger$ and Controlled-SqrtX gates, respectively). Similar gates have also been added to qelib1.inc. The following decompositions of these gates is applied there (unlike the csx gate, these decomposition of the sx and sxdg gates are completely equivalent to the rx(π/2) and rx(-π/2) gates respectively, and if the global phase is important for your purposes, then these decompositions require adding it as $pmpi/4$ respectively!):

// sqrt(X)
gate sx a { sdg a; h a; sdg a; }
// inverse sqrt(X)
gate sxdg a { s a; h a; s a; }
...
// controlled-sqrt(X)
gate csx a,b { h b; cu1(pi/2) a,b; h b; }

UPD2: The new IBM Q system has a native implementation of the SqrtX gate along with other innovations: "The ibmq_montreal device has the following native gate set forachieving universal quantum computation: Ctrl-X (CX), Sqrt-X (SX) and Phase(θ)", for details see here

Answered by Aleksey Zhuravlev on August 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP