sympy/sympy — pull request #1546 by lidavidm (2012-09-27 23:59:22+00:00)
Title: Implicit multiplication and function application for sympify

As discussed at https://groups.google.com/forum/?fromgroups=#!topic/sympy/2-GOtltf0Wg

Examples:

>>> sympify('y sin**2 x^2 + 3x + 5', convert_xor=True, implicit=True)
3*x + y*sin(x**2)**2 + 5

>>> sympify('sin x cos x', implicit=True) # this only works for single-variable functions
sin(x)*cos(x)

>>> sympify('cos sin ln log exp tan x', implicit=True)
cos(sin(log(log(exp(tan(x))))))

>>> sympify('x_2', implicit=True) # symbols with underscores in the name are not split
x_2

>>> sympify('theta', implicit=True) # neither are symbols that are Greek letters
theta

>>> sympify('x**2 + 2xy + y**2', implicit=True) # but symbols like 'xy' are split
x**2 + 2*x*y + y**2

>>> sympify('(x+2)(x+5)sin x', implicit=True)
(x + 2)*(x + 5)*sin(x)

There are also test cases in `sympy/parsing/tests/test_implicit_multiplication_application.py`. As for performance, a (poor) benchmark I ran with 10 cases, 100 iterations showed about a 30% increase in time.

If you would like to play with this I have [uploaded a version of SymPy Gamma](sympy-gamma-li.appspot.com) that uses `implicit=True` on all input (it also has some other improvements over the current version). For instance, see http://sympy-gamma-li.appspot.com/input/?i=1%2F2x or http://sympy-gamma-li.appspot.com/input/?i=integrate+x