Sympy symengine calculus

110 views
Skip to first unread message

Matthew Graham

unread,
Jan 10, 2018, 5:13:16 PM1/10/18
to symengine
My first question is:
Does Sympy currently use symengine in the backend or are they seperate libraries with similar syntax?

My second question is:
I noticed that when playing around with the symengine library in python that there is both symengine.diff and symengine.Derivative. I was hoping for clarification on the difference between these.

My third question is:
I cannot seem to find anything on the integration/integral operation (e.g. x -> (1/2)x**2), does this exist in symengine? Thank you

schw...@gmail.com

unread,
Jan 11, 2018, 3:42:55 PM1/11/18
to symengine
Regarding the first question: As far as I came to know:
the engine is a separate library in C(++?), that uses Cython to bind to python. It is designed, such that you can - as easily as possible - use the faster one as backend, but it's far from feature complete.

Second: .diff() does differentiate an expression. It returns the derived expression. Whereas Derivative() is the "not done yet" counterpart. It returns an object d expr/ d x. It returns the symbolic derivative, that has not been executed. You need the latter one for partial differential equations I guess. The first one is if you want to execute on a derivative (most use cases).

Third: I haven't used that, so I don't know, really.

Good Luck!

Ondřej Čertík

unread,
Jan 11, 2018, 4:12:27 PM1/11/18
to syme...@googlegroups.com


On Thu, Jan 11, 2018, at 12:40 PM, schw...@gmail.com wrote:
> Regarding the first question: As far as I came to know:
> the engine is a separate library in C(++?), that uses Cython to bind to
> python. It is designed, such that you can - as easily as possible - use the
> faster one as backend, but it's far from feature complete.

Yes, the symengine library is pure C++, and then there are Python (and other languages) wrappers. SymPy uses SymEngine optionally as a backend for some things, and we are working on using it for more things. We are trying to make the Python wrappers behave just like you would expect from using SymPy, as a drop in replacement.

Ondrej

> Second: .diff() does differentiate an expression. It returns the derived
> expression. Whereas Derivative() is the "not done yet" counterpart. It
> returns an object d expr/ d x. It returns the symbolic derivative, that has
> not been executed. You need the latter one for partial differential
> equations I guess. The first one is if you want to execute on a derivative
> (most use cases).
>
> Third: I haven't used that, so I don't know, really.
>
> Good Luck!
>
> Am Mittwoch, 10. Januar 2018 23:13:16 UTC+1 schrieb Matthew Graham:
> >
> > My first question is:
> > Does Sympy currently use symengine in the backend or are they seperate
> > libraries with similar syntax?
> >
> > My second question is:
> > I noticed that when playing around with the symengine library in python
> > that there is both symengine.diff and symengine.Derivative. I was hoping
> > for clarification on the difference between these.
> >
> > My third question is:
> > I cannot seem to find anything on the integration/integral operation (e.g.
> > x -> (1/2)x**2), does this exist in symengine? Thank you
>
> --
> You received this message because you are subscribed to the Google
> Groups "symengine" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to symengine+...@googlegroups.com.
> To post to this group, send email to syme...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/symengine/7bb5c913-cac6-45bd-afd2-f680fd7db354%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Matthew Graham

unread,
Jan 13, 2018, 5:06:38 PM1/13/18
to symengine
Thank you. How does one go about allowing sympy to backend in symengine?

Björn Dahlgren

unread,
Jan 14, 2018, 8:56:09 PM1/14/18
to symengine
You need to set an environment variable:
export USE_SYMENGINE=1

you can grep sympy's codebase to see what's supported so far.

Best regards,
Björn
Reply all
Reply to author
Forward
0 new messages