docs-v2/content/flux/v0/stdlib/math/log1p.md

3.6 KiB

title description menu weight
math.log1p() function `math.log1p()` returns the natural logarithm of 1 plus `x`. This operation is more accurate than `math.log(x: 1 + x)` when `x` is near zero.
flux_v0_ref
name parent identifier
math.log1p math math/log1p
101

math.log1p() returns the natural logarithm of 1 plus x. This operation is more accurate than math.log(x: 1 + x) when x is near zero.

Function type signature
(x: float) => float

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

x

({{< req >}}) Value to operate on.

Examples

Return the natural logarithm of values near zero

import "math"

math.log1p(x: 0.56)// 0.44468582126144574


Use math.log1p in map

import "math"

data
    |> map(fn: (r) => ({r with _value: math.log1p(x: r._value)}))

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time *tag _value
2021-01-01T00:00:00Z t1 -0.021800000000000003
2021-01-01T00:00:10Z t1 0.1092
2021-01-01T00:00:20Z t1 0.0735
2021-01-01T00:00:30Z t1 0.1753
2021-01-01T00:00:40Z t1 0.15230000000000002
2021-01-01T00:00:50Z t1 0.0443
_time *tag _value
2021-01-01T00:00:00Z t2 0.1985
2021-01-01T00:00:10Z t2 0.0497
2021-01-01T00:00:20Z t2 -0.0375
2021-01-01T00:00:30Z t2 0.1977
2021-01-01T00:00:40Z t2 0.1386
2021-01-01T00:00:50Z t2 0.018600000000000002

Output data

_time _value *tag
2021-01-01T00:00:00Z -0.02204113087688024 t1
2021-01-01T00:00:10Z 0.10363903475948592 t1
2021-01-01T00:00:20Z 0.07092433833669866 t1
2021-01-01T00:00:30Z 0.1615234341566714 t1
2021-01-01T00:00:40Z 0.14175994503783176 t1
2021-01-01T00:00:50Z 0.04334680450336586 t1
_time _value *tag
2021-01-01T00:00:00Z 0.181070774892302 t2
2021-01-01T00:00:10Z 0.048504409059614985 t2
2021-01-01T00:00:20Z -0.03822121282019776 t2
2021-01-01T00:00:30Z 0.18040305097132403 t2
2021-01-01T00:00:40Z 0.12979943753484446 t2
2021-01-01T00:00:50Z 0.018429135468367195 t2

{{% /expand %}} {{< /expand-wrapper >}}