LibM.exp_f64(1.0) Euler's number (e).
LibM.log_f64(10.0) LibM.log_f64(2.0) 3.14159265358979323846 Archimedes' constant (π).
6.283185307179586476925 The full circle constant (τ), equal to 2π.
Calculates the arc cosine of value.
Calculates the arc cosine of value.
Calculates the arc cosine of value.
Calculates the inverse hyperbolic cosine of value.
Calculates the inverse hyperbolic cosine of value.
Calculates the inverse hyperbolic cosine of value.
Calculates the arc sine of value.
Calculates the arc sine of value.
Calculates the arc sine of value.
Calculates the inverse hyperbolic sine of value.
Calculates the inverse hyperbolic sine of value.
Calculates the inverse hyperbolic sine of value.
Calculates the arc tangent of value.
Calculates the arc tangent of value.
Calculates the arc tangent of value.
Calculates the two-argument arc tangent of the ray from (0, 0) to (x, y).
Calculates the two-argument arc tangent of the ray from (0, 0) to (x, y).
Calculates the two-argument arc tangent of the ray from (0, 0) to (x, y).
Calculates the inverse hyperbolic tangent of value.
Calculates the inverse hyperbolic tangent of value.
Calculates the inverse hyperbolic tangent of value.
Calculates the cylindrical Bessel function of the first kind of value for the given order.
Calculates the cylindrical Bessel function of the first kind of value for the given order.
Calculates the cylindrical Bessel function of the first kind of value for the given order.
Calculates the cylindrical Bessel function of the first kind of value for order 0.
Calculates the cylindrical Bessel function of the first kind of value for order 0.
Calculates the cylindrical Bessel function of the first kind of value for order 0.
Calculates the cylindrical Bessel function of the first kind of value for order 1.
Calculates the cylindrical Bessel function of the first kind of value for order 1.
Calculates the cylindrical Bessel function of the first kind of value for order 1.
Calculates the cylindrical Bessel function of the second kind of value for the given order.
Calculates the cylindrical Bessel function of the second kind of value for the given order.
Calculates the cylindrical Bessel function of the second kind of value for the given order.
Calculates the cylindrical Bessel function of the second kind of value for order 0.
Calculates the cylindrical Bessel function of the second kind of value for order 0.
Calculates the cylindrical Bessel function of the second kind of value for order 0.
Calculates the cylindrical Bessel function of the second kind of value for order 1.
Calculates the cylindrical Bessel function of the second kind of value for order 1.
Calculates the cylindrical Bessel function of the second kind of value for order 1.
Calculates the cubic root of value.
Calculates the cubic root of value.
Calculates the cubic root of value.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Calculates the cosine of value, measured in radians.
Calculates the cosine of value, measured in radians.
Calculates the cosine of value, measured in radians.
Calculates the hyperbolic cosine of value.
Calculates the hyperbolic cosine of value.
Calculates the hyperbolic cosine of value.
Calculates the error function of value.
Calculates the error function of value.
Calculates the error function of value.
Calculates 1 minus the error function of value.
Calculates 1 minus the error function of value.
Calculates 1 minus the error function of value.
Calculates the exponential of value.
Calculates the exponential of value.
Calculates the exponential of value.
Calculates the exponential of value.
Calculates 2 raised to the power value.
Calculates 2 raised to the power value.
Calculates 2 raised to the power value.
Calculates the exponential of value, minus 1.
Calculates the exponential of value, minus 1.
Calculates the exponential of value, minus 1.
Fused multiply-add; returns value1 * value2 + value3, performing a single rounding instead of two.
Fused multiply-add; returns value1 * value2 + value3, performing a single rounding instead of two.
Fused multiply-add; returns value1 * value2 + value3, performing a single rounding instead of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Calculates the gamma function of value.
Calculates the gamma function of value.
Calculates the gamma function of value.
Calculates the length of the hypotenuse from (0, 0) to (value1, value2).
Calculates the length of the hypotenuse from (0, 0) to (value1, value2).
Calculates the length of the hypotenuse from (0, 0) to (value1, value2).
Returns the unbiased base 2 exponent of the given floating-point value.
Returns the unbiased base 2 exponent of the given floating-point value.
Returns the unbiased base 2 exponent of the given floating-point value.
Returns the unbiased base 2 exponent of the given floating-point value.
Calculates the integer square root of value.
Calculates the integer square root of value.
Multiplies the given floating-point value by 2 raised to the power exp.
Multiplies the given floating-point value by 2 raised to the power exp.
Multiplies the given floating-point value by 2 raised to the power exp.
Multiplies the given floating-point value by 2 raised to the power exp.
Calculates the logarithmic gamma of value.
Calculates the logarithmic gamma of value.
Calculates the logarithmic gamma of value.
Calculates the logarithm of value to the given base.
Calculates the natural logarithm of value.
Calculates the natural logarithm of value.
Calculates the natural logarithm of value.
Calculates the natural logarithm of value.
Calculates the logarithm of value to base 10.
Calculates the logarithm of value to base 10.
Calculates the logarithm of value to base 10.
Calculates the logarithm of value to base 10.
Calculates the natural logarithm of 1 plus value.
Calculates the natural logarithm of 1 plus value.
Calculates the natural logarithm of 1 plus value.
Calculates the logarithm of value to base 2.
Calculates the logarithm of value to base 2.
Calculates the logarithm of value to base 2.
Calculates the logarithm of value to base 2.
Returns the unbiased radix-independent exponent of the given floating-point value.
Returns the unbiased radix-independent exponent of the given floating-point value.
Returns the unbiased radix-independent exponent of the given floating-point value.
Returns the unbiased radix-independent exponent of the given floating-point value.
Returns the greater of value1 and value2.
Returns the greater of value1 and value2.
Returns the greater of value1 and value2.
Returns the smaller of value1 and value2.
Returns the smaller of value1 and value2.
Returns the smaller of value1 and value2.
Computes the smallest nonnegative power of 2 that is greater than or equal to v.
Computes the smallest nonnegative power of 2 that is greater than or equal to v.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Returns the floating-point value with its exponent raised by exp.
Calculates the sine of value, measured in radians.
Calculates the sine of value, measured in radians.
Calculates the sine of value, measured in radians.
Calculates the hyperbolic sine of value.
Calculates the hyperbolic sine of value.
Calculates the hyperbolic sine of value.
Calculates the square root of value.
Calculates the square root of value.
Calculates the square root of value.
Calculates the square root of value.
Calculates the square root of value.
Calculates the square root of value.
Calculates the square root of value.
Calculates the tangent of value, measured in radians.
Calculates the tangent of value, measured in radians.
Calculates the tangent of value, measured in radians.
Calculates the hyperbolic tangent of value.
Calculates the hyperbolic tangent of value.
Calculates the hyperbolic tangent of value.
Calculates the arc cosine of value.
Calculates the inverse hyperbolic cosine of value.
Calculates the arc sine of value.
Calculates the inverse hyperbolic sine of value.
Calculates the arc tangent of value.
Calculates the two-argument arc tangent of the ray from (0, 0) to (x, y).
Calculates the two-argument arc tangent of the ray from (0, 0) to (x, y).
Calculates the two-argument arc tangent of the ray from (0, 0) to (x, y).
Calculates the inverse hyperbolic tangent of value.
Calculates the cylindrical Bessel function of the first kind of value for the given order.
Calculates the cylindrical Bessel function of the first kind of value for the given order.
Calculates the cylindrical Bessel function of the first kind of value for the given order.
Calculates the cylindrical Bessel function of the first kind of value for order 0.
Calculates the cylindrical Bessel function of the first kind of value for order 0.
Calculates the cylindrical Bessel function of the first kind of value for order 0.
Calculates the cylindrical Bessel function of the first kind of value for order 1.
Calculates the cylindrical Bessel function of the first kind of value for order 1.
Calculates the cylindrical Bessel function of the first kind of value for order 1.
Calculates the cylindrical Bessel function of the second kind of value for the given order.
Calculates the cylindrical Bessel function of the second kind of value for the given order.
Calculates the cylindrical Bessel function of the second kind of value for the given order.
Calculates the cylindrical Bessel function of the second kind of value for order 0.
Calculates the cylindrical Bessel function of the second kind of value for order 0.
Calculates the cylindrical Bessel function of the second kind of value for order 0.
Calculates the cylindrical Bessel function of the second kind of value for order 1.
Calculates the cylindrical Bessel function of the second kind of value for order 1.
Calculates the cylindrical Bessel function of the second kind of value for order 1.
Calculates the cubic root of value.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
BigFloat does not support signed zeros; if value2 == 0, the returned value is non-negative.
Returns the floating-point value with the magnitude of value1 and the sign of value2.
Calculates the cosine of value, measured in radians.
Calculates the hyperbolic cosine of value.
Calculates the error function of value.
Calculates 1 minus the error function of value.
Calculates the exponential of value.
require "complex" Math.exp(4 + 2.i) # => -22.720847417619233 + 49.645957334580565.i
Calculates the exponential of value.
Calculates 2 raised to the power value.
Calculates the exponential of value, minus 1.
Fused multiply-add; returns value1 * value2 + value3, performing a single rounding instead of two.
Math.fma(0.1, 10.0, -1.0) # => 5.551115123125783e-17 1.0 * 10.0 - 1.0 # => 0.0
Fused multiply-add; returns value1 * value2 + value3, performing a single rounding instead of two.
Math.fma(0.1, 10.0, -1.0) # => 5.551115123125783e-17 1.0 * 10.0 - 1.0 # => 0.0
Fused multiply-add; returns value1 * value2 + value3, performing a single rounding instead of two.
Math.fma(0.1, 10.0, -1.0) # => 5.551115123125783e-17 1.0 * 10.0 - 1.0 # => 0.0
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Decomposes the given floating-point value into a normalized fraction and an integral power of two.
Calculates the length of the hypotenuse from (0, 0) to (value1, value2).
Equivalent to
Math.sqrt(value1 ** 2 + value2 ** 2)
Calculates the length of the hypotenuse from (0, 0) to (value1, value2).
Equivalent to
Math.sqrt(value1 ** 2 + value2 ** 2)
Calculates the length of the hypotenuse from (0, 0) to (value1, value2).
Equivalent to
Math.sqrt(value1 ** 2 + value2 ** 2)
Returns the unbiased base 2 exponent of the given floating-point value.
Returns the unbiased base 2 exponent of the given floating-point value.
Returns the unbiased base 2 exponent of the given floating-point value.
Raises ArgumentError if value is zero.
Returns the unbiased base 2 exponent of the given floating-point value.
Calculates the integer square root of value.
Multiplies the given floating-point value by 2 raised to the power exp.
Multiplies the given floating-point value by 2 raised to the power exp.
Multiplies the given floating-point value by 2 raised to the power exp.
Multiplies the given floating-point value by 2 raised to the power exp.
Calculates the logarithmic gamma of value.
Math.lgamma(2.96)
is equivalent to
Math.log(Math.gamma(2.96).abs)
Calculates the logarithmic gamma of value.
Math.lgamma(2.96)
is equivalent to
Math.log(Math.gamma(2.96).abs)
Calculates the logarithmic gamma of value.
Math.lgamma(2.96)
is equivalent to
Math.log(Math.gamma(2.96).abs)
Calculates the logarithm of value to the given base.
Calculates the natural logarithm of value.
require "complex" Math.log(4 + 2.i) # => 1.4978661367769956 + 0.4636476090008061.i
Calculates the logarithm of value to base 10.
require "complex" Math.log10(4 + 2.i) # => 0.6505149978319906 + 0.20135959813668655.i
Calculates the logarithm of value to base 10.
Calculates the natural logarithm of 1 plus value.
Calculates the logarithm of value to base 2.
require "complex" Math.log2(4 + 2.i) # => 2.1609640474436813 + 0.6689021062254881.i
Returns the unbiased radix-independent exponent of the given floating-point value.
For BigFloat this is equivalent to #ilogb.
Raises ArgumentError is value is zero.
Returns the greater of value1 and value2.
Returns the greater of value1 and value2.
Returns the smaller of value1 and value2.
Returns the smaller of value1 and value2.
Computes the smallest nonnegative power of 2 that is greater than or equal to v.
The returned value has the same type as the argument. Raises OverflowError if the result does not fit into the argument's type.
Math.pw2ceil(33) # => 64 Math.pw2ceil(64) # => 64 Math.pw2ceil(-5) # => 1
Computes the smallest nonnegative power of 2 that is greater than or equal to v.
The returned value has the same type as the argument.
Math.pw2ceil(33) # => 64 Math.pw2ceil(64) # => 64 Math.pw2ceil(-5) # => 1
Calculates the sine of value, measured in radians.
Calculates the hyperbolic sine of value.
Calculates the square root of value.
require "big" Math.sqrt(1_000_000_000_000.to_big_i * 1_000_000_000_000.to_big_i) # => 1000000000000.0
Calculates the square root of value.
require "big" Math.sqrt(1_000_000_000_000.to_big_f * 1_000_000_000_000.to_big_f) # => 1000000000000.0
Calculates the square root of value.
require "big" Math.sqrt(1_000_000_000_000.to_big_r * 1_000_000_000_000.to_big_r) # => 1000000000000.0
Calculates the square root of value. Inspired by the following blog post of Pavel Panchekha on floating point precision.
require "complex" Math.sqrt(4 + 2.i) # => 2.0581710272714924 + 0.48586827175664565.i
Although the imaginary number is defined as i = sqrt(-1), calling Math.sqrt with a negative number will return -NaN. To obtain the result in the complex plane, Math.sqrt must be called with a complex number.
Math.sqrt(-1.0) # => -NaN Math.sqrt(-1.0 + 0.0.i) # => 0.0 + 1.0.i
Calculates the tangent of value, measured in radians.
Calculates the hyperbolic tangent of value.
© 2012–2026 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.19.0/Math.html