Changes

Jump to navigation Jump to search
582 bytes removed ,  16:13, 26 May 2012
no edit summary
The math [[Module Library|XQuery Module]] defines functions to perform mathematical operations, such as <code>{{Code|pi</code>}}, <code>{{Code|asin</code> }} and <code>{{Code|acos</code>}}. Most functions are specified in the [http://www.w3.org/TR/xpath-functions-30/ Functions and Operators Specification] of the upcoming XQuery 3.0 Recommendation, and some additional ones have been added in this module.
=Conventions=
All functions in this module are assigned to the <code>{{Code|http://www.w3.org/2005/xpath-functions/math</code> }} namespace, which is statically bound to the <code>{{Code|math</code> }} prefix.<br/>
=Functions=
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:pi</b>() as ||xs:double</code>}}
|-
| '''Summary'''
|Returns the <code>{{Code|xs:double</code> }} value of the mathematical constant π whose lexical representation is 3.141592653589793.
|-
| '''Examples'''
|
* <code>{{Code|2*math:pi()</code> }} returns <code>{{Code|6.283185307179586e0</code>}}.* <code>{{Code|60 * (math:pi() div 180)</code> }} converts an angle of 60 degrees to radians.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:e</b>() as ||xs:double</code>}}
|-
| '''Summary'''
|Returns the <code>{{Code|xs:double</code> }} value of the mathematical constant <i>e</i> whose lexical representation is 2.718281828459045.
|-
| '''Examples'''
|
* <code>{{Code|5*math:e()</code> }} returns <code>{{Code|13.591409142295225</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:sqrt</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the square root of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the <code>{{Code|xs:double</code> }} value of the mathematical square root of <code>{{Code|$arg</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:sin</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the sine of the <code>{{Code|$arg</code>}}, expressed in radians.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the sine of <code>{{Code|$arg</code>}}, treated as an angle in radians.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:cos</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the cosine of <code>{{Code|$arg</code>}}, expressed in radians.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the cosine of <code>{{Code|$arg</code>}}, treated as an angle in radians.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:tan</b>(|$ as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the tangent of <code>{{Code|$arg</code>}}, expressed in radians.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the tangent of <code>{{Code|$arg</code>}}, treated as an angle in radians.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:asin</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the arc sine of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc sine of <code>{{Code|$arg</code>}}, returned as an angle in radians in the range -π/2 to +π/2.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:acos</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the arc cosine of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc cosine of <code>{{Code|$arg</code>}}, returned as an angle in radians in the range 0 to +π.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:atan</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the arc tangent of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of <code>{{Code|$arg</code>}}, returned as an angle in radians in the range -π/2 to +π/2.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:atan2</b>(|$arg1 as xs:double?, $arg2 as xs:double) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the arc tangent of <code>{{Code|$arg1</code> }} divided by <code>{{Code|$arg2</code>}}, the result being in the range -π/2 to +π/2 radians.<br/>If <code>{{Code|$arg1</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of <code>{{Code|$arg1</code> }} divided by <code>{{Code|$arg2</code>}}, returned as an angle in radians in the range -π to +π.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:pow</b>(|$arg1 as xs:double?, $arg2 as xs:double) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns <code>{{Code|$arg1</code> }} raised to the power of <code>{{Code|$arg2</code>}}.<br/>If <code>{{Code|$arg1</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the <code>{{Code|$arg1</code> }} raised to the power of <code>{{Code|$arg2</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:pow(2, 3)</code> }} returns <code>{{Code|8</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:exp</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns <i>e</i> raised to the power of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the value of <i>e</i> raised to the power of <code>{{Code|$arg</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:exp(1)</code> }} returns <i>e</i>.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:log</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the natural logarithm of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the natural logarithm (base <i>e</i>) of <code>{{Code|$arg</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:log(math:e())</code> }} returns <code>{{Code|1</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:log10</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the base 10 logarithm of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the base 10 logarithm of <code>{{Code|$arg</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:log(100)</code> }} returns <code>{{Code|2</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:random</b>() as ||xs:double?</code>}}
|-
| '''Summary'''
|Returns a random <code>{{Code|xs:double</code> }} value between <code>{{Code|0.0</code> }} and <code>{{Code|1.0</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:sinh</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the hyperbolic sine of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic sine of <code>{{Code|$arg</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:sinh(0)</code> }} returns <code>{{Code|0</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:cosh</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the hyperbolic cosine of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic cosine of <code>{{Code|$arg</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:cosh(0)</code> }} returns <code>{{Code|1</code>}}.
|}
|-
| width='90' | '''Signatures'''
|<code><b>{{Func|math:tanh</b>(|$arg as xs:double?) as |xs:double?</code>}}
|-
| '''Summary'''
|Returns the hyperbolic tangent of <code>{{Code|$arg</code>}}.<br/>If <code>{{Code|$arg</code> }} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic tangent of <code>{{Code|$arg</code>}}.
|-
| '''Examples'''
|
* <code>{{Code|math:tanh(100)</code> }} returns <code>{{Code|1</code>}}.
|}
[[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu