# Representing a real valued vector with qubits

I have some understanding that with qubits, I can represent a $$2^n$$ size vector using only $$n$$ qubits. However, I'm having trouble putting this together in a way that can make a useful circuit. Say I want to represent the input $$(0 \ 0 \ 0 \ 1)$$ for my circuit.

I should be able to do this with only 2 qubits. Starting with the initial state $$|0\rangle|0\rangle$$, which as far as I know represents the vector $$(1 \ 0 \ 1 \ 0)$$, I can use a not gate on the second qubit to transform that to $$(1 \ 0 \ 0 \ 1)$$. However, I'm not sure what operation I can do to put the first qubit into a $$(0 \ 0)$$ state.

On top of that, I have even less of an idea of how to represent real-value vectors, like $$(0.5 \ 0.5)$$ (assuming including a normalization constant). I have a feeling I can use phase, but I'm not sure how to set up a circuit to achieve this.

Edit: Realized my earlier representation was very off. The initial state $$|00\rangle$$ is the same as the vector $$(1 \ 0 \ 0 \ 0)$$, so transforming that into the the desired $$(0 \ 0 \ 0 \ 1)$$ Would just require two NOT gates:

0 -- NOT -- 1
0 -- NOT -- 1


However, I'm still unsure how to represent real-valued vectors, or even a vector like $$(1 \ 0 \ 1 \ 0)$$.

• Hi, Philip. Welcome to Quantum Computing SE! Please use MathJax for properly typesetting mathematical expressions). Go through How to write a good question? and consider editing your question appropriately. – Sanchayan Dutta Jan 2 at 21:28
• Thanks for putting in the effort! MathJax has a steep learning curve but it's extremely useful for proper typesetting and is worth the effort. As mentioned here, you should use \rangle to produce $\rangle$ and \langle to produce $\langle$. Don't use the greater than > and lesser than < symbols for the bra-ket notation. Also, when you're writing a column or row vector, make sure to put spaces or commas between the elements; you could use \ for generating a space. For example: $(1 \ 0 \ 1 \ 0)$. I've edited it in, this time. – Sanchayan Dutta Jan 3 at 14:27

$$(1,0,1,0)$$ means

$$1 (1,0,0,0) + 1 (0,0,1,0)$$

and you already know how $$| 0 0 \rangle$$ and $$(1,0,0,0)$$ correspond.

To make $$(0,0,1,0)$$ the encoding would be $$| 1 0 \rangle$$. I'm assuming you are reading the entries as 0,1,2,3 in that order for the vector and the first qubit corresponds to the most significant bit. (Little vs Big endian). If not, make the necessary changes.

So all together you need $$1 | 00 \rangle + 1 | 10 \rangle$$.

For other combinations like $$(a_0 , 0 , a_2 , 0)$$ change the coefficents. $$a_0 | 00 \rangle + a_2 | 10 \rangle$$

• That makes sense, but what would an example circuit be to create that? For the $(1010)$ case, it would be a superposition of $|00\rangle + |10\rangle$, so I could imagine using a Hadamard gate on the first qubit. However, I am still unsure how to encode an arbitrary constant – Philip Massey Jan 3 at 14:17
• If you are only looking at things like $(a_0,0,a_2,0)$ then you are only applying a unitary to the first qubit. You can fully parameterize those with Euler angles so figure out the angles in $R_X (\alpha) R_Z (\beta) R_X (\gamma)$ such that $| 0 \rangle \to a_0 | 0 \rangle + a_2 | 1 \rangle$. – AHusain Jan 3 at 15:47