# Hello Quantum: Taking your first steps into quantum computation

--

If you want to start playing with quantum computers, you’ve come to the right place. In this article we’ll get you started with the fundamentals of quantum computing. We’ll also show you how to start experimenting yourself with the IBM Quantum Composer.

If you want to start by doing things rather than reading things, check out the *Hello Quantum* game that this tutorial is based on, either for your iOS device or your Android device. There’s also a section of the Qiskit textbook where you can solve and learn about the puzzles in your browser.

But for those of you who would rather just read a blog post, let’s get on with it!

## The very basics

Before we get to quantum computers, what are normal computers?

Put simply, they are devices that store and process information using *bits. *These are simple chunks of information that take one of two possible values. We could call these values `True`

and `False`

, or `Yes`

and `No`

, or `On`

and `Off`

, but usually we call them `0`

and `1`

.

Quantum computers instead use *qubits*. These are quantum objects that can be made to give us a bit. While they are still quantum, we can play with them in ways that are impossible to do with bits alone. This can make them harder to keep track of, which is exactly why normal computers struggle to simulate them. But if we know what we are doing, we can harness them to solve problems that even supercomputers couldn’t manage within our lifetime.

## Asking qubits questions

The process of getting a bit from a qubit is essentially like asking a question. We can ask any of an infinite set of possible questions, each of which can be answered with a simple `0`

or `1`

.

Over the last few decades of studying qubits, two possible questions have become our favorites. So, despite our infinite set of choices, we usually just pick one of these.

The way we phrase our questions depends on the way we are describing the qubit. In this article, and in the game *Hello Quantum* we describe them in a visual way, using a pair of coloured circles.

One of our questions is to ask about the bottom circle in the image above. Is it black, or is it white? The other question is to ask the same thing about the top one.

Asking questions of qubits used to be something only scientists could do. Now anyone can have a go, with IBM Quantum.

We represent quantum programs using a collection of lines, each representing the life of a particular qubit.

The events in the life of a qubit are represented by the symbols that sit on the lines. To ask a question, you just need the right symbols.

Here’s the one you need to ask about the qubit’s bottom circle.

Since we are asking whether the bottom circle is black or white, the bit values we get as an answer will reflect these possibilities. We get a result of `0`

if the bottom circle is black, and`1`

if it is white. If it is neither, the qubit is in a bit of a quandry. It can only answer questions with a `0`

or `1`

, so it has no other answer to give. So in the case of an outline circle, it just randomly decides whether to give us a `0`

or `1`

.

To ask about the top circle, we need to use a couple of the symbols (which are called *gates*, by the way).

Asking this question will also result in an answer of `0`

or `1`

depending on whether the circle is black or white, but now it is the top circle that we are looking at.

You might have noticed something in the images above. When the top circle is certain of the answer it would give, the bottom one is completely uncertain. And vice-versa.

This is because a qubit can only be certain of its answer to one question at a time. This is due to fundamental uncertainty that exists within quantum systems. The qubit really doesn’t know how it would answer some questions, and only makes up its mind at the moment that it is asked.

So far we’ve just talked about one qubit. Now let’s play with two at once. We’ll represent the second qubit in a similar way to the first: as a rectangle containing two circles.

Thanks to the constantly present randomness, this description isn’t good enough. For example, here’s something we can do with a couple of qubits before they get measured.

This is a little quantum program for two qubits. We’ll get round to explaining all these components later in the article. But hopefully you can just accept it for now.

After we run this program, let’s ask both qubits about their bottom circles.

The results are random. So maybe all the certainty is in the top circles?

Nope! They are random too. Our qubits apparently have all outline circles.

Where has the certainty gone? To find out, try asking the questions at the same time.

Though both bottom circles give random answers, those answers are certain to agree. This is where our certainty has gone!

This is a pretty strange thing to happen. The qubits truly did not know how they would answer these questions until we asked them. But somehow, they conspired to always agree.

Accounting for effects like this is going to require some extra detail in our visualization of the qubit states. We need to keep track of whether the answers given by the two qubits agree or disagree. And we need to do that for all possible pairs of questions, whether the answers seem random or not.

Let’s start by adding another circle, nestled between the bottom ones for the two qubits. When we colour this black, it means that the bottom circles are certain to agree.

Now try asking both qubits about their top circle. You’ll find they are certain to disagree.

We’ll need to add in another circle to represent this. Let’s think of the image as a grid, and put the extra circle where the top rows meet. We’ll represent the certain disagreement by colouring this circle white.

We could also ask one qubit about its top circle and the other about its bottom circle. If you try these combinations of measurements, you’ll find that they are equally likely to agree or disagree.

This information also needs to be added to our picture. Another couple of circles are needed to fill in the blank spaces. To represent that fact that agreement (or disagreement) is random, we’ll use outline circles.

Now we have a picture that gives us a full description of the answers we expect, whatever questions we choose to ask.

## Giving qubits answers

Qubits all start off their life in the same way: When asked about their bottom circle, they’ll give the answer `0`

. This is called the`|0〉`

state.

So two qubits at the beginning of their lives will look like this

When you look at `|0〉`

, you are probably wondering about the `|`

and `〉`

. But there’s no need to worry about them too much They are basically there as labels, reminding us that this is not the number 0, or a bit value `0`

, but instead a description of a qubit. We could equally have flagged this up by colouring the 0 green, or drawing it on the crown of a princess. Feel free to use those conventions if you prefer.

If our qubits stayed `|0〉`

forever, our quantum computer would be pretty boring. So we need to do things with them. The simplest thing to do is flip the bottom circle from black to white, or back again. Just like flipping a light switch. This is done with the `X`

gate.

Note that this is sometimes also represented by the following symbol.

Doing an `X`

gate to a qubit flips its bottom circle. So if it was going to answer `0`

, it will now answer `1`

and vice-versa. This means getting a bottom circle that is white. This is called the state `|1〉`

.

Since random stays random, doing an `X`

to an outline circle won’t affect it.

Changing the bottom circle of a qubit also affects how it relates to other qubits. Agreements become disagreements, and vice versa. So the effect of `X`

will be to flip a whole row of circles.

In the image above, the `X`

gate is placed on the bottom line, since this corresponds to the qubit on the left of our image. To do an `X`

on the other qubit, we drag the `X`

gate over to the top line.

Sometimes we might also want to flip the top circle of a qubit instead. This is done by a gate called `Z`

. Here is it applied to the qubit on the left.

These operations, `X`

and `Z`

, are examples of *Clifford operations*. This fancy name just tells us that they are operations with a relatively straightforward effect on the circles. In fact, this visualization comes precisely from the way we like to think about Clifford operations and their effects.

There are other Clifford operations too. There is `H`

, which swaps the two circles of a qubit, as well as their corresponding rows.

With this we can change which questions the qubits have a certain answer to. For example we can take the state`|0〉`

, for which the bottom circle is black, and use the `H`

to swap that black circle up to the top. Then a qubit that was certain to answer `0`

when asked about its bottom circle now does so for the top.

The resulting state can’t be `|0〉`

, because that name is already taken. So we call it `|+〉`

.

If we do an `X`

before the `H`

, or a `Z`

after, we can make its top circle white instead. This is a state we call `|-〉`

.

These simple manipulations won’t help us do very much. If we want to use the full potential of quantum computers, we need to use gates that act on both qubits at once.

## Making qubits talk to each other

As we’ve seen, qubits only have a limited amount of certainty in their answers to questions. When programming quantum computers, our goal is to manage that certainty as best we can. We must guide it on a journey from input to output.

So far, we haven’t got many tools to help us to that. In fact, the `H`

gate is the only one that has moved the certainty around at all. It is hardly enough to explore the entire grid, as you will see by playing levels 1 and 2 of *Hello Quantum*.

To really get things moving, we need a new kind of gate. We need gates that act on more than one qubit at once. We need *controlled gates*.

One of the most important controlled operations is the the controlled-Z, also known as the `cz`

. This is the one we introduce in level 3 of *Hello Quantum*. At the time of writing, this was not yet available on the IBM Quantum Composer as a native gate. But if it were, it would look like this.

There are a few possible ways ways we can explain the effects of the `CZ`

. Each of these stories seem to be saying something quite different. But somehow, they are all equally true.

One is to say that the `CZ`

first looks at the bottom circle of the left qubit. Depending of whether this circle is white or black, the `CZ`

either does a `Z`

to the right qubit, or does nothing to it. The left qubit is therefore effectively acting like a switch, deciding whether the right qubit gets a Z or not.

Another explanation of the CZ is exactly the same as this, but with the roles of the two qubits reversed.

In these examples, it is the right qubit that acts like a switch and the left one that might get a Z. Though it is the exact same `CZ`

, it can be interpreted in the completely opposite way!

The third way of explaining the `CZ`

is quite different. We can think of it as simply something that moves circles around. Specifically, it swaps two pairs of circles. One pair on the left.

And another pair on the right.

Though this interpretation is fundamentally different from the other two, it still completely captures the effects of the `CZ`

. You can look at the same `CZ`

acting on the same state, and interpret in any of the three ways.

This explanation is not without its troublesome parts. Check out what it does to the circle at the very top of the grid.

In the first example, the circle at the very top was turned from outline to white. In the second, it turned from outline to black. What is the logic behind this?

It’s possible to solve all the puzzles of Hello Quantum without understanding this effect. But if you want to become a quantum programmer, you’d probably like to know what is going on. So we are going to give you the opportunity to find out for yourself!

The only reason this effect doesn’t seem to make much sense is that the grid is not quite big enough. The eight circles don’t fully describe a pair of qubits. For a complete description, we need to add another possible question. On the Quantum Composer, this question can be done with the following gates.

To keep track of what answers it will give, we need to add another circle to our description of each qubit.

Here the new circle is in the middle, and has been coloured a bit differently to highlight it.

To describe the possible outcomes of the middle circle, and all their possible agreements and disagreements with each other and the other questions, we need a grid with 15 circles.

With these, you can solve the mystery of the `CZ`

. And you can also check out how the `X`

, `Z`

and `H`

gates affect these new circles, as well as trying out new gates like `S`

. Just get playing with the new measurement on the Quantum Composer, and use your results to understand the bigger grid. For a guide on how to set up the Quantum Composer for this, see the article here. The specifics are very out of date, but the general advice is solid.

## Beyond Clifford

All the gates we’ve discussed so far are what we call Clifford gates. Each can be interpreted in terms of just swapping circles, or flipping them between black and white.

There is much we can do with Clifford gates. They are key to the way we move information around in quantum computers. They are also excellent at error correction, since they can be used to seek out imperfections, tell us where they are, and let is correct them.

For full quantum computation, however, we need something more. We need to move beyond circles that are just black, white or outline. We need to get ones that are ‘mostly black’ or ‘pretty much random, but a bit biased towards white’. We need to spread out the certainty, rather than keeping in little islands. Then after swishing it around the grid for a bit, we can recombine it in new and unexpected ways.

To do these things, we need the unimaginatively named *non-Clifford gates*.

There are none of these in the app version of Hello Quantum, but there is one in its sister game in the Qiskit textbook.

Also, the IBM Quantum Composer has a whole host of non-Clifford gates. The easiest ones to try are T and Tdg. You’ll need the full 15 qubit grid to figure these out, but you have all you need to have a go.

## Beyond two qubits

The game Hello Quantum helps you build up intuition and knowledge with just two qubits. Once you have that, you can begin tackling larger numbers.

To fully describe three qubits, we’ll again need to keep track of each of how it would answer the three questions. And we’d need to keep track of how answers to questions on one qubit agree or disagree with the others. And how does this relate to what the third one is doing? This needs a lot of circles. A cube full of 63 of them, to be exact.

Extend this to four qubits, and you need a hypercube of 255 circles. For n qubits, it takes 4ⁿ-1. The amount of information we’d need to keep track of increases exponentially with the number of qubits!

This means that visualizations like the one used in Hello Quantum will only ever be useful for small numbers of qubits. After all, if we could visualize what was going on in a large quantum computer easily, it would mean that we can easily simulate it. And if we could easily simulate quantum computers, there’d be no need to build them.

But there is a need to build them. By guiding information through this massive space of possibilities, we can find routes from input to output that would be impossible on a standard computer. Sometimes, these will be a lot faster. Some programs that would take a planet sized supercomputer the age of the universe to solve will be doable with much more reasonably sized quantum computers in a much more reasonable time.

But when you are starting out, it’s fine just to stick with just a couple of qubits.