mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
51 lines (31 loc) • 1.27 kB
Markdown
# Function log
Calculate the logarithm of a value.
For matrices, the function is evaluated element wise.
## Syntax
```js
math.log(x)
math.log(x, base)
```
### Parameters
Parameter | Type | Description
--------- | ---- | -----------
`x` | Number | BigNumber | Boolean | Complex | Array | Matrix | null | Value for which to calculate the logarithm.
`base` | Number | BigNumber | Boolean | Complex | null | Optional base for the logarithm. If not provided, the natural logarithm of `x` is calculated. Default value: e.
### Returns
Type | Description
---- | -----------
Number | BigNumber | Complex | Array | Matrix | Returns the logarithm of `x`
## Examples
```js
math.log(3.5); // returns 1.252762968495368
math.exp(math.log(2.4)); // returns 2.4
math.pow(10, 4); // returns 10000
math.log(10000, 10); // returns 4
math.log(10000) / math.log(10); // returns 4
math.log(1024, 2); // returns 10
math.pow(2, 10); // returns 1024
```
## See also
[exp](exp.md),
[log10](log10.md)
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->