3
$\begingroup$

Was in class where we look at both and notice that there is a difference in the error, but we didn't go into why. The other method used the taylor expansion $$e^x=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+...$$

Why does using the identity $$e^x=\frac{1}{e^{-x}}$$ work better for negative numbers?

To try and clear up what I'm asking, we coded a program to graph the error of the taylor series expansion of $e^x$ to n terms. We then coded another one to use the identity mentioned above in the expansion and noticed that it worked better for negative numbers, why is that the case?

For comparison, we were comparing the the absolute fractional error of the sums $$\frac{T(x,N)-e^x}{e^x}$$ for each method (with the identity and without). Where $T(x,N)$ is the N-th order taylor series expansion of $e^x$. We plotted the error against the order of expansion (number of terms considered in the sum). We evaluated various numbers, and saw that without using the identity, the error was higher for negative numbers.

$\endgroup$
10
  • 1
    $\begingroup$ Why was this downvoted? $\endgroup$
    – parsiad
    Jan 29, 2017 at 21:10
  • 1
    $\begingroup$ @parsiad based on the closed-vote, it seems that someone found it unclear what exactly is being asked. I would agree that it's not clear what the asker means. $\endgroup$ Jan 29, 2017 at 21:21
  • 1
    $\begingroup$ @Citut when you say $1/e^{-x}$ works better "for negative numbers", do you mean $1/e^{-x}$ works better "for negative values of $x$"? $\endgroup$ Jan 29, 2017 at 21:22
  • 1
    $\begingroup$ @Citut also, could you clarify what "works better" is supposed to mean (or what you think it should mean)? Do you mean that the series for $1/e^{-x}$ is supposed to converge more quickly? $\endgroup$ Jan 29, 2017 at 21:23
  • 1
    $\begingroup$ @Omnomnomnom it is pretty obvious that "converge quicklier" is exactly what OP meant. $\endgroup$
    – Wolfram
    Jan 29, 2017 at 21:35

3 Answers 3

3
$\begingroup$

Intuitive answer: when we sum the series for positive up to $x^n/n!$, the order of absolute error margin is roughly the module of the next term $|x^{n+1}/(n+1)!|$ of the series, because each next term is much less then the previous for large enough $n$. So for $e^{-x}$ and $e^x$ the absolute error margin is roughly the same if we add up to the $n$th term, because these modules coincide for opposite numbers. However, for $x<0$ $e^x<e^{-x}$, and so the relative error margin is much higher for $e^x$, than for $e^{-x}$. However, if we calculate $e^x$ as $1/e^{-x}$ than the relative margin is the same as of $e^{-x}$, and thus is better.

$\endgroup$
0
$\begingroup$

I know it's really late, but since there is no right answer I'll answer it myself.

First thing you need to know is what is called "Machine Epsilon". When a computer represents a number in floating point (32 or 64 bits) let's say the number 1, there is a slight margin of error ($2^{-23}$ for 32 bit and $2^{-52}$ for 64 bit). That is what we call $\epsilon$.

If we add/substract a number $x$ < $\epsilon$ to another number $y$ our machine will compute it as $y$, not considering the number $x$ since it is < $\epsilon$.

The Taylor series $e^x$ for $x$ < 0, the factors of the polynomial look like this:
$$e^X = -f_1 + f_2 - f_3 + f_4 \pm\cdots \pm f_n$$ As you see we keep alternating between positive and negative factors. When the order gets bigger the new factors get smaller and more precise so there's room for adding or substracting numbers around $\epsilon$ thus creating unwanted error.

If we compute $e^x$ for $x$ < 0 like $\frac{1}{e^{|x|}}$ all the factors of the Taylor series are positive and we avoid $\epsilon$ errors. Thus, the method converges in less iterations.

PD: I just created an account to answer this I hope it's understandable and answered your question :)

$\endgroup$
0
$\begingroup$

This is what is known as a Padé approximant. Due to the additional terms in the denominator, the series can be made to be more well-behaved as well as converge faster in a region of interest. In this case, the seemingly improved convergence comes about from the fact that the given expansion has lower absolute error for negative $x$, but it fails to give better convergence as $x\to0$. To get better convergence near $x=0$, you should instead use the identity

$$e^x=\frac{e^{x/2}}{e^{-x/2}}=\frac{1+\frac x2+\frac{x^2}8+\dots}{1-\frac x2+\frac{x^2}8-\dots}$$

as suggested by Wikipedia.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.