blob: 2b44fdeb3bcb0aeb306706caf71eff9b14135cfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* coshf.c
*
* Hyperbolic cosine
*
*
*
* SYNOPSIS:
*
* float x, y, coshf();
*
* y = coshf( x );
*
*
*
* DESCRIPTION:
*
* Returns hyperbolic cosine of argument in the range MINLOGF to
* MAXLOGF.
*
* cosh(x) = ( exp(x) + exp(-x) )/2.
*
*
*
* ACCURACY:
*
* Relative error:
* arithmetic domain # trials peak rms
* IEEE +-MAXLOGF 100000 1.2e-7 2.8e-8
*
*
* ERROR MESSAGES:
*
* message condition value returned
* coshf overflow |x| > MAXLOGF MAXNUMF
*
*
*/
/* cosh.c */
/*
Cephes Math Library Release 2.2: June, 1992
Copyright 1985, 1987, 1992 by Stephen L. Moshier
Direct inquiries to 30 Frost Street, Cambridge, MA 02140
*/
#include <math.h>
extern float MAXLOGF, MAXNUMF;
float expf(float);
float coshf(float xx)
{
float x, y;
x = xx;
if( x < 0 )
x = -x;
if( x > MAXLOGF )
{
mtherr( "coshf", OVERFLOW );
return( MAXNUMF );
}
y = expf(x);
y = y + 1.0/y;
return( 0.5*y );
}
|