# Qubits and quantum circuits

### Qubits

You can find 1,000,001 perfectly decent explanations of what a qubit is almost anywhere, so I’ll be brief here. A qubit is a quantum system which can be observed in exactly one of only two quantum states; a ground state, and an excited state. The physics of how they are realized is not our focus here, but there are several ways to build them, and more are actively being researched all the time.

We choose to write the state of such a quantum system as a vector in a 2-dimensional complex vector space. A qubit in the ground state is assigned the coordinates $$(1,0)$$, and a qubit in the excited state is assigned the coordinates $$(0,1)$$. These are given the labels $$|0\rangle$$ and $$|1\rangle$$ respectively. Beware that you don’t confuse $$| 0\rangle$$ with the zero vector $$(0,0)$$, which shouldn’t really appear unless we make a mistake. The way I remember these labels is by thinking

$$|0\rangle$$ means the zeroth coordinate is 1, $$|1\rangle$$ means the first coordinate is 1, …

This thinking extends extremely easily when we consider states of multiple qubits.

What I’ve just defined is called the computational basis, and while it is not the only set of basis vectors available to us, it is the natural and easy choice and I will stick to it throughout these articles. We are in the 2-dimensional complex vector space spanned by $$|0\rangle = \begin{pmatrix}1\\0\end{pmatrix},\qquad |1\rangle = \begin{pmatrix}0\\1\end{pmatrix}.$$ The fact (which I assert without proving but which I would argue is obviously true) that these two vectors span the space means we can construct any vector in that space by writing a linear combination of them, as in $$|\psi\rangle = \alpha_0|0\rangle + \alpha_1|1\rangle.$$ This isn’t just a mathematical point. The physic of quantum mechanics tells us that the state of this quantum system physically exists as just such a linear combination, so this is a real valid physical state for any two complex numbers $$\alpha_0$$ and $$\alpha_1$$. This is the principle of quantum superposition. We normally require that states are normalized, which is why we developed that function, which does place restraints on these complex numbers.

By the way, this is where qubits make their first major departure from classical bits. Bits may exist only as the discrete values 0 or 1; no linear combination is possible. So while a single bit may take on only two values, a single qubit in principle has an infinity of states to choose from.

### Quantum circuits

We’ll start with a quick primer on quantum circuits. We can draw a few analogies between these and classical logics circuits, but there are enough difference that it’s important not to take the analogy too far. Figure 1 is a picture of one of the simplest and most common quantum circuit components you will see, and we’ll use it to briefly explain the basic objects.

Starting at the left, what we see are two qubit states, both in the state called $$|0\rangle$$. Protruding out to the right are two horizontal lines, commonly called ‘wires’. However, these should not be interpreted as literal wires as in a normal electrical circuit. Instead, you should think of movememt to the right as advancement through time. The initial qubit states are defined on the left, and the states evolve over time as we apply various gates and operations to them. When we get to the end, we see the final state $$|00\rangle+|11\rangle$$.

How do we interpret this symbol? Easily enough: if I tell you that a 2-qubit system is in the state $$|01\rangle$$, it just means that the first qubit is in state $$|0\rangle$$ and the second qubit is in the state $$|1\rangle$$. This is more properly written as $$|0\rangle_A\otimes|1\rangle_B$$, which is the Kronecker product of the qubit state vectors, with the subscripts acting as labels for the different qubits. For brevity this is almost always written the shorter way, and I will always do so unless there is a particularly compelling reason not to.

Earlier I said that we can read $$|a\rangle$$ as “the $$a$$th coordinate is 1, etc”. This also works for states of multiple qubits, but be careful: $$|11\rangle$$ does not mean the 11th coordinate. If 11 is interpreted as being in binary notation, then converting it to base ten form gives $$(11)_{\textrm{binary}}=3_{\textrm{decimal}}$$. I’d encourage you to familiarise yourself with binary numbers and in particular how to convert them to decimal form.

It is natural to think of the the left-most qubit bank in Figure 1 as the initial state of a memory bank (or register), and the right-most qubits as the final state of that same memory bank after we have run our program. Due to the way we’re accustomed to reading and writing it is tempting to think of the initial state as an input and the final state as an output. I myself will use these terms, and while it’s not entirely incorrect, taking that analogy too far can cause confusion.

So, in order, this circuit

1. Initializes the state $$|0\rangle\otimes|0\rangle$$,
2. Applies the H gate to the top qubit, transforming its state in a way we will discuss later,
3. Applies the CNOT gate from to top qubit to the bottom qubit (more on this later)
4. Gives the final state $$|0\rangle\otimes|0\rangle+|1\rangle\otimes|1\rangle$$

This is a very special state as it is maximally entangled. This means that if you only measure one of the qubits, you know with absolute certainty what the state of the other qubit will be, without even having to look at it. Entanglement is a uniquely quantum resource and is responsible for much of the power of quantum computing.

It’s incredibly lucky that such a simple way to draw these circuits exists, thanks mostly to David Deutsch. It relieves a powerful visual aid in a field where the mental load is generally very high.

That’s probably enough for now. Next time I’ll introduce the most important/common quantum gates, and then we’ll start building a few simple circuits.

### Summary

Our functional repertoire hasn’t changed. We learned how to read qubit states and looked at a simple quantum circuit.