NRG Ljubljana home

SNEG

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.

The canonical fermion identity c c† + c† c = 1, with a workflow from operators to bases and matrices.

Get started

The latest published release is SNEG 2.1 (1 August 2026). No compilation is required.

With Mathematica 12.1 or newer, install or update the latest release directly from a notebook:

PacletInstall[
  "https://github.com/rokzitko/sneg/releases/latest/download/SNEG.paclet"
]

Load the package and check its version:

Needs["sneg`"]
$SnegVersion

Both Needs["sneg`"] and Needs["Sneg`"] are supported. The code requires Mathematica 7 or newer and has been tested with versions through 15. See the installation guide for details.

Manual source installation, including Mathematica 7–12.0

Download the development source (ZIP) and place the extracted contents in the directory returned by:

FileNameJoin[{$UserBaseDirectory, "Applications", "sneg"}]

Name the directory sneg, renaming sneg-main if necessary. Load a manual installation with:

<< sneg`

A checkout at any location can also be loaded directly:

Get["/absolute/path/to/sneg/sneg.m"]

What’s new in SNEG 2.1

Read the full release notes. 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.
  • Conjugation, commutators, anticommutators, spin inversion, vacuum expectation values, and Wick expansion.
  • 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

Worked notebooks from this site

These historical examples illustrate SNEG’s notation and applications. Open them in Mathematica with SNEG installed to evaluate the calculations.

Examples of SNEG notebook output: occupation-number states, operator expressions, bra-ket notation, and symbolic sums.
SNEG’s formatted notebook output keeps operators, states, and symbolic expressions readable.

Licence and citation

SNEG is free software, distributed under the GNU General Public License, version 2 or later.

When publishing work that uses SNEG, please cite:

R. Žitko, SNEG – Mathematica package for symbolic calculations with second-quantization-operator expressions, Computer Physics Communications 182, 2259–2264 (2011). Paper (PDF).

A citable historical software snapshot is also available: SNEG 2.0.0 on Zenodo (2022).

Help and feedback

Report bugs or suggest improvements through GitHub Issues. For other inquiries, contact rok.zitko@ijs.si.

Earlier news (2006–2022)

Browse archived SNEG releases.