What are other faster methods of calculating $e^x$ up to any number of decimals other than using the Taylor series formula?
Fastest way to calculate $e^x$ up to arbitrary number of decimals?
15
$\begingroup$
algorithms
elementary-functions
-
2I'm told the series converges rapidly and is well-conditioned. Have you tried that? – 2011-01-21
-
3Why not use the standard series expansion $\sum_i x^i/i!$ ? I'm not sure, but it may pay of to first convert to a value in $[0,1[$, e.g. to calculate $e^{10}$, calculate $(e^{1/2})^{20}$ – 2011-01-21
-
1For what values of $x$ are you trying to calculate $e^x$? The exponential series itself converges pretty fast for small values of $x$. Are you looking for something faster than that? Is $x$ likely to be a large number? – 2011-01-21
-
1I believe Haskell supports it. And many programmings languages have standard libraries which support it. E.g. Java has java.math.BigDecimal. – 2011-01-21
-
0@Peter: Haskell (and Python) have arbitrary precision integers, but not arbitrary precision floating point, so one still has a little bit of plumbing to do. – 2011-01-21
-
0I don`t about BigDecimal in java but I am familiar with there is long in Python which is similar to it and even it can do addition and multiplication of large integers, but when it comes to decimals numbers having a long fractional part, it often rounds them and am pretty sure this is the case with Java too... So the conclusion is that you cannot use this series method for finding e^x upto a large number of decimals, because you have to redefine all elementary operations again and this formula thus, believe me, takes a very large amount of time. – 2011-01-22
-
2I used the generalized continued fraction method (http://en.wikipedia.org/wiki/Generalized_continued_fraction) to find e upto large number of decimals, and it is way to fast than this series method... The only problem with is that I don`t know how deep I should go to find e^x upto a particular decimal places... I usually have to find it for large value... So if someone can help me with this it would be great!! – 2011-01-22
-
1To evaluate $e^x$ for large values of $x$, use the idea of *range reduction* explained in my answer. You'll need to evaluate the constant $\ln 2$ to an accuracy corresponding to what your computation requires, but since it's a constant, you may only need to compute and store it once. I'll add a note on how to get $\ln 2$ to my answer. – 2011-01-22
-
0The GNU library for bignum deals with rational numbers, and it should be usable from lots of languages. – 2011-02-02