File Exchange

image thumbnail

Euler's Number

version 1.0.5 (6.52 KB) by Kareem Elgindy
This function gives the numerical value of Euler's number accurate to 10,000 significant digits.


Updated 28 Feb 2021

View Version History

View License

Have you ever wondered why Euler's number e = 2.71828... is not a built-in constant in MATLAB? We can produce Euler's number in MATLAB by evaluating exp(1), or possibly using exp(sym(1)) for the exact representation. But e is a very common constant in mathematics and it is as important as pi to some scholars, so after all these many versions of MATLAB, why haven't they recognize this valuable constant yet and show some appreciation by defining it as an individual constant rather than having to use the exp function for that? One possible reason for neglecting this important constant is that e is a scientific notation that stands for 10, so if MATLAB Development Team decided to define Euler's number as e, there would be a confusion among e = 10 and e = Euler's number.
In this file I defined a simple function named en to stand for Euler's number that gives its numerical value accurate to 10,000 significant digits. So MATLAB users can still keep e as a scientific notation while enjoying the luxury of having Euler's number well defined and added to the list of constants already defined in MATLAB. The acquired numerical value is a more accurate approximation to Euler's number than MATLAB numerical approximation obtained using the usual command exp(1) in double-precision floating-point systems, as tested on MATLAB R2019b and R2020a.
To use the file efficiently, simply put it in MATLAB search path. Enjoy!

Cite As

Kareem Elgindy (2021). Euler's Number (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!