Euler's Number

This function gives the numerical value of Euler's number accurate to 10,000 significant digits.
251 Downloads
Updated 28 Feb 2021

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 (2024). Euler's Number (https://www.mathworks.com/matlabcentral/fileexchange/77046-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!

Version Published Release Notes
1.0.5

If d significant digits is needed, for 2 <= d <= 10,000, type vpa(en,d).

1.0.4

This function can now give the numerical value of Euler's number accurate to 10,000 significant digits.

1.0.3

This function can now give the numerical value of Euler's number accurate to 10,000 digits instead of just 16 significant digits.

1.0.2

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.

1.0.1

It is intended to use this code to perform additions, subtractions, multiplications, and divisions with Euler's number. If exponentiation or more accuracy is required use exp.

1.0.0