I’ll try to explain the topics to the best of my ability, but it would help for anyone reading this to understand the basics of linear algebra and digital logic. (You can learn about linear algebra here, and digital logic here).

Lets start with a quick recap of digital logic. Digital logic is based around the manipulation of electricity in circuits to make calculations. For the sake of abstraction, we simplify the state of a wire carrying electricity with a state of ‘1’ or ‘0’, representing ‘on’ or ‘off’. By arranging transistors in specific patterns, we can create ‘Logic gates’, which take one or more inputs, and produce an output depending on a specific set of boolean logic.

Common logic gates and their corresponding truth tables.

By chaining these basic gates together, we can create more complicated gates, and by chaining more complicated gates together, we can eventually end up with a CPU through enough abstraction.

As stated previously, we’re going to need a way of representing digital logic mathematically, and we’ll start by describing traditional logic as such. With linear algebra, you can represent the classical bits ‘1’ and ‘0’ as 2x1 column vectors as such:

With the figure on the left being the dirac notation of the vector. By representing our bits as such, we can model logical operations on a bit by using vector transformations. Note that while there are many operations you can do on two bits with logic gates (AND, NOT, XOR etc…), there are only four operations you can do on a single bit: identity, negation, constant 0 and constant 1. Identity leaves the bit unchanged, negation flips the bit (sets 0 to 1 or 1 to 0), and constant-1 and 0 set the bit to 1 or zero regardless of what it was originally.

Given our new representation of a bit, you can see that it’s now quite simple to perform operations on this bit by performing vector transformations on it.

Before moving on, we’ll need to cover a topic known as reversible computing. This simply means that for an operation or logic gate to be reversible, you must be able to determine the set of inputs used, given the output and the name of the operation used. From this, you can probably tell that the Identity and Negation operations are reversible, while the constant-1 and 0 operations are not. Owing to the unitarity property of quantum mechanics, quantum computers only ever use reversible operations, and so we will solely focus on these. Later on, we will be converting non-reversible gates to reversible ones to make them possible to use in a quantum computer.

You can represent multiple bits at a time by using the tensor product of each bit together.

Now that we’ve got most of the maths we need, we’ll introduce our first quantum logic gate. This operator is called a CNOT, or controlled NOT gate and is very important to reversible and quantum computing. A CNOT gate works on a pair of bits and returns a pair of bits. The first bit is designated the ‘control’ bit, and the other the ‘target’ bit. If the control bit is 1, the target bit is flipped, and if the control bit is 0, the target bit is left unchanged.

This operator can be represented with the following transformation vector:

To demonstrate what we’ve covered so far, this is how we would use a CNOT gate on multiple bits:

To summarise everything up until this point, in the first example we expand |10⟩ into its tensor product, apply the CNOT matrix to get a new resulting product state, then we factor it out to get a result of |11⟩, as we would expect from the CNOT table that was shown before.

Now that we’ve covered all the maths needed to understand traditional computing and bits, we can start to discuss actual quantum computing and quantum bits.