Changes

Jump to navigation Jump to search
27 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"
=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 [https://www.w3.org/TR/xpath-functions-31/ 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='120' | '''Signatures''' | <code> '''{{Func|math:pi'''() as ||xs:double</code> }} |- | '''Summary''' |Returns the {{Code|xs:double}} value of the mathematical constant π. |- | '''Rules''' |This function returns the <code>xs:double</code> value whose lexical representation is 3.141592653589793. |- | '''Examples''' |The expression <code>* {{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== {| | '''Signatures''' | <code> width='100%''math:e'''() as xs:double</code>
|-
| width='120' | '''SummarySignatures''' |Returns the value of the mathematical constant <i>e</i>.{{Func|math:sqrt|$arg as xs:double?|xs:double?}}
|-
| '''RulesSummary''' |This function returns Returns the square root of {{Code|$arg}}.<br/>If {{Code|$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%'
|-
| width='120''Examples''' |The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>. |} ==math:sqrt== {| |-|'''Signatures''' | <code> '''{{Func|math:sqrt'''(sin|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the square root sine of the argument{{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the sine of {{Code|$arg}}, treated as an angle in radians.|} ==math:cos=={| width='100%'
|-
|width='120''Rules''' |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== {| |-|'''Signatures''' | <code> '''{{Func|math:sin'''(cos|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the sine cosine of {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the argumentcosine of {{Code|$arg}}, expressed treated as an angle in radians.|} ==math:tan=={| width='100%'
|-
|width='120''Rules''' |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== {| |-|'''Signatures''' | <code> '''{{Func|math:cos'''(tan|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the cosine tangent of {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the argumenttangent of {{Code|$arg}}, expressed treated as an angle in radians.|} ==math:asin=={| width='100%'
|-
|width='120''Rules''' |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== {| |-|'''Signatures''' | <code> '''{{Func|math:tan'''(asin|$ arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the tangent arc sine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the argumentempty sequence, expressed the empty sequence is returned.<br />Otherwise the result is the arc sine of {{Code|$arg}}, returned as an angle in radiansin the range -π/2 to +π/2.|} ==math:acos=={| width='100%'
|-
|width='120''Rules''' |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== {| |-|'''Signatures''' | <code> '''{{Func|math:asin'''(acos|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the arc sine cosine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc cosine of {{Code|$arg}}, returned as an angle in radians in the argumentrange 0 to +π.|} ==math:atan=={| width='100%'
|-
|width='120''Rules''' |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== {| |-|'''Signatures''' | <code> '''{{Func|math:acos'''(atan|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the arc cosine tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of {{Code|$arg}}, returned as an angle in radians in the argumentrange -π/2 to +π/2.|} ==math:atan2=={| width='100%'
|-
| width='120' | '''Signatures'''|{{Func|math:atan2|$arg1 as xs:double?, $arg2 as xs:double|xs:double?}}|-|'''RulesSummary''' |If <code>Returns the arc tangent of {{Code|$arg1}} divided by {{Code|$argarg2}}, the result being in the range -π/2 to +π/2 radians.<br/code> If {{Code|$arg1}} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the arc cosine tangent of <code>{{Code|$arg1}} divided by {{Code|$arg</code>arg2}}, returned as an angle in radians in the range 0 to +π. |} ==math:atanpow== {| |-|'''Signatures''' | <code> '''math:atanwidth='100%''($arg as xs:double?) as xs:double?</code>
|-
| width='120' |'''SummarySignatures''' |Returns the arc tangent of the argument.{{Func|math:pow|$arg1 as xs:double?, $arg2 as xs:double|xs:double?}}
|-
|'''RulesSummary''' |If <code>Returns {{Code|$arg1}} raised to the power of {{Code|$argarg2}}.<br/code> If {{Code|$arg1}} 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 arg1}} raised to the range -π/2 to +π/2. |} ==math:atan2== power of {{Code| |-|'''Signatures''' | <code> '''math:atan2'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code> }}.
|-
|'''SummaryExamples''' |Returns the arc tangent of the first argument divided by the second argument* {{Code|math:pow(2, the result being in the range -π/2 to +π/2 radians3)}} returns {{Code|8}}.|} ==math:exp=={| width='100%'
|-
|width='120''Rules''' |If <code>$arg1</code> is the empty sequence, the function 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 +π. |} ==math:pow== {| |-|'''Signatures''' | <code> '''{{Func|math:pow'''(exp|$arg1 arg as xs:double?, $arg2 as |xs:double?) as xs:double?</code> }}
|-
|'''Summary''' |Returns <i>e</i> raised to the power of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the first argument empty sequence is returned.<br />Otherwise the result is the value of <i>e</i> raised to the power of the second argument{{Code|$arg}}.
|-
|'''RulesExamples''' |If <code>$arg1</code> is the empty sequence, the function * {{Code|math:exp(1)}} returns the empty sequence.Otherwise the result is the <codei>$arg1e</code> raised to the power of <code>$arg2</codei>. |} ==math:log=={| width='100%'
|-
|width='120''Examples''' |The expression <code>math:pow(2, 3)</code> returns <code>8</code>. |} ==math:exp== {| |-|'''Signatures''' | <code> '''{{Func|math:exp'''(log|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the natural logarithm of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the natural logarithm (base <i>e</i> raised to the power ) of the argument{{Code|$arg}}.
|-
|'''RulesExamples''' |If <code>$arg</code> is the empty sequence, the function * {{Code|math:log(math:e())}} returns the empty sequence.Otherwise the result is the value of <i>e</i> raised to the power of <code>$arg</code>{{Code|1}}. |} ==math:log10=={| width='100%'
|-
|width='120''Examples''' |The expression <code>math:exp(1)</code> returns <i>e</i>. |} ==math:log== {| |-|'''Signatures''' | <code> '''{{Func|math:log'''(log10|$arg as xs:double?) as |xs:double?</code> }}
|-
|'''Summary''' |Returns the natural 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}}.
|-
|'''RulesExamples''' |If <code>$arg</code> is the empty sequence, the function * {{Code|math:log(100)}} returns the empty sequence{{Code|2}}.Otherwise the result is the natural logarithm (base <i>|} =Additional Functions= ==math:e</i>) of <code>$arg</code>. =={| width='100%'
|-
|width='120''Examples''' |The expression <code>math:log(math:e())</code> returns <code>1</code>. |} ==math:log10== {| |-|'''Signatures''' | <code> '''{{Func|math:log10'''($arg as e||xs:double?) as xs:double?</code> }}
|-
|'''Summary''' |Returns the base 10 logarithm {{Code|xs:double}} value of the argumentmathematical constant <i>e</i> whose lexical representation is 2.718281828459045.
|-
|'''RulesExamples''' |If <code>$arg</code> is the empty sequence, the function * {{Code|5*math:e()}} returns the empty sequence{{Code|13.Otherwise the result is the base 10 logarithm of <code>$arg</code>591409142295225}}. |} ==math:sinh=={| width='100%'
|-
|width='120''Examples''' |The expression <code>math:log(100)</code> returns <code>2</code>. |} ==math:random== {| |-|'''Signatures''' | <code> '''{{Func|math:random'''() sinh|$arg as xs:double?</code> |xs:double?}}
|-
|'''Summary''' |Returns a random valuethe hyperbolic sine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic sine of {{Code|$arg}}.
|-
|'''RulesExamples''' |This function returns a random <code>xs* {{Code|math:double</code> value between <code>sinh(0.)}} returns {{Code|0</code> and <code>1.0</code>}}. |} ==math:sinhcosh== {| |-|'''Signatures''' | <code> width='100%''math:sinh'''($arg as xs:double?) as xs:double?</code>
|-
| width='120' |'''SummarySignatures''' |Returns the hyperbolic sine of the argument.{{Func|math:cosh|$arg as xs:double?|xs:double?}}
|-
|'''RulesSummary''' |If <code>Returns the hyperbolic 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 hyperbolic sine cosine of <code>{{Code|$arg</code>}}.
|-
|'''Examples''' |The expression <code>* {{Code|math:sinhcosh(0)</code> }} returns <code>0</code>{{Code|1}}. |} ==math:coshtanh== {| |-|width='100%''Signatures''' | <code> '''math:cosh'''($arg as xs:double?) as xs:double?</code>
|-
| width='120' |'''SummarySignatures''' |Returns the hyperbolic cosine of the argument.{{Func|math:tanh|$arg as xs:double?|xs:double?}}
|-
|'''RulesSummary''' |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>}}.
|-
|'''Examples''' |The expression <code>* {{Code|math:coshtanh(0100)</code> }} returns <code>{{Code|1</code>}}. |} ==math:tanhcrc32==  {| |-|'''Signatures''width=' | <code> 100%'''math:tanh'''($arg as xs:double?) as xs:double?</code>
|-
| width='120' |'''SummarySignatures''' |Returns the hyperbolic tangent of the argument.{{Func|math:crc32|$string as xs:string?|xs:hexBinary?}}<br />
|-
|'''RulesSummary''' |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.
|-
|'''Examples''' |The expression <code>* {{Code|math:crc32("")}} returns {{Code|'00000000'}}.* {{Code|math:tanhcrc32(100"BaseX")</code> }} returns <code>1</code>{{Code|'4C06FC7F'}}. |} =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