2.4 KiB
2.4 KiB
| title | description | menu | weight | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| math.hypot() function | `math.hypot()` returns the square root of `p*p + q*q`, taking care to avoid overflow and underflow. |
|
101 |
math.hypot() returns the square root of p*p + q*q, taking care to avoid overflow
and underflow.
Function type signature
(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
import "math"
math.hypot(p: 2.0, q: 5.0)// 5.385164807134505
Use math.hypot in map
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
| triangle | a | b |
|---|---|---|
| t1 | 12.3 | 11.7 |
| t2 | 109.6 | 23.3 |
| t3 | 8.2 | 34.2 |
| t4 | 33.9 | 28 |
| t5 | 25 | 25 |
Output data
| _value | a | b | triangle |
|---|---|---|---|
| 16.975865220954127 | 12.3 | 11.7 | t1 |
| 112.04931949815669 | 109.6 | 23.3 | t2 |
| 35.16930479836074 | 8.2 | 34.2 | t3 |
| 43.9682840238279 | 33.9 | 28 | t4 |
| 35.35533905932738 | 25 | 25 | t5 |
{{% /expand %}} {{< /expand-wrapper >}}