Your Search Results

    Math.log1p()

    This is an experimental technology, part of the Harmony (ECMAScript 6) proposal.
    Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.

    Summary

    The Math.log1p() function returns the natural logarithm (base e) of 1 + a number, that is

    x>-1,Math.log1p(x)=ln(1+x)\forall x > -1, \mathtt{\operatorname{Math.log1p}(x)} = \ln(1 + x)

    Syntax

    Math.log1p(x)

    Parameters

    x
    A number.

    Description

    If the value of number is less than -1, the return value is always NaN.

    Because log1p is a static method of Math, you always use it as Math.log1p(), rather than as a method of a Math object you created (Math is not a constructor).

    Examples

    Example: Using Math.log1p

    Math.log1p(1)  // 0.6931471805599453
    Math.log1p(0)  // 0
    Math.log1p(-1) // -Infinity
    Math.log1p(-2) // NaN
    

    Polyfill

    function log1p(x) {
      return Math.log(1 + x);
    }
    

    Specifications

    Specification Status Comment
    ECMAScript 6 (ECMA-262)
    The definition of 'Math.log1p' in that specification.
    Draft Initial definition.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support Not supported 25 (25) Not supported Not supported Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported Not supported 25.0 (25) Not supported Not supported Not supported

    See also

    • The Math object it belongs to.

    Document Tags and Contributors

    Contributors to this page: fred.wang, fscholz
    Last updated by: fred.wang,