Changes

Jump to navigation Jump to search
5,455 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"
<p>The math module [[Module Library|XQuery Module]] defines extension 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. Some of the functions have also been specified in the[http[https://www.w3.org/TR/xpath-functions-1131/ Functions and Operators Specification] of the upcoming XQuery 13.1 0 Recommendation, and some additional ones have been added in this module.</p> <h2>math:pi</h2> =Conventions= All functions in this module are assigned to the <tablecode> <trnowiki> http://www.w3.org/2005/xpath-functions/math<td width="90"/nowiki> <b/code>Signaturesnamespace, which is statically bound to the {{Code|math}} prefix.<br/b> </td> <td> =W3 Functions= <code> <b>==math:pi</b>() as =={| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:pi||xs:double</code> }} <br /> |- </td> </tr> <tr> <td> <b>Summary</b> </td> | '''Summary''' <td>|Returns the {{Code|xs:double}} value of the mathematical constant πwhose lexical representation is 3.141592653589793.</td> </tr> |- <tr> | '''Examples''' <td> | <b>Rules</b> * {{Code|2*math:pi()}} returns {{Code|6.283185307179586e0}}. </td> <td>This function returns the <code>xs* {{Code|60 * (math:double</code> value whose lexical representation is 3pi() div 180)}} converts an angle of 60 degrees to radians.141592653589793.<br /> </td> |}  </tr> ==math:sqrt== <tr> {| width='100%' <td> |- <b>Examples</b> | width='120' | '''Signatures''' </td> <td>The expression <code>2*|{{Func|math:pi()</code> returns <code>6.283185307179586e0</code>sqrt|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the square root of {{Code|$arg}}.<br />The expression <code>60 * (math:pi() div 180)</code> converts an angle of 60 degrees to radiansIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /> Otherwise the result is the {{Code|xs:double}} value of the mathematical square root of {{Code|$arg}}. </td> </tr> </table> |} <h2>==math:e</h2> sin==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math|{{Func|math:sin|$arg as xs:e</b>() as double?|xs:double</code> ?}} <br /> |- </td> </tr> <tr> <td> <b>Summary</b> </td> | '''Summary''' <td>|Returns the value sine of the mathematical constant {{Code|$arg}}, expressed in radians.<ibr/>eIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /i>Otherwise the result is the sine of {{Code|$arg}}, treated as an angle in radians.</td> </tr> |}  <tr> ==math:cos== <td> {| width='100%' <b>Rules</b> |- </td> <td>This function returns the <code>| width='120' | '''Signatures'''|{{Func|math:cos|$arg as xs:double?|xs:double</code> value whose lexical representation is 2.718281828459045.<br /> ?}} |-| '''Summary'''|Returns the cosine of {{Code|$arg}}, expressed in radians.<br/td> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /tr> Otherwise the result is the cosine of {{Code|$arg}}, treated as an angle in radians. <tr> |} <td> <b>Examples</b> ==math:tan== </td> {| width='100%'|-| width='120' | '''Signatures''' <td>The expression <code>5*|{{Func|math:e()</code> returns <code>13tan|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the tangent of {{Code|$arg}}, expressed in radians.591409142295225<br/code>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /> Otherwise the result is the tangent of {{Code|$arg}}, treated as an angle in radians. </td> |} </tr> </table> <h2>==math:sqrt</h2> asin==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>|{{Func|math:sqrt</b>(asin|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> </td> ''' <td>|Returns the square root arc sine of the argument{{Code|$arg}}.<br/td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>If {{Code|$arg</code> }} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the <code>xs:double</code> value arc sine of the mathematical square root of <code>{{Code|$arg<}}, returned as an angle in radians in the range -π/2 to +π/code>2.<br /> </td> |} </tr> </table> <h2>==math:sin</h2> acos==<table> <tr> <td {| width="90"> '100%'|- <b>| width='120' | '''Signatures</b> </td> ''' <td> <code> <b>|{{Func|math:sin</b>($arg acos|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> | '''Summary''' |Returns the arc cosine of {{Code|$arg}}.<br/tr> <tr> <td> <b>Summary</b> </td> <td>Returns If {{Code|$arg}} is the sine of empty sequence, the argument, expressed in radiansempty sequence is returned.<br /td> </tr> Otherwise the result is the arc cosine of {{Code|$arg}}, returned as an angle in radians in the range 0 to +π. <tr> |} <td> <b>Rules</b> ==math:atan=={| width='100%'|- </td> | width='120' | '''Signatures''' <td>If <code>|{{Func|math:atan|$argas xs:double?|xs:double?}}|-| '''Summary'''|Returns the arc 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 sine arc tangent of <code>{{Code|$arg</code>}}, treated returned as an angle in radians.<br in the range -π/> <2 to +π/td> 2. </tr> |}</table> <h2>==math:cos</h2> atan2==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>|{{Func|math:cos</b>(atan2|$arg arg1 as xs:double?) , $arg2 as xs:double|xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> ''' </td> <td>|Returns the cosine arc tangent of the argument, expressed {{Code|$arg1}} divided by {{Code|$arg2}}, the result being in the range -π/2 to +π/2 radians.<br/td> If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br /tr> <tr> Otherwise the result is the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, returned as an angle in radians in the range -π to +π. <td> |} <b>Rules</b> </td> ==math:pow=={| width='100%'|- <td>If <code>$arg</code> is the empty sequence| width='120' | '''Signatures'''|{{Func|math:pow|$arg1 as xs:double?, $arg2 as xs:double|xs:double?}}|-| '''Summary'''|Returns {{Code|$arg1}} raised to the function returns the empty sequence.<br />Otherwise the result is the cosine power of <code>{{Code|$argarg2}}.<br/code>If {{Code|$arg1}} is the empty sequence, treated as an angle in radiansthe empty sequence is returned.<br /> Otherwise the result is the {{Code|$arg1}} raised to the power of {{Code|$arg2}}. </td> |- </tr> </table> | '''Examples''' |<h2>* {{Code|math:tan</h2> pow(2, 3)}} returns {{Code|8}}.|}<table> <tr> ==math:exp== <td {| width="90"> '100%'|- <b>| width='120' | '''Signatures</b> </td> ''' <td> <code> <b>|{{Func|math:tan</b>($ exp|$arg as xs:double?) as |xs:double?}}|-| '''Summary'''|Returns </codei> e<br /i> raised to the power of {{Code|$arg}}.<br/td> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /tr> Otherwise the result is the value of <tri> <td> <b>Summarye</bi> </td> <td>Returns the tangent raised to the power of the argument, expressed in radians{{Code|$arg}}.</td> </tr> |- <tr> | '''Examples''' <td> | <b>Rules* {{Code|math:exp(1)}} returns </bi> e</tdi> .|} ==math:log== <td>If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the tangent {| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:log|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the natural logarithm of <code>{{Code|$arg}}.<br/code>, treated as an angle in radiansIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /> Otherwise the result is the natural logarithm (base </tdi> e</tri> ) of {{Code|$arg}}.</table> |-| '''Examples''' |<h2>* {{Code|math:log(math:asin</h2> e())}} returns {{Code|1}}.<table> |} <tr> <td width="90"> =math:log10== <b>Signatures</b> {| width='100%' </td> |- <td> | width='120' | '''Signatures''' <code> <b>math|{{Func|math:asin</b>(log10|$arg as xs:double?) as |xs:double?</code> }}|-| '''Summary''' |Returns the base 10 logarithm of {{Code|$arg}}.<br /> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> Otherwise the result is the base 10 logarithm of {{Code|$arg}}. </tr> |- <tr> <td> | '''Examples''' <b>Summary</b> | </td> <td>Returns the arc sine of the argument* {{Code|math:log(100)}} returns {{Code|2}}.</td> </tr> |} <tr> <td> =Additional Functions=  <b>Rules</b> ==math:e== </td> {| width='100%' <td>If <code>$arg</code> is |-| width='120' | '''Signatures'''|{{Func|math:e||xs:double}}|-| '''Summary'''|Returns the empty sequence, {{Code|xs:double}} value of the function returns the empty sequence.mathematical constant <br /i>Otherwise the result is the arc sine of <code>$arge</codei>, returned as an angle in radians in the range -π/2 to +π/whose lexical representation is 2.<br /> 718281828459045.|- </td> | '''Examples''' </tr> |</table> * {{Code|5*math:e()}} returns {{Code|13.591409142295225}}.|} <h2>==math:acos</h2> sinh==<table> <tr> <td {| width="90"> '100%'|- <b>| width='120' | '''Signatures</b> </td> ''' <td> <code> <b>|{{Func|math:acos</b>($sinh|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> | '''Summary''' |Returns the hyperbolic sine of {{Code|$arg}}.<br/tr> <tr> <td> <b>Summary</b> </td> <td>Returns If {{Code|$arg}} is the arc cosine of empty sequence, the argumentempty sequence is returned.<br /td> </tr> Otherwise the result is the hyperbolic sine of {{Code|$arg}}. <tr> |- <td> | '''Examples''' <b>Rules</b> | </td> <td>If <code>$arg</code> is the empty sequence, the function * {{Code|math:sinh(0)}} returns the empty sequence{{Code|0}}.<br />Otherwise the result is the arc cosine of <code>|} ==math:cosh=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:cosh|$arg</code>, returned as an angle in radians in as xs:double?|xs:double?}}|-| '''Summary'''|Returns the range 0 to +πhyperbolic cosine of {{Code|$arg}}.<br /> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> Otherwise the result is the hyperbolic cosine of {{Code|$arg}}. </tr> |-</table> | '''Examples''' |<h2>* {{Code|math:atan</h2> cosh(0)}} returns {{Code|1}}.|}<table> <tr> ==math:tanh== <td {| width="90"> '100%' <b>|-| width='120' | '''Signatures</b> </td> <td> ''' <code> <b>|{{Func|math:atan</b>(tanh|$arg as xs:double?) as |xs:double?</code> }}|-| '''Summary''' |Returns the hyperbolic tangent of {{Code|$arg}}.<br /> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns Otherwise the result is the arc hyperbolic tangent of the argument{{Code|$arg}}.</td> </tr> |-| '''Examples''' <tr> | <td> * {{Code|math:tanh(100)}} returns {{Code|1}}. <b>Rules</b> |} </td> <td>If <code>==math:crc32== {| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:crc32|$arg<string as xs:string?|xs:hexBinary?}}<br /code> is |-| '''Summary'''|Calculates the empty sequence, CRC32 check sum of the function returns the empty sequencegiven {{Code|$string}}.<br />Otherwise the result If an empty sequence is supplied, the arc tangent of <code>$arg</code>, empty sequence is returned as an angle in radians in the range -π/2 to +π/2.<br /> </td> |- </tr> | '''Examples'''</table> | <h2>* {{Code|math:atan2</h2> <table> <tr> <td width=crc32("90"> <b>Signatures</b> )}} returns {{Code|'00000000'}}. </td> * {{Code|math:crc32("BaseX")}} returns {{Code|'4C06FC7F'}}. <td> |} <code> <b>math:atan2</b>($arg1 as xs=Changelog= ; Version 9.1* Updated:double?, $arg2 as xs[[#math:double?) as xscrc32|math:double?</code> crc32]] can be called with empty sequence. <br /> </td> ; Version 7.5* Moved: [[Random Module#random:integer|math:random]] and [[Random Module#random:uuid|math:uuid]] have been moved to [[Random Module]]. </tr> <tr> <td> <b>Summary</b> </td> ; Version 7.3 <td>Returns the arc tangent of the first argument divided by the second argument, the result being in * Added: [[#math:crc32|math:crc32]] and [[Random Module#random:uuid|math:uuid]] have been adopted from the range -π/2 to +π/2 radians.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>$arg1</code> is the empty sequence, the function returns the empty sequence.<br />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 +π.<br /> </td> </tr> </table> <h2>math:pow</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:pow</b>($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the first argument raised to the power of the second argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>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 /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:pow(2, 3)</code> returns <code>8</code>.<br /> </td> </tr> </table> <h2>math:exp</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:exp</b>($arg as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns <i>e</i> raised to the power of the argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>$arg</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 /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:exp(1)</code> returns <i>e</i>.<br /> </td> </tr> </table> <h2>math:log</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:log</b>($arg as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the natural logarithm of the argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>$arg</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 /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:log(math:e())</code> returns <code>1</code>.<br /> </td> </tr> </table> <h2>math:log10</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:log10</b>($arg as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the base 10 logarithm of the argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>$arg</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 /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:log(100)</code> returns <code>2</code>.<br /> </td> </tr> </table> <h2>math:random</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:random</b>() as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns a random value.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>This function returns a random <code>xs:double</code> value between <code>0.0</code> and <code>1.0</code>.<br /> </td> </tr> </table> <h2>math:sinh</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:sinh</b>($arg as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the hyperbolic sine of the argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the hyperbolic sine of <code>$arg</code>.<br /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:sinh(0)</code> returns <code>0</code>.<br /> </td> </tr> </table> <h2>math:cosh</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:cosh</b>($arg as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the hyperbolic cosine of the argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>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 /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:cosh(0)</code> returns <code>1</code>.<br /> </td> </tr> </table> <h2>math:tanh</h2> <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:tanh</b>($arg as xs:double?) as xs:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the hyperbolic tangent of the argument.</td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the hyperbolic tangent of <code>$arg</code>.<br /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>math:tanh(100)</code> returns <code>1</code>.<br /> </td> </tr> </table> <div id="footer"> &copy; 2006-10 <a href="http://www.informatik.uni-konstanz.de/en/groups/dbis" target="top"> BaseX; DBIS, U Konstanz &nbsp;</a> <!-- echo "Updated on ".(gmdate('Y/m/d', filectime($_SERVER[SCRIPT_NAME]))); --> <a href='http://twitter.com/home?status=http%3A%2F%2Fwww.basex.org' target='_blank'><img border='0' alt='twitter' src='gfx/twitter.png'/></a> <a href='http://facebook.com/sharer.php?u=http%3A%2F%2Fwww.basex.org' target='_blank'><img border='0' alt='facebook' src='gfx/facebook.png'/></a> <a href='http://del.icio.us/post?url=http%3A%2F%2Fwww.basex.org' target='_blank'><img border='0' alt='delicio.us' src='gfx/deliciousobsolete Utility Module.png'/></a> <br/>&nbsp;
Bureaucrats, editor, reviewer, Administrators
13,551

edits

Navigation menu