Calculates the field value to the exponent power, that is,
fieldexponent
.
It supports decimal values.
Note
Math functions on ARM architecture may return different results in very high-precision calculationsc compared to Intel/AMD architectures.
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
field
can be omitted; the following forms of this function are equivalent:logscale Syntaxmath:pow("value",exponent="value")
and:
logscale Syntaxmath:pow(field="value",exponent="value")
These examples show basic structure only.
math:pow()
Examples
Click
next to an example below to get the full details.Calculate Power of Values
Calculate values raised to a power using the
math:pow()
function
Query
x := 2
exp := 3
| math:pow(field=x, exponent=exp, as=result)
Introduction
In this example, the math:pow()
function is used to
calculate values raised to different powers
(xexp), demonstrating both integer and
decimal exponents.
Step-by-Step
Starting with the source repository events.
- logscale
x := 2 exp := 3
Assigns the value
2
to field x (the value to be raised to a power) and3
to field exp (the exponent). This will calculatex3
, which equals8
. - logscale
| math:pow(field=x, exponent=exp, as=result)
Raises the value in the field x to the power specified by the
exponent
parameter and returns the result in a field named result. If theas
parameter is not specified, the result is returned in a field named _pow as default. Event Result set.
Summary and Results
The query calculates the power of a number by raising it to a specified
exponent. The math:pow()
function supports both
integer and decimal values, making it versatile for various mathematical
calculations. For example, you can calculate squares
(x2), cubes (x3),
or roots (using fractional exponents like 0.5
for
square root).
This query is useful for exponential calculations, geometric computations, scientific notation conversions, and any scenario requiring power operations. The function handles positive and negative numbers, as well as decimal exponents.
Sample output from the incoming example data:
result |
---|
8.000000 |
The result shows that 2
raised to the power of
3
(2³
)
equals 8
, demonstrating the basic power operation.
The function can also handle more complex calculations like
2.5⁴
or
3⁻²
.