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`
Ket
​
Ket[{
b
1
,
b
2
,…,
b
n
}]
represents a computational basis state
|
b
1
,
b
2
,…,
b
n
〉
on a register of
n
unlabeled quantum systems (usually qubits). For a single system,
Ket[b]
with integer v is an alias to
Ket[{b}]
for convenience.
​
​
Ket[{
s
1

b
1
,
s
2

b
2
,…}]
represents a computational basis state
|
b
1
,
b
2
,…〉
on a register of labeled quantum systems
s
1
,
s
2
,…
.
​
​
Ket[spec,{
s
1
,
s
2
,…}]
or
Ket[spec,s]
​ is equivalent to
KetRegulate
[Ket[spec],{
s
1
,
s
2
,…}]]
or
KetRegulate
[Ket[spec],{s}]
. This is useful to specify input/output states in
QuantumCircuit
.
​
​
Ket[…][
s
1
,
s
2
,…]
returns a list of the values associated with the
Species
s
1
,
s
2
,…
.
​
Details and Options

Examples  
(10)
Basic Examples  
(8)
Consider a register of three qubits. A typical quantum state looks as follows.
In[1]:=
in=Ket[{0,1,1}]-I*Ket[{1,0,0}]
Out[1]=
|0,1,1〉-|1,0,0〉
We want to operate a string of Pauli operators.
In[2]:=
op=Pauli[{3,2,0}]
Out[2]=
Z⊗Y⊗I
Operate the above operate on the input state.
In[3]:=
out=op**in
Out[3]=
-|0,0,1〉-|1,1,0〉
In many case, you do not have to type the computational basis states.
In[4]:=
bs=Basis[3]
Out[4]=
{|0,0,0〉,|0,0,1〉,|0,1,0〉,|0,1,1〉,|1,0,0〉,|1,0,1〉,|1,1,0〉,|1,1,1〉}
​
Consider a register of qubits. We will refer to the register with symbol S.
In[1]:=
Let[Qubit,S]
These three expressions are equivalent.
In[2]:=
Ket[S[1]1]​​Ket[S[1,$]1]​​Ket[S[1,$,$]1]
Out[2]=

1
S
1

Out[2]=

1
S
1

Out[2]=

1
S
1

Consider a superposition state.
In[3]:=
in=Ket[S@{1,2,3}{0,1,1}]-I*Ket[S@{1,2,3}{1,0,0}]
Out[3]=

0
S
1
1
S
2
1
S
3
-
1
S
1
0
S
2
0
S
3

Consider a string of Pauli operators.
In[4]:=
op=S[1,3]**S[2,2]
Out[4]=
Z
S
1
Y
S
2
Operate the above operator on the input state.
In[5]:=
out=op**in
Out[5]=
-
0
S
1
0
S
2
1
S
3
-
1
S
1
1
S
2
0
S
3

Construct the computational basis.
In[6]:=
Basis[S@{1,2,3}]
Out[6]=

0
S
1
0
S
2
0
S
3
,
0
S
1
0
S
2
1
S
3
,
0
S
1
1
S
2
0
S
3
,
0
S
1
1
S
2
1
S
3
,
1
S
1
0
S
2
0
S
3
,
1
S
1
0
S
2
1
S
3
,
1
S
1
1
S
2
0
S
3
,
1
S
1
1
S
2
1
S
3

​
Q3: Symbolic Quantum Simulation assumes default values for any species in
Ket
[<|…|>]
when the values of the species are not specified explicitly, and hence the following two expressions are equivalent.
In[1]:=
u=Ket[S[1]0]+IKet[S[1]1]
Out[1]=

0
S
1
+
1
S
1

In[2]:=
v=Ket[]+IKet[S[1]1]
Out[2]=
|␣〉+
1
S
1

In[3]:=
u-v//Elaborate
Out[3]=
0
The
KetRegulate
converts Ket into a more human readable form.
In[4]:=
w=v//KetRegulate
Out[4]=

0
S
1
+
1
S
1

In[5]:=
w//KetTrim
Out[5]=
|␣〉+
1
S
1

​
This shows an advanced method to specify a logical basis state for labelled systems.
In[1]:=
Ket[S[{1,2,3,4}]{0,0,1,0},S[5]0]
Out[1]=

0
S
1
0
S
2
1
S
3
0
S
4
0
S
5

In[2]:=
ss=S[{1,2,3}]​​Ket[ss{0,0,1}]​​Ket[ss1]
Out[2]=
{
X
S
,
Y
S
,
Z
S
}
Out[2]=

0
S
1
0
S
2
1
S
3

Out[2]=

1
S
1
1
S
2
1
S
3

In[3]:=
bs=Basis[S[{1,2}]]
Out[3]=

0
S
1
0
S
2
,
0
S
1
1
S
2
,
1
S
1
0
S
2
,
1
S
1
1
S
2

In[4]:=
v​​w=S[2,1]**S[1,1]**v​​u=S[3,2]**w
Out[4]=
|␣〉+
1
S
1

Out[4]=

0
S
1
1
S
2
+
1
S
1
1
S
2

Out[4]=
-
0
S
1
1
S
2
1
S
3
+
1
S
1
1
S
2
1
S
3

In[5]:=
u//KetRegulate​​matU=Matrix[u];matU//MatrixForm​​uu=u⊗Ket[S[2]1]​​matUU=Matrix[uu];​​matUU//MatrixForm
Out[5]=
-
0
S
1
1
S
2
1
S
3
+
1
S
1
1
S
2
1
S
3

Out[5]//MatrixForm=
0
0
0
-1
0
0
0

Out[7]//InputForm=
-Ket[<|S[$] -> 0, S[2, $] -> 1, S[3, $] -> 1|>] +
I*Ket[<|S[$] -> 1, S[2, $] -> 1, S[3, $] -> 1|>]
​
You can add additional elements or modifies existing elements.
You can extract the bit values by giving the particular qubit as an input.
​
​
Here $ is explicitly specified.
To the column vector form, then back to the Ket form.
To be compared with the KetForm[]
​
Sometime one has to manually put spin values. In such a case, the following form will be useful to avoid tedious typing. Notice the Null input at the end, which will be automatically converted to the default value.
It is equivalent to
One can mix up different kinds of Species as well.

© 2025 Wolfram. All rights reserved.

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