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

Q3mini

Guides

  • Fermionic Quantum Computation
  • Q3: Symbolic Quantum Simulation
  • Quantum Information Systems
  • Quantum Many-Body Systems
  • Quantum Spin Systems

Tech Notes

  • About Q3
  • Q3: Quick Start
  • Quantum Fourier Transform
  • Quantum Information Systems with Q3
  • Quantum Many-Body Systems with Q3
  • Quantum Operations
  • Quantum Spin Systems with Q3
  • Quantum States
  • Quantum Teleportation
  • Quick Quantum Computing with Q3

Symbols

  • Basis
  • Boson
  • Bra
  • CNOT
  • ControlledGate
  • ExpressionFor
  • Fermion
  • Heisenberg
  • Ket
  • Let
  • Majorana
  • Matrix
  • Multiply
  • NambuGreen
  • NambuHermitian
  • NambuMatrix
  • NambuUnitary
  • Pauli
  • Phase
  • QuantumCircuit
  • Qubit
  • Qudit
  • RandomWickCircuitSimulate
  • Rotation
  • Species
  • Spin
  • SWAP
  • WickCircuit
  • WickEntanglementEntropy
  • WickEntropy
  • WickGreenFunction
  • WickJump
  • WickLindbladSolve
  • WickLogarithmicNegativity
  • WickMeasurement
  • WickMonitor
  • WickMutualInformation
  • WickNonunitary
  • WickSimulate
  • WickState
  • WickUnitary

Overviews

  • The Postulates of Quantum Mechanics
  • Quantum Algorithms
  • Quantum Computation: Models
  • Quantum Computation: Overview
  • Quantum Error-Correction Codes
  • Quantum Information Theory
  • Quantum Noise and Decoherence
QuantumMob`Q3mini`
Matrix
​
Matrix
[expr,{
a
1
,
a
2
,…}]
constructs the matrix representation of the expression
expr
on the total system consisting of
a
1
,
a
2
, ….
​
​
Matrix
[expr]
figures out the subsystems involved in
expr
.
​
​
Matrix
[dyadic,{
a
1
,
a
2
,…},{
b
1
,
b
2
,…}]
is for the dyadic expression acting on
{
a
1
,
a
2
,…}
from the right and on
{
b
1
,
b
2
,…}
from the left.
​
Details and Options

Examples  
(24)
Basic Examples  
(4)
For expressions in the explicit Pauli operators,
Matrix
gives the matrix representation of them.
In[1]:=
expr=Pauli[{3,2}]+IPauli[{1,2}]
Out[1]=
X⊗Y+Z⊗Y
In[2]:=
mat=Matrix@expr;​​mat//MatrixForm
Out[2]//MatrixForm=
0
-
0
1

0
-1
0
0
1
0

-1
0
-
0
In[3]:=
new=ExpressionFor[mat]​​expr-new//Elaborate
Out[3]=
-Z⊗
+
X
+Z⊗
-
X
+
+
X
⊗
+
X
-
+
X
⊗
-
X
+
-
X
⊗
+
X
-
-
X
⊗
-
X
Out[3]=
0
In[4]:=
vec={1,I,-I,1}
Out[4]=
{1,,-,1}
In[5]:=
ket=ExpressionFor[vec]
Out[5]=
|0,0〉+|0,1〉-|1,0〉+|1,1〉
In[6]:=
new=Matrix[ket];​​new//MatrixForm
Out[6]//MatrixForm=
1

-
1
In[7]:=
vec-new
Out[7]=
{0,0,0,0}
​
Matrix works for many different Species. Let us consider
Qubits
.
In[1]:=
Let[Qubit,S]
This is another expression in terms of the implicit Pauli operators.
In[2]:=
expr=S[1,1]**S[2,2]-S[1,2]**S[2,1]+S[1,1]**S[2,3]
Out[2]=
X
S
1
Y
S
2
+
X
S
1
Z
S
2
-
Y
S
1
X
S
2
In[3]:=
mat=Matrix[expr];​​mat//MatrixForm
Out[3]//MatrixForm=
0
0
1
0
0
0
2
-1
1
-2
0
0
0
-1
0
0
​
Note that giving an explicit list of systems (qubits in the present case), the order of the specified systems changes the explicit form of the matrix. This is because matrix representation depends on the choice of basis.
In[1]:=
mat1=Matrix[expr,{S[1],S[2]}];​​mat1//MatrixForm​​mat2=Matrix[expr,{S[2],S[1]}];​​mat2//MatrixForm
Out[1]//MatrixForm=
0
0
1
0
0
0
2
-1
1
-2
0
0
0
-1
0
0
Out[1]//MatrixForm=
0
1
0
0
1
0
-2
0
0
2
0
-1
0
0
-1
0
The above expression acts non-trivially only on qubits S[1,$] and S[2,$], but trivially on other qubits, say, S[3,$]. Therefore, any implicit Pauli operators S[3,μ] does not appear in the expression. If you want to include the qubit S[3,$] in the matrix expression as well, then just include it in the specification of the qubits.
In[2]:=
mat3=Matrix[expr,{S[1],S[2],S[3]}];​​mat3//MatrixForm
Out[2]//MatrixForm=
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
2
0
-1
0
0
0
0
0
0
2
0
-1
1
0
-2
0
0
0
0
0
0
1
0
-2
0
0
0
0
0
0
-1
0
0
0
0
0
0
0
0
-1
0
0
0
0
You can recover the operator expression from the matrix representation using
ExpressionFor
.
In[3]:=
new=ExpressionFor[mat,S@{1,2}]​​expr-new//Elaborate
Out[3]=
+
S
1
Z
S
2
+2
+
S
1
-
S
2
+
-
S
1
Z
S
2
-2
-
S
1
+
S
2
Out[3]=
0
​
Here is another example for
Qudits
.
In[1]:=
Let[Qudit,A]
In[2]:=
op=A[1,01]-IA[1,12]+A[1,02]
Out[2]=
(|1〉〈0|)
1
+
(|2〉〈0|)
1
-
(|2〉〈1|)
1
In[3]:=
mat=Matrix[op];​​mat//MatrixForm
Out[3]//MatrixForm=
0
0
0
1
0
0
1
-
0
In[4]:=
new=ExpressionFor[mat,A[1]]​​op-new
Out[4]=
(|1〉〈0|)
1
+
(|2〉〈0|)
1
-
(|2〉〈1|)
1
Out[4]=
0
Scope  
(4)

Generalizations & Extensions  
(5)

Interactive Examples  
(11)

SeeAlso
Basis
 
▪
ExpressionFor
TechNotes
▪
Quantum Information Systems with Q3
▪
Quantum Many-Body Systems with Q3
▪
Quantum Spin Systems with Q3
▪
Q3: Quick Start
RelatedGuides
▪
Q3: Symbolic Quantum Simulation
▪
Quantum Information Systems
▪
Quantum Many-Body Systems
▪
Quantum Spin Systems

© 2025 Wolfram. All rights reserved.

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