Package com.oracle.truffle.api.utilities
Class MathUtils
java.lang.Object
com.oracle.truffle.api.utilities.MathUtils
This class contains mathematical methods that are not already provided by
Math
that are generally useful for language implementations.- Since:
- 24.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
acosh
(double x) Computes the inverse (area) hyperbolic cosine (acosh) of adouble
value.static double
asinh
(double x) Computes the inverse (area) hyperbolic sine (asinh) of adouble
value.static double
atanh
(double x) Computes the inverse (area) hyperbolic tangent (atanh) of adouble
value.
-
Method Details
-
asinh
public static double asinh(double x) Computes the inverse (area) hyperbolic sine (asinh) of adouble
value.asinh(x); derived from fdlibm (s_asinh.c) Method : Based on asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] we have asinh(x) := x if 1+x*x=1, := sign(x)*(log(x)+ln2)) for large |x|, else := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2)))
- Parameters:
x
- The number whose inverse hyperbolic sine is to be returned.- Returns:
- The inverse hyperbolic sine of
x
. - Since:
- 24.1
-
acosh
public static double acosh(double x) Computes the inverse (area) hyperbolic cosine (acosh) of adouble
value.__ieee754_acosh(x); derived from fdlibm (e_acosh.c) Method : Based on acosh(x) = log [ x + sqrt(x*x-1) ] we have acosh(x) := log(x)+ln2, if x is large; else 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. Special cases: acosh(x) is NaN with signal if x<1. acosh(NaN) is NaN without signal.
- Parameters:
x
- The number whose inverse hyperbolic cosine is to be returned.- Returns:
- The inverse hyperbolic cosine of
x
. - Since:
- 24.1
-
atanh
public static double atanh(double x) Computes the inverse (area) hyperbolic tangent (atanh) of adouble
value.__ieee754_atanh(x); derived from fdlibm (e_atanh.c) Method : 1.Reduced x to positive by atanh(-x) = -atanh(x) 2.For x>=0.5 1 2x x atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) 2 1 - x 1 - x For x<0.5 atanh(x) = 0.5*log1p(2x+2x*x/(1-x)) Special cases: atanh(x) is NaN if |x| > 1 with signal; atanh(NaN) is that NaN with no signal; atanh(+-1) is +-INF with signal.
- Parameters:
x
- The number whose inverse hyperbolic tangent is to be returned.- Returns:
- The inverse hyperbolic tangent of
x
. - Since:
- 24.1
-