The routine may be called by the names s13aaf or nagf_specfun_integral_exp.
3Description
s13aaf calculates an approximate value for
using Chebyshev expansions, where is real. For , the real part of the principal value of the integral is taken. The value is infinite, and so, when , s13aaf exits with an error and returns the largest representable machine number.
For ,
where .
For ,
where .
In both cases, .
For , 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 , which corresponds to a simple zero of Ei().
s13aaf guards against producing underflows and overflows by using the argument
, see the Users' Note for your implementation for the value of . To guard against overflow, if the routine terminates and returns the negative of the largest representable machine number. To guard against underflow, if the result is set directly to zero.
Cody W J and Thatcher Jr. H C (1969) Rational Chebyshev approximations for the exponential integral Ei Math. Comp.23 289–303
5Arguments
1: – Real (Kind=nag_wp)Input
On entry: the argument of the function.
Constraint:
or .
2: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, and the function is infinite.
On entry, and the constant .
The evaluation has been abandoned due to the likelihood of overflow.
Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
Unless stated otherwise, it is assumed that .
If and are the relative errors in argument and result respectively, then in principle,
so the relative error in the argument is amplified in the result by at least a factor . 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 1
It should be noted that, for absolutely small , the amplification factor tends to zero and eventually the error in the result will be limited by machine precision.
For absolutely large ,
the absolute error in the argument.
For , empirical tests have shown that the maximum relative error is a loss of approximately decimal place.
8Parallelism and Performance
s13aaf is not threaded in any implementation.
9Further Comments
None.
10Example
The following program reads values of the argument from a file, evaluates the function at each value of and prints the results.