nag_cos_integral (s13acc) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_cos_integral (s13acc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_cos_integral (s13acc) returns the value of the cosine integral Cix .

2  Specification

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

3  Description

nag_cos_integral (s13acc) evaluates
Cix = γ + lnx + 0 x cosu - 1 u du x > 0
where γ  denotes Euler's constant.
The approximation is based on several Chebyshev expansions.

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

5  Arguments

1:     xdoubleInput
On entry: the argument x  of the function.
Constraint: x>0.0 .
2:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_REAL_ARG_LE
On entry, x must not be less than or equal to 0.0: x=value .
The function is not defined for this value and the result returned is zero.

7  Accuracy

If E  and ε  are the absolute and relative errors in the result and δ  is the relative error in the argument then in principle these are related by E δ cosx  and ε δ cosx / Cix . That is, accuracy will be limited by machine precision near the origin and near the zeros of cosx , but near the zeros of Cix  only absolute accuracy can be maintained.
For large values of x , Cix sinx / x  therefore δ x cotx  and since δ  is limited by the finite precision of the machine it becomes impossible to return results which have any relative accuracy. That is, when x 1 / δ  we have that Cix 1 / x E  and hence is not significantly different from zero.
Hence, for x > x hi , where x hi  is a machine-dependent value, Cix  in principle has values less than machine precision, and so is set directly to zero.

8  Further Comments

None.

9  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.

9.1  Program Text

Program Text (s13acce.c)

9.2  Program Data

Program Data (s13acce.d)

9.3  Program Results

Program Results (s13acce.r)


nag_cos_integral (s13acc) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG C Library Manual

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