Tuesday, 19 April 2016

Entanglement with the simplest maths possible


This is part of a project to get people involved with quantum error correction. See here for more info.

You have probably heard that quantum mechanics is weird. You may also know that it has some strange correlations, known as entanglement, which are a big contribution to that weirdness.
In this post we will try to show that it's not all that weird, and that you can understand it without complicated maths. We'll also show how you can use entanglement to do something that no boring normal correlations can do: Teleportation!

This is a sequel to my earlier, and surprisingly successful, post on the maths of qubits (also known as 'Quantum mechanics with the simplest maths possible'). It also provides some of the maths behind my recent posts on quantum error correction. Nevertheless, I'll try to keep it pretty self-contained.

The story so far...

We are dealing with the simplest kind of quantum system. Some call them qubits. Some call them spin-1/2s. It doesn't matter what names we use though, so we'll just choose the ones that make our life easy.

A qubit can be in one of two states: up or down. You can ask it whether it's in state up or down: we call this a measurement. When it is up, it is not down. When it is down, it is not up. If it were neither, it would not be a qubit. So far, so normal.

But a qubit is quantum. It can be undecided about whether to be up or down. This is described by two numbers, which we call the upness and downness. When it is definitely up, its upness is 1 and its downness is 0. When its down, its upness is 0 and its downness is 1. When its undecided, both are somewhere in between. These are called quantum superpositions.

If we measure whether it is up or down, it will be forced to choose. The probability of choosing up is the upness squared (i.e. upness × upness = upness2). The probability of down is the downness squared. Since it must be up or down, adding up the probabilites for the two must give us 1. So

upness2 + downness2 = 1 .

In some sense, these probabilities are the true measures of how biased the qubit is towards up and down. So the actual upness and downness can be a bit crazy as long as they still make sense as probabilities when squared. The consequence of this is that the upness and downness can actually be negative numbers if they want, because negative numbers still square to positive numbers.

For example, imagine a qubit with an upness of 1, and one with an upness of -1. What's the difference? Well, the one with an upness of 1 is just the state up. For the other, if we ask whether it's up or down it'll answer 'up' with probability (-1)= 1, which makes it a certainty. And if it is certain that its own state is up, with no regard to the strange minus sign, who are we to argue?

To do maths we need some way of writing the superpositions down. If we have some state that we want to call S, we write it down like this.

S = (upness of S) x up + (downness of S) x down

Here we have written quantum states in an equation as if they were numbers, which might be a bit confusing. We have to remember what is a number and what isn't. So, from now on, all quantum states will be underlined.

S = (upness of S) x up + (downness of S) x down

That's better! This includes all the relevant information, and looks nice and mathsy.

This equation has a x and a + in there, which look like multiplication and addition. However, unlike normal multiplication, the one here doesn't multiply numbers together. Instead it multiplies a number with a quantum state, whatever that means. Nevertheless, when we do algebra type stuff with them, they follow the same rules as multiplication and addition. So let's just pretend they make sense.

Two of our favourite states are called left and right. The state called right is a superposition of up and down that has the same upness as downness.

right = √½ × up + √½ × down,

Left is the same, but it has a negative downness.

left = √½ x up + (-√½) x down

It turns out that these are as different from each other as up and down. This is because of the minus sign, which does interesting things with the maths when part of a superposition as we found out last time. And because these states are completely different, we are also allowed to measure whether our qubit is left or right.

What if we have a qubit that is in the up state and we measure whether it is left and right? Well, just as left is a superposition of up and down, up can be thought of as a superposition of left and right.

up = √½ × left + √½ × right

So if we do the left/right measurement, the qubit will have to decide one way or the other. 

It's not just the up state can be thought of as a superposition of left and right. Anything can

S = (leftness of S× left + (rightness of S) × right
= (upness of S) x up + (downness of S) x down

Entanglement

In the original draft of this post, there was a bunch of stuff about how to describe pairs of qubits,  and some of the details about some of the more interesting measurements for them work. But that made everything far too long. All that stuff was moved to its own post: Fun measurements for pairs of qubits. So if you want the full experience, check that out before you continue.

I'll assume you're skipping it, so let's take a few paragraphs for a very brief overview of the world of two qubits. For this we need to know what the possible states of two qubits are. Each qubit has two possible states: up and down. So two qubits have four possible states: both up, both down, the first one up and the second one down and vice-versa. Let's call these uu, dd, ud and du. The kind of superpositions that you can get for two qubits then look like this

uuness x uu + udness x ud + duness x du + ddness x dd .

If we simply have something like uu, the two qubits are in their own state and don't really care what the other is doing. This is also true for the state

½ uu + ½ ud + ½ du + ½ dd

Despite having lots of fancy superpositions going on, it turns out that this is just another way of writing that both qubits are in the state left. Again, they are both doing their own thing, without any relation to the other. There are lots of states like this. They are called separable states.

Separable states are not so intesting. More interesting would be something like

 √½ x uu + √½ x dd

Here the qubits are in a superposition of being up and down, but they will always be the same. So if one gets measured and decides to be up, the other will somehow instantly know about it. Then if it gets measured, it can give the same result. States that are correlated like this are more interesting than separable states. They are called entangled. In the rest of this post we'll look at how the kind of measurements that can create entanglement, and see how it can be used to teleport.

This will by no means tell you everything you need to know about entanglement. As a quantum information theorist, I find it best to try and understand entanglement by looking at what it can do. Teleportation is part of that, but we'll also look at other things like non-locality in the future.

Bell Measurements

What kind of measurements can we do for two qubits? Well we could just measure both to see if they are up or down. But there's another possibility, that's a bit less disruptive. This looks at the up and down states, but only tells you whether these states for the two qubits are the same or different. So if they are in the state uu or dd, it gives you the result same. Crucially, it would do this also for any superposition of uu and dd, without messing up the superposition. Similarly, ud, du or any superposition thereof would give the result 'different'.

This measurement is called ZZ. It has a friend, XX, which does the same thing but with the states left and right. These measurements are also ones that play nicely together. Suppose you have a state for which you know what the outcome of the ZZ measurement would be, but instead measure XX. This might force a decision out of the qubits and change the state. But whatever changes happen, the outcome for the ZZ measurement will stay the same. This sounds quite normal, given that this is exactly how measurements work in our world of big things. But in quantum mechanics, measurements working well together like this is a rarity.

After doing a ZZ measurement, we know exactly how the up/down states of our two qubits are correlated. After doing an XX we know the same for the left/right states. Because they play nicely together, after doing both of these measurements we know about both types of correlation at the same time. This gives us a state of two qubits that are correlated state in an interesting way. The combination of an ZZ and XX measurement must therefore be quite an interesting measurement. For that reason, it gets its own name: a Bell measurement.

Suppose the results to both XX and ZZ came out 'same'. Because they play nicely together, we know that they'd definitely give the same results if we did the same measurements again. There is only one state that give these definite answers. It's one with a lot of quantum entanglement, and is called Φ
Φ = √½ x uu + √½ x dd = √½ x ll + √½ x rr
 
For the other three possible combinations of answers we would get three similar states, called Φ', Ψ or Ψ'.

Bell measurements are pretty useful. Suppose we take some boring state like uu, which is not entangled. If we then we do a Bell measurement, they will be forced to be one of these four entangled states. They are boring no longer.

Bell measurements are named after J. S. Bell, who was the first to really show that entanglement could do things beyond the abilities of normal correations. The four states Φ, Φ', Ψ or Ψ' are call the Bell states, or Bell pairs.

Quantum Teleportation

Now we have Bell measurements we can do fun things. One of those fun things is teleportation! 

Here's the situation. There are these two guys: Alice and Bob. They met ages ago, at a conference or something. They did a Bell measurement on a couple of qubits and got the state Φ. Then they went home to their own labs, each taking one of the qubits of the Bell pair.

Much later, Alice gets a spare qubit. She doesn't know what the state is. Maybe its even entangled to some other stuff. She doesn't know. She doesn't care. She doesn't want it.

But Bob does. He really wants it. I don't know why. Alice could just send it to Bob, but sending it so it doesn't get messed up by noise is really expensive. He doesn't want it that much! Is there a cheaper way from Alice to send it to Bob?

Perhaps Alice could measure it, work out what it is and just tell Bob. Unfortunately, it cannot be so simple. What measurement would she do? If she did an up/down measurement, it would have to choose to be up or down. If it was actually left or right, we wouldn't know. If it was entangled to something else, that entanglement would be destroyed. So she won't have given Bob what he wanted. She would have messed it up. But Alice knows her quantum mechanics, so she doesn't do this.

What could she do instead? Maybe they could use that Bell pair they've been sitting on.

Before we look at how to do this, lets just recap a little. Alice and Bob have three qubits between them, one is a some state S and the other two are a Bell pair. Alice has two (the spare one and half of a Bell pair) and Bob has one (half of a Bell pair).
Alice wonders what would happen if she forced her to qubits to become a Bell pair, by doing a Bell measurement. Then there would still have a Bell pair, but now Alice would have it all. So what would Bob have? Alice thinks that, to make everything nice and symmetric, he must end up with the state of the spare qubit.

Bob is skeptical. He thinks that the Bell measurement might end up extracting some information about the spare qubit. As we saw before, that would be bad and mess it up.

Alice can easily counter this. Her half of the Bell pair is randomly either up or down, and no-one knows which. This randomness will make the outcome of a ZZ measurement random too, whatever the state of the spare qubit is. The same is true for an XX measurement. In neither case do we find out anything about the state of the spare qubit.

Bob is still not convinced. He thinks that it might cause the state of the spare qubit to just be destroyed. This perhaps seems reasonable. His half of the Bell pair has never even been near the spare qubit, so how could it magically acquire the spare qubit's state? And information gets lost all the time in our everday human world. Why wouldn't qubits suffer the same.

Alice nevertheless sticks to her guns, and demands they do the maths to see who is right. For that we'll to work out how to describe three qubits. But that's not much different to two qubits, which isn't too much different to one qubit, so we'll dive straight in.

For the unknown state S of Alice's spare qubit, we'll need to write it in the most general way possible.

S = (upness of S) x up + (downness of S) x down

The Bell pair is in the state
Φ = √½ x uu + √½ x dd

Now lets write the state of all three together, and do so as some superpoistion of the three qubit states uuu, uud, udu, etc. For this we'll think of the first qubit as Alice's spare one, the next one as Alice's half of the Bell pair and the last as Bob's half of the Bell pair. So the state uud would mean that both of Alice's are up, and Bob's qubit is down.

To write down the correct three qubit state, we'll need to calculate the uuuness, the uudness and all the rest. We can get the uuunes by multiplying the upness of the spare qubit and the uuness of Φ

uuuness = (upness of S) x √½ ,

And so on for all the others. Because

uddness = (upness of S) x √½ ,
duuness = (downness of S) x √½ ,
dddness = (downness of S) x √½ ,

All the rest are zero because they would need the two qubits of the Bell pair to be different, and Φ does not allow that.
All in all, we get the three qubit state

(upness of S) x √½ x uuu + (upness of S) x √½ x udd
+ (downness of S) x √½ x duu + (downness of S) x √½ x ddd .

If Alice makes a ZZ measurement on the first two qubits, there's some parts of this state that will give the result 'same' (namely uuu and ddd), and some parts that'll give 'different' (udd and duu). This means the qubits have to decide one way or the other when she makes the measurement. Let's suppose they decide to be the same. The state after measurement will then be

(upness of S) x uuu + (downness of S) x ddd .

Here we've also removed a the √½ for each state. This is just something we need to do after measurements, to make sure the numbers that should add up to 1, still do.

The state we get here is quite interesting. We now have all three qubits entangled together, and the information about the state of the spare qubit is now spread over all three. It's as if all three qubits are now working together to be the spare qubit. If you wanted to measure whether it was up or down, you could do it by measuring any of the three.

Now we are part way there. Bob has a share in the spare qubit state, and could even do an up/down measurement if he wanted. But he might want to do other, more interesting things. For that he needs complete control of the spare qubit state, so Alice needs to somehow give up her part.

By doing an XX measurement she will not get any information about the spare qubit state, as we discussed earlier. She will also force her two qubits to be a Bell pair. This is because she will know definitely the outcomes of both and XX and ZZ measurement, and only Bell pairs can do that. So she'll have no information about the spare qubit, either in her measurement results or her qubits. So Bob must have it all.

Let's make sure by doing the maths. For that we need to know a little more about the state Φ'. Unlike Φ, which gives the result 'same' for both an ZZ and XX measurement, Φ' will always say 'same' for ZZ and 'different' for XX. In the mathsy way, it looks like this

Φ' = √½ x uu + (-√½) x dd = √½ x lr + √½ x rl

Using this, and the mathsy form of Φ from before, we can see that uu and dd can be though of as a superpositon of Φ and Φ'

uu = √½ x Φ + √½ x Φ'
dd = √½ x Φ - √½ x Φ'

So the state that we got after the ZZ measurement can be rewritten

(upness of S) x uuu + (downness of S) x ddd
= (upness of S) x √½ x (Φ u + Φ' u)
+ (downness of S) x √½ x (Φ d - Φ' d)

Here Φ u describes the state where Alice's two qubits are in state Φ and Bob's one is in state u, etc.

When Alice makes the XX measurement of the her qubits, she gets the result 'same' or 'different'. The same result is consistent only with Φ, and the different result is consistent only with Φ'. So if she gets 'same', the state afterwards is

(upness of S) x Φ u + (downness of S) x Φ d

Again we've removed each √½, because that's what you do after measurements. In this state we find that Alice's qubits always have the state Φ. So all the superposition stuff is actually just because Bob's state is

(upness of S) x u + (downness of S) x d

This is exactly the state of the spare qubit, just as he wanted.
It worked! Alice was right! If she makes the ZZ and XX measurements, and gets the result 'same' for both, Bob's qubit magically acquires the state that the spare qubit used to have. Even though his qubit never went anywhere near the spare one!

But what if Alice gets different results? For the other three options for her Bell test, Bob will get the one of the following states

(upness of S) x up + ( - downness of S) x down
(downness of S) x up + (upnness of S) x down
(downness of S) x up + (-upness of S) x down

For the first one the downness has got a minus sign in front of it. But that's okay, Bob just needs to do something called a phase flip to get his qubit into the state it should be. For the second we have the upness and downness the wrong way around. But Bob can use a bit flip to correct that. For the last, Bob just needs to do both
But it is important that Bob knows exactly which flip to do. So he needs Alice to tell him the result of her measurement. She just gets on the phone, tells him and then he does it. Then he always has the state of the spare qubit, just as he wanted.

Without this information, all he knows is that he randomly has one of the four possibilities. That doesn't do him any good. In fact, there's no way to tell the difference between that and his half of the Bell pair, so he can't even tell whether or not Alice has done the measurement yet. That's good, because this would allow Alice and Bob to communicate instantly, which the theory of relativity does not allow. So without knowing anything about the speed of light, the maths we've used to describe quantum states have nevertheless made sure that we can't communicate faster than it.

When Bob does get Alice's result (which is just some random outcome that gives no information about the spare qubit state) and combines it with his qubit (which never met the spare qubit) somehow that combine to form the spare qubit state. That's that magic of entanglement!

I think that one interesting thing here is that quantum mechanics had a choice. It could either allow information to get deleted from the universe, or allow states of qubits to magically be transported far away Star Trek style. It chose Star Trek. Quantum mechanics is weird, but it's good weird.

Footnotes
1. This is the same as asking whether there are an even or odd number of downs, as we do in this post on quantum error correction. If there are even, it means uu or dd, so they are the same. Odd means ud or du, so they are different.



Monday, 18 April 2016

10 - The Toric Code (part 5)

This is part of a project to get people involved with quantum error correction. See here for more info.

I'm going to jump straight in with this post. If you want an intro, see part 4.

Protecting against measurements

We have information stored in a toric code, which is a grid of noisy qubits. If they get hit by bit flips, its mostly fine. The only way for bad things to happen is if a load of bit flips happen all at the same time, and do so on a loop that goes around the doughnut. That's unlikely, so we're mostly okay.

Bad things also happen if the qubits get measured on a loop through the doughnut. Currently we have no way of detecting or correcting these, so they will build up over time and soon mess up our logical qubit. So how can we manage them?

Currently we have a rule for each white square: each must have an even number of 1s around it. By looking at which of these rules are broken, we can work out how to get rid of the bit flip errors. But let's forget about these rules for a while. Instead we will come up with some new rules that can be used to detect the measurements. Once we've worked those out, we can try the two sets of rules play well together.

Rules for blue plaquettes

Let's now think about the code using the + and – states from last time. With these we can declare a rule for each blue squares: when looked at in terms of + and -, each must have an even number of -'s (and therefore an even number of +'s).

There are many possible patterns of +'s and -'s that obey these rules. Here's a few.

These should look pretty familiar. They are the same ones as before, but with 0 replaced with +, 1 to –, white squares with blue and everything turned 90 degrees.

Now we go off and get a cup of tea, and a Gremlin sees an opportunity for some mischief. It measures one of the qubits to see if it is 0 or 1. Every qubit here is + or -, both of which are a superposition of 0 and 1. So the measured qubit will randomly choose one or the other. Let's say, for sake of argument, it chooses 0.


When we get back from our tea break, we check whether the blue squares are following the rules. Most are, but what about the two near the measured qubit?

When we measure those squares, we are asking them to look at how many of the qubits are in state +, and how many are in state -, and tell us whether the number of -'s is odd or even. For most of the qubits, which are simply in state + or -, this is an easy job. But the measured one is in state 0, a superposition of + and -. This has to decide whether to be + or – before the question can be answered.

If it decides to be +, which is what this qubit was originally, the rules are obeyed on these squares. The qubit has also been forced into a state that is nothing like the 0 state that the Gremlin measured, so that information is now out of date and the Gremlin knows nothing. All is well.

If it decides to be the opposite of what it was originally, the effect is similar to a bit flip. Except this kind of flip turns + to – and – to +. We call these phase flips. The phase flip causes the rules to be broken on the two blue squares. But, just like with bit flips and white squares, this allows us to detect and correct the errors. Also, the qubit is again forced into a state that has nothing to do with the one that the Gremlin measured. So its information is again out of date, and all is well.

With these rules, protecting the code from measurements is exactly the same as protecting it from bit flips. So a few measurements here and there don't cause a big problem. We can just detect them, remove their effects and update the state to make sure their results can't tell anyone anything about our logical qubit. The only way for an unwanted measurement to happen is if a load of measurements happen all at the same time, and do so on a loop that goes through the doughnut. That's unlikely, so we're mostly okay.

Combining the rules

We now have a set of rules for dealing with bit flips, and a set for dealing with phase flips. But we really need them to work together, so we can deal with both at the same time.

Getting things to work together in quantum mechanics is not always possible. Suppose we have a single qubit, and set two rules:

i) When we measure whether it is 0 or 1, the answer must always come out 0.
ii) When we measure whether it is + or -, the answer must always come out +.

The only way to make a qubit always give us the result 0 for a 0/1 measurement, as rule (i) requires, is to have it in state 0. But this is a superposition of + and -. So it gives the result – half the time when we do a +/- measurement, breaking rule (ii). Similarly, the + state is the only one that always obeys rule (ii), but it breaks (i) half the time.

If the same was true for the rules for the squares, we would get loads of broken rules all the time. It would be impossible to get enough information to detect and correct the errors, because of all the random nonsense that comes from the rules fighting each other.

But there is a big difference between rules (i) and (ii), and the rules we use in the toric code. There is not just one state that satisfies the rules for the white squares, but there are many patterns of 0s and 1s that do it. And any superposition of these will obey them too. There are also many patterns of +'s and -'s that obey the blue square rules, as do their superpositions. With more possibilities, there is hope.

Any state can be thought of either in terms of 0s and 1s or in terms of +'s and -'s. Just like a single qubit in state 0 can be thought of as just a 0, or as a superposition of + and -. So it could be that some superposition of white rule abiding 0s and 1s turns out to be the same state as some superposition of blue rule abiding +'s and -'s. If so, states like this would obey both the rules for white squares and blue squares at once.

Fortunately, it turns out that there are states like this. They are not just nice simple patterns of +'s and -'s as in the figure above, or nice simple patterns of 0s and 1s as in the figures for previous posts. We need a big superposition to make sure that the rules can work well together. In fact, for a logical 0 we need a superposition of every possible set of 0s and 1s that could be used for a logical 0. Making such a complicated set of correlated qubits is going to be quite hard, and is the main reason that you can't buy a toric code from the shops at the moment. But experimentalists are working hard towards this goal..

With both sets of rules working well together, we just need to keeping checking on both types of square. When we see white rules broken, we know that a bit flip has happened, and can correct it. When blue rules are broken, we detect and correct phase flips. As long as unlikely things don't happen, or logical qubit will keep nice and safe.

Phase flips and +/- measurements

So far we've assumed that the only kind of bad things that happen are bit flips and unwanted measurements of 0 and 1. But what about phase flips, or unwanted measurements of + and -? Our code naturally sorts those out too. What about other crazy weird quantum stuff? It turns out that anything that could ever happen can be thought of as some combination of bit and phase flips. So whatever happens, once we measure what rules are being obeyed, the noise gets forced to decide what kind of bit and phase flips it wants to be. The we detect and correct those, and all is well. The toric code (as well as other quantum error correcting codes) protects us from everything.

Summary

Well, perhaps it doesn't protect is from everything: big and horrible errors that hit us all at once can still get under the radar. But as long as they are rare, our logical qubit will last a long time. And if they are not rare enough, we just make our code bigger so they need to be ever bigger and more horrible before they can mess us up.

So that's the toric code in 5 parts. Next we will move on to its flat brother, the planar code. But first, in this post we take a look at some of the maths behind all this. I try to keep it with little maths as possible, but it did turn out to be a bit long. There is a bit of teleportation in there, though.


Thursday, 14 April 2016

9 - The Toric Code (part 4)

This is part of a project to get people involved with quantum error correction. See here for more info.

It's been almost a month since part 3 in our series on the toric code. Since then we released our app, and the source code. But now it's finally time to see how the toric code deals with things being measured when they shouldn't be. For this we'll need to meet a couple of new friends, called + and -.

Summary

Let's quickly remind ourselves what's going on. We have a bunch of qubits, which are just like bits (with values 0 and 1) except that they are allowed to do quantum stuff.

Unfortunately, things happen to our qubits that we don't want. Sometimes they get bit flipped, which turns 0 to 1 or 1 to 0. Sometimes they get measured, which interferes with quantum stuff. All this noise means that we can't use our qubits to make quantum computers. Not without some fancy tricks, anyway.

The fanciest of tricks is quantum error correction. We take many of these noisy qubits, which we call `physical qubits', and use them to build one almost noiseless `logical qubit'.

In the toric code we do this by putting the physical qubits on a grid that's wrapped around a torus, and imposing the rule that there must always be an even number of 0's around each white square. This still lets us have many different patterns of 0s and 1s, as below. When we want our logical qubit to have value 1, we use patterns like (c) and (d) which have a big loop of 1s around the torus (or any odd number of these loops). When we want our logical qubit to be 0 we use something like (a) or (b) which don't have a loop like that, or have an even number.



Using the toric code makes a logical bit that's hard to flip. You need to flip a whole bunch of physical bits on a line to make (a) become (c), or (b) become (d), or anything else that's logical 0 become logical 1.

It's most likely that noise won't be able to do a complete loop of bit flips, but instead will just do some flips here and there. These will usually break the rule that there should be an even number of 1s around each white square. So by checking the squares to see where the rules are broken, the bit flips can be detected and corrected.

The toric code also makes it hard to measure whether the logical qubit is 0 or 1. For that we also need to use a big long loop, this time one going the other way.
If we measured each physical qubit along the blue loop, we could work out whether there was an odd or even number of loops passing from left to right, and so whether the logical qubit is 0 or 1. We could also do it with the green loop, or a whole bunch of others. But anything less than a big loop through the torus won't be able to tell us anything.

Even so, suppose that every second there is a 1 in 100 chance that a Gremlin finds and measures each physical qubit. After a few minutes, the chance that each has been measured at least once is pretty high. If the Gremlins teamed up, they'd almost certainly have enough information to work out what the logical qubit is doing.

This is not good enough. We need some way to keep the Gremlins from getting this information. We need to be able to detect when they measure, and then change things around so their information is out of date. Can we do this?

The + and - states

So far we've always described qubits as things that can be 0 or 1, or a quantum superposition of the two. This suggests that 0 and 1 are special states, and the superpositions are just weird quantum things. But that's not true.


So why have we focussed on 0 and 1? One very useful thing about them is that 0 and 1 are completely different from each other. A bit or qubit can be one or the other. But it can't be neither or both. Even when a qubit is a quantum superposition of the two it isn't really both. It's still either one or the other, but just refuses to make up its mind.

Because of the difference between these two states, it makes sense to ask whether a qubit is 0 or 1. This is a measurement that quantum mechanics allows us to make, and all the measurements we've imagined so far have used this fact.

But there are other states that are like this. An infinite amount of them, in fact. But today we'll start looking at everyone's second favourite: + and -.

The state + is a superposition of 0 and 1. If you had a qubit that was +, and you measured whether it was 0 or 1, it would randomly choose one or the other. The same is true for  -.

But the types of superposition going on in + and - are very different. It takes a bit of maths to explain this, so we won't go into any more detail here. But, if you're interested, check out this post, where they go by the names 'left' and 'right'.

The states + and - are as different from each other as 0 and 1 are, and we can use them to measure our qubit. So if we have a qubit in state 0, and measure whether it is + or -, what happens? Well it turns out that 0 can just be thought of as a superposition of + and -, so we get a random result out.

We can also use them to describe the state of our qubit. Instead of saying that a qubit is in state 0, or 1, or some superposition of the two, we can say that is +, or -, or some superposition of the two. Any state can be described in either way. Both are just ways that we can talk about strange quantum states in a way that makes sense to our monkey brains, that would rather be thinking about something simple like bananas. Neither is more important than the other, or the infinitely many other ways we could describe quantum states.

Detecting unwanted measurements

Putting this behaviour together gives us a clue about how to detect whether or not Gremlins are going around measuring our stuff. Say we make a qubit in state + and then go off to make a cup of tea. While we're away, a Gremlin comes along and measures whether it is 0 or 1. The qubit then randomly chooses to be one or the other. Either way, it is no longer a simple +. Instead it is a superposition of + and -.

Now we come back from our tea break and want to check if everything is okay. So we measure if the qubit is + or -, expecting it to still be + as we left it. But the result will instead be randomly either + or -.

If we get the result +, we think that all is well. And indeed it is. Though the Gremlin made a measurement, our qubit is back as we wanted it. Also, the information that the Gremlin has become useless. By updating the state of the qubit, our measurement has made the Gremlin's measurement result irrelevant.

If we get the result -, our measurement has still updated the qubit and made the Gremlin's information irrelevant. But, since it is not the + we expected, it has also given us a clue that something dodgy is going on. We'll need to be more careful during our next tea break!

Complementary observables

It is possible for us to make a qubit which, when asked if it is 0 or 1, will always reply 0. That qubit would simply be in state 0.

It is also possible for us to make a qubit which, when asked if it is + or -, will always reply +. That qubit would simply be in state +.

But it is impossible for us to make a qubit which has both properties. It can never be certain of its answer to both questions. Otherwise 0 and + would have to be the same thing, which they're not. Any questions like these, where a quantum system cannot be fully certain of its answer to both at once, are called complementary observables.

Interestingly, there are very similar measurements we can do, which somehow manage to avoid this. But for these, we'll need a pair of qubits.

Suppose we ask the pair of qubits to look at whether they are 0 and 1, but only tell us whether there is an even or odd number of 1s. If we want the answer to be 'even', we can make them both be 0, or both be 1, or be any superposition of these two.

We could also ask the qubits whether they have an even or odd number of -'s. Again, if we want the answer to be even, we can make them both be +, or both be -, or be any superposition of the two

What if we want them always to answer 'even', whichever of these two questions is asked? For this we would need a state that can be described as a superposition of both qubits being 0 and both being 1, and can also be described as a superposition of both qubits being + and both being -. Then it would always has an even number of 1s, or an even number of -'s, depending on how you look at it.

It turns out that such a thing does exist. In fact it is a so-called entangled state, which has properties that Einstein described as 'spooky'. We'll look at the maths of this in a more mathsy post in a few weeks.

Next time we will use these properties to add some new rules to the toric code, based on the states + and -. These won't disturb what we've done so far, but they'll let us detect and correct stray measurements just as we did before with bit flips.