Introduction to Quantum Computing — For Newbies and IT Professionals — Part 2

Enter the world of Quantum Computing with a 3-part Introduction

This is a continuation of the introduction to quantum computing series of articles. Check here for the first part. In this article, we will go through the quantum concepts like qubits, superposition, entanglement, different models of building quantum computers etc.

Before we get into Quantum computing, let’s start with Quantum Physics. Simply put, Quantum Physics describes the behavior of atoms and fundamental particles, like electrons and photons. It explains how everything works! A quantum computer works by controlling the behaviour of these particles, using phenomenon like entanglement and superposition.

A Quantum computer is quite unlike the computers one uses today, since it has a non-binary identity. A classical computer stores either a 0 or a 1 as a bit so it has a specific value at a time. Each byte can represent 2⁸ = 256 different numbers composed of eight 0s or 1s, but it can only hold one value at a time.

A bit in a quantum computer (qubit) can exist in a superposition, or a combination of 0 and 1, with some probability of being 0 and some probability of being 1. That means it can be a 0 and 1 at the same time. Eight qubits can represent all 256 values at the same time. This phenomenon of being in two or more states at once is known as superposition.

This fluid nature is what is unique about quantum computing and one has to give up on precise values for 0 and 1, allowing for the uncertainity (using probability). It has the possiblity of retaining many states at the same time. It is quite a hard concept to really wrap your head around because you can’t really experience/see it in the everyday life. However its effects can be seen in action through quantum computers, which use the laws of quantum physics.

With a qubit, we replace the terminology of on or off, 0 or 1, with |0⟩ and |1⟩, respectively. |0⟩ and |1⟩ are using the Ket notation here.

Ket-bra notation: Kets represent column vectors; a bra is a ket’s row vector counterpart. However, in Quantum computing literature, you would mostly find use of the Ket notation.

Image for post
Image for post
Source: Dancing with Qubits

Following representation for a quantum bit is on what is called a Bloch sphere.

Image for post
Image for post
Source: Dancing with Qubits

Note: If you need a linear algebra refresher, check out the linear algebra notebook on this link from Microsoft Quantum, with explanations for matrices, vectors, unitary matrices, tensor products etc. There are other notebooks related to quantum computing there as well, so feel free to take a look around.

|0⟩ is (1, 0) and |1⟩ is (0, 1) in the standard basis e1 and e2.|0⟩ and |1⟩ are are an orthonormal basis and sometimes also known as the computational basis. There are other important orthonormal basis like |+⟩ and |−⟩ (hadamard basis) and |i⟩ and |i⟩ (circular basis).

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Source: Dancing with Qubits

In the above Bloch sphere, |0⟩ and |1⟩ are on the z-axis, |+⟩ and |−⟩ are on the x-axis, while |i⟩ and |i⟩ are the y-axis.

Now let’s say |ψ⟩ = a|0⟩ + b|1⟩ is a quantum state, then a and b (also called probability amplitudes) represent the probability of being |0⟩ and |1⟩ respectively, such that we have |ψ|² = |a|² + |b|² = 1. The qubit always becomes the state |0⟩ or |1⟩ (no more in a superposition state) when we read information from it by a process called measurement.

During measurement, a qubit is forced to collapse irreversibly from a superposition state, through projection to either |0⟩ or |1⟩. However, it is possible to move qubit to an infinite number of other states and change from one of them to another while we are computing with the qubit before measurement.

In quantum computing, you operate on qubits or do transformations using matrices. Each operation has its own unitary matrix (A matrix is unitary when it is invertible, and its inverse is equal to its adjoint). These operations are operated through “gates” and since a qubit state is a two-dimensional vector, all quantum gates have 2 x 2 matrices.

Important gates/operations on a single qubit:

  • X gate — It is used as a bit flip gate, as it reverses the probabilities of measuring |0⟩ and |1⟩. For |ψ⟩ = a |0⟩ + b |1⟩ , X |ψ⟩ = b |0⟩ + a |1⟩. Thus after applying X gate, the probabilities of measuring |0⟩ and |1⟩ are reversed.
  • H gate — The Hadamard gate is one of the most frequently used gates in quantum computing. H is often the first gate applied in a circuit. When you read ‘‘put the qubit in superposition’’ it usually means ‘‘take the qubit initialized in the |0⟩ state and apply H to it.’’ The Hadamard matrix is the change of basis matrix from {|0⟩, |1⟩} to {|+⟩, |−⟩}.
  • Y gate Y does a bit flip and a phase flip at the same time. It rotates qubit states by π around the y axis on the Bloch sphere. It swaps |0⟩ and |1⟩ and so is a bit flip. It also swaps |+⟩ and |−⟩ but leaves |i⟩ and |−ialone.
  • Z gateZ is called a phase flip gate. Since it reverses the sign of the second amplitude, it is also called a sign flip gate. It rotates qubit states by π around the z axis on the Bloch sphere. The Z gate swaps |+⟩ and |−⟩ as well as |i⟩ and |−i⟩. It leaves |0⟩ and |1⟩ alone on the Bloch sphere. For |ψ⟩ = a |0⟩ + b |1⟩ in C2, Z |ψ⟩ = a |0⟩ − b |1⟩ . The probabilities of measuring |0⟩ and |1⟩ do not change after applying Z.

X, Y and Z are actually using Pauli matrices and are also called Pauli gates. There are a few other gates like S, T that basically perform arbitrary rotation around z-axis. In a similar fashion, you can have gates perform arbitrary rotation around x and y axis, if needed.

Until now we concentrated on a single qubit. However to do anything useful with quantum computing, you would need more than one qubit and operate on them. Every time we add a qubit to a quantum system to create a new one, the state space doubles in dimension. This is because we multiply the dimension of the original system’s state space by 2 when we do the tensor product. A 3-qubit quantum system has a state space of dimension 8, a 4-qubit quantum system has a state space of dimension 16 and so on.

A two qubits system in superposition states is represented by a linear combination of vectors |00⟩, |01⟩, |10⟩, and |11⟩:

Image for post
Image for post

where

Image for post
Image for post

and with the vectors represented as follows:

Image for post
Image for post

Similarly, a three qubit system in superposition state is represented by a linear combination of vectors |000⟩, |010⟩, |100⟩, |110⟩, |001⟩, |011⟩, |101⟩, and |111⟩ similar to the one above and so on.

Qubits can interact with each other in such a way that after the interaction,
they are no longer independent. In other words, if we have two qubits entangled, the probability of observing the state of the first qubit as |0⟩ is correlated with the probability of observing the state of the other qubit also as |0⟩.

Entanglement between quantum particles can persist even when the particles are physically separated. We do the entanglement while the qubits are close together. Once the qubits are entangled, the distance between them plays no role in their entangled state. One qubit could be somewhere on the northern hemisphere, while the other is somewhere in the southern hemisphere, they would stay entangled!

Entanglement also persists in time, through gate transformations/operations and measurement. So, for example, even though entangled qubit 1 is measured first and its value destroyed, the correlation can persist until qubit 2 is measured!

The entangled state is also known as a Bell state and there are four of them:

Image for post
Image for post

For example, in the first Bell state, the probability of observing|01⟩ and |10⟩ is zero, whereas the |00⟩ and |11⟩ is equal (1/2). Note that each individual qubit has an equal probability of being read as |0⟩ or |1⟩. Because of entanglement, probabilities associated with multi-qubit states like |00⟩ cannot in general be decomposed into products of individual probabilities.

Thus, a 2-qubit quantum state|Ψ⟩ is entangled if and only if it cannot be written as the tensor products of two 1-qubit kets:

Image for post
Image for post

where

Image for post
Image for post
  • Toffoli CCNOT gate — The quantum Toffoli CCNOT gate operates on three qubits. If the first two qubits are |1⟩ then it flips the third, otherwise it does nothing. This gate is equivalent to the NAND gate in the classical computing. A Toffoli CCNOT gate is represented in the following way in a quantum circuit. The first two qubits go in the first two lines.
Image for post
Image for post
  • CNOT gate — CNOT is the operation responsible for entaglement. It can’t be performed with photon polarization but can be performed with rydberg atoms (atoms with a very big radius). This gate is equivalent to the XOR gate in the classical computing. Let’s say we have two qubits q1 and q2 with states s1 and s2. Then, if s1 is |1⟩, then the state of q1 remains s1 but s2 becomes X |s2 (it gets flipped), otherwise the states of q1 and q2 are not changed. A CNOT gate is represented in the following way in a quantum circuit. The first line is where q1 goes, whereas q2 goes on the second line
Image for post
Image for post

What has been described until now is the gate model for quantum computing. In the gate model, the input are the qubits which are further fed to a quantum circuit made out of gates as described above. In the end, the result is collected using a measurement. Measurement is also called interference in some quantum literature.

Image for post
Image for post
Source: Amazon Braket Tech Talk — In the quantum circuit, H stands for Hadamard gate, responsible for superposition

To generalize how you would normally go about in quantum computing, you can remember this:

Superposition →Computations (Gates/Operations) →Measurement

Following table represents the operators, gates and their corresponding matrices:

Image for post
Image for post
Source: Quantum Logic Gates on Wikipedia

There are other models for doing quantum computing such as Adiabatic Quantum Computing (AQC), but they will be discussed in the next part of this series, along with amplitude amplification, quantum teleportation, development libraries etc. Hope to see you there!

A Certified Multi-Cloud Architect/Big Data/ML Specialist and Quantum Computing Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store