Let's assume we have a normalized data vector $\vec{x}= [x_1,x_2]$. How can I prepare a state $$|\psi\rangle = x_1|0\rangle+x_2|1\rangle$$ for any $\vec{x}$. I know that this state is in general not reachable through a single rotation, but is there a systematic way of finding a sequence of unitaries (let's call it $U_s$ here), that performs a transformation, such that $U_s|0\rangle=|\psi\rangle$?



Theorem: Suppose $U$ is a unitary operation on a single qubit. Then there exist real numbers $\alpha, \beta, \gamma, \delta$ such that $$ U = e^{i\alpha} R_z(\beta) R_y(\gamma)R_z(\delta) $$

This is on page 175 of this textbook.

Ignore the global phase, each of these gates can be implement directly on a quantum computer. So given a vector $\vec{x}$, you just work-out what $U$ needs to be, then find the appropriate angles $\alpha, \beta, \gamma, \delta$ . To find $U$ that takes $|0\rangle$ to $\vec{x}$, note that $U$ must take the form $\begin{pmatrix} x_1 & u_{12} \\ x_2 & u_{22} \end{pmatrix}$. To get the second column, pick some arbitrary vector that is independent from $\vec{x}$, then perform the the Gram-Schmidt process.

If you use Qiskit, you can initialize your state directly. For example:

from qiskit.quantum_info import random_state
from qiskit import QuantumCircuit, execute, Aer, IBMQ
provider = IBMQ.load_account()

num_qubits = 1
random_initial_state = random_state(2**num_qubits) #you can place specific vector here
circuits = []
circuit = QuantumCircuit(num_qubits,num_qubits)
circuit.initialize(random_initial_state, 0)  
  • $\begingroup$ +1 Note that you can avoid Gram-Schmidt and just set $u_{12} = \overline{x_2}$ and $u_{22} = -\overline{x_1}$. Substitute into dot product to see how this works. $\endgroup$ Mar 14 '21 at 8:37
  • 1
    $\begingroup$ @AdamZalcman Thanks for the comment. You made a good point. That will indeed create a unitary matrix. I was just trying to give a general procedure at how one can systematically do such thing. $\endgroup$
    – KAJ226
    Mar 14 '21 at 16:07

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.