Ever heard the gazillion references from Marvel movies about the quantum space time narrative? For example consider this line uttered by Tony Stark from Endgame, “Quantum fluctuation messes with the Planck scale, which then triggers the Deutsch Proposition”. In this blog post we will discuss the fundamental principles of superposition and entanglement that a quantum computer operates on and make sense of the quantum world.

**Classical Superposition**

In order to understand superposition, we must first understand the concept of waves. Neil Bohr proposed the idea that fundamental particles like electrons and photons behave in some ways like waves and in some other ways as particles. A wave is just a periodic function that describes oscillating behavior. The motion of a pendulum as it swings back and forth can be described via a sin or cos wave.

For example, this is what light(an electromagnetic wave) looks like. It consists of electric and magnetic field vectors oscillating mutually perpendicular to each other.

Superposition is a term used when two or more physical quantities like displacement or force are added together to produce a new quantity which is the sum of the original components.

Consider a situation when two pulses on a string approach each other. As they pass through each other, they will “interfere” following the principle of superposition. As evident from the diagram, when the pulses meet, the sum of their components will add up to produce a new wave.

Noise cancelling headphones create a sound wave with the exact same magnitude as the sound wave of noise outside, but inverted(reflected about y axis), thus cancelling the noise from outside.

**Transitioning from classical to quantum superposition**

A great way to think about quantum superposition is to imagine flipping a coin in the air. What state is it in as it spins in air? Heads or Tails? We say that it is in a superposition of being in heads or tails because it is not in a definite state or it exists in both heads and tails simultaneously. However, once a coin lands on the ground it is no longer in a state of superposition. Whenever a measurement(in this case observing the final state of the coin as it lands) is taken, the superposition is destroyed and the final state is measured with 100% probability(heads/tails). If you are curious to learn more about quantum probabilities and what it means to perform a quantum toss? Check out qiskit.org/textbook/what-is-quantum to find out more!

**Superposition applied to qubits**

What makes a quantum computer special is that it is operated by qubits, which can exist in a superposition of 0 and 1. This is the “secret” behind a quantum computer and what gives the ability to perform computations at exponential speed ups over classical computers. A computation that would need 2 bits(0 and 1) can now be performed on one qubit as it carries information about both the bits at once.

**Representing Qubit on Bloch Sphere**

Bra-ket Notation, named after physicist Paul Dirac, is the notation and mathematical formalism that you must know in order to represent a quantum mechanical circuit. This is useful when working with quantum circuits and encoding information on qubits.

A qubit is represented by the Greek letter *Ψ* and enclosed inside | ⟩. This is a special type of bracket known as a “ket”. Therefore, if we wanted to represent the state of a qubit, we would write it as |*Ψ*⟩.

The fundamental unit of computation is always 0 or 1. Therefore, the state of a system in superposition is represented as a|0⟩+b|1⟩. In math lingo, we would call this as taking a “linear combination” of two vectors, |0⟩ and |1⟩.

The terms “a” and “b” that we attached to |0⟩ and |1⟩ represent the “amplitude” of a state. An important property they must satisfy is that

|a|²+|b|²=1.

This is called the “normalization rule”. Why should this rule hold? Because a and b are numbers that represent probabilities. For example, for a fair coin, we would say we have a 50% chance of getting heads and 50% chance of getting tails. Therefore, we represent the state of the system to be

The square of probabilities should add up to 1 always, which you can check if you square the amplitudes and sum them.

Now Let’s move on to something useful in quantum computing which is the Bloch sphere

A bloch sphere is a geometric representation of a quantum state. In the picture above, we represent *|Ψ*⟩ as a vector in 3 dimensional space. We can see three coordinate axes : X,Y,Z which we would be familiar with from high school geometry. In quantum mechanics we call these **basis vectors. **What’s special about basis vectors? Any linear combination of these basis vectors spans all of 3 dimensional space. In other words, it is possible to construct any *|Ψ*⟩ and the length or “norm” of *|Ψ*⟩ is the radius of the bloch sphere. The bloch sphere is constructed using spherical coordinates. If you’re interested in learning more about spherical coordinates, then check out tutorial.math.lamar.edu/classes/calciii

|0⟩ and |1⟩, are called the computational basis( or the Z-basis). This is because in programming languages like Qiskit, we can only measure the state of a qubit along the Z-basis . The other two bases are called the X-basis and the Y-basis. The numbers

are called the “eigenstates” of the X and Y basis respectively.

For understanding what the X and Y basis is, let’s introduce the 3 fundamental gates of quantum computing also known as the Pauli Gates. And this is where a special feature of quantum computing known as reversible gates stems from.

In classical computing, the three main gates we know of are the AND, OR, and NOT gate( apart from XOR and NAND gates)

Out of these, only the NOT gate is reversible. But what do I mean by “reversible”. Let’s look at the truth tables of the AND,OR and NOT gate

In the OR Gate, we can’ t trace back to the input from the output. For example, if the output is 1, we don’t know whether the input combination was {0,1}, {1,0} or {1,1}.

Similarly, for the AND gate, we can not deterministically say what the inputs are from output. Hence, we call these gates irreversible.

But as for the NOT gate,

If the output is 1, we are 100% sure that the input is 0 and vice-versa. In general if a gate can be represented as an injective or one-to-one function, then the gate is reversible.

Now, back to quantum gates! There are 3 fundamental gates: The Pauli-X, Pauli-Y, and Pauli-Z gates.

The analogue of NOT gate is the Pauli-X gate:

Any gate in quantum mechanics can be represented as a matrix. A matrix is just an array of numbers. The Pauli-X gate is a 2×2 matrix as it has 2 rows and 2 columns. On the right we have its Dirac notation equivalent. What is the effect of applying a Pauli-X gate on |0⟩? By the way, the matrix notation of |0⟩ and |1⟩ is:

Now we will use matrix multiplication to find out what the result of a Pauli-X operator on state |0⟩ is

But first: Lets do a small review on matrix multiplication

So we take the first element 0 of first matrix, multiply it by first element of 2nd matrix, take 2nd element 1 of first matrix, multiply it by second element of 2nd matrix and add the resulting products and do the same thing for bottom two element

As you can see, this is an example of a bit flip as state |0⟩ gets transformed to |1⟩ and vice-versa

The Pauli-Y gate: The matrix notation of a Pauli-Y gate is

Where i is the imaginary unidad or the square root of -1. Intuitively, let’s see the action of Y gate on a Bloch sphere. It maps state |0⟩ to i|1⟩ and |1⟩ to -i|1⟩. Also note cómo the states |1⟩ and i|1⟩ are indistinguishable. This is because these states only differ by a global “phase” not a relative phase

Qué do I mean by global and relative phase?

Any state vector can be written as the combination of sin and cos functions The relative phase is determined by e^(i**ϕ**)and the global phase is a value we can factor from both cos and sin terms.

Geometrically, a Pauli-Y gate rotates a state 180 degrees around the Y axis of bloch sphere

The third gate is the Pauli-Z gate

Which has the effect of a phase flip as it rotates the state of qubit by π radians (180 degrees) around the Z axis.

As you can see from the diagram above, Pauli Z gate has no effect on |0⟩ but maps |1⟩ to -|1⟩

Applying a Pauli-Z gate has the effect of rotating a state about the Z-axis. We will use this fact when we are programming quantum circuits in the future.

So what’s so special about these Pauli gates: they are represented by unitary matrices and that’s what makes them reversible. Also note by reversible we mean in between the time of initializing the qubits and measuring them, the operations or gates we apply to a qubit are reversible. After we measure a qubit, its state has collapsed and we can no longer talk about reversibility. The idea of reversible computing is explored very well over here https://en.wikipedia.org/wiki/Reversible_computing

Finally: The gate that creates superposition: Hadamard gate

The Hadamard gate is what creates a superposition of states |0⟩ and |1⟩

It’s matrix representation is

The result of applying a Hadamard gate on |0⟩ and |1⟩ is

So, in effect, if you want to create a superposition state of a qubit, the Hadamard gate is operated on the qubit

**Entanglement**

So far we have only dealt with measurement and operating gates on a single qubit. However, a very cool property of qubits that is not exhibited by its classical counterparts is the phenomenon of entanglement: When multiple qubits are entangled with each other. Einstein once described entanglement as “spooky action at a distance”.

Suppose we have two fair coins. Classically, the sample space after measuring outcome of these two coin tosses would be {HH,HT,TH,TT}, each outcome happening with a 25% probability. However, if you entangle both the coins, they would be in a state

Mathematically, an entangled pair of qubits is created by doing a tensor product between them

For the entangled pair above, only two outcomes are possible: Either both coins land on heads or both coins land on tails, with 50% probability for each. So imagine one of the qubit is located on Mars, whilst the other on Earth. If we measure the state of one coin, and let’s say it comes out heads, we know for sure that the other qubit would have been heads.

**Creating Entanglement**

The CNOT Gate is used to entangle two qubits together: the CNOT gate takes in two inputs- a control qubit and a target qubit and follows this rule

It performs a X-gate on the target qubit if the control qubit is in state |1⟩, else if the control qubit is in state |0⟩, the target qubit is unchanged.

Let’s do an example, keeping in mind the concepts of superposition and entanglement we’ve learnt

Consider the following circuit created on Qiskit. Note that q0 and q1 are initialized to the |0⟩ state. q1 is the control qubit and q0 is the target qubit. We have a Hadamard gate applied on the first qubit, which makes it in state 1/sqrt2(|0⟩+|1⟩). After applying the CNOT gate, it entangles the state of target qubit which is |0⟩ and control qubit. So we get 1/sqrt2(|00⟩+|10⟩).Now when the control is |0⟩, the target qubit stays in state |0⟩. However, when control is |1⟩, the target qubit gets flipped to state |1⟩. Therefore the result after we measure the output will be 1/sqrt2(|00⟩+|11⟩). We can see that this state has 50% probability of being measured in the state |00⟩, and 50% chance of being measured in the state |11⟩. This is how we created the entangled state for our coin toss

This is a one of a “Bell State”. This state cannot be written as a product of two separate qubit states. The CNOT gate is also reversible, so we can figure out the original qubit states if we reverse the operation

Are you interested in learning more about quantum computing and getting an in-depth overview of topics like quantum gaming, quantum cryptography and more! Check out https://www.youtube.com/watchv=SV9_EosLmOM&t=283s