Quantum Computation
Quantum computation is the use of quantum mechanical systems to perform computations. A classical computer uses a bit of either 0 or 1. In contrast, a quantum bit (qubit) can be both 0 and 1 at the same time. This package aims to classically simulate a wide range of quantum computations using the Wolfram Language.
Discrete Quantum Mechanics
basis vectors encoding quantum states and operators | |
quantum discrete state, defined by an association, a complex vector, or a density matrix | |
quantum discrete operator, defined by an association or a matrix representation | |
quantum measurement operator, defined by a matrix, a collection of positive matrices (POVM) or an eigenbasis (projective) | |
description of possible measurement results, containing a probability distribution as well as possible quantum states after the measurement |
Basic objects of discrete quantum mechanics.
A fundamental object in our framework is . Quantum states and operators are defined with respect to a basis. can be constructed for any number of qudits, with any dimensionality. There are also a set of named basis (e.g., PauliX or Bell) built-in into the quantum framework.
Define a quantum basis given dimensions (3x5):
In[277]:=
QuantumBasis |
Out[277]=
QuantumBasis
|
Define a quantum basis by an association:
In[148]:=
QuantumBasis |
Out[148]=
QuantumBasis
|
There are many named-basis built into the framework:
In[278]:=
["Computational"],
["PauliY"],
["Bell"],
["Dirac"],
["Schwinger"],
["Wigner"]
QuantumBasis |
QuantumBasis |
QuantumBasis |
QuantumBasis |
QuantumBasis |
QuantumBasis |
Out[278]=
QuantumBasis
,QuantumBasis
,QuantumBasis
,QuantumBasis
,QuantumBasis
,QuantumBasis
|
|
|
|
|
|
In[150]:=
basis=
[3];Normal/@basis["ElementAssociation"]
QuantumBasis |
Out[151]=
|0〉{1,0,0},|1〉{0,1,0},|2〉{0,0,1}
In[153]:=
QuantumBasis |
Out[153]=
QuantumBasis
|
In[154]:=
Normal/@%["ElementAssociation"]
Out[154]=
|00〉{{1,0,0},{0,0,0}},|01〉{{0,1,0},{0,0,0}},|02〉{{0,0,1},{0,0,0}},|10〉{{0,0,0},{1,0,0}},|11〉{{0,0,0},{0,1,0}},|12〉{{0,0,0},{0,0,1}}
After a basis objects has been defined, it is straightforward to use the basis to construct state and operator. A quantum state is represented by object and a quantum operator is represented by .
Define a pure 2-dimensional quantum state (qubit) in Pauli-X basis:
In[155]:=
QuantumState |
Out[155]=
QuantumState
|
In[156]:=
%["Amplitudes"]
Out[156]=
1,-
ψ
x
-
ψ
x
+
If the basis is not specified, the default is the computational basis:
In[157]:=
state=
[{1/Sqrt[2],0,0,1/Sqrt[2]}];Normal/@state["Basis"]["ElementAssociation"]
QuantumState |
Out[158]=
|00〉{{1,0},{0,0}},|01〉{{0,1},{0,0}},|10〉{{0,0},{1,0}},|11〉{{0,0},{0,1}}
The default dimensionality is 2. Therefore, if the vector has more than 2 elements, it is interpreted as a multi-qubit state. But, one may change the dimensionality as follows:
In[159]:=
state=
[{1/Sqrt[2],0,0,1/Sqrt[2]},4]
QuantumState |
Out[159]=
QuantumState
|
Within the package, many named states are available for easy access:
In[160]:=
["UniformSuperposition"],
["PsiPlus"],
["GHZ"]
QuantumState |
QuantumState |
QuantumState |
Out[160]=
QuantumState
,QuantumState
,QuantumState
|
|
|
We can also define a mixed state by inputting a density matrix:
In[279]:=
QuantumState |
Out[279]=
QuantumState
|
In[162]:=
state=
["PhiMinus"];AssociationMap[state[#]&,{"Amplitudes","DensityMatrix","Formula"}]//Dataset
QuantumState |
Out[163]=
| ||||||||||
Define a quantum operator by a matrix, basis, and order. The order is the information about which subsystems the operator would act on. For example order {1,2} means it would act on subsystem 1 and 2. If the basis is not specified, the default is the computational basis.
In[164]:=
QuantumOperator |
Out[164]=
QuantumOperator
|
Define operator by names:
In[165]:=
["H",{2}],
["CNOT"],
["Toffoli"]
QuantumOperator |
QuantumOperator |
QuantumOperator |
Out[165]=
QuantumOperator
,QuantumOperator
,QuantumOperator
|
|
|
Extract properties of operator:
In[166]:=
operator=
["CNOT",{1,2}];operator["Matrix"]//MatrixFormoperator["HermitianQ"]
QuantumOperator |
Out[167]//MatrixForm=
1 | 0 | 0 | 0 |
0 | 1 | 0 | 0 |
0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
Define a measurement operator on the 2nd qubit (in computational basis):
Define measurement operator by names:
Define a POVM measurement:
Extract various properties of a QuantumMeasurementOperator:
We can also extract the possible states after measurement (post-measurement states) by:
The second method is by defining a multiqubit basis and use it as the eigenbasis of the measurement. In this case, a list of eigenvalues is also needed:
Tensor product of states and bases:
Basis change for a quantum state:
Basis change for a quantum operator:
One can do algebraic operations on quantum operators and the result will be a QuantumOperator:
The Berkeley B operator:
One can easily construct new quantum operator from composition of different operators:
SWAP.Controlled-U.SWAP means a an upside down controlled-U operator (switching control and target):
Quantum Information & Computation
Basic objects and operations in discrete quantum mechanics naturally lead to an application in quantum information and computation. Quantum Information is the study of information encoded in quantum systems. Meanwhile, quantum computation is the manipulation of quantum information to perform a computation.
Trace out the second subsystem in a two-qubit state:
Example of partial transpose:
Checking whether a subsystem 1 and 3 is entangled in "W" state:
Measuring trace distance between a pure state and a mixed state:
This package also supports Schmidt decomposition and spectral decomposition.
Example of Schmidt decomposition:
Example of spectral decomposition:
Example for the construction of quantum circuit without measurement:
Add measurement into the circuit:
Decomposition of CNOT:
A quantum gate for the magic basis transformation (transforming 2 qubit computational basis to the Bell basis):
A quantum gate with many control-0, control-1 and targets