Summary
Add asinh() function to Math.java and StrictMath.java.
Problem
The IEEE 754 2019 standard recommends platform include various "additional mathematical operations" (section 9.2). The asinh (inverse hyperbolic sine) function if one of those.
Solution
Ported the asinh() function from fdlibm.
Specification
In both java.lang.Math and java.lang.StrictMath added:
/**
* Returns the inverse hyperbolic sine of a {@code double} value.
* The inverse hyperbolic sine of <i>x</i> is defined to be a function such that
* asinh({@linkplain Math#sinh sinh(<i>x</i>)}) = <i>x</i> for any <i>x</i>.
* Note that range of the exact asinh is not limited.
* <p>Special cases:
* <ul>
*
* <li>If the argument is zero, then the result is a zero with the
* same sign as the argument.
*
* <li>If the argument is positive infinity, then the result is
* positive infinity.
*
* <li>If the argument is negative infinity, then the result is
* negative infinity.
*
* <li>If the argument is NaN, then the result is NaN.
*
* <p>The computed result must be within 2.5 ulps of the exact result.
*
* </ul>
* @param x The number whose inverse hyperbolic sine is to be returned.
* @return The inverse hyperbolic sine of {@code x}.
* @since 27
*/
public static double asinh(double x) {
return StrictMath.asinh(x);
}
diff --git a/src/java.base/share/classes/java/lang/Math.java b/src/java.base/share/classes/java/lang/Math.java
index 55659bed57b..6270011b96d 100644
--- a/src/java.base/share/classes/java/lang/Math.java
+++ b/src/java.base/share/classes/java/lang/Math.java
@@ -108,8 +108,8 @@
* sin}, {@link cos cos}, {@link tan tan}, {@link asin asin}, {@link
* acos acos}, {@link atan atan}, {@link exp exp}, {@link expm1
* expm1}, {@link log log}, {@link log10 log10}, {@link log1p log1p},
- * {@link sinh sinh}, {@link cosh cosh}, {@link tanh tanh}, {@link
- * hypot hypot}, and {@link pow pow}. (The {@link sqrt sqrt}
+ * {@link sinh sinh}, {@link cosh cosh}, {@link tanh tanh}, {@link asinh asinh},
+ * {@link hypot hypot}, and {@link pow pow}. (The {@link sqrt sqrt}
* operation is a required part of IEEE 754 from a different section
* of the standard.) The special case behavior of the recommended
* operations generally follows the guidance of the IEEE 754
@@ -2758,6 +2758,36 @@ public static double tanh(double x) {
return StrictMath.tanh(x);
}
+ /**
+ * Returns the inverse hyperbolic sine of a {@code double} value.
+ * The inverse hyperbolic sine of <i>x</i> is defined to be a function such that
+ * asinh({@linkplain Math#sinh sinh(<i>x</i>)}) = <i>x</i> for any <i>x</i>.
+ * Note that range of the exact asinh is not limited.
+ * <p>Special cases:
+ * <ul>
+ *
+ * <li>If the argument is zero, then the result is a zero with the
+ * same sign as the argument.
+ *
+ * <li>If the argument is positive infinity, then the result is
+ * positive infinity.
+ *
+ * <li>If the argument is negative infinity, then the result is
+ * negative infinity.
+ *
+ * <li>If the argument is NaN, then the result is NaN.
+ *
+ * <p>The computed result must be within 2.5 ulps of the exact result.
+ *
+ * </ul>
+ * @param x The number whose inverse hyperbolic sine is to be returned.
+ * @return The inverse hyperbolic sine of {@code x}.
+ * @since 27
+ */
+ public static double asinh(double x) {
+ return StrictMath.asinh(x);
+ }
+
/**
* Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
* without intermediate overflow or underflow.
diff --git a/src/java.base/share/classes/java/lang/StrictMath.java b/src/java.base/share/classes/java/lang/StrictMath.java
index 499fce73aee..901b3295d5b 100644
--- a/src/java.base/share/classes/java/lang/StrictMath.java
+++ b/src/java.base/share/classes/java/lang/StrictMath.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,8 @@
* {@code exp}, {@code log}, {@code log10},
* {@code cbrt}, {@code atan2}, {@code pow},
* {@code sinh}, {@code cosh}, {@code tanh},
- * {@code hypot}, {@code expm1}, and {@code log1p}.
+ * {@code asinh}, {@code hypot}, {@code expm1},
+ * and {@code log1p}.
*
* <p>
* The platform uses signed two's complement integer arithmetic with
@@ -2170,6 +2171,34 @@ public static double tanh(double x) {
return FdLibm.Tanh.compute(x);
}
+ /**
+ * Returns the inverse hyperbolic sine of a {@code double} value.
+ * The inverse hyperbolic sine of <i>x</i> is defined to be a function such that
+ * asinh({@linkplain Math#sinh sinh(<i>x</i>)}) = <i>x</i> for any <i>x</i>.
+ * Note that range of the exact asinh is not limited.
+ * <p>Special cases:
+ * <ul>
+ *
+ * <li>If the argument is zero, then the result is a zero with the
+ * same sign as the argument.
+ *
+ * <li>If the argument is positive infinity, then the result is
+ * positive infinity
+ *
+ * <li>If the argument is negative infinity, then the result is
+ * negative infinity
+ *
+ * <li>If the argument is NaN, then the result is NaN.
+ *
+ * </ul>
+ * @param x The number whose inverse hyperbolic sine is to be returned.
+ * @return The inverse hyperbolic sine of {@code x}.
+ * @since 27
+ */
+ public static double asinh(double x) {
+ return FdLibm.Asinh.compute(x);
+ }
+
/**
* Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
* without intermediate overflow or underflow.
- csr of
-
JDK-8375285 Port fdlibm asinh to Java
-
- Open
-