nag_exp_integral (s13aac) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_exp_integral (s13aac)


    1  Purpose
    7  Accuracy

1  Purpose

nag_exp_integral (s13aac) returns the value of the exponential integral E1x.

2  Specification

#include <nag.h>
#include <nags.h>
double  nag_exp_integral (double x, NagError *fail)

3  Description

nag_exp_integral (s13aac) calculates an approximate value for
E1 x = -Ei -x = x e-u u du .  
using Chebyshev expansions, where x is real. For x<0, the real part of the principal value of the integral is taken. The value E1 0  is infinite, and so, when x=0 , nag_exp_integral (s13aac) exits with an error and returns the largest representable machine number.
For 0<x4,
where t=12x-1.
For x>4,
where t=-1.0+14.5 x+3.25 =11.25-x 3.25+x .
In both cases, -1t+1.
For x<0, the approximation is based on expansions proposed by Cody and Thatcher Jr. (1969). Precautions are taken to maintain good relative accuracy in the vicinity of x0-0.372507, which corresponds to a simple zero of Ei(-x).
nag_exp_integral (s13aac) guards against producing underflows and overflows by using the argument xhi ; see the Users' Note for your implementation for the value of xhi . To guard against overflow, if x<- xhi  the function terminates and returns the negative of the largest representable machine number. To guard against underflow, if x>xhi  the result is set directly to zero.

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Cody W J and Thatcher Jr. H C (1969) Rational Chebyshev approximations for the exponential integral Eix Math. Comp. 23 289–303

5  Arguments

1:     x doubleInput
On entry: the argument x of the function.
Constraint: -xhix<0.0 or x>0.0.
2:     fail NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

Dynamic memory allocation failed.
See Section in How to Use the NAG Library and its Documentation for further information.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
On entry, x=0.0 and the function is infinite.
The evaluation has been abandoned due to the likelihood of overflow. The argument x<-xhi.

7  Accuracy

Unless stated otherwise, it is assumed that x>0.
If δ and ε are the relative errors in argument and result respectively, then in principle,
ε e-x E1 x ×δ  
so the relative error in the argument is amplified in the result by at least a factor e-x/E1x. The equality should hold if δ is greater than the machine precision (δ due to data errors etc.) but if δ is simply a result of round-off in the machine representation, it is possible that an extra figure may be lost in internal calculation and round-off.
The behaviour of this amplification factor is shown in the following graph:
Figure s13aaf1_fig
Figure 1
It should be noted that, for absolutely small x, the amplification factor tends to zero and eventually the error in the result will be limited by machine precision.
For absolutely large x,
the absolute error in the argument.
For x<0, empirical tests have shown that the maximum relative error is a loss of approximately 1 decimal place.

8  Parallelism and Performance

nag_exp_integral (s13aac) is not threaded in any implementation.

9  Further Comments


10  Example

The following program reads values of the argument x from a file, evaluates the function at each value of x and prints the results.

10.1  Program Text

Program Text (s13aace.c)

10.2  Program Data

Program Data (s13aace.d)

10.3  Program Results

Program Results (s13aace.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −50 −40 −30 −20 −10 0 10 20 30 40 −5 −4 −3 −2 −1 0 1 2 3 4 5 E1(x) x Example Program Returned Values for the Exponential Integral E1(x) gnuplot_plot_1

nag_exp_integral (s13aac) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016