PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_arccos (s09ab)
Purpose
nag_specfun_arccos (s09ab) returns the value of the inverse circular cosine, , via the function name; the result is in the principal range .
Syntax
Description
nag_specfun_arccos (s09ab) calculates an approximate value for the inverse circular cosine,
. It is based on the Chebyshev expansion
where
.
For .
For .
For .
For is undefined and the function fails.
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:
-
-
nag_specfun_arccos (s09ab) has been called with , for which arccos is undefined. A zero result is returned.
-
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 relative errors in the argument and the result, respectively, then in principle
The equality should hold if
is greater than the
machine precision (
is due to data errors etc.), but if
is due simply to round-off in the machine it is possible that rounding etc. in internal calculations may lose one extra figure.
The behaviour of the amplification factor is shown in the graph below.
In the region of
this factor tends to zero and the accuracy will be limited by the
machine precision. For
close to one,
, the above analysis is not applicable owing to the fact that both the argument and the result are bounded
,
.
In the region of we have , that is the result will have approximately half as many correct significant figures as the argument.
In the region , we have that the absolute error in the result, , is given by , that is the result will have approximately half as many decimal places correct as there are correct figures in the argument.
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:
s09ab_example
function s09ab_example
fprintf('s09ab example results\n\n');
x = [-0.5 0.1 0.9];
n = size(x,2);
result = x;
for j=1:n
[result(j), ifail] = s09ab(x(j));
end
disp(' x arccos(x)');
fprintf('%12.3e%12.3e\n',[x; result]);
s09ab example results
x arccos(x)
-5.000e-01 2.094e+00
1.000e-01 1.471e+00
9.000e-01 4.510e-01
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015