Quantum foundationsLesson 3 of 5

Matrices

Matrices are the mathematical building blocks for quantum bits, quantum gates, and quantum circuits.

Matrices

This quick review of matrices will prime you to learn what qubits actually represent, including a concrete, non-woo-woo definition of superposition. Let’s get started.

Grid of numbers

A matrix is just a grid of numbers; rows and columns containing values. Matrices can be of any size. Here’s an example of a 3×2 matrix. It is 3 columns wide and 2 rows tall, containing the values 1 through 6.

When describing the dimensions of a matrix we always specify the number of rows first, then the number of columns. The above is an example of a 3×2 matrix, while below is a matrix containing similar data, but in a 2×3 configuration.

Order matters

For our purposes, we’ll express our matrices in row-major order. This means we read the values just as they are ordered above, starting with the top-most row, reading values from left to right, then proceeding to the next row down and repeating that process. Our choice of row-major order makes reading and writing matrix values more akin to reading and writing in English; easier to type and program here.

Vectors are slices

While a matrix is a two-dimensional grid of numbers, a vector is more like a slice of numbers, such as a “skinny” matrix that is only one column wide, or a “flat” matrix that is only one row high. Let’s look at some examples of matrices that are simultaneously vectors.

While the above 2×2 matrix is not a vector, you could say that it contains vectors: Two column vectors or two row vectors. Because vectors are just a type of matrix we can add them, multiply them, and so on, just like any other matrix. Vectors will play a prominent role in defining Qubits and expressing the state of a quantum circuit.

Complex numbers

In addition to storing regular numbers, matrices can contain complex numbers. This is both useful and necessary: Qubits are really just a pair of complex numbers that we store in a 1×2 matrix. So, yes, the example matrices above are each larger than a qubit!

Stay in the loop.

Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.