# Quantum Computing

## Navigation

- Quantum bits
- Computational basis states
- General qubit states
- Common terminology
- Normalisation constraint
- Quantum logic gates
- Quantum circuits
- Multi-gate quantum circuits
- The Hadamard gate
- Measuring a qubit
- General single-qubit gates
- Unitary matrices
- The controlled-NOT gate
- Quantum computing summary

## Quantum bits

- Computers provide information through units known as
*bits*:- Bits are likely stored as tiny electric charges on nanometer-scale capacitors;
- A bit can have a state of either 1 or 0;
- Everything a computer does can be broken down into a combination of 1’s and 0’s.

- Similarly, quantum computers use quantum bits, or
*qubits*:- Just like a bit, qubits have a state;
- Whereas the state of a bit is a number (0 or 1), the state of a qubit is a vector;
- Specifically, the state of a qubit is a vector in a two-dimensional vector space;
- This vector space is known as
*state space*.

### Review:

- The quantum equivalent of a bit is a qubit;
- Qubits have a state;
- Much like a bit, that state is an abstract mathematical object;
- Whereas a bit’s abstract state is a number, 0 or 1, the state of a qubit is a 2-dimensional vector;
- We call the 2-dimensional vector space where states live
*state space*.

Henceforth we’ll use the phrase “classical bit”, after “classical physics” to describe the informational unit we are familiar with in ordinary computing.

## Computational basis states

There are two special quantum states which correspond to the

This notation with *ket* notation, and things like *kets*. Don’t be thrown off by the unfamiliar terminology – a ket is just a vector, and when we say something is a ket, all we mean is that it’s a vector.

- |0⟩ is a
*computational basis state*for a qubit, and plays much the same role as 0 does for a classical bit - There is a another computational basis state, denoted
, which plays the same role as 1 does for a bit$\mid 1\u27e9$ - Like
,$\mid 0\u27e9$ is just a notation for a two-dimensional vector, in this case:$\mid 1\u27e9$

## General qubit states

The computational basis states **two-dimensional vector**. Here’s an example, with a graphical illustration emphasizing the vector nature of the state:

The state

Quantum states are not only two-dimensional vectors, they are *complex vectors*, that is, they can have complex numbers as entries. So, for instance, another quantum vector is the state:

which can be written in the conventional component vector representation as:

## Common terminology

People will say a state like *superposition* of

Another common term is *amplitude*. An amplitude is the coefficient for a particular state in superposition. For instance, in the state

## Normalisation constraint

Recall that a quantum state is a two-dimensional complex vector. Actually, it can’t be just any vector—there’s a constraint. The constraint is this: **the sums of the squares of the amplitudes must be equal to 1**.

For example, for the state

In more general states, the amplitudes can be complex numbers denoted by alpha *normalization constraint*:

It’s called that because if you think of

Then the normalization constraint is the requirement that the length of the state is equal to 1. So it’s a unit vector, or a *normalized* vector, and that’s why this is called a normalization constraint.

The quantum state of a qubit is a vector of unit length in a two-dimensional complex vector space known as state space.

## Quantum logic gates

In a classical NOT logic gate, the input and output are swapped. An input of

On a computational basis, the quantum NOT gate does the same:

The computational basis states aren’t the only states possible for a qubit. When a NOT gate is applied to a general superposition state, that is,

NOT gates are usually denoted by the symbol

## Quantum circuits

So far we have seen algebraic ways of writing down the way the *quantum circuit* representation. In a quantum circuit we depict an

The line from left to right is what’s called a *quantum wire*. A quantum wire represents a single qubit. The term “wire” and the way it’s drawn looks like the qubit is moving through space. But it's often helpful to instead think of left-to-right as representing the passage of time. So the initial segment of wire is just the passage of time, with nothing happening to the qubit. Then the

Sometimes we’ll put the input and output states explicitly in the quantum circuit, so we have something like:

This may also be represented as a

## Multi-gate quantum circuits

A simple multi-gate quantum circuit is shown below. It’s just a circuit with two

Visualising this in a matrix representation:

Thus, this circuit would be equivalent to a quantum wire:

## The Hadamard gate

The first quantum gate, the *Hadamard* gate. Denoting the gate by

Just like the

## Measuring a qubit

- The quantum state of any system is not directly observable
- There is no way to figure out the identity of
or$\alpha $ if they start out unknown$\beta $ - The amplitudes are kind of a
*hidden information*

- There is no way to figure out the identity of
- Rather than somehow measuring these amplitudes, we can extract information by a process called
*measurement in the computational basis* - If we measure a qubit with state
in the computational basis, then the outcome is a classical bit$\alpha \mid 0\u27e9+\beta \mid 1\u27e9$ - Either
, with a probability$0$ $\mid \alpha {\mid}^{2}$ - Or
, with a probability$1$ $\mid \beta {\mid}^{2}$

- Either
- The corresponding state of the qubit after the measurement is
or$\mid 0\u27e9$ $\mid 1\u27e9$ - After the the measurement, no matter what the outcome,
and$\alpha $ are gone$\beta $ - This means you cannot store an infinite amount of classical information in a qubit

So the way a quantum computation works is that we manipulate a quantum state using a series of quantum gates, and then at the end of the computation (typically) we do a measurement to read out the result of the computation. If our quantum computer is just a single qubit, then that result will be a single classical bit. If, as is more usually the case, it’s multiple qubits, then the measurement result will be multiple classical bits.

It’s a single-qubit quantum circuit, with input the state *Hadamard* gate. The circuit finishes with a measurement in the computational basis, denoted by the slightly elongated semi-circle. The

## General single-qubit gates

We now know about the NOT and Hadamard gates, and also about the measurement process that can be used to extract classical information from our quantum circuits. In this section, let’s return to quantum gates, and take a look at the most general single-qubit gate. To do that it helps to recall the matrix representations of the NOT and Hadamard gates:

If the input to these gates is the quantum state

A general single-qubit gate works similarly. In particular, a general single-qubit gate can be represented as a *U*. If the input to the gate is the state

What does it mean for a matrix

So for a

The *dagger operation*, or *Hermitian conjugation, or just the *conjugation* operation. We’ll use all three terms on occasion.

As well as the *Pauli matrices*. These are useful tools in our quantum gate toolkit and they expand the repertoire of moves we have available to us. They’re crucial, for example, in protocols such as quantum teleportation and quantum error correction.

Another good example of a quantum gate is a rotation, the kind of matrix you’ve most likely been seeing since high school. It’s just the ordinary rotation of the 2-dimensional plane by an angle

## Unitary matrices

- Unitary matrices preserve the length of their inputs
- If we take any vector
and compute the length$\mid \psi \u27e9$ it’s always equal to the length$\mid \mid U\mid \psi \u27e9\mid \mid $ of the original vector$\mid \mid \mid \psi \u27e9\mid \mid $ - They’re much like rotations or reflections in ordinary (real) space, which also don’t change lengths
- In a sense, the unitary matrices are a complex generalization of real rotations and reflections

- This is good for qunatum gates because the input state will be normalized (have length 1), since that’s a requirement for a quantum state
- Fortunately, the length-preserving property of unitary matrices ensures the output state is properly normalized

Not only are gates unitary, to ensure that states remain normalized; also, quantum states are normalized, since measurement probabilities must sum to 1. It all fits together. In fact, it turns out that unitary matrices are the *only* matrices which preserve length in this way. And so a good way of thinking about unitary matrices is that they’re exactly the class of matrices which preserve length. That’s the geometric interpretation (and intuitive meaning) of the algebraic condition

## The controlled-NOT gate

We’ve developed most of the ideas needed to do universal quantum computing. We understand qubits, quantum states, and have a repertoire of quantum gates. However, all our gates involve just a single qubit. To compute, we need some way for qubits to interact with one another. That is, we need quantum gates which involve two (or more) qubits.

An example of such a gate is the controlled-NOT (or CNOT) gate. In the quantum circuit language we have two wires, representing two qubits, and the following notation to represent the CNOT gate:

- The top wire with the small, filled dot is called the
*control*qubit - The bottom wire with the larger, unfilled circle on it is called the
*target*qubit

The four computational basis states, corresponding to the four possible states of a two-bit system, are:

And, for a two-qubit system, not only can we have those four states, we can also have superpositions (i.e., linear combinations) of them:

The amplitudes

The CNOT gate operates very simply. If the control qubit is set to 1, as in the states

The CNOT can be thought of as a very simple kind of `if-then`

statement: `if`

the control qubit is set, `then`

NOT the target qubit. But while simple, it can be used as a building block to build up other, more complex kinds of conditional behavior.

Summing all four equations above into a single equation, suppose

The above equation makes clear that the CNOT leaves the control qubit **the CNOT is unitary**, and thus preserves the length of quantum states, as we expect.

Of course, the CNOT doesn’t just appear in two-qubit computations. It also appears in computations involving more qubits. Let’s suppose we have three qubits, for instance, and computational basis states such as

What goes on? Well, we can write out what happens on an arbitrary computational basis state,

CNOT has been described as a “classical” gate, but it can be combined with single-qubit gates to do non-classical things. An example is the diagram below, a two-qubit computation starting with the

Recall that for a single qubit the Hadamard gate takes

Next we apply the CNOT gate. This leaves the

This output state is a highly non-classical state – it’s actually a type of state called an *entangled state*. There’s no obvious interpretation of this state as a classical state, unlike say a computational basis state such as

## Quantum computing summary

We can summarize the three steps in a quantum computation as follows:

- Start in a computational basis state
- Apply a sequence of CNOT and single-qubit gates
- To obtain the result, measure in the computational basis. The probability of any result, say 00...0, is just the square of the absolute value of the corresponding amplitude

That’s all a general quantum computation is! If you understand this model, you know what a quantum computer is.