Symbolic second-quantization algebra in Mathematica.
Build operators, states, bases, and matrix representations with an
open-source Wolfram Language package. SNEG handles noncommuting
operators and sign-sensitive algebra, from normal ordering and Wick
expansion to exact-diagonalization problems.
Get started
The latest published release is
SNEG 2.2.1
(29 November 2026). No compilation is required.
With Mathematica 12.1 or newer, install or update the
latest release directly from a notebook:
SNEG 2.2.1 keeps delta, step-function, and positivity rules within the
package and updates the Mathematica help, manual, and Wick theorem example.
See the 2.2.1 release notes
and the 2.2.0 feature overview.
Historical downloads are in the legacy archive.
From operator algebra to matrix elements
At the core of SNEG is nc, noncommutative multiplication
that automatically orders operators according to their declared
commutation or anticommutation rules.
Operator algebra
Fermionic, bosonic, Majorana, and spin operators, plus
Grassmann variables and fermionic coherent states.
Normal and particle-hole ordering, including a
no-reordering convention.
Symbolic sums, dummy-index renaming, and Kronecker-delta
simplification.
Selected Baker–Campbell–Hausdorff identities and
noncommutative power-series expansions.
States, bases, and matrices
Occupation-number states and efficient application of
operator strings.
Symmetry-adapted bases for charge, spin, and isospin,
with optional reflection parity.
Basis transformations, tensor products, merging,
decomposition, and orthogonalization.
Dense and sparse operator matrices, with constructors for
number, hopping, interactions, and projectors.
Dirac bra-ket notation and finite single- and multi-mode
phonon spaces.
SNEG provides the symbolic foundation of NRG Ljubljana.
It is also used for exact diagonalization of Hubbard clusters,
perturbation theory, and teaching second-quantization methods.
Documentation and examples
Mathematica help
The SNEG 2.2 paclet includes searchable English function reference
pages, tutorials, and evaluated examples in the Wolfram Documentation
Center on Mathematica 14.0 or newer. Search for a SNEG function or click
Documentation in the notebook startup message to open
the SNEG guide (paclet:SNEG/guide/SNEG).
SNEG quick reference
has installation instructions and four runnable Mathematica recipes for
fermionic algebra, Wick’s theorem, exact diagonalization, and Green’s functions.
Manual and companion notebooks
Second Quantization with SNEG (PDF)
is the 288-page tutorial and reference manual for SNEG 2.2. It includes
a grouped function reference and exercises with solutions. Worked
calculations cover electrons in crystals, electron–phonon coupling,
correlated electrons, superconductivity, and magnetism.
The 15 companion Mathematica notebooks
reproduce calculations from the manual, including the Hubbard dimer,
the SSH chain, and the superconducting impurity.
To build the PDF locally, run
wolframscript -file doc/manual/build-manual.wl from the
repository root. The output is doc/manual/sneg-manual.pdf.
See the manual build requirements.