Changes

Jump to navigation Jump to search
5,420 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.
<p>The math =Conventions= All functions in this module defines extension functions are assigned to perform mathematical operations, such as the <code>pi<nowiki>http://www.w3.org/2005/xpath-functions/math</codenowiki>, </code>asin</code> and <code>acos</code>. All functions are preceded by namespace, which is statically bound to the <code>{{Code|math:}} prefix.<br/code> prefix. Some of the functions have also been specified in the[http://www.w3.org/TR/xpath-functions-11/ Functions and Operators Specification] of the upcoming XQuery 1.1 Recommendation.</p> =W3 Functions= ==math:pi== <table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> |{{Func|math:pi||xs:double}} <td> |- <code> | '''Summary''' <b>math:pi</b>() as |Returns the {{Code|xs:double</code> <br /> }} value of the mathematical constant π whose lexical representation is 3.141592653589793. </td> |- </tr> | '''Examples''' <tr> | <td> <b>Summary</b> </td> <td>Returns the value of the mathematical constant π* {{Code|2*math:pi()}} returns {{Code|6.283185307179586e0}}.</td> </tr> * {{Code|60 * (math:pi() div 180)}} converts an angle of 60 degrees to radians. <tr> |} <td> <b>Rules</b> ==math:sqrt== </td> <td>This function returns the <code>{| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:sqrt|$arg as xs:double?|xs:double</code> value whose lexical representation is 3.141592653589793?}}|-| '''Summary'''|Returns the square root of {{Code|$arg}}.<br /> </td> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /tr> Otherwise the result is the {{Code|xs:double}} value of the mathematical square root of {{Code|$arg}}. <tr> |} <td> <b>Examples</b> ==math:sin=={| width='100%'|- </td> | width='120' | '''Signatures''' <td>The expression <code>2*|{{Func|math:pi()sin|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the sine of the {{Code|$arg}}, expressed in radians.<br/code> returns <code>6.283185307179586e0</code>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />The expression <code>60 * (math:pi() div 180)</code> converts Otherwise the result is the sine of {{Code|$arg}}, treated as an angle of 60 degrees to in radians.<br /> </td> |} </tr> </table> ==math:ecos== <table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math|{{Func|math:cos|$arg as xs:e</b>() as double?|xs:double</code> ?}} <br /> |- </td> | '''Summary''' |Returns the cosine of {{Code|$arg}}, expressed in radians.<br/tr> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<tr> <tdbr /> Otherwise the result is the cosine of {{Code|$arg}}, treated as an angle in radians. <b>Summary</b> |} </td> <td>Returns the value of the mathematical constant <i>e</i>.</td> ==math:tan== </tr> {| width='100%' <tr> |- <td> <b>Rules</b> | width='120' | '''Signatures''' </td> <td>This function returns the <code>|{{Func|math:tan|$arg as xs:double?|xs:double</code> value whose lexical representation is 2.718281828459045?}}|-| '''Summary'''|Returns the tangent 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 tangent of {{Code|$arg}}, treated as an angle in radians. <tr> |} <td> <b>Examples</b> ==math:asin=={| width='100%'|- </td> | width='120' | '''Signatures''' <td>The expression <code>5*|{{Func|math:e()asin|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the arc sine of {{Code|$arg}}.<br/code> returns <code>13.591409142295225</code>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /> </td> </tr> <Otherwise the result is the arc sine of {{Code|$arg}}, returned as an angle in radians in the range -π/2 to +π/table> 2.|} ==math:sqrtacos== <table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> </td> <td> <code> ''' <b>|{{Func|math:sqrt</b>(acos|$arg as xs:double?) as |xs:double?</code> }}|-| '''Summary''' |Returns the arc cosine of {{Code|$arg}}.<br /> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> Otherwise the result is the arc cosine of {{Code|$arg}}, returned as an angle in radians in the range 0 to +π. </tr> |} <tr> <td> ==math:atan== <b>Summary</b> {| width='100%' </td> |- <td>Returns the square root of the argument.</td> | width='120' | '''Signatures''' </tr> |{{Func|math:atan|$arg as xs:double?|xs:double?}} <tr> |- <td> | '''Summary''' <b>Rules</b> |Returns the arc tangent of {{Code|$arg}}.<br/td> <td>If <code>{{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 tangent of the mathematical square root of <code>$arg<{{Code|$arg}}, returned as an angle in radians in the range -π/2 to +π/code>2.<br /> </td> </tr> </table> |} ==math:sinatan2== <table> {| width='100%' <tr> |- <td | width="90"> '120' | '''Signatures''' <b>Signatures</b> </td> <td> <code> <b>|{{Func|math:sin</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 sine arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, the argument, expressed 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> Otherwise the result is the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, returned as an angle in radians in the range -π to +π. <tr> |} <td> <b>Rules</b> ==math:pow=={| width='100%' </td> |- <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 sine 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'''|* {{Code|math:pow(2, 3)}} returns {{Code|8}}.|} ==math:cosexp== <table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> </td> <td> <code> ''' <b>|{{Func|math:cos</b>(exp|$arg as xs:double?) as |xs:double?</code> }}|-| '''Summary''' |Returns <br /i> e</tdi> raised to the power of {{Code|$arg}}.<br/tr> <tr> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<tdbr /> Otherwise the result is the value of <bi>Summarye</bi> raised to the power of {{Code|$arg}}. </td> |- <td>Returns the cosine of the argument, expressed in radians.| '''Examples'''|* {{Code|math:exp(1)}} returns </tdi> e</tri> . <tr> |} <td> <b>Rules</b> ==math:log=={| width='100%' </td> |- <td>If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is the cosine of <code>| width='120' | '''Signatures'''|{{Func|math:log|$arg</code>, treated as an angle in radiansas xs:double?|xs:double?}}|-| '''Summary'''|Returns the natural logarithm of {{Code|$arg}}.<br /> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> Otherwise the result is the natural logarithm (base </tri> e</tablei> ) of {{Code|$arg}}. |-=| '''Examples'''|* {{Code|math:log(math:e())}} returns {{Code|1}}.|} ==math:tanlog10== <table> <tr> <td {| width="90"> '100%'|- <b>| width='120' | '''Signatures</b> </td> ''' <td> <code> <b>|{{Func|math:tan</b>($ log10|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> | '''Summary''' |Returns the base 10 logarithm of {{Code|$arg}}.<br/tr> <tr> <td> <b>Summary</b> </td> <td>Returns If {{Code|$arg}} is the tangent of empty sequence, the argument, expressed in radiansempty sequence is returned.<br /td> </tr> Otherwise the result is the base 10 logarithm of {{Code|$arg}}. <tr> |- <td> | '''Examples''' <b>Rules</b> | </td> <td>If <code>$arg</code> is the empty sequence, the function * {{Code|math:log(100)}} returns the empty sequence{{Code|2}}.<br />Otherwise the result is the tangent of <code>$arg</code>, treated as an angle in radians.<br /> </td> </tr> </table> |} =Additional Functions= ==math:asin=math:e=={| width= '100%'<table> |- <tr> <td | width="90"> '120' | '''Signatures''' <b>Signatures</b> |{{Func|math:e||xs:double}} </td> |- <td> | '''Summary''' |Returns the {{Code|xs:double}} value of the mathematical constant <codei> e<b/i>whose lexical representation is 2.718281828459045.|-| '''Examples'''|* {{Code|5*math:asin</b>e($arg as xs:double?) as xs:double?</code> }} returns {{Code|13.591409142295225}}. <br /> |} </td> </tr> ==math:sinh== <tr> {| width='100%' <td> |-| width='120' | '''Signatures''' <b>Summary</b> |{{Func|math:sinh|$arg as xs:double?|xs:double?}} </td> |- <td>| '''Summary'''|Returns the arc hyperbolic sine of the argument{{Code|$arg}}.<br/td> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /tr> <tr> Otherwise the result is the hyperbolic sine of {{Code|$arg}}. <td> |- <b>Rules</b> | '''Examples''' </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 sine of <code>|} ==math:cosh=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:cosh|$arg</code>, returned as an angle in radians in xs:double?|xs:double?}}|-| '''Summary'''|Returns the range -π/2 to +π/2hyperbolic 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> |-| '''Examples'''|* {{Code|math:cosh(0)}} returns {{Code|1}}.|}</table> ==math:acostanh== <table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> </td> <td> <code> ''' <b>|{{Func|math:acos</b>(tanh|$arg as xs:double?) as |xs:double?</code> }}|- <br /> | '''Summary''' |Returns the hyperbolic tangent of {{Code|$arg}}.<br/td> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /tr> <tr> <td> <b>Summary</b> </td> <td>Returns Otherwise the result is the arc cosine hyperbolic tangent of the argument{{Code|$arg}}.</td> </tr> |- <tr> | '''Examples'''| <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|$argstring 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 If an empty sequence is supplied, the result empty sequence is the arc cosine of <code>$arg</code>, returned as an angle in radians in the range 0 to +π.<br /> returned.|- </td> | '''Examples''' </tr> |</table> * {{Code|math:crc32("")}} returns {{Code|'00000000'}}. ==* {{Code|math:atancrc32("BaseX")}} returns {{Code|'4C06FC7F'}}.|} =Changelog= <table> <tr> ; Version 9.1 <td width="90"> * Updated: [[#math:crc32|math:crc32]] can be called with empty sequence. <b>Signatures</b> </td> ; Version 7.5 <td> <code> <b>* Moved: [[Random Module#random:integer|math:atan</b>($arg as xsrandom]] and [[Random Module#random:double?) as xsuuid|math:double?</code> uuid]] have been moved to [[Random Module]]. <br /> </td> ; Version 7.3 </tr> <tr> <td> <b>Summary</b> </td> <td>Returns the arc 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 arc tangent of <code>$arg</code>, returned as an angle in radians in the range -π/2 to +π/2.<br /> </td> </tr> </table> ==math:atan2== <table> <tr> <td width="90"> <b>Signatures</b> </td> <td> <code> <b>math:atan2</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 arc tangent of the first argument divided by the second argument, the result being in 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> ==math:pow== <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> ==math:exp== <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> ==math:log== <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> ==math:log10== <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> ==math:random== <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> ==math:sinh== <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> ==math:cosh== <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> ==math:tanh== <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/delicious.png'/></a> <br/>&nbsp;[[Category:XQuery* Added: [[#math:crc32|math:crc32]]and [[CategoryRandom Module#random:Wikifyuuid|math:uuid]]have been adopted from the obsolete Utility Module.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu