MXQuery supports the same mathematical functions as Zorba, using the same namespace and modules.
In addition, it supports a function a general exponentiation function pow(). For convenience, this function is placed into the same module as the other math functions.


import module namespace math =

"http://www.zorbaxquery.com/zorba/mathfunctions";


math:sqrt ($arg as numeric?) as numeric?


math:exp ($arg as xs:double) as xs:double

math:log ($arg as xs:double) as xs:double

math:sin ($arg as xs:double) as xs:double

math:cos ($arg as xs:double) as xs:double

math:tan ($arg as xs:double) as xs:double

math:asin ($arg as xs:double) as xs:double

math:acos ($arg as xs:double) as xs:double

math:atan ($arg as xs:double) as xs:double


math:pow($base as numeric?, exp as as numeric?) as as xs:double
For sqrt, if type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
All the transcendental functions (exp, log, sin, cos, tan, asin, acos, atan) take double arguments and return doubles.
For arguments outside their domain, the following functions return NaN: sqrt and ln, for negative arguments; and asin and acos, for arguments outside [1, 1].