[444] | 1 | |
---|
| 2 | /* @(#)w_acosh.c 5.1 93/09/24 */ |
---|
| 3 | /* |
---|
| 4 | * ==================================================== |
---|
| 5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
---|
| 6 | * |
---|
| 7 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
---|
| 8 | * Permission to use, copy, modify, and distribute this |
---|
| 9 | * software is freely granted, provided that this notice |
---|
| 10 | * is preserved. |
---|
| 11 | * ==================================================== |
---|
| 12 | * |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | /* |
---|
| 16 | FUNCTION |
---|
| 17 | <<acosh>>, <<acoshf>>---inverse hyperbolic cosine |
---|
| 18 | |
---|
| 19 | INDEX |
---|
| 20 | acosh |
---|
| 21 | INDEX |
---|
| 22 | acoshf |
---|
| 23 | |
---|
| 24 | SYNOPSIS |
---|
| 25 | #include <math.h> |
---|
| 26 | double acosh(double <[x]>); |
---|
| 27 | float acoshf(float <[x]>); |
---|
| 28 | |
---|
| 29 | DESCRIPTION |
---|
| 30 | <<acosh>> calculates the inverse hyperbolic cosine of <[x]>. |
---|
| 31 | <<acosh>> is defined as |
---|
| 32 | @ifnottex |
---|
| 33 | . log(<[x]> + sqrt(<[x]>*<[x]>-1)) |
---|
| 34 | @end ifnottex |
---|
| 35 | @tex |
---|
| 36 | $$ln\Bigl(x + \sqrt{x^2-1}\Bigr)$$ |
---|
| 37 | @end tex |
---|
| 38 | |
---|
| 39 | <[x]> must be a number greater than or equal to 1. |
---|
| 40 | |
---|
| 41 | <<acoshf>> is identical, other than taking and returning floats. |
---|
| 42 | |
---|
| 43 | RETURNS |
---|
| 44 | <<acosh>> and <<acoshf>> return the calculated value. If <[x]> |
---|
| 45 | less than 1, the return value is NaN and <<errno>> is set to <<EDOM>>. |
---|
| 46 | |
---|
| 47 | You can change the error-handling behavior with the non-ANSI |
---|
| 48 | <<matherr>> function. |
---|
| 49 | |
---|
| 50 | PORTABILITY |
---|
| 51 | Neither <<acosh>> nor <<acoshf>> are ANSI C. They are not recommended |
---|
| 52 | for portable programs. |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | QUICKREF |
---|
| 56 | ansi svid posix rentrant |
---|
| 57 | acos n,n,n,m |
---|
| 58 | acosf n,n,n,m |
---|
| 59 | |
---|
| 60 | MATHREF |
---|
| 61 | acosh, NAN, arg,DOMAIN,EDOM |
---|
| 62 | acosh, < 1.0, NAN,DOMAIN,EDOM |
---|
| 63 | acosh, >=1.0, acosh(arg),,, |
---|
| 64 | |
---|
| 65 | MATHREF |
---|
| 66 | acoshf, NAN, arg,DOMAIN,EDOM |
---|
| 67 | acoshf, < 1.0, NAN,DOMAIN,EDOM |
---|
| 68 | acoshf, >=1.0, acosh(arg),,, |
---|
| 69 | |
---|
| 70 | */ |
---|
| 71 | |
---|
| 72 | /* |
---|
| 73 | * wrapper acosh(x) |
---|
| 74 | */ |
---|
| 75 | |
---|
| 76 | #include "fdlibm.h" |
---|
| 77 | #include <errno.h> |
---|
| 78 | |
---|
| 79 | #ifndef _DOUBLE_IS_32BITS |
---|
| 80 | |
---|
| 81 | #ifdef __STDC__ |
---|
| 82 | double acosh(double x) /* wrapper acosh */ |
---|
| 83 | #else |
---|
| 84 | double acosh(x) /* wrapper acosh */ |
---|
| 85 | double x; |
---|
| 86 | #endif |
---|
| 87 | { |
---|
| 88 | #ifdef _IEEE_LIBM |
---|
| 89 | return __ieee754_acosh(x); |
---|
| 90 | #else |
---|
| 91 | double z; |
---|
| 92 | struct exception exc; |
---|
| 93 | z = __ieee754_acosh(x); |
---|
| 94 | if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
---|
| 95 | if(x<1.0) { |
---|
| 96 | /* acosh(x<1) */ |
---|
| 97 | exc.type = DOMAIN; |
---|
| 98 | exc.name = "acosh"; |
---|
| 99 | exc.err = 0; |
---|
| 100 | exc.arg1 = exc.arg2 = x; |
---|
| 101 | exc.retval = 0.0/0.0; |
---|
| 102 | if (_LIB_VERSION == _POSIX_) |
---|
| 103 | errno = EDOM; |
---|
| 104 | else if (!matherr(&exc)) { |
---|
| 105 | errno = EDOM; |
---|
| 106 | } |
---|
| 107 | if (exc.err != 0) |
---|
| 108 | errno = exc.err; |
---|
| 109 | return exc.retval; |
---|
| 110 | } else |
---|
| 111 | return z; |
---|
| 112 | #endif |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|