Back to Influxdb

math.pow() function

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

latest2.3 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#L1796-L1796 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

math.pow() returns x**y, the base-x exponential of y.

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

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

Parameters

x

({{< req >}}) Base value to operate on.

y

({{< req >}}) Exponent value.

Examples

Return the base-x exponential of a value

js
import "math"

math.pow(x: 2.0, y: 3.0)// 8.0


Use math.pow in map

js
import "math"

data
    |> map(fn: (r) => ({_time: r._time, _value: math.pow(x: r.t1, y: r.t2)}))

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

Input data

_timet1t2
2021-01-01T00:00:00Z-2.1819.85
2021-01-01T00:00:10Z10.924.97
2021-01-01T00:00:20Z7.35-3.75
2021-01-01T00:00:30Z17.5319.77
2021-01-01T00:00:40Z15.2313.86
2021-01-01T00:00:50Z4.431.86

Output data

_time_value
2021-01-01T00:00:00ZNaN
2021-01-01T00:00:10Z144532.83209763622
2021-01-01T00:00:20Z0.0005641862251143407
2021-01-01T00:00:30Z3886587782891166000000000
2021-01-01T00:00:40Z24672926229934220
2021-01-01T00:00:50Z15.933490684011332

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