3
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

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)
| improve this answer | |
$\endgroup$
2
$\begingroup$

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.

The fact is that in many cases, but not all, in IBMQ/Qiskit it is assumed that rz is implemented as u1, although actually rz(ϕ) is different to u1(ϕ) by a global phase exp(-iϕ/2) and this can be significant in cases like adding control to an unitary gate (in the answer you can see an example of the controlled version of this circuit, which would be incorrect if the crz gate were not replaced by the cu1 gate).

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 $\pm\pi/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

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ I would not use sx and sxdg gates decompositions from qelib1.inc, they are completely equivalent to rx($\pi/2$) and rx($-\pi/2$) gates, respectively. In the source code of the sx gate, you can see that you still need to add a global phase $\pm\pi/4$ to them, perhaps this will be correct. $\endgroup$ – Psanfi Aug 25 at 5:44
  • $\begingroup$ Correct point, I will edit the text of the answer in this part. $\endgroup$ – Aleksey Zhuravlev Aug 25 at 6:20
0
$\begingroup$

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

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Hello Aman, could you flesh out your answer a little? For a subject such as quantum computation, where the basics are significantly different from normal computation, to provide a little bit of explanation. $\endgroup$ – Niel de Beaudrap Oct 30 '19 at 10:45

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.