Main Page » XQuery » Functions » Math Functions

Math Functions

This module defines functions to perform mathematical operations, such as pi, asin and acos. Most functions are described in detail in the XQuery Functions and Operators Specification, and some functions have been added.

Conventions

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

Functions

math:pi

Signature
math:pi() as xs:double
SummaryReturns the 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:double
) as xs:double?
SummaryReturns $x raised to the power of $y.
Examples
math:pow(2, 3)
Result: 8

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: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

math:log10

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

math:sin

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

math:cos

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

math:tan

Signature
math:tan(
  $radians  as xs:double?
) as xs:double?
SummaryReturns the tangent of $radians, expressed 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(
  $x  as xs:double?,
  $y  as xs:double
) as xs:double?
SummaryReturns the arc tangent of $x divided by $y, 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

math:cosh

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

math:tanh

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

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.

⚡Generated with XQuery