mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
63 lines
1.7 KiB
Markdown
63 lines
1.7 KiB
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
<h1 id="function-log">Function log <a href="#function-log" title="Permalink">#</a></h1>
|
|
|
|
Calculate the logarithm of a value.
|
|
|
|
To avoid confusion with the matrix logarithm, this function does not
|
|
apply to matrices.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.log(x)
|
|
math.log(x, base)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | number | BigNumber | Complex | Value for which to calculate the logarithm.
|
|
`base` | number | BigNumber | Complex | Optional base for the logarithm. If not provided, the natural logarithm of `x` is calculated. Default value: e.
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
number | BigNumber | Complex | Returns the logarithm of `x`
|
|
|
|
|
|
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```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
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[exp](exp.html),
|
|
[log2](log2.html),
|
|
[log10](log10.html),
|
|
[log1p](log1p.html)
|