SNEG library

SNEG library is a Mathematica package that provides a framework for performing calculations using the operators of the second quantization with an emphasis on the anti-commuting fermionic operators in the context of solid-state and atomic physics. It consists of a collection of transformation rules that define the algebra of operators and a comprehensive library of utility functions. The cornerstone of SNEG is a definition of non-commutative multiplication with automatic reordering of operators in a standard form (usually the conventional normal ordering with creation operators preceding the annihilation operators), which takes into account selected (anti)commutation rules. Standard form reordering allows simplifications of expressions and the choice of normal ordering permits efficient evaluation of matrix elements in a given basis.

The library makes otherwise tedious calculations a routine operation. Especially, it prevents inauspicious sign errors when commuting fermionic operators.


Note: you need to have Mathematica or Mathematica Player installed in order to view the following examples.
Additional examples can be found in the Further examples sections of the Help notebooks for SNEG functions. See also Quick start manual in the form of Mathematica notebook.




The SNEG library is useful beyond the NRG calculations. It has been applied to perform exact diagonalizations on Hubbard clusters, perturbation theory to higher orders and calculation of commutators of complex operator expressions. It should also be suitable for educational purposes, since it simplifies tedious calculations with second-quantization operators, much like Mathematica eased learning calculus. A number of examples is included in the SNEG library distribution; they can easily be extended to non-trivial calculations.


Download the current version of "sneg" from github (external link, zip file)

Installation: On macOS, copy sneg.m and, optionally, Kernel/init.m, to

in your home directory. On Linux, copy the archive contents to
in your home directory.

Please cite R. Zitko, Comp. Phys. Comm. 182 2259, (2011) and DOIZenodo snapshot. if you make extensive use of SNEG in your research.

Older releases

SNEG version 1.250 (Jan 2019)

SNEG version 1.234 (Sep 2013)

SNEG version 1.232 (Nov 2012)

SNEG version 1.228 (March 2011)

SNEG version 1.191 (April 2008)

SNEG version 1.168 (January 2007)

SNEG version 1.76 (November 2006)

Last modified: 27.6.2022 Request more information Rok Zitko's home page