MathUtil

object MathUtil

Math static utility methods.

Functions

Link copied to clipboard

Calculates inverse hyperbolic cosine of a double value.

Link copied to clipboard

Calculates inverse hyperbolic sine of a double value.

Link copied to clipboard

Calculates inverse hyperbolic tangent of a double value.

Link copied to clipboard
fun gcd(a: Long, b: Long): Long

Return the greatest common divisor of a and b, consistently with BigInteger.gcd.

Link copied to clipboard
fun log(base: Double, x: Double): Double

Calculates logarithm in a given base with doubles.

fun log(x: Int, base: Int): Int

fun log(x: Long, base: Int): Int

Returns x <= 0 ? 0 : Math.floor(Math.log(x) / Math.log(base))

Link copied to clipboard

Return a relative error bound for a sum of numValues positive doubles, computed using recursive summation, ie. sum = x1 + ... + xn. NOTE: This only works if all values are POSITIVE so that Σ |xi| == |Σ xi|. This uses formula 3.5 from Higham, Nicholas J. (1993), "The accuracy of floating point summation", SIAM Journal on Scientific Computing.

Link copied to clipboard
fun sumUpperBound(sum: Double, numValues: Int): Double

Return the maximum possible sum across numValues non-negative doubles, assuming one sum yielded sum.