Last change
on this file since 389 was 389, checked in by coas-nagasima, 5 years ago |
ビルドが通るよう更新
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
569 bytes
|
Rev | Line | |
---|
[388] | 1 | #include "libm.h"
|
---|
| 2 |
|
---|
| 3 | #if FLT_EVAL_METHOD==2
|
---|
| 4 | #undef sqrt
|
---|
| 5 | #define sqrt sqrtl
|
---|
| 6 | #endif
|
---|
| 7 |
|
---|
| 8 | /* acosh(x) = log(x + sqrt(x*x-1)) */
|
---|
| 9 | double acosh(double x)
|
---|
| 10 | {
|
---|
| 11 | union {double f; uint64_t i;} u = {.f = x};
|
---|
| 12 | unsigned e = u.i >> 52 & 0x7ff;
|
---|
| 13 |
|
---|
| 14 | /* x < 1 domain error is handled in the called functions */
|
---|
| 15 |
|
---|
| 16 | if (e < 0x3ff + 1)
|
---|
| 17 | /* |x| < 2, up to 2ulp error in [1,1.125] */
|
---|
| 18 | return log1p(x-1 + sqrt((x-1)*(x-1)+2*(x-1)));
|
---|
| 19 | if (e < 0x3ff + 26)
|
---|
| 20 | /* |x| < 0x1p26 */
|
---|
| 21 | return log(2*x - 1/(x+sqrt(x*x-1)));
|
---|
| 22 | /* |x| >= 0x1p26 or nan */
|
---|
| 23 | return log(x) + 0.693147180559945309417232121458176568;
|
---|
| 24 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.