Help with recognizing e

19 views
Skip to first unread message

נדב שוייגר

unread,
Nov 2, 2016, 11:30:31 AM11/2/16
to sympy
Hi, I'm creating a derivative tool as an exercise using SymPy.

I get this following problem when using it:
The tool is based on receiving textual user input and assuming deriving in respect to 'x'.
In order to do so, i set x as a symbol and pass it as the second parameter to diff(). 
When differentiating "e**x" I get: "e**x*log(e)". This answer, while correct, bothers me because I'd like SymPy to know that log(e) == 1.

Any help?

Aaron Meurer

unread,
Nov 2, 2016, 1:23:47 PM11/2/16
to sy...@googlegroups.com
The SymPy name for exp(1) is E.

If you are using sympify() or parse_expr() you can map e to E using locals:

In [38]: sympify('log(e)', locals={'e': E})
Out[38]: 1

That's basically equivalent to running

e = E

before the given expression.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/938ae0c0-eedb-4442-8e26-4b91a65a3301%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages