s Chapter Contents
s Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_cos_integral (s13acc)

## 1  Purpose

nag_cos_integral (s13acc) returns the value of the cosine integral $\mathrm{Ci}\left(x\right)$.

## 2  Specification

 #include #include
 double nag_cos_integral (double x, NagError *fail)

## 3  Description

nag_cos_integral (s13acc) evaluates
 $Cix = γ + ln⁡x + ∫ 0 x cos⁡u - 1 u du x > 0$
where $\gamma$ 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: ${\mathbf{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: ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
The function is not defined for this value and the result returned is zero.

## 7  Accuracy

If $E$ and $\epsilon$ are the absolute and relative errors in the result and $\delta$ is the relative error in the argument then in principle these are related by $\left|E\right|\simeq \left|\delta \mathrm{cos}x\right|$ and $\left|\epsilon \right|\simeq \left|\left(\delta \mathrm{cos}x\right)/\mathrm{Ci}\left(x\right)\right|$. That is, accuracy will be limited by machine precision near the origin and near the zeros of $\mathrm{cos}x$, but near the zeros of $\mathrm{Ci}\left(x\right)$ only absolute accuracy can be maintained.
For large values of $x$, $\mathrm{Ci}\left(x\right)\sim \left(\mathrm{sin}x\right)/x$ therefore $\sim \delta x\mathrm{cot}x$ and since $\delta$ is limited by the finite precision of the machine it becomes impossible to return results which have any relative accuracy. That is, when $x\ge 1/\delta$ we have that $\left|\mathrm{Ci}\left(x\right)\right|\le 1/x\sim E$ and hence is not significantly different from zero.
Hence, for $x>{x}_{\mathrm{hi}}$, where ${x}_{\mathrm{hi}}$ is a machine-dependent value, $\mathrm{Ci}\left(x\right)$ in principle has values less than machine precision, and so is set directly to zero.

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)