Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Exponential Integral En

Synopsis
#include <boost/math/special_functions/expint.hpp>
namespace boost{ namespace math{

template <class T>
calculated-result-type expint(unsigned n, T z);

template <class T, class Policy>
calculated-result-type expint(unsigned n, T z, const Policy&);

}} // namespaces

The return type of these functions is computed using the result type calculation rules: the return type is double if T is an integer type, and T otherwise.

The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

Description
template <class T>
calculated-result-type expint(unsigned n, T z);

template <class T, class Policy>
calculated-result-type expint(unsigned n, T z, const Policy&);

Returns the exponential integral En of z:

Accuracy

The following table shows the peak errors (in units of epsilon) found on various platforms with various floating point types, along with comparisons to other libraries. Unless otherwise specified any floating point type that is narrower than the one shown will have effectively zero error.

Table 8.77. Error rates for expint (En)

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Exponential Integral En

Max = 0.589ε (Mean = 0.0331ε)

(GSL 2.1: Max = 58.5ε (Mean = 17.1ε))

Max = 9.97ε (Mean = 2.13ε)

Max = 9.97ε (Mean = 2.13ε)

Max = 7.16ε (Mean = 1.85ε)

Exponential Integral En: small z values

Max = 0ε (Mean = 0ε)

(GSL 2.1: Max = 115ε (Mean = 23.6ε))

Max = 1.99ε (Mean = 0.559ε)

Max = 1.99ε (Mean = 0.559ε)

Max = 2.62ε (Mean = 0.531ε)

Exponential Integral E1

Max = 0.556ε (Mean = 0.0625ε)

(GSL 2.1: Max = 0.988ε (Mean = 0.469ε))

Max = 0.965ε (Mean = 0.414ε)

Max = 0.965ε (Mean = 0.408ε)

Max = 0.988ε (Mean = 0.486ε)


Testing

The tests for these functions come in two parts: basic sanity checks use spot values calculated using Mathworld's online evaluator, while accuracy checks use high-precision test values calculated at 1000-bit precision with NTL::RR and this implementation. Note that the generic and type-specific versions of these functions use differing implementations internally, so this gives us reasonably independent test data. Using our test data to test other "known good" implementations also provides an additional sanity check.

Implementation

The generic version of this function uses the continued fraction:

for large x and the infinite series:

for small x.

Where the precision of x is known at compile time and is 113 bits or fewer in precision, then rational approximations devised by JM are used for the n == 1 case.

For x < 1 the approximating form is a minimax approximation:

and for x > 1 a Chebyshev interpolated approximation of the form:

is used.


PrevUpHomeNext