log.md (1294B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function log 4 5 Calculate the logarithm of a value. 6 7 For matrices, the function is evaluated element wise. 8 9 10 ## Syntax 11 12 ```js 13 math.log(x) 14 math.log(x, base) 15 ``` 16 17 ### Parameters 18 19 Parameter | Type | Description 20 --------- | ---- | ----------- 21 `x` | number | BigNumber | Complex | Array | Matrix | Value for which to calculate the logarithm. 22 `base` | number | BigNumber | Complex | Optional base for the logarithm. If not provided, the natural logarithm of `x` is calculated. Default value: e. 23 24 ### Returns 25 26 Type | Description 27 ---- | ----------- 28 number | BigNumber | Complex | Array | Matrix | Returns the logarithm of `x` 29 30 31 ### Throws 32 33 Type | Description 34 ---- | ----------- 35 36 37 ## Examples 38 39 ```js 40 math.log(3.5) // returns 1.252762968495368 41 math.exp(math.log(2.4)) // returns 2.4 42 43 math.pow(10, 4) // returns 10000 44 math.log(10000, 10) // returns 4 45 math.log(10000) / math.log(10) // returns 4 46 47 math.log(1024, 2) // returns 10 48 math.pow(2, 10) // returns 1024 49 ``` 50 51 52 ## See also 53 54 [exp](exp.md), 55 [log2](log2.md), 56 [log10](log10.md), 57 [log1p](log1p.md)