Prof. Gabriel T. Landi

Quantum Thermodynamics and Quantum Transport (QT2) group.

Instituto de Física da Universidade de São Paulo,

São Paulo, Brazil.


Simple yet useful functions for quantum information tasks in Mathematica.

Qulib is a library we  are continually developing in our group , intended for dealing with simple Quantum Information tasks in Mathematica. The philosophy is to focus only on simple (and non-invasive) functions, but which are nonetheless used all the time (like partial traces, Pauli matrices and so on!)

(other examples are provided below)

Some useful features include:

  • Easy functions for taking the partial trace, outer products, Kronecker products, etc.
  • Functions information-theoretic quantities, such as von Neumann entropy, concurrence, fidelity, etc. 
  • Tools for solving Lindblad master equations using vectorization. 
  • Functions for loading Pauli operators for multiple qubits, bosonic/fermionic operators, etc.
  • Properties and algebra of Gaussian states. 
  • Quantum Metrology with qubits and Gaussian states. 

Download & usage:

Have a look at the Mathematica notebook (.nb) . It contains all functions as Initialization Cells, together with documentation and examples. If you simply want to play with some of the functions, just run the Initialization Cells of this notebook.

A more systematic way of loading the functions is through the following line of code, which can be placed anywhere in the notebook:


Finally, if you wish to install the library in your computer, for further use, follow these steps:

  • Download the Mathematica package (.m) (this is like the .nb, but without the pretty formatting). 
  • Then follow these instructions for installing a package in Mathematica.
  • You will then be able to load the library any time Mathematica starts by typing


Finally, if you are a heavy user (like me), you can set it up so that Qulib is automatically loaded when Mathematica opens.  To do this:

  • Open Mathematica and type $UserBaseDirectory. 
  • This should print out a directory such as "/Users/gtlandi/Library/Mathematica”.
  • Navigate to this directory and, in the sub-folder “Kernel", open the file init.m
  • In this file you can put any command that you want to be evaluated when Mathematica is initialized. 
  • You can therefore put something like:


Additional examples:

Spin chains: eigenvalues, Lindblad equation &c.

Bosonic systems and metrology.