Which expansion of $e$ is more accurate?

We have two forms of $e^x$

$$e^x=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+....$$ and $$e^x=\frac{1}{\displaystyle 1-x+\frac{x^2}{2!}-\frac{x^3}{3!}+....}$$ The second form comes from $e^x=1/e^{-x}$

Which one is more accurate if I want to find any value of $e^x$


Solution 1:

The accuracy of any Taylor expansion of a given order is given by the next order of the expansion. For this very case, the answer is that it depends on how far out you want to take the expansions. For example,

$$\frac1{1-x} = 1+x+x^2+O(x^3)$$

This has twice the error as the expansion $1+x$, whose next term is $x^2/2!$. However,

$$\begin{align}\frac1{1-x+x^2/2} &= 1+\left (x-\frac{x^2}{2} \right ) + \left (x-\frac{x^2}{2} \right )^2+ \left (x-\frac{x^2}{2} \right )^3 + \cdots \\&= 1+x+\frac{x^2}{2} + O(x^4)\end{align}$$

Thus, for the second-order expansion, the reciprocal has a smaller error. However, for the cubic expansion, the expansion is

$$1+x+\frac{x^2}{2}+\frac{x^3}{6}+\frac{x^4}{12} + O(x^5) $$

whereas the fourth order term in the direct, Taylor expansion of the exponential is $x^4/24$. Thus, the direct Taylor expansion is more accurate out to fourth order.

There is a systematic way to prove that the accuracy alternates with order oddness or evenness by considering the error in the expansion of $e^x \cdot e^{-x}=1$.

ADDENDUM

The proof is actually not all that hard. Consider the finite approximations to the equation $e^x \cdot e^{-x}=1$:

$$\left (\sum_{k=0}^m \frac{x^k}{k!} \right ) \left (\sum_{k=0}^m (-1)^k \frac{x^k}{k!} \right ) $$

It may be easily shown that the coefficients of $x$, $x^2$, ..., $x^m$ are zero. We now consider the first error term, i.e., the coefficient of $x^{m+1}$:

$$\frac{x^1}{1!} \frac{(-1)^m x^m}{m!} + \frac{x^2}{2!} \frac{(-1)^{m-1} x^{m-1}}{(m-1)!} +\cdots + \frac{x^m}{m!} \frac{(-1)^1 x^1}{1!} = \sum_{k=1}^m \frac{(-1)^{m-k+1}}{k! (m-k+1)!} x^{m+1}$$

Rewrite this sum, sans the $x^{m+1}$ term, as

$$\sum_{k=0}^{m-1} \frac{(-1)^{m-k}}{(k+1)! (m-k)!} = (-1)^m \sum_{k=0}^{m-1} \frac{(-1)^k}{k! (m-k)!} \frac1{k+1}$$

We can evaluate this sum by realizing that

$$(1-x)^m = \sum_{k=0}^m (-1)^k \binom{m}{k} x^k $$

so that

$$\sum_{k=0}^m (-1)^k \binom{m}{k} \frac1{k+1} = \int_0^1 dx \, (1-x)^m = \frac1{m+1}$$

Therefore, by subtracting off the last term in the sum, we find that

$$(-1)^m \sum_{k=0}^{m-1} \frac{(-1)^k}{k! (m-k)!} \frac1{k+1} = - \frac{1-(-1)^m}{(m+1)!}$$

Therefore, we now may say that

$$\frac1{\displaystyle \sum_{k=0}^m (-1)^k \frac{x^k}{k!} } = \sum_{k=0}^m \frac{x^k}{k!} + \frac{1-(-1)^m}{(m+1)!} x^{m+1} + O(x^{m+2})$$

For even values of $m$, the next term error is zero, which is smaller than that for the direct Taylor series, which has error $x^{m+1}/(m+1)!$. On the other hand, for odd values, the error is double that of the direct Taylor series. This agrees with the above examples.

ADDENUDUM II

You may use the above analysis to determine whether you can get better accuracy using

$$e^x = \frac{e^{x/2}}{e^{-x/2}} $$

(Generally speaking, rational approximations to functions that agree with Taylor series in certain limits are called Pade approximates, and may be very useful in some situations.)

Solution 2:

While the first one approaches from below the other one oscillates near the actual values, it also depends how many terms (say t) you evaluate, for most of the case with large t both are approximately equal but with smaller t the first one is more accurate see graphs: enter image description hereenter image description here

In case of odd t it is above $e^x$ since negative terms dominate and denominator becomes small, but when t is even it forms a characteristic hill which is smaller than the actual curve.In both cases, the first formula is more accurate.

Solution 3:

Here's one quick observation. Letting $$f_{1,n}(x)=\sum_{k=0}^n \frac{x^n}{n!}$$ and $$f_{2,n}(x)=1/\left(\sum_{k=0}^n \frac{(-x)^n}{n!}\right),$$ we have $$\lim_{x\rightarrow\pm\infty}f_{1,n}(x) = \pm\infty \: \text{ and } \: \lim_{x\rightarrow\pm\infty}f_{2,n}(x) = 0.$$ Thus, I suppose we'd expect $f_{1,n}(x)$ to be a better approximation for positive $x$ and $f_{2,n}(x)$ to be a better approximation for negative $x$.

In the image below, for example, the thick, blue graph shows $f(x)=e^x$, the green graph shows $f_{1,6}(x)$, and the red graph shows $f_{2,6}(x)$. We can clearly see that $f_{2,6}$ veers away from $f$ for positive $x$, while $f_{1,6}$ is still a reasonable approximation - at least on this scale. The reverse is true for negative $x$.

enter image description here

Solution 4:

I'm not sure what you mean by "more accuracy."

But the second series has alternating addition and subtraction. Subtraction is subject to loss of precision. (Example: $1.234-1.2=0.034$, a loss of two significant digits.)

So the first is more accurate in that sense.