Changes

Jump to navigation Jump to search
5,456 bytes removed ,  14:39, 16 April 2019
no edit summary
<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:[http://www.w3.org/TR/xpath-functions-1130/ 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=<table> All functions in this module are assigned to the <tr> <td width="90"code> <bnowiki>Signatures<http:/b> </td> <td> <code> <b>www.w3.org/2005/xpath-functions/math:pi</bnowiki>() as xs:double</code> namespace, which is statically bound to the {{Code|math}} prefix.<br /> </td> </tr> =W3 Functions= <tr> <td> ==math:pi== <b>Summary</b> {| width='100%' </td> |- <td>Returns the | width='120' | '''Signatures'''|{{Func|math:pi||xs:double}}|-| '''Summary'''|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}}.* {{Code|60 * (math:pi() div 180)}} converts an angle of 60 degrees to radians.|} </td> <td>This function returns the <code>xs==math:double</code> value whose lexical representation is 3.141592653589793.<br /> sqrt== </td> {| width='100%' </tr> |- <tr> <td> <b>Examples</b> </td> | width='120' | '''Signatures''' <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 If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<codebr />60 * (mathOtherwise the result is the {{Code|xs:pi() div 180)</code> converts an angle double}} value of the mathematical square root of 60 degrees to radians{{Code|$arg}}.<br /> </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> ''' <td>|Returns the value sine of the mathematical constant <i>e{{Code|$arg}}, expressed in radians.<br/i>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> </tr> <tr> <td> Otherwise the result is the sine of {{Code|$arg}}, treated as an angle in radians. <b>Rules</b> |} </td> <td>This function returns the <code>xs==math:double</code> value whose lexical representation is 2.718281828459045.<br /> cos=={| width='100%' </td> |- </tr> | width='120' | '''Signatures''' <tr> |{{Func|math:cos|$arg as xs:double?|xs:double?}} <td> |- <b>Examples</b> | '''Summary''' </td> <td>The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>|Returns the cosine of {{Code|$arg}}, expressed in radians.<br /> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /td> Otherwise the result is the cosine of {{Code|$arg}}, treated as an angle in radians. </tr> |}</table> <h2>==math:sqrt</h2> tan==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> </td> ''' <td> <code> <b>|{{Func|math:sqrt</b>(tan|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> </td> ''' <td>|Returns the square root tangent of the argument{{Code|$arg}}, expressed in radians.<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 of the mathematical square root of <code>tangent of {{Code|$arg</code>}}, treated as an angle in radians.<br /> </td> |}  </tr> </table> <h2>==math:sin</h2> asin==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> </td> <td> ''' <code> <b>|{{Func|math:sin</b>(asin|$arg as xs:double?) as |xs:double?</code> }} |-| '''Summary'''|Returns the arc sine 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 sine of the argument{{Code|$arg}}, expressed returned as an angle in radians.<in the range -π/td> <2 to +π/tr> 2. <tr> |} <td> <b>Rules</b> ==math:acos== </td> {| width='100%' <td>If <code>|-| width='120' | '''Signatures'''|{{Func|math:acos|$arg</code> is the empty sequenceas xs:double?|xs:double?}}|-| '''Summary'''|Returns the arc cosine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the sine arc cosine of <code>{{Code|$arg</code>}}, treated returned as an angle in radiansin the range 0 to +π.<br /> </td> |} </tr> </table> <h2>==math:cos</h2> atan==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math:cos</b>(|{{Func|math:atan|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>Summary</b> | '''Summary''' </td> <td>|Returns the cosine arc tangent of the argument, expressed in radians{{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 cosine 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:tan</h2> atan2==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>|{{Func|math:tan</b>(atan2|$ arg1 as xs:double?) , $arg2 as xs:double|xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> </td> ''' <td>|Returns the 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> <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%'|-| width='120' | '''Signatures''' <td>If <code>|{{Func|math:pow|$arg</code> is the empty sequencearg1 as xs:double?, the function returns the empty sequence.<br />Otherwise the result is the tangent of <code>$arg</code>, treated as an angle in radiansarg2 as xs:double|xs:double?}}|-| '''Summary'''|Returns {{Code|$arg1}} raised to the power of {{Code|$arg2}}.<br /> If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br /td> Otherwise the result is the {{Code|$arg1}} raised to the power of {{Code|$arg2}}. </tr> |-</table> | '''Examples''' |<h2>* {{Code|math:asin</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:asin</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> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<trbr /> Otherwise the result is the value of <tdi> <b>Summarye</bi> </td> <td>Returns the arc sine raised to the power of the argument{{Code|$arg}}.|-| '''Examples'''|* {{Code|math:exp(1)}} returns </tdi> e</tri> .|} <tr> <td> ==math:log== <b>Rules</b> {| width='100%' </td> |- <td>If <code>$| width='120' | '''Signatures'''|{{Func|math:log|$arg</code> is as xs:double?|xs:double?}}|-| '''Summary'''|Returns the natural logarithm of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the arc sine of natural logarithm (base <codei>$arge</codei>, returned as an angle in radians in the range -π/2 to +π/2) of {{Code|$arg}}.<br /> </td> |- </tr> | '''Examples'''</table> | <h2>* {{Code|math:log(math:acos</h2> e())}} returns {{Code|1}}.|}<table> <tr> ==math:log10== <td {| width="90"> '100%' <b>|-| width='120' | '''Signatures</b> </td> <td> ''' <code> <b>|{{Func|math:acos</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 arc cosine of empty sequence, the argumentempty sequence is returned.<br /td> </tr> Otherwise the result is the base 10 logarithm of {{Code|$arg}}. <tr> |-| '''Examples''' <td> | <b>Rules</b> * {{Code|math:log(100)}} returns {{Code|2}}. </td> |} <td>If <code>$arg</code> is the empty sequence, the function returns =Additional Functions= ==math:e=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:e||xs:double}}|-| '''Summary'''|Returns the empty sequence.<br />Otherwise {{Code|xs:double}} value of the result is the arc cosine of mathematical constant <codei>$arge</codei>, returned as an angle in radians in the range 0 to +πwhose lexical representation is 2.718281828459045.<br /> </td> |- </tr> | '''Examples'''</table> | <h2>* {{Code|5*math:atan</h2> e()}} returns {{Code|13.591409142295225}}.|}<table> <tr> ==math:sinh== <td {| width="90"> '100%' <b>Signatures</b> |- </td> <td> <code> | width='120' | '''Signatures''' <b>|{{Func|math:atan</b>(sinh|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> ''' </td> <td>|Returns the arc tangent hyperbolic sine of the argument{{Code|$arg}}.<br/td> </tr> <tr> <td> <b>Rules</b> </td> <td>If <code>{{Code|$arg</code> }} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the arc tangent hyperbolic sine of <code>{{Code|$arg</code>, returned as an angle in radians in the range -π/2 to +π/2}}.<br /> </td> |- </tr> | '''Examples'''</table> | <h2>* {{Code|math:atan2</h2> sinh(0)}} returns {{Code|0}}.<table> |} <tr> <td width="90"> =math:cosh== <b>Signatures</b> {| width='100%' </td> |- <td> | width='120' | '''Signatures''' <code> <b>|{{Func|math:atan2</b>(cosh|$arg1 arg as xs:double?, $arg2 as |xs:double?) as xs:double?</code> }} <br /> |- </td> | '''Summary''' |Returns the hyperbolic cosine of {{Code|$arg}}.<br/tr> <tr> <td> <b>SummaryIf {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /b> </td> <td>Returns Otherwise the result is the arc tangent hyperbolic cosine of the first argument divided by the second argument, the result being in the range -π/2 to +π/2 radians{{Code|$arg}}.</td> </tr> |-| '''Examples''' <tr> | <td> * {{Code|math:cosh(0)}} returns {{Code|1}}. <b>Rules</b> |} </td> <td>If <code>==math:tanh=={| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:tanh|$arg1<arg as xs:double?|xs:double?}}|-| '''Summary'''|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 arc hyperbolic tangent of <code>{{Code|$arg1</code> divided by <code>$arg2</code>, returned as an angle in radians in the range arg}}.|-π to +π.<br /> </td> | '''Examples'''| </tr> * {{Code|math:tanh(100)}} returns {{Code|1}}.</table> |} <h2>==math:pow</h2> crc32== <table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math:pow</b>($arg1 |{{Func|math:crc32|$string as xs:doublestring?, $arg2 as |xs:double?) as xs:doublehexBinary?</code> }}<br /> </td> |- </tr> <tr> <td> <b>| '''Summary</b> ''' </td> <td>Returns |Calculates the first argument raised to the power CRC32 check sum of the second argumentgiven {{Code|$string}}.<br/td> If an empty sequence is supplied, the empty sequence is returned. </tr> |- <tr> | '''Examples''' <td> | <b>Rules</b> </td> <td>If <code>$arg1</code> is the empty sequence, the function * {{Code|math:crc32("")}} returns the empty sequence{{Code|'00000000'}}.<br />Otherwise the result is the <code>$arg1</code> raised to the power of <code>$arg2</code>* {{Code|math:crc32("BaseX")}} returns {{Code|'4C06FC7F'}}.<br /> </td> |} </tr> <tr> =Changelog= <td> <b>Examples</b> ; Version 9.1 </td> <td>The expression <code>* Updated: [[#math:pow(2, 3)</code> returns <code>8</code>crc32|math:crc32]] can be called with empty sequence.<br /> </td> </tr> ; Version 7.5</table> <h2>* Moved: [[Random Module#random:integer|math:random]] and [[Random Module#random:uuid|math:exp</h2> uuid]] have been moved to [[Random Module]].<table> <tr> ; Version 7.3 <td width="90"> <b>Signatures</b> </td> <td> <code> <b>* Added: [[#math:exp</b>($arg as xscrc32|math:crc32]] and [[Random Module#random:double?) as xsuuid|math:double?</code> <br /> </td> </tr> <tr> <td> <b>Summary</b> </td> <td>Returns <i>e</i> raised to uuid]] have been adopted from 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,550

edits

Navigation menu