Fixed complex phase issue in mathematica implementation