Optimize mathematical formulas for speed with SymPy and various tricks
