> 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 incrementally with one additional
commit since the last revision:
8376665: Fixed definition of inverse cosh.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/29488/files
- new: https://git.openjdk.org/jdk/pull/29488/files/44147eb7..fceec2f1
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=29488&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=29488&range=01-02
Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 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