Skip to content

Conversation

GSam
Copy link
Owner

@GSam GSam commented Aug 23, 2021

Update required version of Python

Update required version of Python
@GSam GSam merged commit 910101f into GSam:master Aug 23, 2021
GSam added a commit that referenced this pull request Aug 23, 2021
This is useful for more general, albeit sometimes inefficient, summation
code. Just copying some taylor expansion code from the internet worked
with sympy but not symengine due to the following error:

Traceback (most recent call last):
  File "example.py", line 32, in <module>
    taylor(symengine.sympify('1/(1-x-x^2)'), 0, 15)
  File "example.py", line 27, in taylor
    p = p + (function.diff(x, i).subs(x, x0))/(factorial(i))*(x - x0)**i
  File "symengine_wrapper.pyx", line 923, in symengine.lib.symengine_wrapper.Basic.diff
  File "symengine_wrapper.pyx", line 4020, in symengine.lib.symengine_wrapper.diff
OverflowError: can't convert negative value to size_t

There are a number of inconsistencies compared to the regular sympy library:

1. Takes no argument:

   >>> symengine.sympify('x**2').diff()
   2*x

   This actually seems helpful, except when you have symengine#2 misleading you.

   This is not accepted in sympy, but doesn't necessarily need a fix.

2. Takes a standalone integer argument and returns a nonsense answer:

   >>> symengine.sympify('x**2').diff(1)
   x**2

   This is simply not accepted in the regular sympy library.

3. Takes multiple integer arguments and aggregates:

    diff(x, 1, 1) == diff(x, 2)

   This does not occur with the sympy library, and does not seem useful.
   It can easily be replaced with diff(x, x), if repetition was necessary.

4. Takes only integer arguments > 1:

   diff(x, 0) returns integer overflow

   This is accepted in sympy.

In this patch, 2-4 are all fixed. #1 seems like a potentially useful (and
likely used) feature.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants