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!
Kareem Elgindy (2023). Euler's Number (https://www.mathworks.com/matlabcentral/fileexchange/77046-euler-s-number), MATLAB Central File Exchange. 取得済み .
プラットフォームの互換性Windows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
If d significant digits is needed, for 2 <= d <= 10,000, type vpa(en,d).
This function can now give the numerical value of Euler's number accurate to 10,000 significant digits.
This function can now give the numerical value of Euler's number accurate to 10,000 digits instead of just 16 significant digits.
The acquired numerical value is a more accurate approximation to Euler's number than MATLAB numerical
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.