The constant \(e\)

class sage.symbolic.constants_c.E

Bases: sage.symbolic.expression.Expression

Dummy class to represent base of the natural logarithm.

The base of the natural logarithm e is not a constant in GiNaC/Sage. It is represented by exp(1).

This class provides a dummy object that behaves well under addition, multiplication, etc. and on exponentiation calls the function exp.

EXAMPLES:

The constant defined at the top level is just exp(1):

sage: e.operator()
exp
sage: e.operands()
[1]

Arithmetic works:

sage: e + 2
e + 2
sage: 2 + e
e + 2
sage: 2*e
2*e
sage: e*2
2*e
sage: x*e
x*e
sage: var('a,b')
(a, b)
sage: t = e^(a+b); t
e^(a + b)
sage: t.operands()
[a + b]

Numeric evaluation, conversion to other systems, and pickling works as expected. Note that these are properties of the exp() function, not this class:

sage: RR(e)
2.71828182845905
sage: R = RealField(200); R
Real Field with 200 bits of precision
sage: R(e)
2.7182818284590452353602874713526624977572470936999595749670
sage: em = 1 + e^(1-e); em
e^(-e + 1) + 1
sage: R(em)
1.1793740787340171819619895873183164984596816017589156131574
sage: maxima(e).float()
2.718281828459045
sage: t = mathematica(e)               # optional - mathematica
sage: t                                # optional - mathematica
E
sage: float(t)                         # optional - mathematica
2.718281828459045...

sage: loads(dumps(e))
e

sage: float(e)
2.718281828459045...
sage: e.__float__()
2.718281828459045...
sage: e._mpfr_(RealField(100))
2.7182818284590452353602874714
sage: e._real_double_(RDF)   # abs tol 5e-16
2.718281828459045
sage: import sympy
sage: sympy.E == e # indirect doctest
True