Search code examples
python-3.xlinear-algebraquantum-computingqiskit

How to create a new quantum gate and qubit initialised to a certain value


I am trying to implement the Quantum HHL algorithm on QISKit package of IBM on Python. I have tried searching the documentation for a method to initialize a qubit to a certain value and to create a new unitary gate with specified values.

In the documentation, I found this, which is the class of a Quantum Gate. I tried to make a new instance of this class but I couldn't because not much documentation has been done about the arguments to be passed while initializing the instance of the class.


Solution

  • As of QISKit v0.4.9, the u3() function parametrizes an arbitrary single-qubit unitary gate U(θ, φ, λ) (for details, see formula (2)). Obviously, you can use the u3() function to set a qubit to any value.

    For example, this is how you can implement the X-gate and apply it to some qubit qr[0] via the U3-gate:

    u3(theta=math.pi, phi=0, lam=0, q=qr[0])