Matrices and Quantum Operations
Matrices and Quantum Operations
In[]:=
<<Wolfram`QuantumFramework`
Key Concepts
Key Concepts
◼
Matrix multiplication
◼
Tensor product
◼
Unitary matrix
Matrix Multiplication
Matrix Multiplication
You have just seen that quantum states can be represented as vectors and matrices. It should then be no surprise that quantum operators can also be represented this way. Matrix multiplication can be used to write down the rules by which a quantum operation turns one quantum state into another.
If you would like a full review of matrices and matrix arithmetic, this can be found in Introduction to Linear Algebra or Introduction to Finite Mathematics. Luckily, the Wolfram Language can automate the arithmetic so you can focus on the results.
Recall that a matrix can be specified as a list of lists:
In[]:=
{{a,b},{c,d}}//MatrixForm//TraditionalForm
Out[]//TraditionalForm=
a | b |
c | d |
A vector can be simply specified as a list of coefficients:
In[]:=
{x,y}//MatrixForm//TraditionalForm
Out[]//TraditionalForm=
x |
y |
In[]:=
{{a,b},{c,d}}.{x,y}
Out[]=
{ax+by,cx+dy}
Written in traditional notation:
In[]:=
a | b |
c | d |
x |
y |
Out[]//TraditionalForm=
ax+by |
cx+dy |
Example
Example
Compute the product of the matrix and the vector .
2 | -5 |
-1 | 4 |
3 |
-2 |
Solution
Automate the computation:
In[]:=
{{2,-5},{-1,4}}.{3,-2}
Out[]=
{16,-11}
The product is the vector .
16 |
-11 |
Quantum Operators as Matrices
Quantum Operators as Matrices
Let’s examine the Dirac notation for the result of applying a particular quantum operator to an initial state:
In[]:=
(QuantumOperator[{{a,b},{c,d}}]@QuantumState[{x,y}])//TraditionalForm
Out[]//TraditionalForm=
(ax+by)|0〉+(cx+dy)|1〉
This result should remind you of the generic matrix product in the last section.
In[]:=
(QuantumOperator[{{a,b},{c,d}}]@QuantumState[{x,y}])["Matrix"]//MatrixForm//TraditionalForm
Out[]//TraditionalForm=
ax+by |
cx+dy |
You know from the last lesson that a quantum state can be represented by a list of amplitudes. These amplitudes can also represent coefficients in a complex vector space. Notice how the operator in the last example was specified by a matrix.
22
All of the quantum gates you have seen in circuits can be represented by matrices. Below are some common qubit operations along with their circuit diagram symbols and matrices in the computational basis:
Out[]=
Operator | Diagram | Matrix | ||||
I |
| |||||
NOT |
| |||||
X |
| |||||
Y |
| |||||
Z |
| |||||
H |
| |||||
T |
| |||||
S |
| |||||
P[θ] |
|
Circuits as Matrices
Circuits as Matrices
A quantum circuit is just the application of a sequence of quantum operations to your initial state. The matrix which represents the entire circuit is just the product of all the matrices representing the individual operations.
Consider the following example:
In[]:=
circuitXZ=QuantumCircuitOperator[{"X","Z"}];circuitXZ["Diagram"]
Out[]=
The property of operators and circuit operators can be used to obtain their matrix representation:
"Matrix"
In[]:=
circuitXZ["Matrix"]//MatrixForm//TraditionalForm
Out[]//TraditionalForm=
0 | 1 |
-1 | 0 |
Let’s check that the product of the operator’s matrices gives the circuit’s matrix:
In[]:=
(QuantumOperator["Z"]["Matrix"].QuantumOperator["X"]["Matrix"])//MatrixForm//TraditionalForm
Out[]//TraditionalForm=
0 | 1 |
-1 | 0 |
That means the result of running any given quantum circuit on any initial state can be classically computed by performing enough matrix multiplications:
That’s essentially how the Wolfram Quantum Framework allows you to compute the results of running quantum circuits, even though it is a classical computer program. For small quantum circuits, you are far better just doing the matrix multiplications classically than trying to build and run a quantum computer. However, the size of the matrices needed to model quantum circuits grows exponentially with the number of qubits involved. Thus, classical computers eventually reach a limit on the size of quantum system which they can effectively predict.
Multi-qubit States
Multi-qubit States
So far, you have only seen matrix and vector representations of single qubits and single-qubit operations. However, a useful quantum circuit will have more than one qubit. How can these be represented with matrices?
Consider the 2-qubit state “10”. A 2-qubit state can be specified by 4 complex amplitudes:
It is conventional to order the vector coefficients by ascending value of the basis bit sequences when read in binary:
In general, a 2-qubit state would look like this:
If the amplitudes are already normalized, then the probability of each measurement result is just the norm squared of each amplitude:
You should take note that each of the amplitudes above correspond to the combined 2-qubit state. What if you want to begin with two single-qubit states and describe their combination?
Note how the amplitudes of the combined state are related to the products of amplitudes of the single-qubit states:
The probability distribution may look complicated at first:
However, the expression simplifies greatly if the amplitudes of each single qubit state were properly normalized:
Example
Example
Represent their combined state as a vector. Compute the probability for each possible bit sequence if the combined state is measured in the computational basis.
Solution
The combined state will be a tensor product:
The Dirac notation and amplitudes are as follows:
This can be represented by the following vector:
Probabilities are the norm squared of the normalized amplitudes:
Multi-qubit Operators
Multi-qubit Operators
Since much of quantum mechanics can be represented by linear algebra, matrix multiplication (and more generally tensor contraction) can be used to let classical computers predict the results of running quantum circuits. However, this is only practical up to a certain size of quantum system.
The table below has some common 2-qubit operations along with their circuit diagrams and matrix representations in the computational basis:
Unitary Operators
Unitary Operators
You may wonder, can any matrix represent a quantum operation? According the usual formalism of quantum mechanics, the answer is a resounding no. Only a special class of matrices called unitary matrices can represent quantum operations.
Consider the following operator:
This operator is specified by a unitary matrix:
User-defined operators can be used in circuit diagrams:
This particular unitary has the following effect on the register state:
Multi-qubit operators can be defined by matrices of the appropriate size:
This circuit results in the following state:
Applying this circuit to the register state gives the following result: