Mathematica code