Changes

Jump to navigation Jump to search
1,290 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 the <code>math:</code> prefix. Some of the functions have also been specified in the [httphttps://www.w3.org/TR/xpath-functions-1131/ 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><nowiki>http://www.w3.org/2005/xpath-functions/math</nowiki></code> namespace, which is statically bound to the {{Code|math}} prefix.<br/> =W3 Functions=
==math:pi==
{||-| valign='top' width='90' | '''Signatures'''|<code><b>math:pi</b>() as xs:double</code><br />|-| valign='top' | '''Summary'''|Returns the value of the mathematical constant π.|-| valign='top' | '''Rules'''|This function returns the <code>xs:double</code> value whose lexical representation is 3.141592653589793.<br />|-| valign='top' | '''Examples''100%'|The expression <code>2*math:pi()</code> returns <code>6.283185307179586e0</code>.<br />The expression <code>60 * (math:pi() div 180)</code> converts an angle of 60 degrees to radians.<br />|} ==math:e=={|
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:e</b>() as pi||xs:double</code><br />}}
|-
| valign='top' | '''Summary'''|Returns the {{Code|xs:double}} value of the mathematical constant <i>e</i>π whose lexical representation is 3.141592653589793.
|-
| valign='top' | '''RulesExamples'''|This function * {{Code|2*math:pi()}} returns the <code>xs:double</code> value whose lexical representation is 2{{Code|6.718281828459045283185307179586e0}}.<br />* {{Code|-| valign='top' | '''Examples'''|The expression <code>560 *(math:epi()</code> returns <code>13.591409142295225</code>div 180)}} converts an angle of 60 degrees to radians.<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 the argument.|-| valign='top' {{Code| '''Rules'''|If <code>$arg}}.<br/code> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis 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 argument{{Code|$arg}}, expressed in radians.|-| valign='top' | '''Rules'''|If <codebr/>If {{Code|$arg</code> }} is the empty sequence, the function returns the empty sequenceis 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 the argument{{Code|$arg}}, expressed in radians.|-| valign='top' | '''Rules'''|If <codebr/>If {{Code|$arg</code> }} is the empty sequence, the function returns the empty sequenceis 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 the argument{{Code|$arg}}, expressed in radians.|-| valign='top' | '''Rules'''|If <codebr/>If {{Code|$arg</code> }} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the tangent of <code>{{Code|$arg</code>}}, treated as an angle in radians.<br />
|}
==math:asin==
{||-| valign='top' width='90' | '''Signatures''100%'|<code><b>math:asin</b>($arg as xs:double?) as xs:double?</code><br />
|-
| valignwidth='top120' | '''SummarySignatures'''|Returns the arc sine of the argument.{{Func|math:asin|$arg as xs:double?|xs:double?}}
|-
| valign='top' | '''RulesSummary'''|If <code>Returns the arc sine of {{Code|$arg}}.<br/code> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis 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==
{||-| valign='top' width='90' | '''Signatures''100%'|<code><b>math:acos</b>($arg as xs:double?) as xs:double?</code><br />
|-
| valignwidth='top120' | '''SummarySignatures'''|Returns the arc cosine of the argument.{{Func|math:acos|$arg as xs:double?|xs:double?}}
|-
| valign='top' | '''RulesSummary'''|If <code>Returns the arc cosine of {{Code|$arg}}.<br/code> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis 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 the argument.{{Code|-| valign='top' | '''Rules'''|If <code>$arg}}.<br/code> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis 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 the first argument {{Code|$arg1}} divided by the second argument{{Code|$arg2}}, the result being in the range -π/2 to +π/2 radians.|-| valign='top' | '''Rules'''|If <codebr/>If {{Code|$arg1</code> }} is the empty sequence, the function returns the empty sequenceis 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|$arg1}} raised to the first argument power of {{Code|$arg2}}.<br/>If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the {{Code|$arg1}} raised to the power of the second argument{{Code|$arg2}}.
|-
| valign='top' | '''RulesExamples'''|If <code>$arg1</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the <code>$arg1</code> raised to the power of <code>$arg2</code>.<br />|-* {{Code| valign='top' | '''Examples'''|The expression <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|$arg}}.<br/>If {{Code|$arg}} is the argumentempty sequence, the empty sequence is returned.<br />Otherwise the result is the value of <i>e</i> raised to the power of {{Code|$arg}}.
|-
| valign='top' | '''RulesExamples'''|If <code>$arg1</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the value of <i>e</i> raised to the power of <code>$arg</code>.<br />|-| valign='top' | '''Examples'''* {{Code|The expression <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|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the argumentresult is the natural logarithm (base <i>e</i>) of {{Code|$arg}}.
|-
| valign='top' | '''RulesExamples'''|If <code>$arg1</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the natural logarithm (base <i>e</i>) of <code>$arg</code>.<br />|-* {{Code| valign='top' | '''Examples'''|The expression <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|$arg}}.<br/>If {{Code|$arg}} is the argumentempty sequence, the empty sequence is returned.<br />Otherwise the result is the base 10 logarithm of {{Code|$arg}}.
|-
| valign='top' | '''RulesExamples'''|If <code>$arg1</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the base 10 logarithm of <code>$arg</code>.<br />|-| valign='top' | '''Examples'''* {{Code|The expression <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 the {{Code|xs:double}} valueof the mathematical constant <i>e</i> whose lexical representation is 2.718281828459045.
|-
| valign='top' | '''RulesExamples'''|This function * {{Code|5*math:e()}} returns a random <code>xs:double</code> value between <code>0.0</code> and <code>1{{Code|13.0</code>591409142295225}}.<br />
|}
==math:sinh==
{||-| valign='top' width='90' | '''Signatures''100%'|<code><b>math:sinh</b>($arg as xs:double?) as xs:double?</code><br />
|-
| valignwidth='top120' | '''SummarySignatures'''|Returns the hyperbolic sine of the argument.{{Func|math:sinh|$arg as xs:double?|xs:double?}}
|-
| valign='top' | '''RulesSummary'''|If <code>Returns the hyperbolic sine of {{Code|$arg}}.<br/code> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis 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|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the argumentresult is the hyperbolic cosine of {{Code|$arg}}.
|-
| valign='top' | '''RulesExamples'''|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the hyperbolic cosine of <code>$arg</code>.<br />|-| valign='top' | '''Examples'''* {{Code|The expression <code>math:cosh(0)</code> }} returns <code>{{Code|1</code>}}.<br />
|}
==math:tanh==
{|width='100%'
|-
| valign='top' width='90120' | '''Signatures'''|<code><b>{{Func|math:tanh</b>(|$arg as xs:double?) as |xs:double?</code><br />}}
|-
| valign='top' | '''Summary'''|Returns the hyperbolic tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the argumentresult is the hyperbolic tangent of {{Code|$arg}}.
|-
| valign'''Examples'''|* {{Code|math:tanh(100)}} returns {{Code|1}}.|} ==math:crc32== {| width='100%'|-| width='top120' | '''RulesSignatures'''|If {{Func|math:crc32|$string as xs:string?|xs:hexBinary?}}<codebr />|-| '''Summary'''|Calculates the CRC32 check sum of the given {{Code|$argstring}}.<br/code> is the If an empty sequenceis supplied, the function returns the empty sequence.<br />Otherwise the result is the hyperbolic tangent of <code>$arg</code>returned.<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 [[CategoryRandom Module#random:uuid|math:XQueryuuid]]have been moved to [[Random Module]].--; Version 7.3* Added: [[User#math:CGcrc32|CGmath:crc32]] 17and [[Random Module#random:59, 21 January 2011 (CET)uuid|math:uuid]] have been adopted from the obsolete Utility Module.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu