Proposal: sympy.e, similar to sympy.pi

6,947 views
Skip to first unread message

Jeff Pickhardt

unread,
Jan 23, 2011, 7:20:33 PM1/23/11
to sy...@googlegroups.com
Sympy has sympy.pi and sympy.I, however Euler's constant is found via sympy.exp(1).

What do you guys think of the idea of creating sympy.e = sympy.exp(1)?

--
Jeff Pickhardt

Aaron Meurer

unread,
Jan 23, 2011, 9:14:41 PM1/23/11
to sy...@googlegroups.com
It's there. Use SymPy.E

Aaron Meurer

> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>

Chris Smith

unread,
Jan 23, 2011, 9:51:17 PM1/23/11
to sy...@googlegroups.com
Jeff Pickhardt wrote:
>> Sympy has sympy.pi and sympy.I, however Euler's constant is found via
>> sympy.exp(1).
>>

I suppose the reason that E rather than e is available is to keep it from clashing with commonly used lowercase symbol names. But since pi is a lower case constant I would think that people would be aware of e. I would be in favor of changing the E to e. If someone wipes out e with a variable of the same name they can always access it through S.Exp1, too.

Chris

Stuart Brorson

unread,
Jan 23, 2011, 9:09:52 PM1/23/11
to sy...@googlegroups.com
> What do you guys think of the idea of creating sympy.e =
sympy.exp(1)?

Love it. Good idea.

Makes me think.... What about other constants, like Euler's gamma
(0.577....)? Should there be a set of constants which are built
into sympy?

Just a stray thought....

Stuart Brorson

Aaron S. Meurer

unread,
Jan 24, 2011, 12:56:50 PM1/24/11
to sy...@googlegroups.com
We already have that too:

>>> import sympy
>>> sympy.EulerGamma
EulerGamma
>>> sympy.EulerGamma.evalf()
0.577215664901533

Aaron Meurer

Aaron S. Meurer

unread,
Jan 24, 2011, 1:02:26 PM1/24/11
to sy...@googlegroups.com
I think pi is lowercase because its lowercase pi, although with that logic, gamma should be Gamma. However, they match the names from the math module:

>>> import math
>>> math.pi
3.141592653589793
>>> math.gamma(4)
6.0
>>> sympy.gamma(4)
6

On the other hand, we do have math.e, so I guess not everything matches something else. E and I (capital) are used by Maple, and I think it's probably a good convention in SymPy to make single letter names upper case, since import * is executed a lot with the sympy module.

And besides, it's probably best to leave things named the way that they are, unless there is a very good reason to change them, like there was with sum and abs.

Aaron Meurer

Reply all
Reply to author
Forward
0 new messages