📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

The Math Behind Quantum Entanglement | Use A Quantum Computer Today | Ep.2

Qiskit13:11

Transcription

Here's a question that has puzzled physicists for nearly a century. How can two particles, separated by any distance, instantly know what the other is doing? Einstein famously called it spooky action at a distance, and he refused to believe it was real. But it is. And at the end of this lesson, you'll understand the math behind it.

In the previous lesson, we learned how to produce an entangled state of two qubits, known as a Bell state. When we measured the state, we saw that the measurements of the two qubits were correlated. When one was measured to be zero, the other was also measured to be zero. And when one was measured to be one, the other was also one. This is a hallmark of quantum entanglement.

But what really is entanglement or superposition? And how do quantum gates play a role in creating and changing these states? Before we get into deep, it's important to first take a step back and cover some of the fundamental concepts and math. Let's go back to the Bell state that we created in lesson one. So recall that this image represents the quantum circuit for making a Bell state. The two black horizontal lines represent our two qubits. And the boxes and other symbols on the lines represent gates or operations performed on the corresponding qubits, zero and one. The double line down here is a classical information bus that allows us to store the classical information that we obtain by measuring the two qubits. And the two boxes at the very end are our measurement gates, signifying the end of the quantum computation and that it's time to measure and record the qubits' final state.

Now let's take a minute to look at this mathematically. We are going to write out our quantum states using something called Dirac notation. Phi plus is the Bell state here. And we write it in Dirac notation with these angled brackets. Now the expression for the Bell state that we are creating looks something like this. So each two terms here represents the two possible measurement outcomes of the state. So when we measure the state, we will find that both of these qubits are either both in state zero or they're both in state one. These are the possible measurement outcomes where the bit on the right represents qubit zero and the one on the left represents qubit one. The one over root two here is called the normalization constant. And it's there to ensure that the sum of the squares of each of these coefficients in the state all add up to one.

You can also choose to write the state as a vector. In this notation, our Bell state would be written like this. By convention, the entries of the vector are ordered as follows. The first entry corresponds to zero zero, the second to zero one, the third to one zero, and the fourth to one one. So for this Bell state, the middle two measurement outcomes are zero since there's no possibility of measuring different states for the different qubits. Unless an error has occurred.

Sticking with the language of linear algebra, we are next going to explore gates. If states are vectors, then gates have to be represented as matrices. A gate acts on a state by transforming its vector into a new vector. Each gate corresponds to a specific matrix that dictates how the state will be transformed. We apply this transformation by multiplying the gate matrix and the original state vector with the gate matrix to the left of the state vector like this. Again, in Dirac notation, where U represents the gate matrix and psi represents the state vector.

Let's look at the Hadamard gate as a first example. The Hadamard gate is a single qubit gate, denoted by this red box with the H in it right here in the circuit diagram, that takes the state zero to the state zero plus one, a superposition, and the state one to zero minus one. Now the matrix that's responsible for this transformation looks like this. But let's actually work it out to make sure that we can check our understanding and that we've got it. So if H is acting on zero, we have one over root two. This is the Hadamard gate acting on state zero in matrix form or as a vector, it looks like one and then zero. And if you work that all out, you're going to get one over root two one one. Where again, this digit here corresponds to state zero and this corresponds to state one. So that is indeed zero plus one. H acting on one now looks like this. Again, this is the Hadamard matrix. Now acting on zero one and that equals one over root two one minus one. So it all works out.

The Hadamard gate creates quantum superposition, one of the most important fundamental quantum concepts. We were a little hand-wavy with what this means in lesson one. We said it was basically like being in the state zero and one a little bit at the same time. But now you can see and understand the math for yourself. And really, that's the best way to solidify understanding in the quantum realm since there's no classical analogy or picture I can give you that accurately describes what's going on. In fact, the phrase the qubit is in both states at the same time can be misleading because we can never directly observe the superposition. A more precise way to describe it is that a superposition is a mathematical description of the quantum state that allows us to calculate the probabilities of different measurement outcomes. Some people think superpositions are physically real, but this is a philosophical interpretation that can't be tested. What is important is that quantum mechanics only predicts the probabilities of measurement results, and it does so with incredible accuracy.

And here's where it gets really interesting. Unlike a classical probability distribution, a quantum superposition allows the different components to interfere with each other like overlapping waves that can either amplify or cancel each other out. This interference is what allows quantum algorithms to produce patterns of measurement outcomes that would be impossible with classical randomness alone. This is the secret sauce.

Now speaking of measurement, how does that work? In quantum mechanics, measurement is random. We will only ever get a zero or a one when we ask a qubit the question, what state are you in? Even if the state was a superposition before we asked. The coefficients tell us the weight or the odds of measuring one state or the other. But the actual result is random. In the superposition state that we created, the coefficient is one over root two, which corresponds to an equal weight or a 50/50 chance of measuring one or the other. If you square this coefficient, you'll see that you get one half. So you have an equal probability of measuring one state or the other. The probabilities always have to sum to one because this is a physical result. And since you always only get one or the other, the probability of all outcomes happening has to work out to 100%. We say that after a measurement has occurred, the superposition collapses because the measurement is not reversible. You can't just undo it and get the superposition state back. It went from a quantum state to a classical state.

Now let's go back to our circuit and look at the two qubit gate. Really quick before we get to the CNOT gate, recall that we actually have two qubits in our system. So we said that the Hadamard gate is equal to one over root two one one one minus one in matrix form. But to apply this gate to the first qubit in a two qubit system and leave the other one alone, we need to expand this matrix into a four by four matrix so that it will apply H to qubit zero and leave qubit one unchanged. The matrix that does this looks like so, where we have essentially the Hadamard gate in the upper quadrant and in the lower right quadrant as well. To check this, let's multiply it through. So if we have the Hadamard gate acting on both qubits that are initialized into state zero zero at the beginning, and we write out our four by four matrix again like so, acting on the initial state gives us 1 over root 2 1 1 0 0 which is equal to 0 0 plus 0 1. So again, leaving qubit 1 unchanged while qubit 0 is affected by the Hadamard gate.

Now let's look at the two-qubit gate. This line with the plus sign in it is called a CNOT gate. The controlled NOT gate is our entangling gate which takes a quantum state from one qubit and mixes it with another in such a way that they become so correlated that there is no classical equivalent. The CNOT gate flips qubit 1 which we call the target qubit only if qubit 0 called the control qubit is in state 1. This is the matrix that corresponds to that interaction. Now let's try applying this gate to the superposition states that we created from applying the Hadamard gate to both qubits in the previous step. And if you work that all through, you'll find you get 1 over root 2 1 0 0 1 which if you recall is exactly the Bell state that we were looking for. 0 0 plus 1 1.

Now the only thing left in our circuit is the measurement gates. When we measure, the quantum state collapses into one of the classically allowed states. So you'll find that we're going to get 0 0 with a probability equal to modulo 1 over root 2 squared. That's 1/2. And you're going to measure 1 1 with the same probability. 1 over root 2 squared and that is also equal to a half. This reproduces the correlated measurement outcomes that we observed in the circuit in lesson 1.

That's it for lesson 2. We walked through the basic math behind two of the most important gates in quantum computing and showed how we recreated the famous Bell state we measured in lesson 1. You now have the mathematical foundation to understand what's really happening inside a quantum computer because all gates and states work this exact same way. If you know how to write your state and your gate acting on that state in matrix form, you can work through the math. For your learning objective for episode 2, I encourage you to work through the math and the linear algebra that we just learned together. Only add in a few extra gates at the end, a few rotation gates, the Z gate and the X gate, and try to end up with this Bell state at the end. Again, we'll be using this Bell state in future episodes, so this will serve you well if you actually take the time and work through the math. Share what you learn in the comments below. Episode 3 is coming soon.