2

I would like to make a single-qubit gate which gives |0> or |1> with reference to a parameter.

For example, I set a parameter theta in range of 0 to 2π. When theta is in range of 0 to π, the gate returns |0> and when theta is in range of π to 2π, the gate returns |1>.

I am in the environment as follows:

  • Qiskit: 0.12.0
  • Python 3.7.3 .
Ashy
  • 159
  • 5

1 Answers1

3

Quantum gates don't "return" a state, they transform a qubit state into another one. A singe-qubit quantum gate is represented as a 2x2 unitary matrix, and the way it transforms the qubit state is represented as matrix multiplication of this matrix and a vector of length 2 which represents the input state. So the closest to the thing you're trying to do is a gate which transforms an arbitrary input state to |0⟩ or to |1⟩ depending on the value of the parameter.

Quantum gates also have to be reversible, i.e. you need to be able to undo the transformation. The transformation you described makes it impossible, since multiple inputs are mapped to the same output, and you can not recover the input state from the result.

Non-reversible transformations are done not using gates but using measurements. If you need to collapse the input qubit to |0⟩ or |1⟩ depending on a parameter, you can measure it, and depending on the measurement result and the state you need, apply an X gate to the qubit. I.e., if the qubit was measured in the |0⟩ state and you need a |1⟩ (or vice versa), apply X gate, otherwise don't apply it.

Mariia Mykhailova
  • 1,668
  • 1
  • 6
  • 18