8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a76291 commit 3af3753Copy full SHA for 3af3753
numpy/core/src/npymath/npy_math.c.src
@@ -221,7 +221,20 @@ double npy_hypot(double x, double y)
221
#ifndef HAVE_ACOSH
222
double npy_acosh(double x)
223
{
224
- return 2*npy_log(npy_sqrt((x + 1.0)/2) + npy_sqrt((x - 1.0)/2));
+ if (x < 1.0) {
225
+ return NPY_NAN;
226
+ }
227
+
228
+ if (npy_isfinite(x)) {
229
+ if (x > 1e8) {
230
+ return npy_log(x) + NPY_LOGE2;
231
232
+ else {
233
+ double u = x - 1.0;
234
+ return npy_log1p(u + npy_sqrt(2*u + u*u));
235
236
237
+ return x;
238
}
239
#endif
240
0 commit comments