Getting Familiar With Quantum Gates (Without the Math)

In my post on classical computing, I talk about some of the basic gates used in classical circuits. Similarly to classical bits, qubits have gates applied to them to alter their physical state. Mathematically, these gates are operators represented in matrix form.

In some cases, a classical gate will have a related quantum gate where essentially the same function is being performed, but on a quantum instead of classical system. However in other cases, there is no classical gate related to a quantum gate because we are doing things like putting the qubit into a state of superposition, for which there is no equivalent in the classical world.

Another reason there isn’t a quantum gate for every classical gate is because quantum gates have an important requirement: they need to be reversible. This means that you can trace back the operation, undo it. This is not something that is possible with many classical gates. For example, examine the classical XOR gate’s truth table:

Input A Input B Output
0 0 0
0 1 1
1 0 1
1 1 1

If you were just given the output of this gate, you could not reliably know what inputs were used in the operation. If the output of the gate is 1, we know there are three paths to get there (represented by rows 2, 3, and 4 in the table above) but we don’t know which one got us to where we are. This makes this gate irreversible. It also means that some information is being lost in this operation (that is, the values of the inputs). It’s strange to think about, but this loss is actually physical and happens in the form of dissipative heat. There is a minimum amount of energy that must be dissipated when an irreversible operation occurs, and we call that Landauer’s bound after Rolf Landauer.

Matrix math

If you’re wondering when you really need to start using linear algebra to develop your understanding of quantum computing, it’s right about…now. Fortunately for you, the next couple of posts on this blog are going to be about linear algebra and laying down the basic groundwork of the math we’ll need.

In my post on vectors, I already started setting the stage for linear algebra by introducing unit vectors as a way to describe quantum states. Well, when we start looking at quantum gates/operators, we realize that vectors (represented as 1 row or 1 column of numbers) are quickly joined by matrices (which can have more than 1 row and more than 1 column), meaning you need to be familiar with how to do matrix math.

Gates themselves can be represented mathematically as a matrix, and when we “apply” the gate, there is a mathematical operation happening between the matrix and the quantum state (a vector). The resulting vector is the new quantum state.

In this post, we won’t cover the mathematical operations happening behind the scenes when a quantum gate is applied. We’ll come back to that once we’ve talked more about the math in future posts. Instead, we’ll briefly take a look conceptually at a couple of the basic quantum gates that operate on single qubit systems (called unary operators).

UNARY quantum OPERATORS

Hadamard (H) Operator:
$$\ket{0} \xrightarrow{\text{H}} \frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1}$$ $$\ket{1} \xrightarrow{\text{H}} \frac{1}{\sqrt{2}}\ket{0} - \frac{1}{\sqrt{2}}\ket{1}$$

The H gate does something really important - it puts the qubit into a state of superposition, specifically uniform superposition.

$$\frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1} \xrightarrow{\text{H}} \ket{0}$$ $$\frac{1}{\sqrt{2}}\ket{0} - \frac{1}{\sqrt{2}}\ket{1} \xrightarrow{\text{H}} \ket{1}$$

It is also capable of reversing itself when applied twice in a row, which is a feature that comes into play in the next operator.

Identity (I) Operator:
$$\ket{0} \xrightarrow{\text{I}} \ket{0}$$ $$\ket{1} \xrightarrow{\text{I}} \ket{1}$$

The H gate applied twice in a row is the identity gate:

$$ H^2 = I $$

In reality, applying the identity gate means doing nothing to the qubit - in fact, it means trying to physically protect and insulate the qubit from anything disturbing it, otherwise its state will change unintentionally.

Bit Flip (X) Operator:
$$\ket{0} \xrightarrow{\text{X}} \ket{1}$$ $$\ket{1} \xrightarrow{\text{X}} \ket{0}$$

This is related to the NOT operator in classical computing.

Phase Flip (Z) Operator:
$$\ket{0} \xrightarrow{\text{Z}} \ket{0}$$ $$\ket{1} \xrightarrow{\text{Z}} -\ket{1}$$

If you were to apply an H gate to a qubit in the computational state of 0, and then apply the H gate again, you would return back to 0 (this is shown above under the section about the H gate).

If you were to apply an H gate to a qubit in the computational state of 0, and then apply the Z gate, and then the H gate again, you would now land at 1.


So here we are - this is pretty much as far as we can get down the path of quantum computing before needing to rely more heavily on math, specifically linear algebra at this point. Onward!