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

  • EinsteinSummation
  • 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
Details and options
Advanced examples
Core Functions
Details and options
Basic Examples(States and Operators)
Quasi Probability Representations and Examples
Advanced Examples
​
​
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[22]:=
<<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
OperatorVariance
[ψ,op]
Variance of the operator op for a state ψ

States

FockState
[
n
,size]
n-th Fock state in a basis of dimension size
FockState
[{
n
1
,
n
2
,..},size]
Multimode Fock state with occupation numbers
n
i
, with each mode in a basis of dimension size
CoherentState
[size]​​
CoherentState
[size][α]
Parametric state representing a non-normalized coherent state in a basis of dimension size , the complex amplitude is a parameter
ThermalState
[nbar,size]
Thermal mixed state with average number of photons nbar in a 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 are parameters

Operators

AnnihilationOperator
[size, ord]
Bosonic annihilation operator in a truncated Fock spacewith basis dimension size and qudit order ord
DisplacementOperator
[α,size, ord]
Phase space displacement operator of a single mode with complex amplitude alpha , basis dimension size and qudit order ord
SqueezeOperator
[ξ,size,ord]
Squeeze operator of a single mode with complex parameter xi , basis dimension size and qudit order ord
QuadratureOperators
[size,ord]
X
1
and
X
2
position and momentum quadrature operators with basis dimension size and qudit order ord
PhaseShiftOperator
[θ,size,ord]
Phase space rotation operator with rotation angle θ, basis dimension size and qudit order ord
BeamSplitterOperator
[{θ,ϕ},size,ord]
Two mode beam-splitter operator, θ indicates the reflectivity, ϕ the relative phase in a basis of dimension size and qudit order ord
We will briefly demonstrate how to apply all these functions in Wolfram quantum framework.
Details and options

Operators Mathematical Definitions

DisplacementOperator
Exp[α
†
a
-
*
α
a]
SqueezeOperator
Exp
1
2
ξ
2
a
- ξ
†2
a

PhaseShiftOperator
Exp[ θ
†
a
a]
BeamSplitterOperator
Expθ
 ϕ

a
1
†
a
2
-
- ϕ

†
a
1
a
2

QuadratureOperators
X
1
:
1
2
(a+
†
a
)​​
X
2
:
1
2 
(a-
†
a
)
​

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.

Displacement operator ordering

By default when "Ordering" is not specified normal ordering is used, the formulas of the three orders are shown below:
DisplacementOperator
[..,"Ordering"st]
st can be "Normal", "Weak" or "Antinormal".​​​​For "Normal", one gets:​​
Exp[-|α
2
|
/2]Exp[α
†
a
]Exp[-αa]
​​​​For "Weak", one gets:​​
Exp[α
†
a
-αa]
​​​​For "Antinormal", one gets:​​
Exp[|α
2
|
/2]Exp[-αa]Exp[α
†
a
]

Squeeze operator ordering

By default when "Ordering" is not specified normal ordering is used, the formulas of the three orders are shown below:
SqueezeOperator
[…,"Ordering"st]
st
can be "Normal", "Antinormal" or "Weak". Given
ξ=
θ
r
​for "Normal", one gets:​
Exp[-
1
2
θ

Tanh[r]
†2
a
]Exp[-Log[Cosh[r]](
†
a
a+
1
2
)]Exp[
1
2
-θ

Tanh[r]
2
a
]
​​For "Weak", one gets:​
Exp[
1
2
(ξ
2
a
-ξ
†2
a
)]
​​For "Antinormal", one gets:​
Exp[
1
2
-θ

Tanh[r]
2
a
]Exp[Log[Cosh[r]](
†
a
a+
1
2
)]Exp[-
1
2
θ

Tanh[r]
†2
a
]

Basic Examples

Setting the space size

Set the default size to 20:
In[3]:=
SetFockSpaceSize[20];
In[4]:=
AnnihilationOperator[]
Out[4]=
QuantumOperator
Pure map
​
Dimension: 20→20
Order: {1}→{1}

Calling it with no arguments, sets again the default size when loading the paclet which is 16:
In[17]:=
SetFockSpaceSize[];
In[18]:=
AnnihilationOperator[]
Out[18]=
QuantumOperator
Pure map
​
Dimension: 16→16
Order: {1}→{1}


Annihilation operator

Define an annihilation operator with a given size and uses default order (1):
In[21]:=
AnnihilationOperator[8]
Out[21]=
QuantumOperator
Pure map
​
Dimension: 8→8
Order: {1}→{1}

Define an annihilation operator to the second mode with default truncation size:
In[19]:=
AnnihilationOperator[{2}]
Out[19]=
QuantumOperator
Pure map
​
Dimension: 16→16
Order: {2}→{2}

Define an annihilation operator with dimension 5 in the third order (or mode):
In[20]:=
AnnihilationOperator[5,{3}]
Out[20]=
QuantumOperator
Pure map
​
Dimension: 5→5
Order: {3}→{3}


Creation operator and Fock states

Define creation operator just taking the adjoint of the annihilation operator with "Dagger" property or SuperDagger:
In[153]:=
a=AnnihilationOperator[];​​
†
a
@FockState[1]//TraditionalForm

Multimode Fock State

Create a two mode Fock state with occupation numbers 2 and 12:
Apply the annihilation operator to both modes , state|1,11〉 is expected up to a global constant:
Equivalent using QuantumState with strings arguments, but QuantumState with string arguments will not work if one number is bigger than 9( it will interpret it as extra qudits):

Coherent state

Symbolic coherent state:

Cat State

Photon distribution of the same state:

Displacement operator

Create displacement operator of size 40 with amplitude 3+ :
Create a coherent state displacing the vacuum:
Specify the order(mode) of the operator with default size, second mode in this case:

Phase shift operator

Specify the basis size and order:
Phase shift operator coincides with the "Z" gate for qudits when the angle is 2π/n (up to conjugation):

Squeeze operator

Create squeeze operator of default size with complex parameter 1+:
Plot the non-zero amplitudes of the state:

Beam-Splitter Operator

Transform the state |1,1〉 using the symmetric beam-splitter:
Specify the order (where the operator acts) and the basis dimension:

OperatorVariance

Calculate the variance of the quadrature operators for the ground state:
A Fock state has a definite number of photons so the variance of the number operator is zero:

Quadrature Operators

Ordering option

Applications

Mean number of photons

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

Heisenberg evolution of annihilation operator

Define the Hamiltonian:
Superoperator that allows evolving another operator:
Evolve the operator:
Compare the result:

Quasi-probability Representations

Two phase space quasi-probability representations are included Wigner and HusimiQ , which are used extensively in quantum mechanics and quantum optics. They are calculated numerically in a grid of phase space points and an interpolating function is returned. 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:

In the region from -4 to 4:

Fock state HusimiQ Representation

Applications

Expectation values

We will use the Fock state |2〉:
Phase space integral:

Squeezed vacuum Wigner Representation

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

Options

Scaling of the representation for ground state

Using GridSize

Calculating the value of the Wigner function of Fock state |2〉 at the origin:
However, "GridSize" of 20 is not enough for this region and has a lot of numerical error:
The exact value from analytical expression is:
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

Define the basis and the relevant operators:
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
Find the probability of the atom being in the excited state:
Plot the result:
2. Collapse and revivals when the initial field state is a coherent state
Define the initial state and evolve it (we use a random α):
3. Atom "thermalization" (atom interacting with a thermal state field)
Reduced density matrix of the atom:
Plot two components:
Atom gets "thermalized", time average of the coherences → 0:

Jaynes-Cummings with dissipation

Hamiltonian definition:
Jump operators:
Helper definition to get the probability of finding the atom in the excited state:
Damped Rabi oscillations:

© 2025 Wolfram. All rights reserved.

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