# 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 <nag.h>
#include <nags.h>

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:     x – doubleInput
On entry: the argument $x$ of the function.
Constraint: ${\mathbf{x}}>0.0$.
2:     fail – NagError *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)
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 24, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": false}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.6174866557121277, "perplexity_flag": "middle"}