> Hi, please consider the following changes:
>
> This is a port of FDLIBM acosh method.
>
> Original C vs transliteration port:
>
>
> $ diff -w fdlib_acosh.c.txt Acosh.translit.java
> 1c1,3
> < /* __ieee754_acosh(x)
> ---
>> /**
>> * Return the Inverse Hyperbolic Cosine of x
>> *
> 7,8c9,10
> < * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
> < * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
> ---
>> * := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else
>> * := log1p(t+sqrt(2.0*t+t*t)); where t=x-1.
> 14,31c16,19
> <
> < #include "fdlibm.h"
> <
> < #ifdef __STDC__
> < static const double
> < #else
> < static double
> < #endif
> < one = 1.0,
> < ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
> <
> < #ifdef __STDC__
> < double __ieee754_acosh(double x)
> < #else
> < double __ieee754_acosh(x)
> < double x;
> < #endif
> < {
> ---
>> private static final class Acosh {
>> private static final double one = 1.0;
>> private static final double ln2 = 6.93147180559945286227e-01;
>> static double compute(double x) {
> 41c29
> < return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */
> ---
>> return log(x)+ln2; /* acosh(huge)=log(2x) */
> 46c34
> < return __ieee754_log(2.0*x-one/(x+sqrt(t-one)));
> ---
>> return log(2.0*x-one/(x+sqrt(t-one)));
> 49a38
>> }
>
>
>
> Transliteration vs more idiomatic port:
>
> $ diff -w Acosh.translit.java Acosh.fdlibm.java
> 5,7c5,9
> < * Based on
> < * acosh(x) = log [ x + sqrt(x*x-1) ]
> < * we have
> ---
>> *
>> *
>> * acosh(x) is defined so that acosh(cosh(alpha)) = alpha, -INF < alpha
>> < < INF
>> * and cosh(acosh(x)) = x, 1 <= x < INF.
>> * It can be written as acosh(x) = ln(x + sqrt(x^2 - 1)), 1 <= x < INF.
> 11a14,15
>> *
>> *
> 16,17c20
> < private static final class Acosh {
> < private static final double one = 1.0;
> ---
>> static final class Acosh {
> 18a22
>>
> 23c27
> < if(hx<0x3ff00000) { /* x < 1 */
> ---
>> if(hx < 0x3ff00000) { // x < 1 */
> 25,26c29,30
> < } else if(hx >=0x41b00000) { /* x > 2**28 */
> < if(hx >=0x7ff00000) { /* x is inf of NaN */
> ---
>> } else if (hx >= 0x41b00000) { // x > 2**28
>> if(hx >= 0x7ff00000) { // x is
>> inf of NaN
> 28,29c32,34
> < } else
> < return log(x)+ln2; /* acosh(huge)=log(2x)
> *...
Anton Artemov has updated the pull request with a new target base due to a
merge or a rebase. The pull request now contains 11 commits:
- 8376665: Resolved merge conflicts.
- 8376665: Fixed definition of inverse cosh.
- 8376665: Fixed range, added special test case.
- 8376665: Fixed whitespaces.
- 8376665: Fixed whitespaces.
- 8376665: Ported fdlibm acosh function. Added tests.
- Merge remote-tracking branch 'origin/master' into
JDK-8375285-port-fdlibm-asinh-to-java
- 8375285: Added versions.
- 8375285: Addressed the reviewer's comments, fixed year in the copyright
notice.
- 8375285: Addressed the reviewer's comments.
- ... and 1 more: https://git.openjdk.org/jdk/compare/56afb460...32e51c37
-------------
Changes: https://git.openjdk.org/jdk/pull/29488/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29488&range=03
Stats: 582 lines in 7 files changed: 573 ins; 0 del; 9 mod
Patch: https://git.openjdk.org/jdk/pull/29488.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29488/head:pull/29488
PR: https://git.openjdk.org/jdk/pull/29488