Mantis - ALGLIB
Viewing Issue Advanced Details
519 Spec.functions major always 2013-04-23 17:24 2018-01-02 17:23
zaytsev  
SergeyB  
normal  
assigned 3.7.0  
open  
none    
none  
All
0000519: Exponential integral Ei(x) returns 0 for x <= 0
The Ei(x) in ALGLIB returns 0 for all x <= 0 . This is not documented on the website:

http://www.alglib.net/specialfunctions/exponentialintegrals.php

In the source code, however, it says "Not defined for x <= 0", which, of course, explains this behavior, but doesn't really help.

Anyways, the function Ei(x) is defined on all real axis [1] and I see no reason why you would silently return 0 for x <= 0, while many other special function packages allow one to compute Ei(x) for negative arguments.

I need fast and accurate routines to compute the exponential integrals and would highly appreciate if you could address this problem.

Thanks!

[1]: http://mathworld.wolfram.com/ExponentialIntegral.html
I'm looking specifically at the C/C++ version of ALGLIB, but it shouldn't really matter.
Issue History
2013-04-23 17:24 zaytsev New Issue
2013-04-23 17:24 zaytsev Programming language => All
2013-04-23 22:04 SergeyB Note Added: 0000062
2013-04-23 23:38 zaytsev Note Added: 0000063
2018-01-02 17:23 SergeyB Status new => assigned
2018-01-02 17:23 SergeyB Assigned To => SergeyB

Notes
(0000062)
SergeyB   
2013-04-23 22:04   
According to Wiki [2], "definition above can be used for positive values of x, but the integral has to be understood in terms of the Cauchy principal value due to the singularity of the integrand at zero. For complex values of the argument, the definition becomes ambiguous due to branch points at 0 and .[1] In general, a branch cut is taken on the negative real axis".

So values at negative axis are not well-defined because of branch cut.

[2] http://en.wikipedia.org/wiki/Exponential_integral
(0000063)
zaytsev   
2013-04-23 23:38   
Hi Sergey,

The discussion about the ambiguity that you quoted above relates to the function of the complex argument (it starts with "For complex values of the argument..."), however, we are talking about a real-valued function of a real argument here.

Just have a look at the integral, it's well-defined for x < 0, however, at 0 the divergence happens and then, in order to use the same definition for x >= 0, you have to consider it as a VP.

Right now, I've switched to Boost [3], and I'm totally delighted about the accuracy and speed (4x faster then SPECFUN, didn't measure against CEPHES, because I need negative values).

However, Boost is a couple of hundreds of megabytes of source code, which sounds a bit too much if you only want one function out of it :-)

[3]: http://www.boost.org/doc/libs/1_53_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/expint/expint_i.html

Z.