3

How do I embed classical data into qubits? I have a classical data [0 1] and I want to encode it as quantum amplitude to a superposition? What are the gates used to achieve that? I am a beginner to quantum programming?

glS
  • 27,670
  • 7
  • 39
  • 126

2 Answers2

3

Depending on your data there are multiple ways of doing so.

Consider the case of normalized and standardized data (i.e. data on the unit circle). A data point can be given by $(a, b)$ with $|a|^2+|b|^2=1$.

Now we can choose an angle $\theta$ such that $$R_Y(\theta)\lvert 0\rangle = a\lvert 0\rangle + b\lvert 1\rangle.$$ In a similar fashion this can be done for data on the unit sphere.

If your data is more than two-dimensional, you have a similar trick. Suppose you have data given by $(a_1, a_2,\dots,a_{2^n})$, with $\sum_i |a_i|^2 = 1$.

Now choose angles $\vec{\theta}$ such that $$U(\vec{\theta})\lvert 0\rangle = \sum_i a_i \lvert i\rangle,$$ for a suitable $U$. The difficulty with this is that you have to decompose $U$ in a sequence of one- and two-qubit gates.

nippon
  • 1,609
  • 10
  • 23
3

To embed classical data, you don't need superpositions. Bit values 0 and 1 correspond directly to the quantum states of a qubit written as $|0\rangle$ and $|1\rangle$. From a theorist's perspective, we don't worry about making these; it's a fundamental assertion that you can prepare, say, the $|0\rangle$ state. Then one just has to apply the bit-flip gate (also known as Pauli-X) to convert the 0 into a 1.

It's also worth noting that if you only want to perform a classical computation on these bit values (OK, why would you go to the effort of using qubits? but for the sake of argument...), you just rewrite your classical circuit as a classical reversible circuit. This can be implemented directly on the qubits. Each step will work exactly the same as it did on bits, it's just that instead of a register of $n$ bit values $x\in\{0,1\}^n$, you have a state vector $|x\rangle$ of $n$ qubits.

DaftWullie
  • 63,351
  • 4
  • 57
  • 142