This topic describes the syntax and parameters of arithmetic functions. This topic also provides examples on how to use the functions.

Note If you want to obtain a negative value, use the op_neg (positive value) function. For example, use op_neg(1) to return -1.

Functions

Type Function Description
Sum calculation op_sum Returns the sum of passed values.
Basic calculation op_abs Returns the absolute value of a passed value.
op_div_floor Returns the integer part of the quotient of two passed values.
op_div_true Returns the quotient of two passed values.
op_pow Returns a value raised to a specified power.
op_mul Returns the product of two passed values.
op_neg Returns the opposite number of a passed value.
op_mod Returns the remainder of a passed value divided by the other passed value.
op_sub Returns the difference between two passed values.
op_round Returns a passed value rounded.
Mathematical calculation mat_ceil Returns a passed value rounded up to the nearest integer.
mat_exp Returns Euler's number raised to the power of a passed value.
mat_fabs Returns the absolute value of a passed value.
mat_floor Returns a passed value rounded down to the nearest integer.
mat_log Returns the logarithm of a passed value with the other passed value as the base.
mat_log10 Returns the base-10 logarithm of a passed value.
mat_sqrt Returns the square root of a passed value.
mat_degrees Converts radians to degrees.
mat_radians Converts degrees to radians.
mat_sin Returns the sine of a passed value (in radians).
mat_cos Returns the cosine of a passed value (in radians).
mat_tan Returns the tangent of a passed value (in radians).
mat_acos Returns the arc cosine (in radians) of a passed value.
mat_asin Returns the arc sine (in radians) of a passed value.
mat_atan Returns the arc tangent (in radians) of a passed value.
mat_atan2 Returns the arc tangent of the X-coordinate and the Y-coordinate.
mat_atanh Returns the inverse hyperbolic tangent of a passed value.
mat_hypot Returns the Euclidean norm of two passed values.
MATH_PI Obtains the constant pi.
MATCH_E Obtains the constant e.

op_sum

  • Syntax
    op_sum(Value 1, Value 2, ...)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The sum of all passed values is returned.

  • Example: Calculate the sum of the values of the course_price and goods_price fields.
    Raw log entry:
    course_price: 12
    goods_price: 2
    Transformation rule:
    e_set("account", op_sum(v("course_price"),v("goods_price")))
    Result:
    course_price: 12
    goods_price: 2
    account: 14

op_abs

  • Syntax
    op_abs(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The absolute value of the passed value is returned.

  • Example: Calculate the absolute value of the value of the course_price field.
    Raw log entry:
    course_price: -4
    Transformation rule:
    e_set("op_abs", op_abs(v("course_price")))
    Result:
    course_price: -4
    op_abs: 4

op_div_floor

  • Syntax
    op_div_floor(Value 1, Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The integer part of the quotient that is obtained after Value 1 is divided by Value 2 is returned.

  • Example: Calculate the unit price based on the value of the course_price field.
    Raw log entry:
    course_price: 4
    count: 2
    Transformation rule:
    e_set("op_div_floor", op_div_floor(v("course_price"),v("count")))
    Result:
    course_price: 4
    count: 2
    op_div_floor: 2

op_div_true

The op_div_true function is used to calculate the quotient of two passed values.
Note This function automatically converts the data types of passed values. The value that you pass can be a string or an integer.
  • Syntax
    op_div_true(Value 1, Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The quotient that is obtained after Value 1 is divided by Value 2 is returned.

  • Examples
    • Example 1: Calculate the unit price based on the value of the fruit_price field.
      e_set("op_div_true", op_div_true(v("fruit_price"),v("count")))
      Raw log entry:
      fruit_price: 9
      count: 2
      Result:
      fruit_price: 9
      count: 2
      op_div_true: 4.5
    • Example 2: Calculate the acceleration based on the values of the one_speed and two_speed fields. The returned value is rounded. Formula: a = (one_speed - two_speed)/time.
      e_set("a", op_round(op_div_true(op_sub(v("one_speed"),v("two_speed")),v("time")),2))
      Raw log entry:
      one_speed: 9
      two_speed: 2
      time: 3
      Result:
      a:2.33
      one_speed:9
      time:3
      two_speed:2

op_pow

  • Syntax
    op_pow(Value 1,Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    Value 1 raised to the power of Value 2 is returned.

  • Example: Calculate the value of the course field raised to the power of the value of the pow field.
    Raw log entry:
    course: 100
    pow: 2
    Transformation rule:
    e_set("pow_course", op_pow(v("course"),v("pow")))
    Result:
    course: 100
    pow: 2
    pow_course: 10000

op_mul

  • Syntax
    op_mul(Value 1,Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number, string, tuple, or list Yes The value that you want to use for the calculation.
    Value 2 Number Yes The value that you want to use for the calculation.
  • Response
    The product of Value 1 and Value 2 is returned.
    • If Value 1 is a number, the product of Value 1 and Value 2 is returned.
    • If Value 1 is a string, tuple, or list, the result is the original value repeated for the specified times.
  • Examples
    • Example 1
      Raw log entry:
      course: 10
      price: 23
      Transformation rule:
      e_set("account", op_mul(ct_int(v("course")),ct_int(v("price"))))
      Result:
      course: 10
      price: 23
      account: 230
    • Example 2
      Raw log entry:
      course: "abc"
      Transformation rule:
      e_set("course", op_mul(v("course"), 3))
      Result:
      course: "abcabcabc"

op_neg

  • Syntax
    op_neg(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The opposite number of the passed value is returned.

  • Example
    Raw log entry:
    course: -100
    Transformation rule:
    e_set("account", op_neg(v("course_price")))
    Result:
    course: -100
    account: 100

op_mod

  • Syntax
    op_mod(Value 1,Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The remainder that is obtained after Value 1 is divided by Value 2 is returned.

  • Example
    Raw log entry:
    course: 4
    count: 3
    Transformation rule:
    e_set("op_mod", op_mod(v("course"),v("count")))
    Result:
    course: 4
    count: 3
    op_mod: 1

op_sub

  • Syntax
    op_sub(Value 1,Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The difference between Value 1 and Value 2 is returned.

  • Example: Calculate the difference between the value of the count field and the value of the count_apple field.
    Raw log entry:
    count: 6
    count_apple: 3
    Transformation rule:
    e_set("sub_number", op_sub(v("count"),v("count_apple")))
    Result:
    count: 6
    count_apple: 3
    sub_number:  3

op_round

  • Syntax
    op_round(Value, Number of decimal places)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
    Decimal place Number Yes The number of decimal places to which the value is rounded. Default value: 0.
  • Response

    The passed value rounded is returned.

  • Example: Round the value of the price field to one decimal place.
    Raw log entry:
    price: 4.56
    Transformation rule:
    e_set("round_price", op_round(v("price"),1))
    Result:
    price: 4.56
    round_price: 4.6

mat_ceil

  • Syntax
    mat_ceil(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The smallest integer that is not less than the passed value is returned.

  • Example
    Raw log entry:
    price: 4.1
    Transformation rule:
    e_set("mat_ceil", mat_ceil(v("price")))
    Result:
    price: 4.1
    mat_ceil: 5

mat_exp

  • Description

    The mat_exp function is used to calculate Euler's number raised to the power of a passed value.

  • Syntax
    mat_exp(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    Euler's number raised to the power of the passed value is returned.

  • Example
    Raw log entry:
    e: 1
    Transformation rule:
    e_set("e_x", mat_exp(v("e")))
    Result:
    e: 1
    e_x: 2.718281828459045

mat_fabs

  • Description

    The mat_fabs function is used to calculate the absolute value of a passed value.

  • Syntax
    mat_fabs(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The absolute value of the passed value is returned.

  • Example
    Raw log entry:
    course_price: -10
    Transformation rule:
    e_set("mat_fabs", mat_fabs(v("course_price")))
    Result:
    course_price: -10
    mat_fabs: 10.0

mat_floor

  • Description

    The mat_floor function is used to calculate a passed value rounded down to the nearest integer.

  • Syntax
    mat_floor(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The largest integer that is not greater than the passed value is returned.

  • Example
    Raw log entry:
    course_price: 4.9
    Transformation rule:
    e_set("mat_floor", mat_floor(v("course_price")))
    Result:
    course_price: 4.9
    mat_floor: 4

mat_log

  • Description

    The mat_log function is used to calculate the logarithm of a passed value with the other passed value as the base.

  • Syntax
    mat_log(Value 1,Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The value that you want to use for the calculation.
    Value 2 Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The logarithm of Value 1 with base Value 2 is returned.

  • Example
    Raw log entry:
    number1: 100
    number2: 10
    Transformation rule:
    e_set("mat_log", mat_log(v("number1"),v("number2")))
    Result:
    number1: 100
    number2: 10
    mat_log: 2.0

mat_log10

  • Description

    The mat_log10 function is used to calculate the base-10 logarithm of a passed value.

  • Syntax
    mat_log10(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The base-10 logarithm of the passed value is returned.

  • Example
    Raw log entry:
    number: 100
    Transformation rule:
    e_set("number2", mat_log10(v("number")))
    Result:
    number: 100
    numbe2: 2.0

mat_sqrt

  • Description

    The mat_sqrt function is used to calculate the square root of a passed value.

  • Syntax
    mat_sqrt(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The square root of the passed value is returned.

  • Example
    Raw log entry:
    number1: 100
    Transformation rule:
    e_set("sqrt_account", mat_sqrt(v("number1")))
    Result:
    number1: 100
    sqrt_account: 10.0

mat_degrees

  • Description

    The mat_degrees function is used to convert radians to degrees.

  • Syntax
    mat_degrees(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The degrees are returned.

  • Example
    Raw log entry:
    num: 1
    Transformation rule:
    e_set("mat_degrees", mat_degrees(v("num")))
    Result:
    num: 1
    mat_degrees: 57.29577951308232

mat_radians

  • Description

    The mat_radians function is used to convert degrees to radians.

  • Syntax
    mat_radians(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The radians are returned.

  • Example
    Raw log entry:
    rad: 30
    Transformation rule:
    e_set("mat_radians", mat_radians(v("rad")))
    Result:
    rad: 30
    mat_radians: 0.5235987755982988

mat_sin

  • Description

    The mat_sin function is used to calculate the sine of a passed value (in radians).

  • Syntax
    mat_sin(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The sine of the passed value (in radians) is returned.

  • Example
    Raw log entry:
    sin: 90
    Transformation rule:
    e_set("mat_sin", mat_sin(v("sin")))
    Result:
    sin: 90
    mat_sin: 0.8939966636005579

mat_cos

  • Description

    The mat_cos function is used to calculate the cosine of a passed value (in radians).

  • Syntax
    mat_cos(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The cosine of the passed value (in radians) is returned.

  • Example
    Raw log entry:
    cos: 30
    Transformation rule:
    e_set("mat_cos", mat_cos(v("cos")))
    Result:
    cos: 30
    mat_cos: 0.15425144988758405

mat_tan

  • Description

    The mat_tan function is used to calculate the tangent of a passed value (in radians).

  • Syntax
    mat_tan(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The tangent of the passed value (in radians) is returned.

  • Example
    Raw log entry:
    tan: 30
    Transformation rule:
    e_set("mat_tan", mat_tan(v("tan")))
    Result:
    tan: 30
    mat_tan: 1.6197751905438615

mat_acos

  • Description

    The mat_acos function is used to calculate the arc cosine (in radians) of a passed value.

  • Syntax
    mat_acos(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The arc cosine (in radians) of the passed value is returned.

  • Example
    Raw log entry:
    acos: 1
    Transformation rule:
    e_set("mat_acos", mat_acos(v("acos")))
    Result:
    acos: 1
    mat_acos: 0.0

mat_asin

  • Description

    The mat_asin function is used to calculate the arc sine (in radians) of a passed value.

  • Syntax
    mat_asin(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The arc sine (in radians) of the passed value is returned.

  • Example
    Raw log entry:
    asin: 1
    Transformation rule:
    e_set("mat_asin", mat_asin(v("asin")))
    Result:
    asin: 1
    mat_asin: 1.5707963267948966

mat_atan

  • Description

    The mat_atan function is used to calculate the arc tangent (in radians) of a passed value.

  • Syntax
    mat_atan(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The value that you want to use for the calculation.
  • Response

    The arc tangent (in radians) of the passed value is returned.

  • Example
    Raw log entry:
    atan: 1
    Transformation rule:
    e_set("mat_atan", mat_atan(v("atan")))
    Result:
    atan: 1
    mat_atan: 0.7853981633974483

mat_atan2

  • Description

    The mat_atan2 function is used to calculate the arc tangent of the X-coordinate and the Y-coordinate.

  • Syntax
    mat_atan2(x,y)
  • Parameters
    Parameter Type Required Description
    x Number or numeric string Yes The X-coordinate.
    y Number or numeric string Yes The Y-coordinate.
  • Response

    The arc tangent of the X-coordinate and the Y-coordinate is returned.

  • Example
    Raw log entry:
    atan1: 1
    atan2: 2
    Transformation rule:
    e_set("mat_atan2", mat_atan2(v("atan1"),v("atan2")))
    Result:
    atan1: 1
    atan2: 2
    mat_atan2: 0.4636476090008061

mat_atanh

  • Description

    The mat_atanh function is used to calculate the inverse hyperbolic tangent of a passed value.

  • Syntax
    mat_atanh(Value)
  • Parameters
    Parameter Type Required Description
    Value Number or numeric string Yes The X-coordinate.
  • Response

    The inverse hyperbolic tangent of the passed value is returned.

  • Example
    Raw log entry:
    atanh: 0.5
    Transformation rule:
    e_set("mat_atanh", mat_atanh(v("atanh")))
    Result:
    atanh:0.5
    mat_atanh:0.5493061443340548

mat_hypot

  • Description

    The mat_hypot function is used to calculate the Euclidean norm of two passed values.

  • Syntax
    mat_hypot(Value 1,Value 2)
  • Parameters
    Parameter Type Required Description
    Value 1 Number or numeric string Yes The X-coordinate.
    Value 2 Number or numeric string Yes The Y-coordinate.
  • Response

    The Euclidean norm of the passed values is returned.

  • Example
    Raw log entry:
    hypot1: 1
    hypot2: 2
    Transformation rule:
    e_set("mat_hypot", mat_hypot(v("hypot1"),v("hypot2")))
    Result:
    hypot1:1
    hypot2:2
    mat_hypot:2.23606797749979