Path: blob/main/notebooks/intro/describing-quantum-computers.ipynb
3855 views
Describing quantum computers
This chapter will introduce the different mathematical objects and notations that we’re going to be using to describe quantum computers. Symbols, equations and specialist vocabulary allow us to communicate and work with maths in a very concise way, they’re incredibly powerful tools, but they also come at a cost; they are difficult to understand if you don’t know what all the symbols mean, and this can alienate people. To counter this, in this textbook, equations are interactive. You can move your mouse over symbols to see what they mean. We will also slowly sprinkle in some esoteric words so you can start speaking the language of mathematics and quantum computing, and you can see explanations of these words by moving your mouse over these words too.
Amplitudes
A classical probability is often represented by a real number between 0 and 1, but amplitudes also have a direction. A natural candidate to represent an amplitude is a complex number, as a complex number can also be completely described by both a magnitude and a direction, but in this course we will only work with amplitudes that can point in two directions (e.g. left and right) and we won’t worry about anything else.
This makes the maths a lot simpler, as we can now describe any amplitude as a number between -1 and +1; if the number is positive, the amplitude is facing forward, and if it's negative, it's facing backwards. It turns out that this is still enough to do interesting things!
Quick quiz
Which of these is a valid amplitude but not a valid probability?
State vectors
We saw in the last page that we can predict the behaviour of a quantum system by keeping track of the probability amplitudes for each outcome at each point in our computation. We also saw that, for n qubits, there are possible outcomes, and we can store these amplitudes in lists of length which we call vectors. Since these vectors describe the state of our qubits, we call them “state vectors”.
Here is an example of a state vector for a quantum computer with two qubits:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{x-ket}{|x\rang…Spend some time reading the tooltips on the equation above, then answer the questions below.
Quick quiz
In the state vector above, what is the amplitude of the outcome ‘01’?
If the state vector above described the state of some qubits, what would be the probability of measuring ‘00’?
Adding and multiplying vectors
If you study other areas of mathematics, you’ll find that lots of things can be considered vectors. We’ve introduced vectors as ‘lists of numbers’, because this is how we will consider them both in this textbook and in Qiskit. But what separates a vector from any old list of numbers is that mathematicians decided on some well defined rules for adding two vectors, and for multiplying vectors by scalars.
Multiplying vectors by scalars
For example, here is a vector multiplied by a scalar:
ParseError: KaTeX parse error: Undefined control sequence: \cssId at position 1: \̲c̲s̲s̲I̲d̲{_number-three}…We can see that each element of the vector has been multiplied by 3. The more general rule for a vector with elements is:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{scalar}{s} \be…So we could have written the state vector we defined above more neatly like this:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{x-ket}{|x\rang…Adding two vectors
The second rule is for adding two vectors together. This is only defined when the two vectors have the same number of elements, and gives a new vector with the same number of elements. Here is the general rule:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 17: …begin{bmatrix} \̲c̲l̲a̲s̲s̲{_vec-el-0}{a_0…This means we can add and subtract vectors to make new vectors. For example, if we define the the vectors and like so:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{def-00}{|00\ra…We can write ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{x-ket}{|x\rang… in the form:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{x-ket}{|x\rang…We call adding quantum states like this “superposing” them, so we can say “ is a superposition of the states and .” In fact, it’s convention in quantum computing to define the computational basis states like so:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{def-00}{|00\ra…And we can write any quantum state as a superposition of these state vectors, if we multiply each vector by the correct number and add them together:
ParseError: KaTeX parse error: Undefined control sequence: \cssId at position 1: \̲c̲s̲s̲I̲d̲{_psi-ket}{|\ps…Since we can write any vector as a combination of these four vectors, we say these four vectors form a basis, which we will call the computational basis. The computational basis is not the only basis. For single qubits, a popular basis is formed by the vectors ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{plus-ket}{|{+}… and ParseError: KaTeX parse error: Undefined control sequence: \class at position 1: \̲c̲l̲a̲s̲s̲{minus-ket}{|{-…:
Try it
Find values for , , and such that these equations are true:
How many different state vectors are there?
We know that we can represent any quantum state using vectors, but is any vector a valid quantum state? In our case, no; since we square our amplitudes to find the probability of outcomes occurring, we need these squares to add to one, otherwise it doesn't make sense.
ParseError: KaTeX parse error: Undefined control sequence: \cssId at position 1: \̲c̲s̲s̲I̲d̲{sum}{\sum^{N-1…Quick quiz
Which of these is a valid quantum state? (Try adding up the squared amplitudes.)
Another factor is something we call "global phases" of state vector. Since we only know phase exists because of the interference effects it produces, we can only ever measure phase differences. If we rotated all the amplitudes in a state vector by the same amount, we'd still see the exact same behaviour.
For example, there is no experiment we could perform that would be able to distinguish between these two states:
Because the differences between each of the amplitudes is the same. You could say these two vectors are different mathematically, but the same physically.
Quantum operations
So now we know all about the different states our qubits can be in, it’s time to look at how we represent the operations that transform one state to another.
In the same way there is a transition probability that a certain action will transform a coin from heads to tails, there is a transition amplitude for each starting state and end state of our qubits. We can describe any quantum operations through these transition amplitudes.
So, what possible transformations are there? Say we have a starting state that’s transformed to a new state . If we want our representation to cover every possible transformation, then each amplitude in must have a transition amplitude to each amplitude in .
Quick quiz
An -qubit state vector can contain up to amplitudes. What’s the largest number of transition amplitudes we’d need to represent any quantum operation on qubits?
Drawing lines like this is a bit of a messy way of doing it, so instead we can put all these numbers into a matrix:
For example, here is the matrix that represents the CNOT operation we saw in the atoms of computation:
ParseError: KaTeX parse error: Undefined control sequence: \cssId at position 1: \̲c̲s̲s̲I̲d̲{_cnot-gate}{\t…Quick quiz
What is the transition amplitude of the CNOT operation (as shown above) transforming the state to ?
And here is the matrix for the H-gate we saw in the previous page:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 41: …begin{bmatrix} \̲c̲l̲a̲s̲s̲{_t_amp_0_0}{1}…(we use the same rule for multiplying a matrix by a scalar as we do with vectors). And when we want to see what effect an operation will have on some qubits, we multiply each transition amplitude by the amplitude of each state in our input state vector, and then add up the amplitudes for each state to get our output state vector. This is exactly the same as multiplying along each branch in a probability (or amplitude) tree and adding up the total probabilities (or amplitudes) at the end.
For any mathematicians in the audience, this is just standard matrix multiplication.
ParseError: KaTeX parse error: Undefined control sequence: \class at position 50: …begin{bmatrix} \̲c̲l̲a̲s̲s̲{_t_amp_0_0}{1}…Rules of quantum operations
In the same way that not every vector is a valid state vector, not every matrix is a valid quantum operation. If a matrix is to make sense as a real operation, it needs to keep the total probability of the output states equal to 1. So for example, this couldn’t be a real operation:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 17: …begin{bmatrix} \̲c̲l̲a̲s̲s̲{_t_amp_0_0}{1}…Because if it acts on the state we get:
ParseError: KaTeX parse error: Undefined control sequence: \class at position 17: …begin{bmatrix} \̲c̲l̲a̲s̲s̲{_t_amp_0_0}{1}…and the total probabilities add to two, which doesn't make any sense. Alternatively, if it acted on the state , then the total probabilities would add up to zero, which also doesn't make sense. To preserve the total probability in all cases, our operations need to be reversible. This means we can perform our quantum gates backwards to 'undo' them (remembering to reverse any rotations) and be left with the state we started with. We say matrices with this property are unitary. You will often see quantum gates referred to as 'unitaries' or 'unitary gates'.