Range reduction for the exponential integral?

103 Views Asked by At

I would like to compute $\operatorname{Ei}(x)$ to a reasonable precision. Fortunately, I have a computer algebra system (PARI/GP) which includes this function as a built-in, but unfortunately, $\operatorname{Ei}(x)$ causes an overflow. However, it's not that far away: I can compute $\operatorname{Ei}(x/8).$

Is there some sort of 'argument reduction' strategy that would let me take advantage of the existing function, or do I need to code something from the ground up for this?

1

There are 1 best solutions below

0
On

To a first estimate, $$ \operatorname{Ei}(x) \approx \operatorname{Ei}(x/k)^k $$ for $k$ small and $x$ large.

But we can improve on this with

$$ \operatorname{Ei}(x) = e^xf(x) $$ where $$ f(x)=\frac1x + \frac{1}{x^2} + \frac{2}{x^3} + \frac{6}{x^4} + O\left(\frac{1}{x^5}\right) $$ so $$ \begin{array}{ll} \operatorname{Ei}(x/k) &= e^{x/k}f(x/k)\\ \log\operatorname{Ei}(x/k) &= x/k + \log f(x/k)\\ k\log\operatorname{Ei}(x/k) &= x + k\log f(x/k)\\ x &= k\log\operatorname{Ei}(x/k) - k\log f(x/k)\\ \end{array} $$

and so

$$ \begin{array}{ll} \log\operatorname{Ei}(x) &= x + \log f(x)\\ \log\operatorname{Ei}(x) &= k\log\operatorname{Ei}(x/k) - k\log f(x/k) + \log f(x)\\ \operatorname{Ei}(x) &= \exp\big(k\log\operatorname{Ei}(x/k) - k\log f(x/k) + \log f(x)\big)\\ \operatorname{Ei}(x) &= \operatorname{Ei}(x/k)^kf(x)/f(x/k)^k\\ \end{array} $$ which can be approximated with the series. Of course you can take any finite number of terms in $f$, but you can't remove the error term that way.

I'm sure there are better approaches but this is a decent quick-and-dirty approach.