This document defines functions on the datatypes defined in [XML Schema Part 2: Datatypes Second Edition] and the datatypes defined in [XQuery 1.0 and XPath 2.0 Data Model] for use in [XML Path Language (XPath) 2.0], [XQuery 1.0: An XML Query Language] and [XSL Transformations (XSLT) Version 2.0] and other related XML standards. These functions supplement those defined in [XQuery 1.0 and XPath 2.0 Functions and Operators].
1 Introduction
2 Functions on Numbers
2.1 General Mathematical Functions
2.1.1 fn:exp
2.1.2 fn:log
2.1.3 fn:log10
2.1.4 fn:pow
2.1.5 fn:sqrt
2.2 Trigonometric Functions
2.2.1 fn:cos
2.2.2 fn:sin
2.2.3 fn:tan
2.3 Inverse Trigonometric Functions
2.3.1 fn:acos
2.3.2 fn:asin
2.3.3 fn:atan
2.3.4 fn:atan2
2.4 Hyperbolic Trigonometric Functions
2.4.1 fn:cosh
2.4.2 fn:sinh
2.4.3 fn:tanh
A References
A.1 Normative
The purpose of this document is to catalogue the functions available in the XQSharp implementation of XPath 2.0 and XML Query 1.0 in addition to the standard functions and operators specified in [XQuery 1.0 and XPath 2.0 Functions and Operators]. The exact syntax used to invoke these functions is specified in [XML Path Language (XPath) 2.0], [XQuery 1.0: An XML Query Language] and [XSL Transformations (XSLT) Version 2.0].
The following functions are defined on arguments with xs:double? type. Each function returns a value of type xs:double?.
If the first argument is the empty sequence, the empty sequence is returned.
If any of the arguments is "NaN", "NaN" is returned.
| Function | Meaning |
|---|---|
fn:exp
| Returns the value of e raised to the specified power. |
fn:log
| Returns the natural (base e) logarithm of the argument. |
fn:log10
| Returns the common (base 10) logarithm of the argument. |
fn:pow
| Returns the first argument raised to the power of the second argument. |
fn:sqrt
| Returns the square root of the argument. |
fn:exp($arg as xs:double?) as xs:double?
Summary: Returns the value of e raised to the power of $arg.
If the value of $arg is NaN, the xs:double value NaN is returned.
fn:log($arg as xs:double?) as xs:double?
Summary: Returns the natural (base e) logarithm of $arg.
If the value of $arg is NaN, the xs:double value NaN is returned.
fn:log10($arg as xs:double?) as xs:double?
Summary: Returns the common (base 10) logarithm of $arg.
If the value of $arg is NaN, the xs:double value NaN is returned.
fn:pow($arg1 as xs:double?, $arg2 as xs:double) as xs:double?
Summary: Returns $arg1 raised to the power of $arg2.
If the value of $arg1 or $arg2 is NaN, the xs:double value NaN is returned.
The following functions are defined on arguments with xs:double? type. Each function returns a value of type xs:double?.
If the first argument is the empty sequence, the empty sequence is returned.
If any of the arguments is "NaN", "NaN" is returned.
| Function | Meaning |
|---|---|
fn:cos
| Returns the cosine of the argument. |
fn:sin
| Returns the sine of the argument. |
fn:tan
| Returns the tangent of the argument. |
fn:cos($arg as xs:double?) as xs:double?
Summary: Returns the cosine of $arg as an xs:double, where $arg is an angle measured in radians.
If the value of $arg is NaN, positive infinity or negative infinity, the xs:double value NaN is returned.
For values of $arg outside the range from approximately -9223372036854775295 to approximately 9223372036854775295, the fn:cos function returns $arg unchanged.
fn:sin($arg as xs:double?) as xs:double?
Summary: Returns the sine of $arg as an xs:double, where $arg is an angle measured in radians
If the value of $arg is NaN, positive infinity or negative infinity, the xs:double value NaN is returned.
For values of $arg outside the range from approximately -9223372036854775295 to approximately 9223372036854775295, the fn:cos function returns $arg unchanged.
The following functions are defined on arguments with xs:double? type. Each function returns a value of type xs:double?.
If the first argument is the empty sequence, the empty sequence is returned.
If any of the arguments is "NaN", "NaN" is returned.
| Function | Meaning |
|---|---|
fn:acos
| Returns the arccosine (inverse cosine) of the argument. |
fn:asin
| Returns the arcsine (inverse sine) of the argument. |
fn:atan
| Returns the arctangent (inverse tangent) of the argument. |
fn:atan2
| Returns the arctangent (inverse tangent) of the argument first argument divided by the second. |
fn:acos($arg as xs:double?) as xs:double?
Summary: Returns the arccosine (inverse cosine) of $arg as an xs:double angle measured in radians. The value returned is the value θ in the range 0 ≤ θ ≤ π such that cos(θ) = $arg.
If the value of $arg is NaN or is outside the range -1 to +1, the xs:double value NaN is returned.
fn:asin($arg as xs:double?) as xs:double?
Summary: Returns the arcsine (inverse sine) of $arg as an xs:double angle measured in radians. The value returned is the value θ in the range 0 ≤ θ ≤ π such that sin(θ) = $arg.
If the value of $arg is NaN or is outside the range -1 to +1, the xs:double value NaN is returned.
fn:atan($arg as xs:double?) as xs:double?
Summary: Returns the arctangent (inverse tangent) of $arg as an xs:double angle measured in radians. The value returned is the value θ in the range -π/2 ≤ θ ≤ π/2 such that tan(θ) = $arg.
If the argument is NaN, then the xs:double value NaN is returned.
fn:atan2($arg1 as xs:double?, $arg2 as xs:double) as xs:double?
Summary: Returns the arctangent (inverse tangent) of $arg1 divided by $arg2 as an xs:double angle measured in radians. The value returned is the value θ in the range -π ≤ θ ≤ π such that $arg2 * tan(θ) = $arg1.
If $arg2 is positive then the result is in the range 0 ≤ θ < π. If $arg2 is negative then the result is in the range -π ≤ θ < 0.
If $arg2 is 0 then the result is 0 when $arg1 is non-negative, and π if $arg1 is negative.
If the value of $arg1 or $arg2 is NaN, or if both $arg1 and $arg2 are positive or negative infinity, the xs:double value NaN is returned.
fn:atan2 ( 0, 1 ) returns 0.
fn:atan2 ( 0, 0 ) returns 0.
fn:atan2 ( 0, xs:double('-0') ) returns 3.141592653589793.
fn:atan2 ( xs:double('-0'), 0 ) returns -0.
fn:atan2 ( xs:double('-0'), xs:double('-0') ) returns -3.141592653589793.
fn:atan2 ( 1, xs:double('INF') ) returns 0.
fn:atan2 ( xs:double('NaN'), 1) returns NaN.
fn:atan2 ( xs:double('INF'), xs:double('-INF') ) returns NaN.
The following functions are defined on arguments with xs:double? type. Each function returns a value of type xs:double?.
If the first argument is the empty sequence, the empty sequence is returned.
If any of the arguments is "NaN", "NaN" is returned.
| Function | Meaning |
|---|---|
fn:cosh
| Returns the hyperbolic cosine of the argument. |
fn:sinh
| Returns the hyperbolic sine of the argument. |
fn:tanh
| Returns the hyperbolic tangent of the argument. |
fn:cosh($arg as xs:double?) as xs:double?
Summary: Returns the hyperbolic cosine of $arg.
If the value of $arg is NaN, the xs:double value NaN is returned.
fn:sinh($arg as xs:double?) as xs:double?
Summary: Returns the hyperbolic sine of $arg.
If the value of $arg is NaN, the xs:double value NaN is returned.