Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use a constant LETTER in sympy?

Tags:

python

sympy

I want to print the derivative of e**4*x. I want Python to give me 4*e**4x. Instead, it's giving me 4 times THE VALUE OF E. HOw can I get sympy to display e as the letter constant.

Thanks

like image 736
A R Avatar asked Feb 09 '15 00:02

A R


2 Answers

Note that by default in SymPy the base of the natural logarithm is E (capital E). That is, exp(x) is the same as E**x.

like image 124
asmeurer Avatar answered Sep 17 '22 07:09

asmeurer


You should be using exp to represent exponents as opposed to the letter e.

Example, it should be like this:

from sympy import *
x = symbols('x')

print diff(exp(4*x))

This outputs:

4*exp(4*x)

As desired.

Regarding the problem with your code - Without much more else to go on - it seems like you've set e to be a variable somewhere.

like image 31
jrd1 Avatar answered Sep 19 '22 07:09

jrd1