0
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ $$e^x= \sum^\infty_{n=0} \frac{x^n}{n!}$$ $\endgroup$ – chubakueno Jan 5 '14 at 6:10
  • $\begingroup$ @chubakueno. The OP asks for a linear or quadratic approximation. You provide the good answer but with a "few" extra terms ! Cheers. $\endgroup$ – Claude Leibovici Jan 5 '14 at 6:13
  • $\begingroup$ Doesn't this expression give good result only when $x$ is close to $0$ ? $\endgroup$ – Pradipta Jan 5 '14 at 6:28
  • $\begingroup$ @Pradipta. Sure ... but what about x=40 as asked by the OP ? $\endgroup$ – Claude Leibovici Jan 5 '14 at 6:34
  • $\begingroup$ 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) $\endgroup$ – chubakueno Jan 5 '14 at 6:36
4
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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.

Added following comment

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}$$

$\endgroup$
  • $\begingroup$ Could you go ahead ? Thanks. $\endgroup$ – Claude Leibovici Jan 5 '14 at 6:14
  • $\begingroup$ Hope there are enough caveats in my answer. I would never do it myself but here is the answer. $\endgroup$ – user44197 Jan 5 '14 at 6:35
  • $\begingroup$ 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. $\endgroup$ – Claude Leibovici Jan 5 '14 at 6:58
  • $\begingroup$ 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. $\endgroup$ – user44197 Jan 5 '14 at 6:59
  • $\begingroup$ So, we also agree on that ! $\endgroup$ – Claude Leibovici Jan 5 '14 at 7:00
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – user44197 Jan 5 '14 at 7:34
  • $\begingroup$ @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. $\endgroup$ – Claude Leibovici Jan 5 '14 at 7:45
  • $\begingroup$ Can you give an idea of how you got the 12? Just a hint will help. Just curious. $\endgroup$ – user44197 Jan 5 '14 at 7:46
  • $\begingroup$ 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. $\endgroup$ – Claude Leibovici Jan 5 '14 at 7:59
  • $\begingroup$ Got it. I had an error in my calculations and did not get the $12$. Used a CAS (maxima) and verified your answer. $\endgroup$ – user44197 Jan 5 '14 at 15:20
0
$\begingroup$

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} $$

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

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.