linear or quadratic approximation for exp(-x) for large x

Is there any linear or quadratic approximation of $exp(-x)$ where $0<x<L$ ? $L$ is large, may be 40 (say) i.e. $x$ is not close to zero.

• $$e^x= \sum^\infty_{n=0} \frac{x^n}{n!}$$ – chubakueno Jan 5 '14 at 6:10
• @chubakueno. The OP asks for a linear or quadratic approximation. You provide the good answer but with a "few" extra terms ! Cheers. – Claude Leibovici Jan 5 '14 at 6:13
• Doesn't this expression give good result only when $x$ is close to $0$ ? – Pradipta Jan 5 '14 at 6:28
• @Pradipta. Sure ... but what about x=40 as asked by the OP ? – Claude Leibovici Jan 5 '14 at 6:34
• Yes, but the larger you want the x, the more terms you need. If you plot your equation, you will see that it has a really long tail. So in order to fit a quadratic there, you can understand that the coefficients will be very low for such a flat parabola. But you can always approximate it as you want to by choosing three points and interpolating them (it is always possible to construct such a quartic for three diferent points) – chubakueno Jan 5 '14 at 6:36

Make a table of $e^{-n}$ for integers $0 \leq n \leq 40.$ For any real $x$ in the same bounds, take the value $$e^{-\left\lfloor x \right\rfloor} \; e^{\left\lfloor x \right\rfloor - x}$$ As the argument in the second factor is smaller then $1$ in absolute value, you get quite nice convergence for the Taylor series, given in the first comment to the question.

This same method gives the best accuracy for polynomials with integer coefficients as well. Given such a polynomial, its Taylor series around some integer $n$ is another polynomial with integer coefficients. So, for real $x,$ you evaluate the polynomial using its Taylor series around the nearest integer.

I am adding another answer, because this does not answer OP's question but gives my opinion on the problem.

If you want to approximate functions that have large variations in their value, ($e^{-x}$ has 18 orders of magnitude change for $0<x<40$) then Pade approximation may be more appropriate. A quick least square fit using Levenberg-Marquardt nonlinear regression gives $$e^{-x} = \frac{1.1570762 -0.1746994 x + 0.0045234 x^2}{1-2.0289128 x}$$

with error $<0.16$ in the entire range

If you know $L$, then you can use numerical solution to find the approximation (using linear least squares for example). If you are not familiar, I can share some ideas.

First off, no single approximation is going to be good so I would strongly advice against doing this. That said, I will do it for $5 < x < 40$ so you can assess how good the approach is. You may want another approximation for $0 < x < 5$.

Let $$f(x) = e^{-x}\\ g(x) = a_0 + a_1 x + a_2 x^2 \\ e(x) = f(x)-g(x)$$

Let $$J = \int_5^{40} e(x)^2 dx$$ To get a good approximation, we want $J$ to be small. If you integrate it out, you should end up with a quadratic in $a_0$, $a_1$ and $a_2$. You now minimize the error by setting $$\frac{dJ}{d a_0}=0 \\ \frac{dJ}{d a_1}=0 \\ \frac{dJ}{a_2}=0$$ You can calculate the derivatives as $$\frac{d}{d a_0}\int_5^{40} e(x)^2 dx = \int_5^{40} 2 e(x) \frac{d e(x)}{d a_0} dx = -2\int_5^{40} \left(e^{-x} - (a_0+a_1 x + a_2 x^2) \right)dx = 0$$ Similarly $$\frac{d}{d a_1}\int_5^{40} e(x)^2 dx = \int_5^{40} 2 e(x) \frac{d e(x)}{d a_1} dx = -2\int_5^{40} \left(e^{-x} - (a_0+a_1 x + a_2 x^2) \right) x dx = 0$$ $$\frac{d}{d a_2}\int_5^{40} e(x)^2 dx = \int_5^{40} 2 e(x) \frac{d e(x)}{d a_2} dx = -2\int_5^{40} \left(e^{-x} - (a_0+a_1 x + a_2 x^2)\right) x^2 dx = 0$$

Note: These calculations are very sensitive to round off errors, so leave everything in the symbolic form till the very end.

Personally I would try to use different approximations, one for $0<x<5$, $5<x<10$, $10<x$. Not sure when you would want one approximation that fits all. Note that $$e^{-40} = \approx 10^{-18}$$

• Could you go ahead ? Thanks. – Claude Leibovici Jan 5 '14 at 6:14
• Hope there are enough caveats in my answer. I would never do it myself but here is the answer. – user44197 Jan 5 '14 at 6:35
• Please, use what you did for 5 < x < 10 and plot the two curves. Understand that I totally agree with your approach but for things such as Exp[-x] ... Cheers. – Claude Leibovici Jan 5 '14 at 6:58
• I am too ashamed to plot the curves. It is bad! :) No polynomial is going to capture $1:10^{-12}$ variations. Please see my other answer that is more practical. – user44197 Jan 5 '14 at 6:59
• So, we also agree on that ! – Claude Leibovici Jan 5 '14 at 7:00

Combining what Will Jagy proposed and what user44197 gives in his second answer and willing to stay with minimum number of terms (as requested by the post), I propose to use a Pade approximant built around the closest integer x0.

So the simple formula is

Exp[-x0] [1 - (x - x0) / 2 + (x - x0)^2 / 12] / [1 + (x - x0)/2 + (x - x0)^2 / 12]

and the approximation is very good.

• Cool answer. If you want to see the derivation, here it is. As typing in the comments is painful, I will show it without shifting: $e^{-x} = \frac{e^{-x/2}}{e^{x/2}} = \frac{1 - x/2 + (x/2)^2/2}{1+x/2 + (x/2)^2/2}$. I don't see how to get the factor $1/12$. Incidentally, if you just use the first order taylor series approximation, it is called the bilinear or Tustin transform that is used extensively when converting continuous time systems to sampled data systems (digital systems). Cool answer – user44197 Jan 5 '14 at 7:34
• @user44197. What you wrote is the ratio of two Taylor expansions. The factor 1/12 comes directly from the Pade approximant and this is not the same story at all. – Claude Leibovici Jan 5 '14 at 7:45
• Can you give an idea of how you got the 12? Just a hint will help. Just curious. – user44197 Jan 5 '14 at 7:46
• Have a look at en.wikipedia.org/wiki/Padé_approximant and mathworld.wolfram.com/PadeApproximant.html. I suppose that any CAS has this functionality. Let me know if this is not sufficient. – Claude Leibovici Jan 5 '14 at 7:59
• Got it. I had an error in my calculations and did not get the $12$. Used a CAS (maxima) and verified your answer. – user44197 Jan 5 '14 at 15:20

For a good decimal approximation, use the following approximations: $$\exp(2.302585) \approx 10$$ $$\exp(0.693147) \approx 2$$ So, for example say $x = -40$. $$k = \left\lfloor \frac{x}{2.303} \right\rfloor = -18$$ $$m = \left\lfloor \frac{x - 2.303k}{0.693} \right\rfloor = 2$$ $$\epsilon = x - 2.303k - 0.693m = 0.06$$ In the worst case $\epsilon = 0.693$, so worst case is $\exp(\epsilon)=2$, evaluate terms until it is small. $$\exp(\epsilon) = 1 + \epsilon + \epsilon^2/2 + \cdots \approx 1.0618$$ So finally $$\exp(x) = 10^{k} \times 2^m \times \exp(\epsilon) \approx 4.2472 \times 10^{-18}$$ Precise computation shows this is very close. $$\exp(-40) = 4.248354255291588995329234782858658017879565554... \times 10^{-18}$$

• I think the OP wants to approximate the function $e^{-x}$ by a linear or quadratic function. – Michael Albanese Jan 26 '16 at 14:13
• Yes, I do realize that, just in case OP finds this useful. – Anita Jan 26 '16 at 14:51