Changes

Jump to navigation Jump to search
322 bytes removed ,  14:39, 16 April 2019
no edit summary
=Math The math [[Module=Library|XQuery Module]] defines functions to perform mathematical operations, such as {{Code|pi}}, {{Code|asin}} and {{Code|acos}}. 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.
The math module defines extension functions to perform mathematical operations, such as <code>pi</code>, <code>asin</code> and <code>acos</code>. =Conventions= All functions in this module are preceded by assigned to the <code>math:</codenowiki> prefix. Some of the functions have also been specified in the[http://www.w3.org/TR2005/xpath-functions-11/ Functions and Operators Specification] of math</nowiki></code> namespace, which is statically bound to the upcoming XQuery 1.1 Recommendation{{Code|math}} prefix. <br/> =W3 Functions= ==math:pi== {| width='100%'|- | width="90" '120' | <b>'''Signatures</b> ''' | <code> <b>{{Func|math:pi'''() as ||xs:double</code> }} |- | <b>'''Summary</b> ''' |Returns the {{Code|xs:double}} value of the mathematical constant π. |- | <b>Rules</b> |This function returns the <code>xs:double</code> value whose lexical representation is 3.141592653589793. |- | <b>'''Examples</b> '''| * {{Code|The expression <code>2*math:pi()</code> }} returns <code>{{Code|6.283185307179586e0</code>}}.The expression <code>* {{Code|60 * (math:pi() div 180)</code> }} converts an angle of 60 degrees to radians.
|}
==math:esqrt== {| | width="90" | <b>Signatures</b> | <code> <b>math:e''100%'() as xs:double</code>
|-
| <b>Summary</b> width='120' | '''Signatures'''|Returns the value of the mathematical constant <i>e</i>.{{Func|math:sqrt|$arg as xs:double?|xs:double?}}
|-
| '''Summary'''|Returns the square root of {{Code|$arg}}.<b>Rules<br/b> If {{Code|This function returns $arg}} is the empty sequence, the empty sequence is returned.<codebr />Otherwise the result is the {{Code|xs:double</code> }} value whose lexical representation is 2.718281828459045of the mathematical square root of {{Code|$arg}}. |} ==math:sin=={| width='100%'
|-
| <b>Examples</b> |The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>. |} ==math:sqrt== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:sqrt'''(sin|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary'''|Returns the sine of the {{Code|$arg}}, expressed in radians.<bbr/>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the square root sine of the argument{{Code|$arg}}, treated as an angle in radians.|} ==math:cos=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the <code>xs:double</code> value of the mathematical square root of <code>$arg</code>. |} ==math:sin== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:sin'''(cos|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary'''|Returns the cosine of {{Code|$arg}}, expressed in radians.<bbr/>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the sine cosine of the argument{{Code|$arg}}, expressed treated as an angle in radians.|} ==math:tan=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the sine of <code>$arg</code>, treated as an angle in radians. |} ==math:cos== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:cos'''(tan|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary'''|Returns the tangent of {{Code|$arg}}, expressed in radians.<bbr/>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the cosine tangent of the argument{{Code|$arg}}, expressed treated as an angle in radians.|} ==math:asin=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the cosine of <code>$arg</code>, treated as an angle in radians. |} ==math:tan== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:tan'''(asin|$ arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary'''|Returns the arc sine of {{Code|$arg}}.<bbr/>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the tangent arc sine of the argument{{Code|$arg}}, expressed returned as an angle in radiansin the range -π/2 to +π/2.|} ==math:acos=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the tangent of <code>$arg</code>, treated as an angle in radians. |} ==math:asin== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:asin'''(acos|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary'''|Returns the arc cosine of {{Code|$arg}}.<bbr/>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the arc sine cosine of {{Code|$arg}}, returned as an angle in radians in the argumentrange 0 to +π.|} ==math:atan=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc sine of <code>$arg</code>, returned as an angle in radians in the range -π/2 to +π/2. |} ==math:acos== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:acos'''(atan|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary'''|Returns the arc tangent of {{Code|$arg}}.<bbr/>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the arc cosine tangent of {{Code|$arg}}, returned as an angle in radians in the argumentrange -π/2 to +π/2.|} ==math:atan2=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc cosine of <code>$arg</code>, returned as an angle in radians in the range 0 to +π. |} ==math:atan== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:atan'''(atan2|$arg arg1 as xs:double?) , $arg2 as xs:double|xs:double?</code> }}
|-
|'''Summary'''|Returns the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, the result being in the range -π/2 to +π/2 radians.<bbr/>SummaryIf {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br /b> |Returns Otherwise the result is the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, returned as an angle in radians in the argumentrange -π to +π.|} ==math:pow=={| width='100%'
|-
|<b>Rules</b> |If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc tangent of <code>$arg</code>, returned as an angle in radians in the range -π/2 to +π/2. |} ==math:atan2== {| |-|width="90" '120' | <b>'''Signatures</b> '''| <code> <b>{{Func|math:atan2'''(pow|$arg1 as xs:double?, $arg2 as xs:double?) as |xs:double?</code> }}
|-
|<b>'''Summary</b> '''|Returns {{Code|$arg1}} raised to the arc tangent power of {{Code|$arg2}}.<br/>If {{Code|$arg1}} is the first argument divided by empty sequence, the second argument, empty sequence is returned.<br />Otherwise the result being in is the range -π/2 {{Code|$arg1}} raised to +π/2 radiansthe power of {{Code|$arg2}}.
|-
|<b>Rules</b> '''Examples'''|If <code>$arg1</code> is the empty sequence* {{Code|math:pow(2, the function 3)}} returns the empty sequence.Otherwise the result is the arc tangent of <code>$arg1</code> divided by <code>$arg2</code>, returned as an angle in radians in the range -π to +π{{Code|8}}. |} ==math:powexp== {| |-|width="90" | <b>Signatures</b> | <code> <b>math:pow'100%''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>
|-
|<b>Summary</b> width='120' | '''Signatures'''|Returns the first argument raised to the power of the second argument.{{Func|math:exp|$arg as xs:double?|xs:double?}}
|-
|'''Summary'''|Returns <bi>Rulese</bi> raised to the power of {{Code|If <code>$arg1arg}}.<br/code> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the value of <codei>$arg1e</codei> raised to the power of <code>{{Code|$arg2</code>arg}}.
|-
|<b>'''Examples</b> '''|* {{Code|The expression <code>math:powexp(2, 31)</code> }} returns <codei>8e</codei>. |} ==math:explog== {| |-|width="90" | <b>Signatures</b> | <code> <b>math:exp'100%''($arg as xs:double?) as xs:double?</code>
|-
|<b>Summary</b> width='120' | '''Signatures'''|Returns <i>e</i> raised to the power of the argument.{{Func|math:log|$arg as xs:double?|xs:double?}}
|-
|<b>Rules</b> '''Summary'''|If <code>Returns the natural logarithm 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 value of natural logarithm (base <i>e</i> raised to the power ) of <code>{{Code|$arg</code>}}.
|-
|<b>'''Examples</b> '''|The expression <code>* {{Code|math:explog(1math:e())</code> }} returns <i>e</i>{{Code|1}}. |} ==math:loglog10== {| |-|width="90" | <b>Signatures</b> | <code> <b>math:log''100%'($arg as xs:double?) as xs:double?</code>
|-
|<b>Summary</b> width='120' | '''Signatures'''|Returns the natural logarithm of the argument.{{Func|math:log10|$arg as xs:double?|xs:double?}}
|-
|<b>Rules</b> '''Summary'''|If <code>Returns the base 10 logarithm 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 natural base 10 logarithm (base <i>e</i>) of <code>{{Code|$arg</code>}}.
|-
|<b>'''Examples</b> '''|The expression <code>* {{Code|math:log(math:e(100))</code> }} returns <code>1</code>{{Code|2}}. |} =Additional Functions= ==math:log10e== {| |-|width="90" | <b>Signatures</b> | <code> <b>math:log10''100%'($arg as xs:double?) as xs:double?</code>
|-
|<b>Summary</b> width='120' | '''Signatures'''|Returns the base 10 logarithm of the argument.{{Func|math:e||xs:double}}
|-
|<b>Rules</b> '''Summary'''|If Returns the {{Code|xs:double}} value of the mathematical constant <codei>$arge</codei> whose lexical representation is the empty sequence, the function returns the empty sequence2.Otherwise the result is the base 10 logarithm of <code>$arg</code>718281828459045.
|-
|<b>'''Examples</b> '''|The expression <code>* {{Code|5*math:loge(100)</code> }} returns <code>2</code>{{Code|13.591409142295225}}. |} ==math:randomsinh== {| |-|width="90" | <b>Signatures</b> | <code> <b>math:random''100%'() as xs:double?</code>
|-
|<b>Summary</b> width='120' | '''Signatures'''|Returns a random value.{{Func|math:sinh|$arg as xs:double?|xs:double?}}
|-
|<b>Rules</b> '''Summary'''|This function returns a random <code>xs:double</code> value between <code>0Returns the hyperbolic sine of {{Code|$arg}}.0<br/code> and <code>1If {{Code|$arg}} is the empty sequence, the empty sequence is returned.0<br /code>. |} ==math:sinh== Otherwise the result is the hyperbolic sine of {{Code| |-|width="90" | <b>Signatures</b> | <code> <b>math:sinh'''($arg as xs:double?) as xs:double?</code> }}.
|-
|<b>Summary</b> '''Examples'''|Returns the hyperbolic sine of the argument* {{Code|math:sinh(0)}} returns {{Code|0}}.|} ==math:cosh=={| width='100%'
|-
|<b>Rules</b> width='120' | '''Signatures'''|If <code>{{Func|math:cosh|$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic sine of <code>$arg</code>. as xs:double?|xs:double?}}
|-
|<b>Examples</b> '''Summary'''|The expression <code>math:sinh(0)Returns the hyperbolic cosine of {{Code|$arg}}.<br/code> returns <code>0</code>. If {{Code|$arg} ==math:cosh== {| |-|width="90" | <b>Signatures} is the empty sequence, the empty sequence is returned.<br /b> Otherwise the result is the hyperbolic cosine of {{Code| <code> <b>math:cosh'''($arg as xs:double?) as xs:double?</code> }}.
|-
|<b>Summary</b> '''Examples'''|Returns the hyperbolic cosine of the argument* {{Code|math:cosh(0)}} returns {{Code|1}}.|} ==math:tanh=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:tanh|$arg as xs:double?|xs:double?}}
|-
|<b>Rules</b> '''Summary'''|If <code>Returns the hyperbolic tangent 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 cosine tangent of <code>{{Code|$arg</code>}}.
|-
|<b>'''Examples</b> '''|* {{Code|The expression <code>math:coshtanh(0100)</code> }} returns <code>{{Code|1</code>}}. |} ==math:tanhcrc32==  {| |-|width="90" | <b>Signatures</b> | <code> <b>math:tanh''100%'($arg as xs:double?) as xs:double?</code>
|-
|width='120' | '''Signatures'''|{{Func|math:crc32|$string as xs:string?|xs:hexBinary?}}<b>Summary<br /b> |Returns the hyperbolic tangent of the argument.
|-
|<b>Rules</b> '''Summary'''|If <code>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.Otherwise the result is the hyperbolic tangent of <code>$arg</code>returned.
|-
|<b>'''Examples</b> '''|The expression <code>* {{Code|math:tanhcrc32(100"")</code> }} returns <code>{{Code|'00000000'}}.* {{Code|math:crc32("BaseX")}} returns {{Code|'4C06FC7F'}}.|} =Changelog= ; Version 9.1</code>* 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:XQueryuuid|math:uuid]]have been adopted from the obsolete Utility Module.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu