adapted to sympy 0.7.3