Introduction
Quantum computing may be on the cusp of revolutionizing modern computing. Gartner predicts that “by 2023, 20% of organizations will be budgeting for quantum computing projects.”
The major cloud providers: Microsoft, Amazon, Google, IBM, and Oracle are racing to bring quantum computing as a service to their offerings. In addition, companies, universities, and even nation states are investing heavily.
Why all the buzz? Quantum computers offer the potential to bring parallelism to calculations on a scale that cannot be matched by classical computers. They may enable us to model the quantum world, bringing breakthroughs in material science, medicine, you name it.
There already exists actual multi-qubit quantum computers, such as IBM, that allow you to create and run quantum algorithms in the cloud.
Despite the general optimism, there are contrarians who argue that larger multi-qubit systems are not feasible and will never happen. But, the physics underpinning quantum computing has been widely validated experimentally and researches continue to make advances in improving the accuracy of multi-qubit systems.
For software engineers, it’s a field that is ripe for exploration.
My Journey into the Quantum Realm
In all likelihood, like me, you’re a software engineer looking to cut your teeth with the latest quantum tech. Unfortunately, nearly all of the resources online on the topic of quantum computing come from a mathematics or physics bent; much of the time written by physicists for physicists.
When I began learning quantum theory several months ago, my first step was to plunge head first into what, according to some, is the authoritative text on the subject: Quantum Computation and Quantum Information, by Nielsen and Chuang. Apparently this is the book used in many physics schools. I soon found myself struggling with the linear algebra and I knew I was going to need to take a step back and read up on that. Fortunately I had an old (8th) edition of Elementary Linear Algebra, by Anton sitting on my bookshelf; left over from my undergraduate days, nearly two decades ago. I worked my way through that, and thoroughly enjoyed it. Towards the end, after a few weeks of study, I had another crack at a quantum text. This time I chose Quantum Computing for Computer Scientists by Yanofsky and Mannucci. More and more came into focus now. The only thing noticeably missing from the linear algebra book was tensors. I turned to the web for that, and tensor products turned out to be dead simple.
So, armed with my newly acquired linear algebra, I pushed through the quantum computing book; turning to the web to increase clarity here and there. Eventually I found myself where I wanted to be from the beginning, understanding and constructing quantum circuits.
While the mathematics and notation underpinning quantum theory seems daunting at first. Along my own journey, I’ve been taken with the elegance by which it all fits together. I wrote this series of articles to provide you with a grounding in the fundamentals of quantum computing without spending a lot of time on quantum mechanics (the branch of physics). This series doesn’t spend much time on covering the relevant mathematics up front either, but rather introduces critical mathematics along the way. While there’s quite a bit of math and formulas littered throughout these articles, we work through them together.
Let’s dive in.
Bits to Qubits
In quantum computing, a qubit is analogous to a bit in classical computing. As is a qubyte to a byte. As with classical computing, a qubit has two measurable states but there’s a little more to it.
When you measure a qubit, its quantum state is said to collapse; to a value that is either 0 or 1. Before you measure it, however, the two observable states have a certain probability. You can modify the probabilities of a quantum state, and what’s more, you can employ multiple qubits that affect one another.
A qubit is represented as a vector. The zero qubit state is represented by the single column matrix [1, 0]T. The one qubit state is represented by [0, 1]T. These are known as its basis states. The ‘T’ superscript denotes the transpose of the matrix, and allows the matrix to be presented horizontally. It’s used occasionally to save space.
These two basis states are orthonormal, which means they are orthogonal and normalized. Together they are called the computational basis. Let me explain these terms.
Orthogonal means that the inner product of the matrices is 0. To calculate the inner product (a.k.a. the dot product), we multiply each item in the first matrix with its counterpart in the second matrix and sum them all together, like so:

Normalized means that the probabilities of the observable states add up to 1. Determining the probability of quantum states is fundamental to quantum information theory, and we delve further into that later in the article. Firstly, however, we need to cover some basic math; complex numbers and matrix multiplication, then familiarize ourselves with Dirac notation.
Math to Know
Though it may appear otherwise, I’ve tried to keep the math in the article simple. There are, however, a couple operations you need to have under your belt to be able to able to follow along. In particular, you need to know how to multiply complex numbers and matrices. We look at those operations now.
Multiplying Complex Numbers
In quantum computing, qubits are represented as vectors in 3 dimensional space. In quantum circuits, we rotate them and combine them to perform computations. Complex numbers are often used to rotate qubits in this space.
A complex number consists of a real part (x) and an imaginary part (y), as shown:
x + yi
i equals √-1, and (√-1)2 equals -1.
When multiplying two complex numbers, you add together the products of the real and imaginary parts of both numbers. See Figure x.
The result is:
(x1 + y1i)(x2 + y2i) = x1x2 + x1y2i + y1x2i + y1y2(i2)
Since i2 = -1, this simplifies to:
= x1x2 - y1y2 + x1y2i + y1x2i

The following is an example:
(3 + 2i)(4 + 3i) = 12 + 9i + 8i + 6i2 = 12 + 17i - 6 = 6 + 17i
Multiplying Two Matrices
When working with quantum states, there are three matrix by matrix multiplication operations that are commonly performed: direct product, inner product, and tensor product (a.k.a. outer product). We look at the direct product now and cover the inner and tensor products in later sections, as we need them.
The first thing to note is that calculation of the direct product is only valid if the number of columns in the first matrix is equal to the number of rows in the second matrix. See Figure x.
Also notice that the row count for the result equals the row count of the first matrix, and the column count of the result, equals the column count of the second matrix.

The direct product is generally written without an operator as AB, where A and B are two matrices.
Let’s work through an example, where matrix A and B are presented below.

To calculate AB, we multiply each item in the first row of A by the item in the first column of B with same index, and sum the products. The result is 1×2 + 3×3 + 2×1 = 13. The value 13 is placed into the first cell of the result matrix.

We then stay on the first row of A, but we shift to the next column of B; repeating the process until we get to the end of the columns in B.

We then shift down to the second row of A, and back to the first column in B. After we reach the last row in A, we’re done.

Multiplying a Matrix by a Scalar
The principal of multiplying a matrix by a scalar is a simple one: You multiply every item in the matrix by the scalar.
If A is the matrix:

Then multiplying the matrix by a scalar produces:

For example, if the scalar multiplier is 2 and A’s values are:

Then the result is as follows:

If the scalar is a complex number and/or the matrix contains complex numbers, the procedure does not change. You calculate the products using the rules of complex number multiplication, which we looked at in a previous section.
Okay, so we’ve looked at some basic math operations that we need to know to follow along. Let’s move on to something more fun.
Describing Quantum State with Dirac Notation
Dirac notation (also known as bra-ket notation) is everywhere in quantum theory. It’s used to describe quantum states. You can think of it as matrix shorthand.
A single qubit with the zero basis state can be written as a ket, like so:
|0〈
This reads as “ket zero.”
Conversely, a qubit with a one basis state, can be written as:
|1〈
NOTE: In some texts, |0〈 and |1〈 are presented as |↑〈 (spin-up) and |↓〈 (spin-down), respectively. When you visualize a qubit on a three dimensional sphere, |0〈 is up at the north pole and |1〈 is down at the south pole. I use |0〈 and |1〈 exclusively in this series.
Recall that 0 represents the column vector [1, 0]T, and 1 represent [0, 1]T.
| In Dirac notation, the values within the ket (between the vertical line character ‘ | ’ and the angled bracket ‘〈’) are tensor products. |
The tensor product is calculated by multiplying each item in the first matrix by all items in the second matrix, as illustrated:

Tensor products are condensed within Dirac notation, like so:
|1〈 ⊗ |0〈 = |10〈
You can see how they are combined by calculating the tensor product of the matrices, like so:

In a quantum circuit, the inputs to the circuit are combined as tensor products. We explore this later in the series.
For qubits, the Dirac notation lends itself beautifully to a binary representation. Notice below how entries in the matrix correspond to the binary, and in particular how the first entry in the matrix corresponds to 0 and not 1.

NOTE: In some texts, the leading 0’s are omitted and replaced with a subscript indicating the length. So that 0010〈 becomes 104〈. I’ll not be using that convention however.
| If the Dirac notation points to the left rather than the right, as in: 〉0 | , this is called a bra. Together they form a bra-ket. |
Deriving a Bra from a Ket (and Vice Versa)
The bra is the conjugate transpose of the ket. The conjugate transpose is also known as the adjoint matrix, and yet another name is the Hermitian transpose.
To obtain the conjugate transpose, the matrix is rotated and each entry is complex conjugated. For a single column matrix, it just means we turn it horizontally and then take the complex conjugate of each entry. See Figure x.
The complex conjugate simply means changing the sign of the imaginary part. For example, if z = 2 + 3i, then the complex conjugate is z = 2 - 3i.

Why Complex Numbers? You may wonder why quantum theory relies so heavily on complex numbers. Well, if you add two positive real numbers, the result will always increase. That’s not the case with Complex numbers. You can add two complex numbers and produce a smaller result. In fact, they may even cancel each other out. This is referred to as interference, and it’s sometimes employed deliberately to eliminate unwanted states in quantum algorithms.
In the following examples we use the variables a and b, such that a,b ∈ Cd. In other words, a and b denote single column matrices of complex numbers with the number of rows equal to d. Most of the time when we are working with qubits, so the dimension count is 2.
The following illustrates obtaining a bra from a ket:

This process is reversible. To obtain a ket from a bra, do the same thing again; calculate the adjoint.
| When combined, a bra-ket 〉b | a〈 represents the inner product of b and a. It’s sometimes written as 〉b,a〈. The inner product is the sum of the products of corresponding items. This results in a complex scalar value (with or without an imaginary part). Scalar means that it’s not a vector; it’s a magnitude without direction. |

| All quantum states are normalized, that is 〉a | a〈 = 1. This has important implications for the probability of states. We return to it in a later section. |
We’ve seen that quantum theory relies on complex numbers and vectors to describe quantum particles. This algebraic structure is termed a complex vector space and also known as Hilbert Space.
| Another combination of the Dirac notation, which I include for completeness, is the ket-bra. It’s written like this | a〈〉b | or sometimes | aXb | . A ket-bra is the tensor (or outer) product and represents a d by d matrix, illustrated as follows: |

TIP: In quantum theory, it’s common to see the Greek characters φ (phi) and ψ (psi) used as placeholders in bras and kets. For example 〉φ ψ〈 Don’t be put off by the Greek characters, foreign notation, and seemingly complex algebra. It all appears far more complex than it actually is.
Exploring Quantum Superposition
We learned in an earlier section that when you measure a qubit, its quantum state collapses to either 0 or 1. To which value it collapses depends on the way the qubit has been configured. You can change the probability of a qubit collapsing to a particular value. By doing so, you place the qubit into a superposition.
| Now, for a qubit that is in a pure basis state, either | 0〈 or | 1〈, the result is predetermined. It has a 100% chance of collapsing to its respective value. In other words, if you measure a qubit that was placed in the | 0〈 state, for example, you always get 0 because the probability of collapsing to 0, is 1; and the probability of collapsing to 1, is 0. |
But, if you employ, for example, a Hadamard gate in your quantum circuit, you can split the probability of the qubit collapsing to 0 or 1, to a 50/50 chance either way.
When a qubit is in a superposition, its value is undetermined until it’s measured. In fact, a qubit is said to be simultaneously 0 and 1 until then. It’s both!
This is such an unusual phenomenon it has driven physicists bananas. Yet, it has been widely observed experimentally. Remember the old double slit experiment? A photon seemingly goes everywhere, interfering with itself, before landing on a spot. So to does our qubit exist in all observable states until it is measured.
While there the probability of any observable state is essentially random, you can, fortunately, modify the probabilities of the observable states. When you do this, you place the qubit into a superposition.
Disambiguating the Term “State” When one or more qubits make up a quantum system, this system has an overall quantum state at any one time. However, the system has a set of distinct states that it may collapse to when measured. We’ll call these states: observable states.
To recap, as quantum engineers, we have the opportunity to manipulate the probabilities using quantum gates in our quantum circuits. We can also combine qubits in such a way that they correlate with one another. We can even leverage quantum entanglement to instantly affect the state of one qubit with another qubit, even if the qubits are far away from one another. We delve deeper into quantum entanglement in a later article.
The quantum state of one or more qubits can be described using Dirac notation and simple algebra. Observable states and associated probabilities comprise the qubit’s superposition.
| A single qubit can be described by a linear combination of | 0〈 and | 1〈, such that: |
| Ψ〈 = α | 0〈 + β | 1〈 |
α and β are known as complex amplitudes or probability amplitudes. The name ‘amplitude’ comes from the fact that a quantum state is a wave, and a wave is characterized by its amplitudes. [Reference page 106 “Quantum Computing for Computer Scientists”]
Calculating Observable State Probability
To calculate the probability of qubit collapsing to a particular state, we take the square of the modulus of its coefficient. This is known as the Born rule.
| So, for the | ψ〈 example shown above, the probability of | 0〈 is | α | 2. |
Calculating the Modulus
The modulus of a complex number is calculated like so:

To calculate the probability we square that number. All together this can be written succinctly as shown:

This is saying that to calculate the probability of the observable state Xi (which is either going to be 0 or 1 for a qubit), you square the modulus of the dot product. In other words, you project the state your interested in onto the superposition.
Don’t worry if the algebra doesn’t make sense yet. Next we look at an example, and then we further illustrate it using matrices.
Say our qubit superposition is given by the following:

Then the probability of collapsing to 0 is given by:

| Now, we can reduce 〉0 | 0〈 to 1, as shown: |

| and because 〉0 | and | 1〈 are orthogonal, there inner product is 0, as shown: |

So, if we replace those brakets in our probability formula, we see that:

Alternatively, we can look at the same problem, but substitute matrices for our states and calculate the probability that way.

Hopefully the Dirac notation version makes a bit more sense now.
Probability Distribution of Quantum States
| We know that the sum of the probabilities in a probability distribution is always 1. And we learned earlier that all quantum states are normalized, i.e., 〉a | a〈 = 1. For orthonormal bases ([0, 1]†, [1, 0]† and the like) this means that the observable states are in a probability distribution and so their probabilities must also add up to 1. |

Therefore, we can calculate P(1) like so:

Creating Multi-Qubit States
So far we’ve looked at the quantum states of single qubits. We can, of course, create quantum states with multiple qubits. These are known as multi-partite quantum states.
| To do so, we combine states using tensor products. For example, if qubit A is in state | ψ〈A = | 0〈 and qubit B is in state | ψ〈B = | 1〈, then the total state is given by: |
| ψ〈AB = | 0〈A ⊗ | 1〈B = | 01〈AB. |
In this case, we can measure the state of qubit A without collapsing the state of qubit B. The individual states are said to be uncorrelated.
We can, however, place qubits into a state, where measuring one affects another. This is known as entanglement.
Entangling Qubits
For instance, take a well known state (one of the Bell states, which we discuss later), this state describes two qubits in superposition:

The state of the qubits when measured will have a 50% chance of being either 00 or 11.
If we were to measure just one of the qubits, it would cause the other’s state to immediately collapse to the same value. The qubits are said to be entangled.
Determining if Qubits are Entangled
When we look at the mathematics governing entanglement, we can use the matrix representation to tell us if the qubits are entangled.
A vector that can be written as the tensor product of two vectors is called separable. In contrast, if the tensor product state of two qubits cannot be factored, they are said to be entangled. This is pointed out in Andrew Helwer’s introductory video on quantum computing.
| For example, if we take the state | 01〈, and forget for a moment that we know what the tensor product representation is already. |
|  |
| We can see that ac = 0, ad = 1, bc = 0, and bd = 0. If we solve for a, b, c, and d; we get a = 1, b = 0, c = 0, and d = 1. We can factor it, therefore we know | 01〈 is separable and not entangled. |
|  |
| In contrast, if we look at the | φ+〈 state, it is a two qubits state in equal superposition. The matrix representation is calculated below: |
|  |
In this case the matrix is not factorable. ac = 1/√2, ad = 0, bc = 0, bd = 1/√2. There is no solution to a, b, c, and d. Therefore, the matrix is not separable and so the qubits are entangled. In fact, in this case, because of the equal probability of the two states |00〈 and |11〈, |φ+〈 is said to be maximally entangled. They’re as entangled as you can get.
But, how do we create a Bell state? We explore that later in the article. Next we look at visualizing single qubit states.
Visualizing a Qubit on the Bloch Sphere
Many operations on single qubits can be neatly visualized on a 3 dimensional unit sphere, known as the Bloch sphere. See figure x.
A qubit can be represented as a line of length 1 from the center of the sphere to the sphere’s surface.
| At the north poll sits basis state | 0〈; at the south, | 1〈. Before collapsing into a basis state, a qubits superposition may be located anywhere on the Bloch sphere. You can think of θ as latitude and φ as longitude. As we move vertically, north or south, the latitude changes (θ), and as we move horizontally the longitude (φ) changes. |
While the latitude affects the probability of the qubit collapsing to a particular basis state, the longitude does not. The longitude is referred to as the qubit’s phase.

A qubit superposition can be written
| ψ〈 = α | 0〈 + β | 1〈 |
where α and β are its probability amplitudes. They are two complex numbers.
Converting between Cartesian and Polar Representations
Recall that a complex number consists of a real part, x, and an imaginary multiplier, y:
c = x + iy
A complex number can be represented by just x and y. The pair (x, y) is called its Cartesian representation. It can be graphed on a two dimensional Cartesian plane. Such a graph is called an Argand diagram. See figure x.
The arg function can be used to calculate θ. In this case, arg is equivalent to atan2, as shown:
Arg(x + iy) = atan2(y, x) = tan-1(y/x)
Later in this section you see how to use the Arg function to calculate angles (θ, φ) on the Bloch sphere.

We can convert the Cartesian coordinates to polar representation. The polar coordinates consist of the modulus ρ and the angle θ. Recall that to calculate the modulus we use:

To calculate the angle, we use:

To convert back from polar to Cartesian representation, use:

Locating the Qubit on the Bloch Sphere
It’s okay to skim through this section. While its useful to understand how states are translated to the Bloch sphere, you can return to this at a later stage.
α and β can be visualized on the Bloch sphere as a point corresponding to the two angles (θ, φ).
| It turns out that because | α | 2 + | β | 2 = 1 we can calculate a qubit’s position on the Bloch sphere using the following: |

where 0 ≤ θ ≤ π, 0 ≤ φ ≤ 2π
That gives us
α = cos(θ/2), β = eiφ sin(θ/2)
To find the angles use
| θ = 2 cos-1( | α | ) |
and
φ = arg(β) - arg(α)
NOTE: You can also find these values via the state’s density matrix, which is calculated by its ket-bra: ρ = ψ〈〉ψ . But that’s outside the scope of this article.
Conclusion
References
- http://www.vcpc.univie.ac.at/~ian/hotlist/qc/talks/bloch-sphere.pdf
- ^ Sanchayan Dutta
- https://homepages.cwi.nl/~rdewolf/qcnotes.pdf
-
https://en.wikipedia.org/wiki/Quantum_logic_gate
- http://www.vcpc.univie.ac.at/~ian/hotlist/qc/talks/bloch-sphere-rotations.pdf