Calculates the rounded positive square root of a double field.

Note

Math functions on ARM architecture may return different results in very high-precision calculationsc compared to Intel/AMD architectures.

ParameterTypeRequiredDefault ValueDescription
asstringoptional[a] _sqrt The name of the output field.
field[b]stringrequired   The name of the input field.

[a] Optional parameters use their default value unless explicitly set.

[b] The parameter name field can be omitted.

Hide omitted argument names for this function

Show omitted argument names for this function

math:sqrt() Examples

Click + next to an example below to get the full details.

Calculate Rounded Square Root Values

Find and round square roots using the math:sqrt() function

Query
logscale
myvalue := 100
        | math:sqrt(myvalue, as=square_root)
Introduction

In this example, the math:sqrt() function is used to calculate the square root of an assigned value. The input must be a numeric field that can contain decimal values (floating-point numbers).

Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    myvalue := 100

    Assigns the value 100 to a field named myvalue. This creates a new field with a constant value that will be used for the square root calculation.

  3. logscale
    | math:sqrt(myvalue, as=square_root)

    Takes the square root of the value in the myvalue field and returns the result in a new field named square_root. The function automatically rounds the result to the nearest integer. In this case, it calculates the square root of 100, which is 10.

    Note that - if not returning an exact integer, the function rounds the result to the nearest integer in case of non-perfect squares. For example:

    Square root of 90 = 9.487 rounds to 9.

    Square root of 91 = 9.539 rounds to 10.

  4. Event Result set.

Summary and Results

The query is used to calculate the square root of an assigned constant value, demonstrating how to combine value assignment with mathematical functions.

This query is useful, for example, to perform calculations on fixed values or to add reference calculations to existing event data.

Sample output from the incoming example data:

square_root
10