brian2
brian2 copied to clipboard
Revisit sympy processing of exprel
SymPy does all kind of transformations of equations to replace constant terms (e.g. it will replace exp(0) by 1), and that is of course desirable in general. However, in the context of the exprel function which is not used for its mathematical properties but rather for accuracy reasons, this can be problematic. The situation for this actually got a bit better since we no longer considered all numerical literals as floating point values, but I think it is still problematic.
Here's a quick example:
>>> exprel = DEFAULT_FUNCTIONS['exprel']
>>> exprel.sympy_func(sympy.sympify('x + 2'))
exprel(x + 2)
>>> exprel.sympy_func(sympy.sympify('x + 2.0'))
>>> (7.38905609893065*exp(x) - 1)/(x + 2.0)
In the second formulation, we lose all the advantage of the numerically more accurate exprel function. I guess the same also applies to expm1 et log1p.