An Introduction to Quantum Computing

Johannes Hecher
Crayon Data & AI
Published in
18 min readJun 14, 2023

Most people had little idea of what these so-called “computer” machines were capable of or how they worked when they were developed in the mid-20th century. However, some enthusiasts recognized their potential and the computer revolutionized how we live and work today and herald the start of the era of information technology.

Quantum computing could have a similar impact as it has the potential to solve problems that classical computers are incapable of, such as simulating complex chemical reactions, optimizing logistics and supply chains, and realizing unbreakable encryption. Typical industries which will benefit from the so-called “quantum speed-up” and “quantum encryption” are finance, governance, energy, or healthcare (among many others).

As quantum computing continues to develop and become more practical, there will be many opportunities for companies and a growing demand for professionals with expertise in this field. However, quantum-enabled information technology is a very complex topic, wherefore companies and individuals alike must start to educate themselves now so that they are not left behind when the “quantum revolution” happens.

This article takes a closer look at

  • the fundamental mathematical description,
  • the properties that make quantum computing possible, and
  • the options to encode real-world into quantum data.

All topics will be discussed at a high level, however, a basic understanding of math (linear algebra) and computer science are needed.

Topics that will not be discussed in detail are

  • quantum mechanics and physics,
  • the technical details of how quantum computers operate, and
  • the hardware and types of quantum computers.

Math — The Language of Quantum Computing

Math is the foundation on which the theory and concepts of quantum computing are built. When OpenAI’s ChatGTP is asked, “Why is math important for the field of quantum computing?”, it will answer something similar to:

Math is incredibly important for the field of quantum computing because it provides the tools and language necessary to describe and analyze the behavior of quantum systems. […]

The quantum theory was developed in the first half of the 20th century when Physicists were trying to understand what happens in the smallest structures of the known world — the atoms.

Dirac Notation

The fundamental distinction between classical physics and quantum mechanics is the wave-like property of quantum systems. Quantum mechanical systems are described by wave functions which are complex mathematical functions that are related to the probability of measuring a quantum system to be in a particular location or state.

The Dirac notation is a special mathematical notation used in quantum mechanics to describe the state of quantum systems. It is an alternative formalism for representing vectors as well as for linear algebra operations. A form of a quantum system in Dirac notation is represented by a “ket” vector, |⟩, where the complex conjugate, ⟨|, is called “bra”. Here are two examples of the respective vectors:

The inner product (also referred to as the scalar product) of two vectors

is equivalent to the probability amplitude of the quantum state |v⟩ to be observed in the state ⟨u|. This operation is synonymous with measuring a quantum system where the measurement output is a scalar value.

The probability amplitudes of quantum mechanics should not be confused with classical probability. The latter is a result of real numbers () while the former is a result of complex numbers (ℂ).

The state of a quantum system can be manipulated to change its properties. The difference to a “measurement” (i.e. ⟨u|v⟩) is, that the result of such actions is a new (quantum) state and not a probability amplitude. These operators are represented by n × m-dimensional matrices which are defined by the outer product (also referred to as the tensor product) of a ket and a bra

so an operator  = |n⟩⟨m| converts the state |u⟩ into the new state  |u⟩ = |u’⟩. In general, quantum operators are square matrices (n × n) and not rectangular but, in principle, the Dirac notation is not limited to square operators.

Bloch Sphere

The Bloch sphere is a graphical representation of a quantum system such as a quantum computer. It is a useful tool for visualizing states and operations, such as rotations and measurements. Additionally, it is also helpful for understanding the relationship between the phase and the amplitude.

The Bloch sphere is a sphere where the surface represents the superposition of the two basis states |0⟩ and |1⟩ which will be described in more detail below. Any point on the surface of the sphere represents a quantum state, which can be expressed as a linear combination of |0⟩ and |1⟩:

The angles θ and ϕ in the equation are manipulated in a quantum computer. These operations are referred to as quantum computer gates and be discussed below. The cosine and sinus + Euler’s function which head |0⟩ and |1⟩ are their respective probability amplitudes, i.e., the probability of measuring |0⟩ or |1⟩.

Basis States

Basis states of quantum computers are a set of orthogonal vectors that correspond to the possible outcomes of a measurement. Two examples of basis states are

which correspond to the (possible) measurement results along the z-axis of the Bloch sphere, where θ = 0 and π, respectively. The numbers in the ket-vectors refer to physical properties (the spin) which will not be elaborated on here. The other basis states — besides |0⟩ or |1⟩ of the z-axis — are

of the x-axis, which can be easily obtained by looking at the Bloch sphere where θ = π/2 and ϕ = 0 or π. The basis along the y-axis with θ = π/2, and ϕ = π/2 or 3π/2

where

is the imaginary number “iota”. Only one of the axes is measured at a time which is typically chosen to be the z-axis in quantum computing.

Multiple states

Basis states of more than one quantum system can also be represented in the Dirac notation, too. An example of a multi-state (2 states) system in the z-basis is:

The product state of n states is represented by a 2^n vector, thus 4 in the case in this example. Multi-basis states are written as decimal numbers for convenience, i.e.,

Each of these basis states of the entangled multi-qubit system is associated with a probability amplitude α. The generalized state of the quantum system is thus described by the wave function:

which is the mathematical representation of a quantum system. It is this mathematical object that is manipulated and measured with quantum computers. Quantum algorithms are designed to modify the wave function to compute answers to complex mathematical questions.

The Properties of Quantum Systems

The term “quantum systems” refers to physical systems that follow the laws of quantum mechanics. They range from small, isolated particles, such as atoms and photons, to larger, complex systems such as molecules. Humanity has learned to build and manipulate quantum systems, such as quantum computers, to control their (quantum-mechanical) state.

Superposition

One key concept of quantum mechanics that is exploited in quantum computers is superposition. It describes the state of a quantum system as being in multiple states simultaneously, i.e., the system can exist in more than one state at the same time. This strange property of quantum mechanics holds until an observation or measurement is made which causes the quantum state to collapse. Thus, the quantum system “decides” to take on exactly one of its possible states at the time of the measurement.

This concept is often illustrated with the example of Schrödinger’s cat, where a hypothetical “cat in the box” can be considered to be in a superposition of the states “alive” and “dead” until the box is opened. An observation is made, causing the wave function (probability of 50 % alive and 50 % dead) to collapse into one of the two possible states.

Interference

Interference refers to the phenomenon where two or more quantum states are combined to produce a new state. The state of each quantum system is described by a wave function with similar properties to classical waves. The image below shows an example of how waves can add or cancel each other.

This property of quantum systems is utilized in some quantum computing algorithms. Such algorithms are designed so that “bad” results interfere destructively and cancel out, while the probability of “good” results is enhanced.

Entanglement

Entanglement is another fundamental property of quantum physics. It is also one of the critical features exploited in quantum computers. Entanglement describes the case where two or more quantum systems become so strongly correlated that the measurement of one system instantly affects the other. This property holds even when the two entangled systems are separated by a considerable distance (like from one end of the universe to the other).

Entangled quantum systems are used in quantum teleportation where (quantum) information is transferred from one location to another, without physically transmitting the information. The process involves measuring the state of one entangled particle, which instantaneously collapses the state of the other entangled particle, sharing the information.

Qubits — The Building Blocks of Quantum Computing

A bit (short for binary digit) is the smallest unit of information that can be represented by computers. It can be only one of two values 0 and 1.

Quantum computers manipulate media with quantum mechanical properties. These media can be categorized into the following types of quantum computers:

  • atomic: ‘trapped’ atoms in crystals or by electromagnetic fields
  • superconducting: electric circuits of superconducting materials
  • optical: special light sources

quantum computers. The physical units that contain and manipulate a quantum system are called quantum bits or qubits, which use a more sophisticated data representation than classical bits on a computer.

Qubits

The qubit is the smallest information unit of quantum computers. The main difference between a classical bit and a qubit is the way they represent information. A classical bit can be either 0 or 1 and can thus only represent one piece of information.

On the other hand, a qubit can use the quantum mechanical effect of superposition so that it can be in state |0⟩ and |1⟩ at the same time, allowing it to represent more than one piece of information at a time. The superimposed state has the form a|0⟩ + b|1⟩, where a and b are complex numbers that satisfy the condition |a|^2 + |b|^2 = 1.

Notation

A quantum computer consists of multiple qubits, which means, that it can be in more than the two states |0⟩ and |1⟩. An n-qubit state is defined by

The following table provides examples of multi-qubit states with different n.

or in the equivalent decimal representation

A quantum computer with n-qubits is in a superposition of all possible states. The mathematical representation of such a system is

where the sign “⊗n“ indicates the number of qubits in the system.

Quantum Gates

The previous section discussed how information is represented in quantum computers. This section is about how this information can be manipulated. Classic bit operations apply a prescribed boolean function (gate) such as the 1-bit “not” operation (flip the value of the bit) or the 2-bit operations called “and” and “or”.

Quantum gates are operations that manipulate the state of qubits by applying the principles of quantum mechanics, such as superposition, entanglement, and interference. There are several types of quantum gates, and each gate performs a specific operation on one or more qubits. Each quantum gate is represented (mathematically) by a unitary matrix, which describes the transformation of the qubit states under the action of the gate. The unitarity of the matrix ensures that the gate is reversible, which is a fundamental concept of quantum computing, i.e., the conservation of information.

A computation is reversible if it is always possible to recover the input given the output. For instance, the “not” operation is reversible, because if the output bit is “0”, you know the input bit must have been “1”, and vice versa. On the other hand, the “and” operation is not reversible as shown in the following table:

The highlighted part shows three input combinations where the “and” operation results in the value, “0”. It is not possible to say which of the three inputs (“0 & 0”, “0 & 1”, and “1 & 0”) was provided if the only information is that the output is “0”.

Reversible computing is a computing paradigm where the operations performed by a computer can be undone. In other words, if an operation is applied to an input to get some output, then another operation can transform the output and get the original input.

Reversible computing is important for quantum computers because it allows for the conservation of quantum information. Quantum information is fragile and easily lost during computation due to decoherence (cf. to section noise) which occurs when the quantum state of a system interacts with its environment. Reversible computing allows the recovery of quantum information by running the computation backward and recovering the original quantum state.

The most common quantum gates include:

  • Hadamard gate (H gate): This gate is used to create a superposition state on a qubit. It maps the |0⟩ state to the |+⟩ state and the |1⟩ state to the |-⟩ state so that the probability of measuring |0⟩ or |1⟩ after the gate is exactly equal.
  • Controlled not gate (CNOT): This gate is used to entangle two qubits. It applies a conditional bit flip on a “target” qubit if the second qubit — the “control” qubit — is in the |1⟩ state. In the illustration below, the qubit |a⟩ is the control, and |b⟩ is the target. The output |b’⟩ is equal to |b⟩ if |a⟩ = |0⟩ (middle) while it is flipped if |a⟩ = |1⟩ (bottom).
  • Pauli gates (X, Y, and Z): These gates are used to perform a bit flip, phase flip, or both on a qubit.
  • Phase gate (S): This gate introduces a phase shift of π/2 radians on a qubit, which can be used to create interference patterns.

Quantum Circuits

A quantum circuit model is composed of horizontal lines, so-called “wires”, that carry information from the left (the input) to the right (the output). The circuits modeled in quantum computing are acyclic so that the information and the wires never feedback to a prior location in the circuit.

The information carried by the wires is manipulated through gates that perform elementary operations on the information.

Entanglement of two Qubits

The word entanglement was already mentioned multiple times in this article, so it is interesting to see a quantum circuit that realizes such an entanglement of qubits.

The image above shows how the Hadamard gate and the CNOT gate are combined to entangle two qubits. First, the upper qubit is put into a superposition state with the Hadamard gate so that the probability of measuring |0⟩ is equal to the probability of measuring |1⟩ for this qubit. In the second step, this qubit is used as a control to flip the state of the lower qubit.

The qubits are now entangled because the circuit state cannot be described as a combination of single-qubit states. That this statement is true can be shown by looking at the mathematical result of the entangled system:

where the detailed mathematical investigation shows, that there is no combination of single-qubit states |uv⟩ that would describe the final state:

The physical consequence of the entanglement is that the measurement of one qubit must automatically collapse the other qubit. This holds even over large distances. Assuming that person A has one qubit and measures the state |0⟩, then person A knows, that person B, which has the entangled second qubit, will measure the same value. The connection between the two qubits exists only in the quantum world thus it is completely secure, which makes entangled qubits interesting for encryption.

Measurements

The term measurement refers to the mechanism of extracting the Bloch components of a qubit or multiple qubits. These components correspond to the projection of the state vector along the x, y, or z-axis. Only one axis (usually the z-axis) can be measured so the state vector needs to be rotated before the other axes can be measured.

The quantum circuit is closed during the time of the computation, meaning that it is not allowed to interact with its environment, however, it must be allowed to interact with a measurement apparatus at some point to retrieve the properties of the system, which means that the system must be opened. The mind experiment of Schrödinger’s cat is a good analogy for what a “closed” and “open” system is.

Classical Data Representation on Quantum Computers

Classical data must be encoded and transferred to the Quantum computer before it can be used to train the algorithm. This involves mapping classical data into a quantum state that can be processed by a quantum computer. Various techniques have been proposed of which a few will be discussed below.

Basis Encoding

The basis encoding algorithm represents classical data bits by an equal number of qubits, i.e., x = 10101010 becomes |x⟩ = |10101010⟩. This method is very intuitive but requires many qubits compared to other encoding techniques because it needs to map all n classical bits into n qubits.

The table below shows an example of how classical data (called “features” in the table) are mapped on a quantum computer.

Quantum Associative Memory (QAM)

This type of encoding is used for pattern recognition and retrieval. The basic idea of QAM is to store a set of patterns in a quantum register, which is a collection of qubits that are entangled with each other. The entanglement between the qubits ensures that the stored patterns are preserved and can be retrieved. QAM prepares a superposition of basis-encoded values in the register where each value is weighted equally.

The following table provides an example where three values/patterns are first represented as a binary number mapped onto the quantum computer. A quantum state is created by bringing all three patterns into superposition, where the probability of measuring/retrieving one of the three patterns is equal, i.e. 1/3.

To retrieve a pattern from the QAM, a query pattern is sent to the quantum register. The qubits in the quantum register interact with the query pattern, and the resulting state of the qubits is measured. The measured state corresponds to the stored pattern that is most similar to the query pattern.

Amplitude Encoding

Encodes classical data into the amplitudes of a quantum state. The classical values are normalized to the interval [-1, 1] and each value is then represented by an amplitude of a multi-qubit state. It represents a normalized classical N-dimensional data point as the amplitudes of an n-qubit quantum state, i.e.,

The amplitude encoding algorithm can encode a large amount of classical data into a relatively small number of qubits, which is important for implementing quantum machine learning algorithms on state-of-the-art quantum devices.

Angle Encoding

Angle encoding works similarly to amplitude encoding. The difference is that the classical values are normalized to the interval [-π, π] and each value is then represented by a rotation of a single qubit state.

Angle encoding embeds n features into the rotation angles of n qubits.

Feature Embedding

A key concept in data classification methods is that of a “kernel”. Data cannot typically be separated by a hyperplane in its original space. A common technique used to find such a hyperplane consists of applying a non-linear transformation function to the data. This function is called a feature map, as it transforms the raw features, or measurable properties, of the phenomenon or subject under study.

Quantum feature maps can be described as a set of quantum gates that act on a set of qubits and are parametrized by classical data.

How do quantum computers compare to classical computers?

The schooled eye of computer scientists immediately recognized that the binary and decimal representations of qubits look formally identical to the classical case and indeed, the measurement of the state of a quantum computer will always be a classical binary/decimal result.

This raises the question of what the difference between quantum and classical computers is. The answer is somewhat surprising. If an operation or function is executed with a certain input the result will always be the same in the case of a classical computer. The output of the quantum computer will be a distribution of results, meaning, that the results may vary for each computation.

So the results from quantum computers can be seen as “less reliable” than classical computers. Quantum computers need to perform one operation multiple times to get a distribution which then needs to be interpreted. This may seem like a waste of time, but quantum computers have the potential to perform certain tasks exponentially faster than classical computers, which means, that they are still faster than classical computers even if they calculate the same thing 1000 times.

The different operation techniques of quantum and classical computers clearly show that quantum computers are not suitable for all types of computing tasks so it is unlikely that they will completely replace classical computers, but they may become an important supplement to them.

Noise — The Show Stopper of Quantum Computing

One of the main challenges facing the development of practical quantum computers is the problem of noise. Noise in quantum computers is a big field of research and this section is intended to provide a basic overview.

Noise in quantum computers refers to any unwanted and random perturbations in the quantum states of the qubits, which lead to errors in quantum computations. The sources of noise in quantum computers include environmental factors such as temperature fluctuations or electromagnetic fields.

Imagine a gyroscope that is not disturbed by any environmental factors, so that it can spin perfectly. This gyroscope represents a quantum state without any noise.

One of the main challenges to reducing the noise in quantum computers is decoherence which occurs when the quantum system interacts with its environment, causing the quantum state of the system to become entangled with the environment.

One approach to address the effects of noise in quantum computers is to use error correction codes, which encode the quantum information in such a way that errors can be detected and corrected. However, implementing error correction codes requires a large number of qubits and operations, and is therefore challenging for current quantum computing technology. Another idea is to use quantum error mitigation techniques, which aim to reduce the impact of noise on quantum computations. This can be done using a variety of methods, such as dynamical decoupling, quantum error correction, and noise spectroscopy.

Dynamical decoupling is a technique that involves applying a sequence of pulses to the qubits to protect them from environmental noise. This can be effective in reducing the impact of noise on quantum computations but requires careful control of the pulse sequence and timing.

Quantum error correction involves encoding the quantum information in such a way that errors can be detected and corrected using additional qubits. This can be effective in reducing the impact of noise on quantum computations but requires a large number of qubits and operations.

Summary

This post provides an introduction to quantum computing and the potential impact of quantum computing in solving problems that classical computers cannot handle and mentions industries that could benefit from it.

The first part of the text explains the math related to quantum computing such as the Dirac notation, which is used to describe the state of quantum systems, and introduces the Bloch sphere as a graphical representation of quantum systems were introduced. The properties of quantum systems, such as superposition, interference, and entanglement were also covered.

The second part focuses on qubits, which are the building blocks of quantum computing. The difference between classical bits and qubits was explained, especially the concept of superposition and how qubits can represent multiple pieces of information simultaneously. Furthermore, quantum gates were introduced, which are operations that manipulate the state of qubits based on principles of quantum mechanics.

--

--