Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Math extension provides basic mathematical functions such as calculating absolute value, sin, cos, tan, base conversion, parsing, etc. Following are the functions of the Math extension. 

...

Syntax<double> math:abs(<float|double> p1)
Extension TypeFunction
DescriptionReturns the absolute value of p1. This function wraps the java.lang.Math.abs() function.
Examples

Both the following queries return 3 since the absolute value of both 3 and -3 is 3.

  • abs(3)
  • abs(-3)


acos  function

Syntax<double> math:acos(<float|double> p1)
Extension TypeFunction
DescriptionIf -1 <= p1 <= 1, this function returns the arc-cosine (inverse cosine) of p1. If not, it returns NULL. The return value is in radian scale. This function wraps the java.lang.Math.acos()function.
Exampleacos(0.5) returns 1.0471975511965979.

...

Syntax<double> math:asin (<float|double>  p1)
Extension TypeFunction
DescriptionIf -1 <= p1 <= 1, this function returns the arc-sin (inverse sine) of p1. If not, it returns NULL. The return value is in radian scale. This function wraps the java.lang.Math.asin() function.
Exampleasin(0.5) returns 0.5235987755982989.

 

atan function

Syntax<double> math:atan(<int|long|float|double> p1)
Extension TypeFunction
DescriptionReturns the arc-tangent (inverse tangent) of p1. The return value is in radian scale. This function wraps the java.lang.Math.atan() function.
Examplesatan(6d) returns 1.4056476493802699.

...

Syntax<double>  math:cbrt(<int|long|float|double> p1)
Extension TypeFunction
DescriptionReturns the cube-root of p1 (p1 is in radians). This function wraps the java.lang.Math.cbrt() function.
Examplecbrt(17d) returns 2.5712815906582356.

 

e function

Syntax<double>  math:e()
Extension TypeFunction
DescriptionReturns the java.lang.Math.E constant, which is the closest double value to e (which is the base of the natural logarithms).
Examplee() returns 2.7182818284590452354.

...

 

Is Not A Number function 

Syntax< boolean>  math:isNan(<float|double>  p1)
Extension TypeFunction
DescriptionThis function wraps the java.lang.Float.isNaN() and java.lang.Double.isNaN() functions that return true if p1 is a NaN (Not-a-Number) value, or return false otherwise.
ExampleisNan(java.lang.Math.log(-12d)) returns true.

...

Syntax<double> math:percentile (<int|long|float|double>  arg,  <double> p)
Extension TypeFunction
DescriptionReturns the pth percentile value of the arg values. 
Example

from inputStream#window.length(100)

select math:percentile(temperature, 97.0) as percentile

insert into outputStream;

returns 97th percentile value of last 100 temperature values. 

...

Syntax<double> math:pi ( )
Extension TypeFunction
DescriptionReturns the java.lang.Math.PI constant, which is the closest value to pi (i.e. the ratio of the circumference of a circle to its diameter). 
Examplepi() always returns 3.141592653589793.

 

Power function

Syntax<double> math:power ( < int|long|float|double>  value,  <int|long|float|double>   toPower )
Extension TypeFunction
DescriptionReturns value raised to the power of toPower.
Examplepower(5.6d, 3.0d) returns 175.61599999999996.

...

Syntax<double> math:sin (< int|long|float|double >  p1)
Extension TypeFunction
DescriptionReturns the sine of p1 (p1 is in radians). This function wraps the java.lang.Math.sin() function.
Examplesin(6d) returns -0.27941549819892586.

 

sinh function

Syntax<double> math:sinh (< int|long|float|double >  p1)
Extension TypeFunction
DescriptionReturns the hyperbolic sine of p1 (p1 is in radians). This function wraps the java.lang.Math.sinh() function. 
Examplesinh(6d) returns 201.71315737027922.

...

Syntax<double> math:sqrt (< int|long|float|double >  p1)
Extension TypeFunction
DescriptionReturns the square-root of p1. This function wraps the java.lang.Math.sqrt() function. 
Examplesqrt(4d) returns 2.

 

tan  function

Syntax<double> math:tan (< int|long|float|double >  p1)
Extension TypeFunction
DescriptionReturns the tan of p1 (p1 is in radians). This function wraps the java.lang.Math.tan() function. 
Exampletan(6d) returns -0.29100619138474915.

...