hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_sinh (s10ab)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_sinh (s10ab) returns the value of the hyperbolic sine, sinhx, via the function name.

Syntax

[result, ifail] = s10ab(x)
[result, ifail] = nag_specfun_sinh(x)

Description

nag_specfun_sinh (s10ab) calculates an approximate value for the hyperbolic sine of its argument, sinhx.
For x1 it uses the Chebyshev expansion
sinhx=x×yt=xr=0arTrt  
where t=2x2-1.
For 1<xE1,  sinhx=12ex-e-x
where E1 is a machine-dependent constant.
For x>E1, the function fails owing to the danger of setting overflow in calculating ex. The result returned for such calls is sinhsignxE1, i.e., it returns the result for the nearest valid argument.

References

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

Parameters

Compulsory Input Parameters

1:     x – double scalar
The argument x of the function.

Optional Input Parameters

None.

Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W  ifail=1
The function has been called with an argument too large in absolute magnitude. There is a danger of setting overflow. The result is the value of sinhx at the closest argument for which a valid call could be made.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

If δ and ε are the relative errors in the argument and result, respectively, then in principle
ε xcothx×δ.  
That is the relative error in the argument, x, is amplified by a factor, approximately xcothx. The equality should hold if δ is greater than the machine precision (δ is a result of data errors etc.) but, if δ is simply a result of round-off in the machine representation of x, then it is possible that an extra figure may be lost in internal calculation round-off.
The behaviour of the error amplification factor can be seen in the following graph:
Figure 1
Figure 1
It should be noted that for x2 
εxδ=Δ  
where Δ is the absolute error in the argument.

Further Comments

None.

Example

This example reads values of the argument x from a file, evaluates the function at each value of x and prints the results.
function s10ab_example


fprintf('s10ab example results\n\n');

x = [-10   -0.5     0    0.5     25];
n = size(x,2);
result = x;

for j=1:n
  [result(j), ifail] = s10ab(x(j));
end

disp('      x        sinh(x)');
fprintf('%12.3e%12.3e\n',[x; result]);


s10ab example results

      x        sinh(x)
  -1.000e+01  -1.101e+04
  -5.000e-01  -5.211e-01
   0.000e+00   0.000e+00
   5.000e-01   5.211e-01
   2.500e+01   3.600e+10

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015