8000 BUG: npy_acosh fallback too simple. by ewmoore · Pull Request #6976 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: npy_acosh fallback too simple. #6976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion numpy/core/src/npymath/npy_math.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,20 @@ double npy_hypot(double x, double y)
#ifndef HAVE_ACOSH
double npy_acosh(double x)
{
return 2*npy_log(npy_sqrt((x + 1.0)/2) + npy_sqrt((x - 1.0)/2));
if (x < 1.0) {
return NPY_NAN;
}

if (npy_isfinite(x)) {
if (x > 1e8) {
return npy_log(x) + NPY_LOGE2;
}
else {
double u = x - 1.0;
return npy_log1p(u + npy_sqrt(2*u + u*u));
}
}
return x;
}
#endif

Expand Down
0