# Quantum Teleportation from scratch to magic. Part 1 — The What?

Ever wish you could send information instantaneously across the universe perfectly securely? Well that's lucky — you’ve come to the right place.

This is part 1 of my 3-part series on quantum teleportation. In this part, you are going to be led through a wild and woolly path from the very the basics of quantum computing up to a description of the truly mind-blowing quantum teleportation protocol. Don’t worry if you can’t understand it completely, not a brain in the world does! Nevertheless, if you feel stuck at any point please feel free to ask questions in the comments.

In the next part, you will learn how to program it yourself using IBM’s quantum computing python package, qiskit. In the third part, you can read about my hugely unqualified musings on how in the world any of this could be possible and what we should think about a world in which it is.

Prerequisites:

- knowing how to use vectors and matrices
- a willingness to suspend your disbelief as we disprove Plato, Aristotle, Einstein and your deepest intuitions!

**Qubits**

So first things first, how do we represent information on a quantum computer? Classically, ‘bits’ are used which can take a value of either 0 or 1. Quantumly, we use ‘qubits’ which can also take values of 0 or 1. However, we use slightly more complicated notation(s): kets and vectors.

They work as follows:

Basically, the “0 ket” is just another way of writing the vector with a 1 on top and a zero on the bottom. Because these two vectors are orthogonal, they are taken to be the standard units of quantum computing, otherwise known as the ‘computational basis states’.

“Alright cool,” you’re probably saying, “you’ve given me your fancy notation, I’ve never had so much fun in my life, but isn’t it a bit of an overcomplicated way of representing a 0 or a 1?” The answer is yes, it would be pretty unnecessary to have all of this to distinguish just two values. BUT, in *quantum* computing, it turns out that a single qubit can take more interesting values than just 0 or 1. In fact, it can be combinations of both at the same time!

We typically represent an arbitrary qubit as follows:

Now, if you’re paying attention, you probably have (at least) two questions:

- How in the world is it possible for something to be two things at once?!? That makes no sense whatsoever… Even Plato and Aristotle relied on the fact that
*a = a*! What would that even look like? - So what are α and β? Am I supposed to believe that a single arbitrary qubit could represent anything?

Well, I tried to warn you at the beginning but yes, it is, in fact, possible for something to be in two states at once! That is actually one of the most powerful features of quantum computing. As to what that would look like, let’s just say our feeble-monkey-Newton brains wouldn’t be able to process it (more details later on).

With regards to your second question, it is actually true that a single qubit can take an infinite range of states. However, there is some equation between α and β that must hold. Furthermore, our ability to distinguish these infinitely different states is an entirely different question.

**Quiz time!**

What do you think the equation relating α and β is?

I’ll even give you a hint — it comes in the form:

___ + ___ = ___

I’m now going to put in a large photo so you cheaters have some time to think about your principles while you scroll down.

Let me guess, those of you who actually thought about it (cheaters: refresh the page and start again) might have guessed:

α + β = 1

How very classically minded of you… That certainly does seem the most intuitive relation between the two but, once again, quantum computing defies our intuition.

In fact, the real relation is:

**|α|² + |β|² = 1**

What’s the difference? Who even cares? Answer: you (should)

The modulus squared of a number is known as its amplitude and it actually increases the domain of values a huge amount! α and β can now be negative numbers:

They can even be complex numbers:

The point is, thanks to the use of amplitudes our good friends α and β can take on a much larger range of values which includes negative and complex numbers.

**Measurement**

In all likelihood, this idea of being in two states at once, known as ~*quantum superposition*~ is continuing to baffle you. It is extremely difficult to picture what that could look like. But surely these quantum physicists must have observed them so that they could decide that’s how the universe works?

In fact, no person has ever directly seen a superposition and nor will they ever. (To find out more about how they didn’t just make it up out of thin air, check out the double-slit experiment). For us to know about a quantum state, it must first be measured. Fortunately for our monkey-Newton brains, the measurement will always give one output. The measurement outcomes are probabilistic and, you guessed it, can be calculated as follows.

When measuring our good friend ψ:

P(measuring 0) = |α|²

P(measuring 1) = |β|²

Since the amplitudes (not the values themselves) are giving us a probability distribution, it should now make more sense why they have to sum to 1.

Great! So if we want to know ψ then can we keep measuring it until we have a good idea about its distribution between 0 and 1?

NO! Nice try sucker! *Measurement irreversibly destroys a quantum state*. This is known as decoherence and, even worse, often happens just by a quantum state interacting with its environment. This creates a big challenge for constructing a quantum computer because, on the one hand, we don’t want to touch the state too much in order to maintain coherence. But on the other hand, we would like to be able to do operations on a quantum state because otherwise, we would have created an absolutely useless computer.

Quantum computing is basically like having your cake and trying to eat it but if you touch or look at it the wrong way it will turn to sand but if you don’t eat it then it was a waste of money buying the ingredients. Sounds pretty easy right?

**Gates**

So, now that we’ve got our qubit, and (generously) ignoring the conundrum of interacting with it, what can we do to it?

Since we’re representing our qubits as vectors (and kets), it is convenient to represent any transformation on those qubits as matrices.

We know (because I’m telling you) that any transformation on a qubit must maintain our all-important equation|α|² + |β|² = 1. Fortunately, there is a class of matrices that will guarantee this called unitary matrices.

A matrix *U* is unitary if and only if:

The dagger sign means conjugate transpose which is effectively the inverse of an operation. So in words, this means that applying a unitary matrix and then undoing it should be the same as doing nothing. This brings out an interesting feature of quantum computing: **all operations must be reversible **(OK fine, except measurement).

There are **4 basic 1-qubit gates**:

- X (aka NOT gate)
- Y (aka not needed for this article gate)
- Z (aka ‘zee’ gate for you Americans)
- H (aka Hadamard gate aka magic)

For each, we can show what it does to our computational basis states and then find out its matrix representation.

**The X gate** behaves as follows:

So because it takes a zero ket to a 1 ket (first column) and vice versa (second column), this means we can write:

There’s a few things to notice here:

- The conjugate transpose of
*X*is still*X*(this is a property called Hermitian) - Applying X twice is the same as doing nothing, so we know that it is unitary
- It’s called the NOT gate because it behaves same as the classical NOT gate
- We can use our matrix to work out its behaviour on our old friend ψ and find that it just flips the vector upside down

The **Y gate** is pretty boring and irrelevant in my opinion but, for the benefit of the nit-pickers, here’s it matrix anyway:

**The Z gate **is more useful for teleportation, however. It acts on our basis states as follows:

It does nothing to the 0 state and flips the sign of the 1 state. This means that its matrix can be written as:

Notice once again that it is Hermitian (equal to its own inverse) and unitary (doing it and then undoing it is the same as doing nothing).

So what does that minus sign mean? How about I show you what happens to our old friend ψ

That sneaky second step where we distribute Z is possible because we’re working with *linear* algebra and is another very powerful feature of quantum computing.

The cleverest among you might be wondering what difference the Z gate actually makes to that state. Since our measurement probabilities cancel out the minus sign aren’t they basically the same thing? The answer is yes these states are indistinguishable *to us* but no, they are not the same.

To see how they can be treated differently, it helps to consider our final 1-qubit gate: the **Hadamard (H) gate**

This gate creates superpositions (and also turns them back again). The “plus ket” and “minus ket” are simply shorthands for those superpositioned states. Since you’re dying to know, the matrix for the H gate is:

Notice that without the minus sign the H gate would take both 0 and 1 states to the + state. In which case, it would not be reversible or unitary so it could not be a quantum gate.

In terms of our earlier question about what difference does the Z gate do, consider what would happen if we did

Remembering that with matrix multiplication you start from the right, this would give

Try it out for yourself with the 1 ket and you should notice that it gives you 0. We saw earlier that if you take 0 to 1 and 1 to 0, then you have the X gate. We can check this with matrix multiplication too:

So HZH = X! Clearly, the Z gate is making a big difference on states in superpositions.

So a quick summary of our new favourite gates: the X gate flips bits, the Z gate flips signs (on the 1 component) and the H gate goes in and out of superpositions.

**Multiple qubits**

Before introducing gates which involve multiple qubits, we first need to decide how to represent these multiple qubits. The answer is something called the tensor product. The tensor product is a way of combining two vectors which, unlike the dot product, will create another vector with a larger dimension. It works like this:

So, to represent different states in a 2-qubit system we use the tensor product:

The same goes for the remaining states |10> and |11> and also for as many qubits as you wish.

With that being settled, we are ready for our final gate of the day: **the CNOT gate**. The CNOT (aka CX) gate has a control qubit, *c*, and a target qubit, *t. *If the control bit is 0, nothing happens. If the control bit is 1, it will flip the target bit. Assuming the first qubit is the target and the second is the control, we can work out its action on the 4 basis states:

Notice that it effectively just swaps the states |10> and |11>. This means that its matrix is just the identity with those columns swapped:

As with before, the matrix is constructed by only considering what happens when the input is one of the basis states. So, you may be wondering, what happens if we do a CNOT when the control is something like the + state? Does it flip the target half the time? Does it always flip the target? Does it never flip the target?

The answer is no to all of those questions. It does something far more interesting, spreading the ambiguity and destroying the idea that the universe is *locally real* (properties of objects exist independently of our observation; communication between things can’t happen faster than light). So let’s do some calculations to find out. I’ll also draw a circuit diagram alongside. This reads left to right and all qubits start in the 0 state.

At each point we have the following states:

Take a look at the state at the end. Glad I warned you right? Pretty astounding I know.

Oh, what’s that you’re telling me? “Naming a state after a Greek letter (even a capital one) doesn’t automatically make it impressive. This one looks just as boring as all the others”. Well, what if I told you it was called a ~**Bell pair~**? Still not impressed? Then let’s work through it.

To see the power of a Bell pair, we’ll compare it to what happens if I put two qubits through H gates. I would end up with:

Our equations from earlier tell us that we have a 1/4 chance of measuring each of those states. So measuring the qubits individually, we have 1/2 chance of getting a 0 or a 1. If I measure the first qubit and get a 0 (limiting the state to the first two terms), I still have a 1/2 chance of measuring a 0 or a 1 on the second qubit. Each qubit tells us nothing about the other one (which makes sense because we’ve only used one qubit gates).

Now, what happens if I measure a 0 on the first qubit of our Bell pair?

…

Are you ready this time?

…

Are you sure?

Answer: it **guarantees **I will measure a 0 on the second qubit! Similarly, If I measure a 1 on the first qubit, I will certainly measure a 1 on the second qubit. Even if I had the first qubit on Earth and you took the second one to the end of the galaxy, we would always get the same result. This is called **quantum entanglement.**

“BUT HOW????”, I hear you wail. Remember that before measurement, it is in a superposition so we cannot just say that’s the state they were both in all along. Neither can we say they were always going to be a 0 or 1 because if we ran it many times we would get equal proportions of 00 and 11 (see part 2). In fact, even Einstein tried to argue that there was in fact determinism behind the probabilistic outcomes (he famously said of quantum mechanics: “God does not play dice with the universe”). This was disproved by Bell, although the ultimate explanation still remains a very debated issue. The simple answer is that no one has a clue how it happens, but it does anyway.

**Teleportation**

Now that you’re suitably confused, we are ready for the teleportation protocol! Using these magic Bell pairs we just discussed, it is actually possible to send an arbitrary qubit instantaneously across any distance you like.

Imagine that Alice and Bob share a Bell pair (created as above) and Alice would like to send Bob a secret qubit. She can’t do this classically because it would require infinite measurements to learn its state. Interestingly, our requirement for unitary/reversible operations also means that she can’t clone her state and give that copy to him. Instead, she must teleport it to him, destroying her own copy.

Here is the entire process (taken from this wonderful textbook), which I will work through step by step:

Alice starts with 2 qubits — the qubit to teleport, our old friend ψ, and half of the Bell pair; Bob starts with the other half of the Bell pair. So we are starting off with:

Alice does a CNOT on her two qubits, flipping part of her Bell pair:

She now applies the H gate to ψ. Notice she has effectively done the reverse of the process to prepare the Bell pair so it might help to think of this as ‘offloading the magic’ onto her qubit. In any case, we now have the state:

This can be re-arranged (trust me) to

Notice that this can be very conveniently simplified to

So the third qubit is in a superposition of different permutations of trusty ol’ ψ. Imagine that the qubit was sent in a box and may or may not have flipped over (in either direction). If we open the box the wrong way, we would lose our qubit so it's important that we find out what happened to it on its journey. Fortunately, Alice can tell us.

Remember that the first two qubits are Alice’s and the last one is Bob’s. So measuring (the meter sign in the circuit diagram) Alice’s two qubits and getting 00 would mean that Bob now has the original state ψ. But if Alice measures a 1 on her first qubit, then Bob needs to apply a Z gate to recover ψ and if she measures a 1 on her second qubit then Bob must apply an X gate. Unfortunately, this information must be transmitted by classical means. So Alice has to ring Bob up and tell him the results of her measurements — this is what the double lines in the diagram mean. The qubit has been successfully teleported and recovered! Pretty damn cool if you ask me.

You may be a bit disappointed that *quantum *teleportation requires such boring classical fixes. I agree, although if there was no need for classical correction, this whole process could occur faster than the speed of light and if it was sent over long distances between people moving at different speeds then that would allow information to be sent back in time! Although cool, physicists assume that it’s impossible so it's a comforting sort of fix that this doesn't break time as we know it.

This process is also perfectly secure. As long as Alice and Bob trust each other, Alice can only publish her measurement results when Bob says he’s ready. If Eve the eavesdropper tries to measure the qubit along the way, she won’t know what ‘basis to measure in’ (aka corrections to apply) and doing the wrong one would destroy the qubit.

So there you have it! You’ve successfully gone from learning what a qubit is to learning how to teleport one. Hopefully, you’re feeling a little bit confused and very amazed. For me, that feeling still lingers.

If you want to learn more, stay tuned for parts 2 and 3 of this series. To get a more detailed introduction to quantum computing, I would greatly recommend the site ‘Quantum Computing for the Very Curious’ or IBM’s qiskit textbook.