Main Page » XQuery » Functions » Math Functions

Math Functions

This module defines functions to perform mathematical operations, such as pi, asin and acos. All functions are described in detail in the XQuery Functions and Operators specification.

Conventions

All functions are in the http://www.w3.org/2005/xpath-functions/math namespace, to which the math prefix is statically bound.

Functions

math:pi

Signature
math:pi() as xs:double
SummaryReturns the xs:double value of the mathematical constant π.
Examples
math:pi()
Result: 3.141592653589793e0
60 * (math:pi() div 180)
Converts an angle of 60 degrees to radians.

math:e

Signature
math:e() as xs:double
SummaryReturns the xs:double value of the mathematical constant e.
Examples
math:e()
Result: 2.718281828459045e0

math:sqrt

Signature
math:sqrt(  $value  as xs:double?) as xs:double?
SummaryReturns the square root of $value.

math:pow

Signature
math:pow(  $x  as xs:double?,  $y  as xs:numeric) as xs:double?
SummaryReturns $x raised to the power of $y.
Examples
math:pow(2, 3)
Result: 8.0e0

math:exp

Signature
math:exp(  $value  as xs:double?) as xs:double?
SummaryReturns e raised to the power of $value.
Examples
math:exp(1)
Returns e.

math:exp10

Signature
math:exp10(  $value  as xs:double?) as xs:double?
SummaryReturns 10 raised to the power of $value.
Examples
math:exp10(3)
Result: 1.0e3
math:exp10(0.5)
Result: 3.1622776601683795e0

math:log

Signature
math:log(  $value  as xs:double?) as xs:double?
SummaryReturns the natural logarithm (base e) of $value.
Examples
math:log(math:e())
Result: 1.0e0

math:log10

Signature
math:log10(  $value  as xs:double?) as xs:double?
SummaryReturns the base 10 logarithm of $value.
Examples
math:log10(100)
Result: 2.0e0

math:sin

Signature
math:sin(  $radians  as xs:double?) as xs:double?
SummaryReturns the sine of $radians, which is interpreted as an angle in radians.

math:cos

Signature
math:cos(  $radians  as xs:double?) as xs:double?
SummaryReturns the cosine of $radians, which is interpreted as an angle in radians.

math:tan

Signature
math:tan(  $radians  as xs:double?) as xs:double?
SummaryReturns the tangent of $radians, which is interpreted as an angle in radians.

math:asin

Signature
math:asin(  $value  as xs:double?) as xs:double?
SummaryReturns the arc sine of $value, expressed as an angle in radians in the range –π/2 to +π/2.

math:acos

Signature
math:acos(  $value  as xs:double?) as xs:double?
SummaryReturns the arc cosine of $value, expressed as an angle in radians in the range 0 to +π.

math:atan

Signature
math:atan(  $value  as xs:double?) as xs:double?
SummaryReturns the arc tangent of $value, expressed as an angle in radians in the range –π/2 to +π/2.

math:atan2

Signature
math:atan2(  $y  as xs:double,  $x  as xs:double) as xs:double
SummaryReturns the arc tangent of $y divided by $x, expressed as an angle in radians in the range –π to +π.

math:sinh

Signature
math:sinh(  $value  as xs:double?) as xs:double?
SummaryReturns the hyperbolic sine of $value.
Examples
math:sinh(0)
Result: 0.0e0

math:cosh

Signature
math:cosh(  $value  as xs:double?) as xs:double?
SummaryReturns the hyperbolic cosine of $value.
Examples
math:cosh(0)
Result: 1.0e0

math:tanh

Signature
math:tanh(  $value  as xs:double?) as xs:double?
SummaryReturns the hyperbolic tangent of $value.
Examples
math:tanh(100)
Result: 1.0e0

Changelog

Version 11.0Version 9.1
  • Updated: math:crc32 can be called with empty sequence.
Version 7.5Version 7.3
  • Added: math:crc32 and math:uuid have been adopted from the obsolete Utility Module (the predecessor of the current Utility Functions).

⚡Generated with XQuery