Wolfram Mathematica packages
Please e-mail me (mph(at)brandeis.edu) if you find bugs or errors in any of these programs, if you would like to suggest added features, or just to let me know that you've used them. Please also acknowledge me in any publications resulting from research that makes substantial use of any of them.
diffgeo.m
A package for doing GR-type tensor algebra and calculus. Compared to other such packages I know, it is easy to use and fairly comprehensive in the number of functions defined. Here is a notebook with documentation and an example of how to use the package. (Last updated June 2024, with easier ways for entering the metric.)Virasoro.nb
A package that teaches Mathematica the Virasoro algebra. It also computes Kac matrices and determinants and conformal blocks. More generally, it defines an environment for implementing any operator algebra. (Last updated April 2010.)grassmann.m
A simple package that teaches Mathematica how to do algebra and calculus with Grassmann variables. Jointly written with J. Michelson, with contributions from J. Guffin and L. Hlavaty.theta.m
A package that translates between Polchinski's theta-function conventions and Mathematica's.BlockInverse.nb
A short snippet of code that teaches Mathematica to invert a diagonal (or block-diagonal) matrix by inverting each diagonal entry (or block) separately. For algebraic matrices this results in simpler output, and for numerical ones it avoids spurious warnings about ill-conditioned matrices.Fermat.m and psi.m
These packages implement the method for finding "optimal" approximations to the Ricci-flat metric on an algebraic Calabi-Yau manifold, described in the paper "Energy functionals for Calabi-Yau metrics" by A. Nassar and myself (arXiv: 0908.2635 [hep-th]). The use of these packages is illustrated in the notebook optimal.nb. If you want to look inside the packages (for example, to alter them for applications to a different set of Calabi-Yaus), you may find it useful to look at the set of notes strategy.pdf, which describes the calculations, and the notation used, in more detail.
This notebook, by G. Grimaldi and myself, tests the validity of holographic entropy inequalities in 2+1 dimensional vacuum AdS spacetimes, as described in the paper "Testing holographic entropy inequalities in 2+1 dimensions" by B. Grado-White, G. Grimaldi, V. Hubeny, and myself (arXiv: 2407.07165 [hep-th]). If you would like to test some inequalities yourself, you can find a complete list of known inequalities for up to 6 parties in the package HEIallQvec.m (by S. Hernández-Cuenca).
Bonus code: majorization!
Surprisingly, Mathematica does not contain a built-in function for testing majorization of vectors. So here it is:
Majorize[v_List]:= VectorGreaterEqual[Accumulate /@ Reverse /@ NumericalSort /@ v] /; AllTrue[v, NonNegative, 2]
Majorize::usage= "Majorize[{x,y}] yields True for vectors x,y of length n with non-negative components if x majorizes y, i.e. if for all k = 1,...,n, the sum of the largest k components of x is greater than or equal to the sum of the largest k components of y.";