Skip to content

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

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

  1. 4.0
See also .exp .frexp .erfc .gamma also in 4.0