Back to Influxdb

math.expm1() function

content/flux/v0/stdlib/math/expm1.md

latest3.4 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/math/math.flux#L827-L827 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

math.expm1() returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than math.exp(x:x) - 1 when x is near zero.

Function type signature
js
(x: float) => float

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

Parameters

x

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

Examples

Get more accurate base-e exponentials for values near zero

js
import "math"

math.expm1(x: 0.022)// 0.022243784470438233


Use math.expm1 in map

js
import "math"

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

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

Input data

_time*tag_value
2021-01-01T00:00:00Zt1-0.021800000000000003
2021-01-01T00:00:10Zt10.1092
2021-01-01T00:00:20Zt10.0735
2021-01-01T00:00:30Zt10.1753
2021-01-01T00:00:40Zt10.15230000000000002
2021-01-01T00:00:50Zt10.0443
_time*tag_value
2021-01-01T00:00:00Zt20.1985
2021-01-01T00:00:10Zt20.0497
2021-01-01T00:00:20Zt2-0.0375
2021-01-01T00:00:30Zt20.1977
2021-01-01T00:00:40Zt20.1386
2021-01-01T00:00:50Zt20.018600000000000002

Output data

_time_value*tag
2021-01-01T00:00:00Z-0.02156409733567063t1
2021-01-01T00:00:10Z0.11538540511625006t1
2021-01-01T00:00:20Z0.07626853667189179t1
2021-01-01T00:00:30Z0.1916036440887826t1
2021-01-01T00:00:40Z0.16450953689549175t1
2021-01-01T00:00:50Z0.045295896623819054t1
_time_value*tag
2021-01-01T00:00:00Z0.21957202741425103t2
2021-01-01T00:00:10Z0.05095576234958021t2
2021-01-01T00:00:20Z-0.03680558227917823t2
2021-01-01T00:00:30Z0.21859675995131905t2
2021-01-01T00:00:40Z0.14866454228127554t2
2021-01-01T00:00:50Z0.018774057481622756t2

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