Path: blob/main/notebooks/intro/what-is-quantum.ipynb
3855 views
What is quantum?
What is a bit?
In the previous chapter we learnt that ‘bits’ are the world’s simplest alphabet, and that they can be used to represent any information. We also learnt that all modern computers store, and do operations on bits. So far, we’ve only thought about bits as abstract units of information, but to make a working computer, we need to make our bits out of real things. So how can we make a bit in the real world?
How can we store bits?
Punched cards
Punched cards
In the early days of computing, computer scientists stored bits by making holes in paper cards. These cards were divided into grids, and each cell in the grid represents a bit. If there is a hole in that cell, the bit is '1', if no hole, the bit is '0'. If you want to change the value of a bit, you can either punch a new hole, or patch the hole back up.

Compact disks
Compact disks
Compact disks were created in the '80s to store audio recordings using bits. The designers decided to use pits and troughs on the surface of the disk to represent their bits, and we can sweep a laser over the disk to detect them. The disk is read along a spiral line, divided into segments. For each segment, a flat surface represents a '0', and a transition from peak to trough (or vice-versa) represents a '1'.

Electron orbitals
Electron orbitals
You may remember from chemistry (don't worry if not) that particles called electrons orbit the center (nucleus) of an atom. You may also remember that these electrons can only orbit at specific (quantized) distances from the nucleus which we call shells. If we have a way of detecting which shell an electron is in, we can pick two of these shells and use the location of the electron as a bit. If the electron is in one of these shells, the bit is '0', and if it is in the other, the bit is '1'.

The behaviour of both cards and compact disks can be easily explained using classical physics: Physics is essentially a description of the world around us; we do experiments to see how the world behaves, and from this we try to work out what rules the universe follows. “Classical physics” is the name for the set of rules that scientists came up with before the early 1900s, and it’s really good at predicting the behaviour of things like cricket balls and car engines.
But the electron orbiting an atom is a bit different. Around the early 1900s, scientists started being able to study things on the atomic scale. They found that really small things like atoms behave differently to the things we interact with in our day-to-day lives, and in certain cases the rules of classical physics weren’t quite right. The physics they had needed modifying, so the scientists came up with a more accurate set of rules which became known as “quantum physics”.

Key experiments in quantum physics
For those interested, here are quick summaries of some events that led to the development of quantum physics. You don't need to understand these to read the rest of this course, this is just here for those that want to read more about the history and physics.
Hot things emit radiation as light, and the higher the temperature, the higher the frequencies of these light waves. If something only emits and radiates light (i.e., does not reflect it), we call it a ‘black body’. The theoretically perfect black body is not a terrible approximation of many real objects, including stars and planets.
Between 1900-1905, two scientists (Rayleigh and Jeans) used the rules of classical physics to derive an equation that describes how the temperature of a black body affects the frequency of its emitted light waves. The law they derived predicted that hot objects should emit a ridiculous amount of high-frequency (ultraviolet) light, which doesn’t match what we see at all.
Until this point, it was widely accepted that light was a wave. But another scientist (Max Planck) managed to show that, if light had to be emitted in quantized chunks (i.e., particles we now call ‘photons’), you could derive an equation that correctly described the relationship between temperature and emission that we can measure.
If you fire some particles through a hole onto a screen and recorded where they landed, you’d find more in the middle of the screen and less at the edges (the shape is actually a bit more complicated than this but we won't discuss that here). So, what would you expect to happen if you instead fired particles through _two_ holes onto a screen? If the holes were close enough, common sense says we’d see roughly the same thing, with maybe more particles making it through.
But when we try this experiment with small particles such as photons, electrons and even atoms, we see an interference pattern, even if we just send one particle through at a time! This experiment was done all the way back in the late 1700s with light, which lead scientists to believe light was not a particle but instead a wave. But as we saw with the ultraviolet catastrophe, this still wasn’t the entire picture.
Image by Jordgette - Own work, CC BY-SA 3.0, Link
For computer scientists, a natural question is: “What if our bits followed the rules of quantum physics instead of classical physics?”. We call these bits “qubits” for “quantum bit”, and computers that can operate on these bits are called “quantum computers”.
In the next section you can interact with one of these qubits (well, not really – we’re just simulating it - but we promise the behaviour is the same) and discover what 'quantum' is!
Exploring qubits
To explore quantum behaviour, we need to remind ourselves about probabilities. If you’ve read the previous chapter, all the operations we’ve seen so far have been deterministic. This means that, acting on the same input state, they will always give the same output state. Let’s take a look at a new operation that only acts on quantum bits: the Hadamard gate, which we will call the “H-gate” for short.
Exploring the H-gate
We’ve just seen some interesting behaviour: Two probabilistic operations, applied in sequence, seem to “undo” each other! In fact, this simple behaviour is so unusual we can’t describe it using probability trees. There just aren’t any numbers we can put on our branches that give the correct result in all cases.
You might be thinking, “maybe the H-gate knows it’s being applied twice, and behaves differently?”. This would count as another input into the gate, alongside the qubit’s state. You could describe this behaviour if you allow another hidden input to the H-gate operation that we can’t see directly. And in fact, this is sort of what’s happening.
Beyond probabilities
Probabilities are useful for when there are many possible outcomes and we don’t have enough information to work out which will happen, like a dice roll, or a coin toss. We give each outcome a probability and use these to work out the likelihood of something occurring. Probabilities work extremely well for things we usually see in the world around us, but with "quantum" things (like qubits), this approach fails, and we need to update it to explain the behaviour we’re seeing.
So, what’s the solution? To describe quantum mechanics, we can use probability amplitudes. Probability amplitudes are similar to normal probabilities in that:
amplitudes have a magnitude,
each possible outcome has a probability amplitude,
and the magnitude of that outcome's amplitude tells us how likely that outcome is to occur.
But amplitudes also have an extra property which we call "phase". You can think of phase as an angle, so whereas conventional probabilities only have a magnitude, amplitudes also have a direction.
More specifically, an amplitude is a complex number (if you don’t know what a complex number is, don’t worry about that just yet).
The result of phase is that, when we add two of these amplitudes together, they can cancel each other out, just like positive and negative numbers do. This behaviour is called interference and explains all the behaviour specific to quantum mechanics that we don’t see in classical mechanics.
Amplitude Addition Widget
We can see two amplitudes added together below. Try changing the size and direction of the amplitudes. What affect does this have on the size of the amplitude on the right?
To find the probability of measuring an outcome, we square the magnitude of that outcome’s amplitude. This is a mathematical ‘trick’ that makes everything add up nicely at the end.
In fact, the introduction of phases and amplitudes is also a mathematical trick, but it works so well that scientists eventually concluded it must exist. We never see phase directly, but we know it exists because of the interference effects it produces.
Explaining the H-gate

So, with this new tool in our box, can we describe the H-gate?
Seeing as we’ve taken you down this route, you can probably guess the answer is “yes”, and it involves phases. Let’s start by remembering how the H-gate acts on the state . Before the H-gate, the chance of measuring the state was 1, so the magnitude of the amplitude must be 1 too. We can’t tell what the phase is from this information, so we’ll just assume it’s 0.
After we apply the H-gate, we will measure either or with probability . Since we square the magnitudes of our amplitudes to get probabilities, the magnitudes of these two amplitudes must be . We can also say the same if we had started in the state . Again, we can’t get any information about how this transformation might affect the phases yet; they could actually be transformed in any way and we wouldn’t notice through this experiment alone, so we will not make any guesses just yet.
But when we apply two H-gates, we can start to make statements about the phases our amplitudes can have. At the end of our amplitude tree, we have four different branches that lead to only two possible outcomes. To work out the final amplitudes for these outcomes, we need to multiply along those branches and add the amplitudes together, just as we would a probability tree. To give a 0% chance of measuring , we need the amplitudes on the two branches that lead to to have opposite phases.
Since two H-gates in sequence give a deterministic result, the H-gate must always behave in the same way given the same input. Here's one guess for what might happen: Acting on the state, all output amplitudes point in the same direction, but acting on the state, the phase of the state is rotated 180°.
When we chain these trees together, we multiply along the branches and add up the final amplitudes for each state.
Let's start with the two branches that lead to the state . For the top branch, we do , and we add that to the other branch that leads to (for which we also get the ). Adding these together, the final magnitude of the amplitude of the state is . This means the probability of measuring is also .
Our model works so far, let's see what happens to the branches that lead to the state . Both these branches also end up with magnitudes of , but the branch on the bottom is pointing the other way. This means these two amplitudes cancel out! On the amplitude tree, we've used a minus sign to show that the H-gate has reversed the direction of this amplitude. The final amplitude of the state is then , which matches what we thought would happen!
So our amplitude model works! We now have a complete description of the H-gate.
Here, something interesting and counter-intuitive has happened; we use probabilities to account for lack of knowledge, e.g. if we toss a coin, it could be head or tails with equal probability. The reality is that the coin will be in one of these states and we use probabilities to deal with the fact that we don’t know which.
But with this amplitude model, we can’t say the qubit took a specific route (“ or ”) because we wouldn’t see the interference effect. This leads people to say things like “the qubit can be and at the same time!”, which isn’t necessarily an incorrect way to describe the behaviour of the qubit, but also isn’t especially useful to people learning about quantum computing. It’s important to remember that, because we don’t see behaviour like this in our everyday lives, we don’t really have common words for it, which is why scientists created the new words we’ll learn about in this course.
Neatening things up
We now have a working explanation of the H-gate using amplitude trees, but using trees can get messy quite quickly. There are so many branches and labels that even trees for a small number of qubits get very complicated. To simplify this, quantum computer scientists use mathematical objects called ‘vectors’ which, for our purposes, are just lists of numbers. At each point in our computation, we can use a vector to keep track of the amplitudes of all the possible outcomes.
We now have a pretty simple way of simulating qubits, so what’s the point of trying to create a working quantum computer when we already know how to perfectly simulate it using traditional computers? Well, for a small number of qubits, simulating is easy, but if we want to simulate quantum computers with large numbers of qubits, keeping track of all these amplitudes can be very time-consuming and require a lot of memory.
Quick quiz
If you have qubits, how many possible outcomes are there?
If you want to predict the behaviour of qubits using vectors like those above, you need to keep track of at most...
amplitudes
amplitudes
amplitudes
amplitudes
The number of possible outcomes doubles with each extra qubit we add, and if we use this technique, the size of our vectors will grow exponentially too. This isn’t true for every quantum circuit, for example, if we start with all our qubits in the state 0 and do nothing to them, then it’s pretty easy to predict what the output will be. But it seems to be that more difficult quantum circuits can only be simulated on classical computers through algorithms that grow exponentially with the number of qubits in the circuit. The upper limit for simulating a difficult quantum circuit tends to be somewhere between the 30-40 qubit mark.
Summary
We’ve learnt a lot in this chapter, but the key points are:
We can make bits out of objects that follow the rules of quantum mechanics, and we call these “qubits”
These qubits can be described using probability amplitudes, which are like classical probabilities but with “phase”
These amplitudes can cancel each other out (an effect called interference) and this is what causes the previously unexplained behaviour
The best algorithms we have for simulating qubits use exponential resources with the number of qubits, so simulating large numbers of qubits is out of reach for classical computers.
We have seen that quantum computers can do something classical computers can’t: simulating the behaviour of qubits! The classical computer needs exponential resources, but the quantum computer can just carry out the operations and see what happens. The next interesting question is: “Can a quantum computer solve any other problems that a classical computer can’t?”. In this course we’ll see the answer is “yes”!
Exercise
All the qubits on this page have been simulated using classical programs designed using this amplitude model, so why should you believe that's how actual qubits behave? If you want to play around with real qubits on a real quantum computer, check out the IBM Quantum Composer. Why don't you try and recreate this experiment and run it on a device?
You will see lots of other gates and instructions there, most of which we have not covered before. In IBM's composer, if an instruction is grey, then it is not a quantum gate and won't follow the amplitude rules we've discovered in this chapter.
Try it yourself
Using your knowledge of amplitudes, see if you can work out how these gates transform amplitudes:
The X-gate
The Y-gate
The Z-gate
Don't worry! This is a pretty tough exercise, so we'll give you a clue. Each of these three gates (X, Y and Z) will only perform at most two actions: They can swap the amplitudes of the states and :
and/or they can reverse the direction of the state :
Create small circuits with these gates and with H-gates. Try sandwiching the gate you're investigating between two H-gates. Guess the behaviour of each gate and draw amplitude trees to see if you're correct.
Try creating different circuits with H-gates, Z-gates and X-gates: Does your model still predict the right results?
Try in the IBM Quantum Composer