# 7 Quantum Circuits

In the previous chapters, we learned the basics on how to construct a quantum computer. We will now start constructing quantum circuits from these. Note that we will no longer look into probabilistic system.

The quantum systems which we consider in the following sections consist of qubits, unless specified otherwise. A qubit is a quantum state \(\psi\) with \(\psi \in \mathbb{C}^2\).

## 7.1 Visual language

So far we have only seen the elements of quantum computers in a mathematical form. When constructing quantum circuits, this can get very unreadable very fast. Therefore we can draw quantum circuits as a picture, which also helps us to get a better intuition for these circuits. You can see a very simple example here:

In this circuit we have two qubits, which are drawn as separate wires. We first apply the unitary \(X\) on the top wire and at the same time we apply the unitary \(H\) at the bottom wire. Mathematically this can be written as \(X\otimes H\). Next we apply the unitary \(U\), which operates on both qubits. After this, we apply a unitary \(H\) on the bottom wire. Since we do not apply anything on the top wire, we can write this mathematically as \(I\otimes H\). Finally we measure the top qubit. This means a complete measurement in the computational basis of the qubit as described in Section 4.2.

## 7.2 Important gates

When working with quantum computers, we encounter some of the same unitaries very often. We distinguish between single qubit gates (unitary transformations \(\in \mathbb{C}^{2\times 2}\)) and gates on multiple qubits.

### 7.2.1 Single qubit gates

The following gates are relevant single qubit gates:

Note that \(X\) is also called bit-flip.

The Hadamard gate is useful for introducing superpositions as it takes a classical bit \(\begin{pmatrix} 1 \\ 0 \end{pmatrix}\) and transforms it into a superposition \(\begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}\).

### 7.2.2 Controlled-NOT gate

The gates introduced above only operate on a single qubit. To connect two different qubits, we need gates which operate on multiple qubits. For this we introduce the controlled-not:

## 7.3 Ket Notation

So far we have only seen vectors as a way to mathematically describe a quantum state. This can get quite inconvenient if the vector get bigger and also often contains not that much useful information (e.g. a lot of \(0\) entries). We therefore introduce a new form of writing quantum states called the *ket* notation.

The idea works as follows: We can rewrite a quantum state \(\psi\) in the following way \[ \psi = \begin{pmatrix} \psi_1 \\ \psi_2 \\ \vdots \\ \psi_N \end{pmatrix} = \psi_1 \begin{pmatrix} 1 \\ 0 \\ \vdots \\ 0 \end{pmatrix} + \psi_2 \begin{pmatrix} 0 \\ 1 \\ \vdots \\ 0 \end{pmatrix} + \dots + \psi_N \begin{pmatrix} 0 \\ 0 \\ \vdots \\ 1 \end{pmatrix} = \sum_{i=1}^{N} \psi_i \cdot e_i \] The vector \(e_i\) denotes the vector with 0 entries at every position except the \(i\)-th position, where the entry is \(1\).

From this notation we already get an advantage, since we can drop out all \(0\) entries. But we still have no intuitive mapping from the vector \(e_i\) to the classical possibility represented by \(e_i\). For this we use a \(\ket{}\) symbol. More precise this means for a classical possibility \(x\), which is the \(i\)-th possibility and is represented by \(e_i\), we write \[ \ket{x}:= e_i = \begin{pmatrix} 0 \\ \vdots \\ 0 \\ 1 \\ 0 \\ \vdots \\ 0 \end{pmatrix} \leftarrow \text{1 at the $i$-th position} \]

Note that the ket notation can also be used in a few other ways. We can use it as described above to describe the classical possibility \(x\) as \(\ket{x}\), but we also use it to emphasize that \(\psi\) is a quantum state by writing \(\ket{\psi}\) (here \(\psi\) is not a classical possibility). We also have two special cases \(\ket{+}\) and \(\ket{-}\) which are defined as follows: \[ \begin{aligned} \ket{+} &:= \frac{1}{\sqrt{2}} \ket{0} + \frac{1}{\sqrt{2}} \ket{1}\\ \ket{-} &:= \frac{1}{\sqrt{2}} \ket{0} - \frac{1}{\sqrt{2}} \ket{1} \end{aligned} \] Which of the meanings of the symbol \(\ket{}\) is meant has to be deduced from the context.