Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

QuantumFramework

Tutorials

  • Getting Started

Guides

  • Wolfram Quantum Computation Framework

Tech Notes

  • Diagram
  • Exploring Fundamentals of Quantum Theory
  • Quantum Computation

Symbols

  • QuantumBasis
  • QuantumChannel
  • QuantumCircuitOperator
  • QuantumDistance
  • QuantumEntangledQ
  • QuantumEntanglementMonotone
  • QuantumEvolve
  • QuantumMeasurement
  • QuantumMeasurementOperator
  • QuantumMeasurementSimulation
  • QuantumOperator
  • QuantumPartialTrace
  • QuantumStateEstimate[EXPERIMENTAL]
  • QuantumState
  • QuantumTensorProduct
  • QuditBasis
  • QuditName
Quantum Computation
Discrete Quantum Mechanics
Quantum Information & 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
QuantumBasis
basis vectors encoding quantum states and operators
QuantumState
quantum discrete state, defined by an association, a complex vector, or a density matrix
QuantumOperator
quantum discrete operator, defined by an association or a matrix representation
QuantumMeasurementOperator
quantum measurement operator, defined by a matrix, a collection of positive matrices (POVM) or an eigenbasis (projective)
QuantumMeasurement
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
QuantumBasis
. Quantum states and operators are defined with respect to a basis.
QuantumBasis
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
[{3,5}]
Out[277]=
QuantumBasis
Picture: Schrödinger
Rank: 2
Dimension: 15
​

Define a quantum basis by an association:
In[148]:=
QuantumBasis
[0{1,1},1{1,-}]
Out[148]=
QuantumBasis
Picture: Schrödinger
Rank: 1
Dimension: 2
​

There are many named-basis built into the framework:
In[278]:=

QuantumBasis
["Computational"],
QuantumBasis
["PauliY"],
QuantumBasis
["Bell"],
QuantumBasis
["Dirac"],
QuantumBasis
["Schwinger"],
QuantumBasis
["Wigner"]
Out[278]=
QuantumBasis
Picture: Schrödinger
Rank: 1
Dimension: 2
​
,QuantumBasis
Picture: Schrödinger
Rank: 1
Dimension: 2
​
,QuantumBasis
Picture: Schrödinger
Rank: 1
Dimension: 4
​
,QuantumBasis
Picture: Schrödinger
Rank: 2
Dimension: 16
​
,QuantumBasis
Picture: Schrödinger
Rank: 2
Dimension: 4
​
,QuantumBasis
Picture: Schrödinger
Rank: 2
Dimension: 4
​

There are many properties that can be extracted from
QuantumBasis
object. For example:
In[150]:=
basis=
QuantumBasis
[3];​​Normal/@basis["ElementAssociation"]
Out[151]=
|0〉{1,0,0},|1〉{0,1,0},|2〉{0,0,1}
QuantumBasis
supports bases for composite systems (2 qudit system of dimensions
2×3
):
In[153]:=
QuantumBasis
[{2,3}]
Out[153]=
QuantumBasis
Picture: Schrödinger
Rank: 2
Dimension: 6
​

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
QuantumState
object and a quantum operator is represented by
QuantumOperator
.
Define a pure 2-dimensional quantum state (qubit) in Pauli-X basis:
In[155]:=
QuantumState
[{1,-},"X"]
Out[155]=
QuantumState
Pure state
Qudits: 1
Type: Vector
Dimension: 2
Picture: Schrödinger
​

In[156]:=
%["Amplitudes"]
Out[156]=

ψ
x
-
1,
ψ
x
+
-
If the basis is not specified, the default is the computational basis:
In[157]:=
state=
QuantumState
[{1/Sqrt[2],0,0,1/Sqrt[2]}];​​Normal/@state["Basis"]["ElementAssociation"]
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=
QuantumState
[{1/Sqrt[2],0,0,1/Sqrt[2]},4]
Out[159]=
QuantumState
Pure state
Qudits: 1
Type: Vector
Dimension: 4
Picture: Schrödinger
​

Within the package, many named states are available for easy access:
In[160]:=

QuantumState
["UniformSuperposition"],
QuantumState
["PsiPlus"],
QuantumState
["GHZ"]
Out[160]=
QuantumState
Pure state
Qudits: 1
Type: Vector
Dimension: 2
Picture: Schrödinger
​
,QuantumState
Pure state
Qudits: 2
Type: Vector
Dimension: 4
Picture: Schrödinger
​
,QuantumState
Pure state
Qudits: 3
Type: Vector
Dimension: 8
Picture: Schrödinger
​

We can also define a mixed state by inputting a density matrix:
In[279]:=
QuantumState
[(IdentityMatrix[2]+.9PauliMatrix[2])/2]
Out[279]=
QuantumState
Mixed state
Qudits: 1
Type: Matrix
Dimension: 2
Picture: Schrödinger
​

There are many properties that can be extracted from
QuantumState
. For example:
In[162]:=
state=
QuantumState
["PhiMinus"];​​AssociationMap[state[#]&,{"Amplitudes","DensityMatrix","Formula"}]//Dataset
Out[163]=
Amplitudes
Wolfram`QuantumFramework`QuditName[{0,0},DualFalse]
1
2
,Wolfram`QuantumFramework`QuditName[{0,1},DualFalse]0,Wolfram`QuantumFramework`QuditName[{1,0},DualFalse]0,Wolfram`QuantumFramework`QuditName[{1,1},DualFalse]-
1
2

DensityMatrix
SparseArray
Specified elements: 4
Dimensions: {4,4}

Formula
|
00
〉
2
-
|
11
〉
2
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
["CNOT",{2,3}]
Out[164]=
QuantumOperator
Picture: Schrödinger
Arity: 2
Dimension: 4→4
Qudits: 2→2

Define operator by names:
In[165]:=

QuantumOperator
["H",{2}],
QuantumOperator
["CNOT"],
QuantumOperator
["Toffoli"]
Out[165]=
QuantumOperator
Picture: Schrödinger
Arity: 1
Dimension: 2→2
Qudits: 1→1
,QuantumOperator
Picture: Schrödinger
Arity: 2
Dimension: 4→4
Qudits: 2→2
,QuantumOperator
Picture: Schrödinger
Arity: 3
Dimension: 8→8
Qudits: 3→3

Extract properties of operator:
In[166]:=
operator=
QuantumOperator
["CNOT",{1,2}];​​operator["Matrix"]//MatrixForm​​operator["HermitianQ"]
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

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com