math log

For math.

Returns the logarithm for an arbitrary base.

Command Type

built-in

Signature

> math log {flags} (base) ...rest

Parameters

  • base: Base for which the logarithm should be computed.
  • ...rest: The cell-paths/columns to operate on.

Input/output types:

input output
number float
list<number> list<float>
range list<number>
record record

Examples

Get the logarithm of 100 to the base 10.

> 100 | math log 10
2.0

Get the log2 of a list of values.

> [16 8 4] | math log 2
╭───┬──────╮
│ 0 │ 4.00 │
│ 1 │ 3.00 │
│ 2 │ 2.00 │
╰───┴──────╯

Compute the log base 10 of list-valued columns in a record.

> {alice: [1 10 100], bob: [1000 10000]} | math log 10
╭───────┬──────────────╮
│       │ ╭───┬──────╮ │
│ alice │ │ 0 │ 0.00 │ │
│       │ │ 1 │ 1.00 │ │
│       │ │ 2 │ 2.00 │ │
│       │ ╰───┴──────╯ │
│       │ ╭───┬──────╮ │
│ bob   │ │ 0 │ 3.00 │ │
│       │ │ 1 │ 4.00 │ │
│       │ ╰───┴──────╯ │
╰───────┴──────────────╯

Compute the log base 10 of a single column using a cell path.

> {alice: [1 10 100], bob: [1000 10000]} | math log 10 alice
╭───────┬───────────────╮
│       │ ╭───┬──────╮  │
│ alice │ │ 0 │ 0.00 │  │
│       │ │ 1 │ 1.00 │  │
│       │ │ 2 │ 2.00 │  │
│       │ ╰───┴──────╯  │
│       │ ╭───┬───────╮ │
│ bob   │ │ 0 │  1000 │ │
│       │ │ 1 │ 10000 │ │
│       │ ╰───┴───────╯ │
╰───────┴───────────────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.