How to prepare a random 1-qubit superposition for data encoding


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$?



Posted 2021-02-26T18:29:22.523

Reputation: 123



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)  


Posted 2021-02-26T18:29:22.523

Reputation: 6 322