author | description | ms.author | ms.date | ms.service | ms.subservice | ms.topic | no-loc | title | uid | ||
---|---|---|---|---|---|---|---|---|---|---|---|
bradben |
Learn what basic linear algebra concepts are needed to understand quantum computing |
v-benbra |
02/01/2021 |
azure-quantum |
qdk |
overview |
|
Linear algebra for quantum computing |
microsoft.quantum.overview.algebra |
Linear algebra is the language of quantum computing. Although you don’t need to know it to implement or write quantum programs, it is widely used to describe qubit states, quantum operations, and to predict what a quantum computer does in response to a sequence of instructions.
Just like being familiar with the basic concepts of quantum physics can help you understand quantum computing, knowing some basic linear algebra can help you understand how quantum algorithms work. At the least, you’ll want to be familiar with vectors and matrix multiplication. If you need to refresh your knowledge of these algebra concepts, here are some tutorials that cover the basics:
- Jupyter notebook tutorial on linear algebra
- Jupyter notebook tutorial on complex arithmetic
- Linear Algebra for Quantum Computation
- Fundamentals of Linear Algebra
- Quantum Computation Primer
In the topic Understanding quantum computing, you saw that a qubit can be in a state of 1 or 0 or a superposition or both. Using linear algebra, the state of a qubit is described as a vector and is represented by a single column matrix $\begin{bmatrix} a \\ b \end{bmatrix}$. It is also known as a quantum state vector and must meet the requirement that
The elements of the matrix represent the probability of the qubit collapsing one way or the other, with
In Quantum computers and quantum simulators you also saw that quantum operations are used to modify the state of a qubit. Quantum operations can also be represented by a matrix. When a quantum operation is applied to a qubit, the two matrices that represent them are multiplied and the resulting answer represents the new state of the qubit after the operation.
Here are two common quantum operations represented with matrix multiplication.
The X
operation is represented by the Pauli matrix
and is used to flip the state of a qubit from 0 to 1 (or vice-versa), for example
The 'H' operation is represented by the Hadamard transformation
and puts a qubit into a superposition state where it has an even probability of collapsing either way, as shown here
Notice that
A matrix that represents a quantum operation has one requirement – it must be a unitary matrix. A matrix is unitary if the inverse of the matrix is equal to the conjugate transpose of the matrix.
In the examples above, the state of one qubit was described using a single column matrix $\begin{bmatrix} a \\ b \end{bmatrix}$, and applying an operation to it was described by multiplying the two matrices. However, quantum computers use more than one qubit, so how do you describe the combined state of two qubits?
Remember that each qubit is a vector space, so they can't just be multiplied. Instead, you use a tensor product, which is a related operation that creates a new vector space from individual vector spaces, and is represented by the
The result is a four-dimensional matrix, with each element representing a probability. For example,
Just as a single qubit state $\begin{bmatrix} a \\ b \end{bmatrix}$ must meet the requirement that
Linear algebra is the standard language for describing quantum computing and quantum physics. Even though the libraries included with the Microsoft Quantum Development Kit helps you run advanced quantum algorithms without diving into the underlying math, understanding the basics helps you get started quickly and provide a solid foundation to build on.
Install the QDK