Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit sympy processing of exprel #1350

Open
mstimberg opened this issue Sep 24, 2021 · 0 comments
Open

Revisit sympy processing of exprel #1350

mstimberg opened this issue Sep 24, 2021 · 0 comments

Comments

@mstimberg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants
@mstimberg and others