PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_integral_cos (s13ac)
Purpose
nag_specfun_integral_cos (s13ac) returns the value of the cosine integral
via the function name where
denotes Euler's constant.
Syntax
Description
nag_specfun_integral_cos (s13ac) calculates an approximate value for .
For
it is based on the Chebyshev expansion
For
,
where
and
,
.
For
,
to within the accuracy possible (see
Accuracy).
References
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Parameters
Compulsory Input Parameters
- 1:
– double scalar
-
The argument of the function.
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
The result of the function.
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
The function has been called with an argument less than or equal to zero for which the function is not defined. The result returned is zero.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
If
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
That is accuracy will be limited by
machine precision near the origin and near the zeros of
, but near the zeros of
only absolute accuracy can be maintained.
The behaviour of this amplification is shown in
Figure 1.
For large values of , therefore 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 we have that and hence is not significantly different from zero.
Hence
is chosen such that for values of
,
in principle would have values less than the
machine precision and so is essentially zero.
Further Comments
None.
Example
This example reads values of the argument from a file, evaluates the function at each value of and prints the results.
Open in the MATLAB editor:
s13ac_example
function s13ac_example
fprintf('s13ac example results\n\n');
x = [0.2:0.2:1];
n = size(x,2);
result = x;
for j=1:n
[result(j), ifail] = s13ac(x(j));
end
disp(' x Ci(x)');
fprintf('%12.3e%12.3e\n',[x; result]);
s13ac_plot;
function s13ac_plot
x = [0.1:0.1:2.9,3:0.5:26];
for j=1:numel(x)
[ci(j), ifail] = s13ac(x(j));
end
fig1 = figure;
plot(x,ci);
xlabel('x');
ylabel('Ci(x)');
title('Cosine Integral Ci(x)');
axis([0 26 -1.5 1]);
s13ac example results
x Ci(x)
2.000e-01 -1.042e+00
4.000e-01 -3.788e-01
6.000e-01 -2.227e-02
8.000e-01 1.983e-01
1.000e+00 3.374e-01
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015