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

  • Bell's Theorem
  • Circuit Diagram
  • Exploring Fundamentals of Quantum Theory
  • QPU Service Connection
  • Quantum object abstraction
  • Quantum Optimization
  • Second Quantization Functions
  • Tensor Network
  • Quantum Computation

Symbols

  • QuantumBasis
  • QuantumChannel
  • QuantumCircuitMultiwayGraph [EXPERIMENTAL]
  • QuantumCircuitOperator
  • QuantumDistance
  • QuantumEntangledQ
  • QuantumEntanglementMonotone
  • QuantumEvolve
  • QuantumMeasurement
  • QuantumMeasurementOperator
  • QuantumMeasurementSimulation
  • QuantumMPS [EXPERIMENTAL]
  • QuantumOperator
  • QuantumPartialTrace
  • QuantumPhaseSpaceTransform
  • QuantumShortcut [EXPERIMENTAL]
  • QuantumStateEstimate [EXPERIMENTAL]
  • QuantumState
  • QuantumTensorProduct
  • QuantumWignerMICTransform [EXPERIMENTAL]
  • QuantumWignerTransform [EXPERIMENTAL]
  • QuditBasis
  • QuditName
Second Quantization Functions
Core Functions
​​
Advanced examples
Quasi-probability Representations
​
In this Tech Note, we present the implementation of second quantization for bosons within the QuantumFramework, utilizing a truncated Fock space. This approach enables simple manipulation and representation of quantum states, which are essential for a wide range of calculations. By leveraging the core features of the QuantumFramework, we simplify the process of working with common quantum states and operators, facilitating diverse computational tasks in fundamental quantum mechanics and quantum optics.
In[1]:=
<<Wolfram`QuantumFramework`​​<<Wolfram`QuantumFramework`SecondQuantization`

Core Functions

Fock space size and utilities

SetFockSpaceSize
[size]
sets size as the default truncation dimension , after called all the other definitions can use this default size
Commutator
[op1,op2]
Commutator of two operators
OperatorVariance
[ψ,op]
Variance of the operator op for a state ψ

States

FockState
[
n
,size]
n-th Fock state with truncation dimension size
CoherentState
[size]​​
CoherentState
[size][α]
parametric state representing a non-normalized coherent state in a truncated basis of dimension size
ThermalState
[nbar,size]
thermal mixed state with average number of photons nbar in a truncated basis of dimension size
CatState
[size]​​
CatState
[size][α,ϕ]
parametric general cat state representing a superposition of coherent states in a basis of dimension size, the complex amplitude and the phase can be supplied

Operators

AnnihilationOperator
[size]
bosonic annihilation operator in a truncated Fock space with specified size
DisplacementOperator
[α,size]
phase space displacement operator of dimension size with complex displacement amplitude alpha
SqueezeOperator
[ξ,size]
squeeze operator with complex parameter xi of dimension size
QuadratureOperators
[size]
returns
X
1
and
X
2
position and momentum quadrature operators with dimension size
We will briefly demonstrate how to apply all these functions in Wolfram quantum framework.

Ordering Option

Displacement and squeeze operators can have different definitions based on operator ordering. We include the "Ordering" option to specify the order (weak , normal or anti normal ). Theoretically in a infinite dimensional space they are all equivalent , but in a truncated space these operators have numerical error, and depending on the calculation some choice of ordering can be more accurate.

Basic Examples

Setting the space size

Set the default size to 20:
In[4]:=
SetFockSpaceSize[20];
In[4]:=
AnnihilationOperator[]
Out[4]=
QuantumOperator
Pure map
​
Dimension: 20→20
Order: {1}→{1}


Creation operator and Fock states

Define creation operator just taking the adjoint of the annihilation operator with "Dagger" property or SuperDagger:
In[5]:=
a=AnnihilationOperator[];
In[5]:=
†
a
@FockState[1]//TraditionalForm
Out[6]//TraditionalForm=
2
|2〉

Coherent state

Symbolic coherent state:
In[7]:=
CoherentState[][β]//TraditionalForm
Out[7]//TraditionalForm=
|0〉+β|1〉+
2
β
2
|2〉+
3
β
6
|3〉+
4
β
2
6
|4〉+
5
β
2
30
|5〉+
6
β
12
5
|6〉+
7
β
12
35
|7〉+
8
β
24
70
|8〉+
9
β
72
70
|9〉+
10
β
720
7
|10〉+
11
β
720
77
|11〉+
12
β
1440
231
|12〉
+
13
β
1440
3003
|13〉+
14
β
10080
858
|14〉+
15
β
30240
1430
|15〉+
16
β
120960
1430
|16〉+
17
β
120960
24310
|17〉+
18
β
725760
12155
|18〉+
19
β
725760
230945
|19〉
Photon distribution of a coherent state with
α=1.3+2
:
In[120]:=
CoherentState[25][1.3+2]["Normalize"]["ProbabilityPlot",LabelStyle6,AspectRatio1/4]
Out[120]=

Cat State

Create a cat state

α
(|α〉+
ϕ

|-α〉
)
of amplitude
α=2+
and
ϕ=3π/4
:
In[115]:=
CatState[25][2+,3π/4]
Out[115]=
QuantumState
Pure state
Qudits: 1
Type: Vector
Dimension: 25

Photon distribution of the same state:
In[122]:=
CatState[25][2+,3π/4]["ProbabilityPlot",LabelStyle6,AspectRatio1/4]
Out[122]=

Displacement operator

Create displacement operator of size 40 with amplitude 3+ :
In[3]:=
DisplacementOperator[3+,40]
Out[3]=
QuantumOperator

Pure map
​
Dimension: 40→40
Order: {1}→{1}
Data not saved. Save now

Create a coherent state displacing the vacuum:
In[4]:=
DisplacementOperator[α,40][]CoherentState[40][α]
Out[4]=
True

Squeeze operator

Create squeeze operator of default size with complex parameter 1+:
In[12]:=
SqueezeOperator[1.+]
Out[12]=
QuantumOperator
Pure map
​
Dimension: 20→20
Order: {1}→{1}


OperatorVariance

Calculate the variance of the quadrature operators for the ground state:
In[18]:=
OperatorVariance[FockState[0],#]&/@QuadratureOperators[]
Out[18]=

1
4
,
1
4

A Fock state has a definite number of photons so the variance of the number operator is zero:
In[5]:=
a=AnnihilationOperator[];​​OperatorVariance[FockState[2],
†
a
@a]
Out[6]=
0

Commutator

Compute the commutator of quadrature operators, it is

2
1
the error in the last term is expected behaviour due to truncation:
In[6]:=

2
QuantumOperator
["I"[$FockSize]]-Commutator@@QuadratureOperators[]//TraditionalForm
Out[6]//TraditionalForm=
10|19〉〈19|

Applications

Mean number of photons

Using QuantumMeasurementOperator:
Using the probabilities in the diagonal of the density matrix:

Heisenberg evolution of annihilation operator

Options

Displacement operator ordering

By default when "Ordering" is not specified normal ordering is used, the formulas of the three orders are shown below:

Squeeze operator ordering

By default when "Ordering" is not specified normal ordering is used, the formulas of the three orders are shown below:

Quasi-probability Representations

Two phase space quasi-probability representations are included Wigner and HusimiQ , which are used extensively in quantum mechanics and quantum optics. These are calculated numerically in a grid of phase space points. Glauber representation is not included because for a general state is not feasible to implement a numerical algorithm , due to the singularities of this representation.
We will briefly demonstrate how to apply all these functions in Wolfram quantum framework.

Basic Examples

Ground state Wigner Representation:

Using a grid of phase space points from -4 to 4:

Fock state HusimiQ Representation

Applications

Interpolation of a Representation

Phase space integral:

Squeezed vacuum Wigner Representation

This exhibits the non classical behavior of squeezed states regarding the quadratures

Options

Scaling of the representation for ground state

Advanced examples

Decay of a coherent state

Hamiltonian definition:
State evolution:
Saving mean number of photons and fidelity respect to an analytical expression:
Plotting the results:

Optical balance

Considering the following master equation, we look for balance between a driving field Hamiltonian and the single photon loss mechanism:
Random initial state:
Hamiltonian definition associated with the master equation:

Jaynes-Cummings Model

Going to the interaction picture at resonance, we get a time independent Hamiltonian:
Now we try different initial states
1. Rabi oscillations when the field is initially in a Fock state
2. Collapse and revivals when the initial field state is a coherent state
3. Atom "thermalization" (atom interacting with a thermal state field)
Atom gets "thermalized", time average of the coherences → 0:

Jaynes-Cummings with dissipation

Hamiltonian definition:
Jump operators:
Damped Rabi oscillations:

© 2025 Wolfram. All rights reserved.

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