Changes

Jump to navigation Jump to search
625 bytes removed ,  12:32, 2 July 2020
m
Text replacement - "[http://www.w3.org/TR/xpath-functions-30" to "[https://www.w3.org/TR/xpath-functions-31"
The math module defines [[Querying#FunctionsModule Library|XQuery FunctionsModule]] defines functions to perform mathematical operations, such as <code>{{Code|pi</code>}}, <code>{{Code|asin</code> }} and <code>{{Code|acos</code>}}. All Most functions are preceded by specified in the <code>math:</code> prefix, which is linked to the <code>http[https://www.w3.org/2005TR/xpath-functions-31/math</code> namespace. Some Functions and Operators Specification] of the functions upcoming XQuery 3.0 Recommendation, and some additional ones have also been specified added in this module. =Conventions= All functions in this module are assigned to the [<code><nowiki>http://www.w3.org/TR2005/xpath-functions-30/ Functions and Operators Specification] of math</nowiki></code> namespace, which is statically bound to the upcoming XQuery 3.0 Recommendation{{Code|math}} prefix.<br/> =W3 Functions=
==math:pi==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:pi</b>() as ||xs:double</code><br />}}
|-
| valign='top' | '''Summary'''|Returns the <code>{{Code|xs:double</code> }} value of the mathematical constant π whose lexical representation is 3.141592653589793.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|2*math:pi()</code> }} returns <code>{{Code|6.283185307179586e0</code>}}.<br />The expression <code>* {{Code|60 * (math:pi() div 180)</code> }} converts an angle of 60 degrees to radians.<br />|} ==math:e=={||-| valign='top' width='90' | '''Signatures'''|<code><b>math:e</b>() as xs:double</code><br />|-| valign='top' | '''Summary'''|Returns the <code>xs:double</code> value of the mathematical constant <i>e</i> whose lexical representation is 2.718281828459045.<br />|-| valign='top' | '''Examples'''|The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>.<br />
|}
==math:sqrt==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:sqrt</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|}
==math:sin==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:sin</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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.<br />
|}
==math:cos==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:cos</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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.<br />
|}
==math:tan==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:tan</b>(|$ arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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.<br />
|}
==math:asin==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:asin</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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.<br />
|}
==math:acos==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:acos</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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 +π.<br />
|}
==math:atan==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:atan</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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.<br />
|}
==math:atan2==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:atan2</b>(|$arg1 as xs:double?, $arg2 as xs:double) as |xs:double?</code><br />}}
|-
| valign='top' | '''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 +π.<br />
|}
==math:pow==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:pow</b>(|$arg1 as xs:double?, $arg2 as xs:double) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|math:pow(2, 3)</code> }} returns <code>{{Code|8</code>}}.<br />
|}
==math:exp==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:exp</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|math:exp(1)</code> }} returns <i>e</i>.<br />
|}
==math:log==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:log</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|math:log(math:e())</code> }} returns <code>{{Code|1</code>}}.<br />
|}
==math:log10==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:log10</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|math:log(100)</code> }} returns <code>{{Code|2</code>}}.<br />
|}
=Additional Functions= ==math:randome=={|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:random</b>() as e||xs:double?</code><br />}}
|-
| valign='top' | '''Summary'''|Returns a random <code>the {{Code|xs:double</code> }} value between of the mathematical constant <codei>0.0e</codei> and <code>1whose lexical representation is 2.718281828459045.|-| '''Examples'''|* {{Code|5*math:e()}} returns {{Code|13.0</code>591409142295225}}.<br />
|}
==math:sinh==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:sinh</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|math:sinh(0)</code> }} returns <code>{{Code|0</code>}}.<br />
|}
==math:cosh==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:cosh</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''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>}}.<br />
|-
| valign='top' | '''Examples'''|The expression <code>* {{Code|math:cosh(0)</code> }} returns <code>{{Code|1</code>}}.<br />
|}
==math:tanh==
{|width='100%'|-| width='120' | '''Signatures'''|{{Func|math:tanh|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the hyperbolic tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic tangent of {{Code|$arg}}.|-| '''Examples'''|* {{Code|math:tanh(100)}} returns {{Code|1}}.|} ==math:crc32== {| width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:tanh</b>(crc32|$arg string as xs:doublestring?) as |xs:doublehexBinary?</code>}}<br />
|-
| valign='top' | '''Summary'''|Returns Calculates the hyperbolic tangent CRC32 check sum of <code>the given {{Code|$arg</code>string}}.<br/>If <code>$arg</code> is the an empty sequenceis supplied, the empty sequence is returned.<br />Otherwise the result is the hyperbolic tangent of <code>$arg</code>.<br />
|-
| valign='top' | 'Examples''Examples'|* {{Code|math:crc32("")}} returns {{Code|'00000000'}}.* {{Code|The expression <code>math:tanhcrc32(100"BaseX")</code> }} returns <code>1</code>{{Code|'4C06FC7F'}}.<br />
|}
=Changelog= ; Version 9.1* Updated: [[#math:crc32|math:crc32]] can be called with empty sequence. ; Version 7.5* Moved: [[Random Module#random:integer|math:random]] and [[Random Module#random:uuid|math:uuid]] have been moved to [[Random Module]]. ; Version 7.3* Added: [[#math:crc32|math:crc32]] and [[CategoryRandom Module#random:uuid|math:XQueryuuid]]have been adopted from the obsolete Utility Module.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu