[Chapter 21] Reference: Math.log()
Author: David Flanagan
Date: Fri Aug 29 11:17:48 1997

#

| Chapter 21 JavaScript Reference |

# Math.log() Function

## Name

Math.log() Function---compute a natural logarithm

## Availability

Navigator 2.0, Internet Explorer 3.0

## Synopsis

    Math.log(x)

### Arguments

`x`

  Any numeric value or expression greater than zero.

### Returns

The natural logarithm of `x`.

## Description

`Math.log()` computes logex, the natural logarithm of its argument. The argument must be greater than zero.

## Usage

You can compute the base-10 and base-2 logarithms of a number with the following formulas:

log10x = log10(e*logex)

log2x = log2(e*logex)

These formulas translate into the following JavaScript functions:

    function log10(x) { return Math.LOG10E * Math.log(x); }
    function log2(x) { return  Math.LOG2E * Math.log(x); }

## See Also

"Math", "Math.exp()", "Math.LOG2E", "Math.LOG10E"

Math.LN2 |  | Math.LOG10E