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.log1p

(::Math::double x) -> ::Float
Math.log1p(x) → float

Returns “log(x + 1)”, the base E logarithm of (x + 1).

  • Domain: [-1, INFINITY].

  • Range: [-INFINITY, INFINITY].

Examples:

Example
log1p(-1.0)     # => -Infinity
log1p(0.0)      # => 0.0
log1p(E - 1)    # => 1.0
log1p(INFINITY) # => Infinity

Ruby version changes

  1. 4.0
See also .log10 .log2 .log .sin also in 4.0