OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [mathfp/] [e_acosh.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)e_acosh.c 5.1 93/09/24 */
3
 
4
/*
5
FUNCTION
6
<<acosh>>, <<acoshf>>---inverse hyperbolic cosine
7
 
8
INDEX
9
acosh
10
INDEX
11
acoshf
12
 
13
ANSI_SYNOPSIS
14
        #include <math.h>
15
        double acosh(double <[x]>);
16
        float acoshf(float <[x]>);
17
 
18
TRAD_SYNOPSIS
19
        #include <math.h>
20
        double acosh(<[x]>)
21
        double <[x]>;
22
 
23
        float acoshf(<[x]>)
24
        float <[x]>;
25
 
26
DESCRIPTION
27
<<acosh>> calculates the inverse hyperbolic cosine of <[x]>.
28
<<acosh>> is defined as
29
@ifnottex
30
. log(<[x]> + sqrt(<[x]>*<[x]>-1))
31
@end ifnottex
32
@tex
33
$$ln\Bigl(x + \sqrt{x^2-1}\Bigr)$$
34
@end tex
35
 
36
<[x]> must be a number greater than or equal to 1.
37
 
38
<<acoshf>> is identical, other than taking and returning floats.
39
 
40
RETURNS
41
<<acosh>> and <<acoshf>> return the calculated value.  If <[x]>
42
less than 1, the return value is NaN and <<errno>> is set to <<EDOM>>.
43
 
44
You can change the error-handling behavior with the non-ANSI
45
<<matherr>> function.
46
 
47
PORTABILITY
48
Neither <<acosh>> nor <<acoshf>> are ANSI C.  They are not recommended
49
for portable programs.
50
 
51
 
52
QUICKREF ANSI SVID POSIX RENTRANT
53
 acos    n,n,n,m
54
 acosf   n,n,n,m
55
 
56
MATHREF
57
 acosh, NAN,   arg,DOMAIN,EDOM
58
 acosh, < 1.0, NAN,DOMAIN,EDOM
59
 acosh, >=1.0, acosh(arg),,,
60
 
61
MATHREF
62
 acoshf, NAN,   arg,DOMAIN,EDOM
63
 acoshf, < 1.0, NAN,DOMAIN,EDOM
64
 acoshf, >=1.0, acosh(arg),,,
65
 
66
*/
67
 
68
/*
69
 * ====================================================
70
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
71
 *
72
 * Developed at SunPro, a Sun Microsystems, Inc. business.
73
 * Permission to use, copy, modify, and distribute this
74
 * software is freely granted, provided that this notice
75
 * is preserved.
76
 * ====================================================
77
 *
78
 */
79
 
80
/* acosh(x)
81
 * Method :
82
 *      Based on
83
 *              acosh(x) = log [ x + sqrt(x*x-1) ]
84
 *      we have
85
 *              acosh(x) := log(x)+ln2, if x is large; else
86
 *              acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
87
 *              acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
88
 *
89
 * Special cases:
90
 *      acosh(x) is NaN with signal if x<1.
91
 *      acosh(NaN) is NaN without signal.
92
 */
93
 
94
#include "fdlibm.h"
95
 
96
#ifndef _DOUBLE_IS_32BITS
97
 
98
#ifdef __STDC__
99
static const double
100
#else
101
static double
102
#endif
103
one     = 1.0,
104
ln2     = 6.93147180559945286227e-01;  /* 0x3FE62E42, 0xFEFA39EF */
105
 
106
#ifdef __STDC__
107
        double acosh(double x)
108
#else
109
        double acosh(x)
110
        double x;
111
#endif
112
{
113
        double t;
114
        __int32_t hx;
115
        __uint32_t lx;
116
        EXTRACT_WORDS(hx,lx,x);
117
        if(hx<0x3ff00000) {             /* x < 1 */
118
            return (x-x)/(x-x);
119
        } else if(hx >=0x41b00000) {    /* x > 2**28 */
120
            if(hx >=0x7ff00000) {       /* x is inf of NaN */
121
                return x+x;
122
            } else
123
                return log(x)+ln2;      /* acosh(huge)=log(2x) */
124
        } else if(((hx-0x3ff00000)|lx)==0) {
125
            return 0.0;                 /* acosh(1) = 0 */
126
        } else if (hx > 0x40000000) {   /* 2**28 > x > 2 */
127
            t=x*x;
128
            return log(2.0*x-one/(x+sqrt(t-one)));
129
        } else {                        /* 1<x<2 */
130
            t = x-one;
131
            return log1p(t+sqrt(2.0*t+t*t));
132
        }
133
}
134
 
135
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.