Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method · added in Ruby 4.0
Math.expm1
(::Math::double x) -> ::Float
Math.expm1(x) → float
math.c
View on GitHub ↗
static VALUE
math_expm1(VALUE unused_obj, VALUE x)
{
return DBL2NUM(expm1(Get_Double(x)));
}
Returns “exp(x) - 1”, e raised to the x power, minus 1.
-
Domain:
[-INFINITY, INFINITY]. -
Range:
[-1.0, INFINITY].
Examples:
Example
expm1(-INFINITY) # => -1.0 expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1 expm1(0.0) # => 0.0 expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1 expm1(1.0) # => 1.7182818284590453 # E - 1 expm1(2.0) # => 6.38905609893065 # E**2 - 1 expm1(INFINITY) # => Infinity
Ruby version changes
-
4.0
-
Math.log1pandMath.expm1are added. [Feature #21527]
-