Back to Influxdb

math.hypot() function

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

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

math.hypot() returns the square root of p*p + q*q, taking care to avoid overflow and underflow.

Function type signature
js
(p: float, q: float) => float

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

Parameters

p

({{< req >}}) p-value to use in the operation.

q

({{< req >}}) q-value to use in the operation.

Examples

Return the hypotenuse of two values

js
import "math"

math.hypot(p: 2.0, q: 5.0)// 5.385164807134505


Use math.hypot in map

js
import "math"

data
    |> map(fn: (r) => ({r with _value: math.hypot(p: r.a, q: r.b)}))

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

Input data

triangleab
t112.311.7
t2109.623.3
t38.234.2
t433.928
t52525

Output data

_valueabtriangle
16.97586522095412712.311.7t1
112.04931949815669109.623.3t2
35.169304798360748.234.2t3
43.968284023827933.928t4
35.355339059327382525t5

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