Changes

Jump to navigation Jump to search
5,468 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 <a href="http:[http://www.w3.org/TR/xpath-functions-1130/">Functions and Operators Specification</a> ] of the upcoming XQuery 13.1 0 Recommendation, and some additional ones have been added in this module=Conventions= All functions in this module are assigned to the </pcode> <h2nowiki>http://www.w3.org/2005/xpath-functions/math:pi</h2nowiki> <table/code> <tr> <td width="90"> <b>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> <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> </td> <td>This function * {{Code|2*math:pi()}} returns the <code>xs:double</code> value whose lexical representation is 3{{Code|6.141592653589793283185307179586e0}}.<br /> </td> </tr> <tr> <td> <b>Examples</b> </td> <td>The expression <code>2** {{Code|60 * (math:pi()</code> returns <code>6.283185307179586e0</code>.<br />The expression <code>60 * (math:pi() div 180)</code> converts div 180)}} converts an angle of 60 degrees to radians.<br /> </td> |}  </tr> </table> <h2>==math:e</h2> sqrt==<table> <tr> <td {| width="90"> '100%'|- <b>| width='120' | '''Signatures</b> </td> ''' <td> <code> <b>|{{Func|math:e</b>() sqrt|$arg as xs:double</code> ?|xs:double?}} <br /> |- </td> | '''Summary''' |Returns the square root 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 value of result is the {{Code|xs:double}} value of the mathematical constant <i>e</i>square root of {{Code|$arg}}.</td> </tr> |} <tr> <td> ==math:sin== <b>Rules</b> {| width='100%'|- </td> | width='120' | '''Signatures''' <td>This function returns the <code>|{{Func|math:sin|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the sine of the {{Code|$arg}}, expressed in radians.<br/code> value whose lexical representation If {{Code|$arg}} is 2.718281828459045the empty sequence, the empty sequence is returned.<br /> Otherwise the result is the sine of {{Code|$arg}}, treated as an angle in radians. </td> |} </tr> <tr> ==math:cos== <td> {| width='100%' <b>Examples</b> |- </td> | width='120' | '''Signatures''' <td>The expression |{{Func|math:cos|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the cosine of {{Code|$arg}}, expressed in radians.<code>5*math:e()</code> returns <code>13.591409142295225</codebr/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br /> Otherwise the result is the cosine of {{Code|$arg}}, treated as an angle in radians. </td> </tr> </table> |} <h2>==math:sqrt</h2> tan==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math:sqrt</b>($arg |{{Func|math:tan|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> | '''Summary''' </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> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> ''' </td> <td>|Returns the arc sine of the argument, expressed in radians.</td> </tr> <tr> <td> <b>Rules</b> {{Code|$arg}}.<br/td> <td>If <code>{{Code|$arg</code> }} is the empty sequence, the function returns the empty empty sequenceis returned.<br />Otherwise the result is the arc sine of <code>{{Code|$arg</code>}}, treated returned as an angle in radiansin the range -π/2 to +π/2.<br /> </td> |} </tr> </table> <h2>==math:cos</h2> acos==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>|{{Func|math:cos</b>(acos|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>| '''Summary</b> ''' </td> <td>|Returns the arc cosine of the argument, expressed in radians{{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 cosine of <code>${{Code|$arg</code>}}, treated returned as an angle in radiansin the range 0 to +π.<br /> </td> |} </tr> </table> <h2>==math:tan</h2> atan==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math:tan</b>(|{{Func|math:atan|$ arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> </tr> <tr> <td> <b>Summary</b> </td> | '''Summary''' <td>|Returns the 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 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==math:asin</h2> atan2==<table> {| width='100%' <tr> |- <td | width="90"> '120' | '''Signatures''' <b>Signatures</b> </td> <td> <code> <b>|{{Func|math:asin</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 arc sine tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, the argumentresult 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 arc sine power of <code>{{Code|$argarg2}}.<br/code>, returned as an angle in radians in If {{Code|$arg1}} is the empty sequence, the range -π/2 to +π/2empty 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:acos</h2> pow(2, 3)}} returns {{Code|8}}.|}<table> <tr> ==math:exp== <td {| width="90"> '100%'|- <b>| width='120' | '''Signatures</b> ''' </td> <td> <code> <b>math|{{Func|math:acos</b>(exp|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> | '''Summary''' |Returns </tri> <tr> <td> <b>Summarye</bi> </td> <td>Returns raised to the arc cosine power 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 arc cosine value of <codei>$arge</codei>, returned as an angle in radians in raised to the range 0 to +πpower of {{Code|$arg}}.<br /> </td> |- </tr> | '''Examples'''</table> |* {{Code|math:exp(1)}} returns <h2i>math:atane</h2i> .<table> |} <tr> <td width="90"> =math:log== <b>Signatures</b> {| width='100%' </td> |- <td> | width='120' | '''Signatures''' <code> <b>|{{Func|math:atan</b>(log|$arg as xs:double?) as |xs:double?</code> }} <br /> |- </td> | '''Summary''' |Returns the natural logarithm of {{Code|$arg}}.<br/tr> If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<trbr /> Otherwise the result is the natural logarithm (base <tdi> <b>Summarye</bi> ) of {{Code|$arg}}. </td> |- <td>Returns the arc tangent of the argument.</td> | '''Examples''' </tr> | <tr> <td> * {{Code|math:log(math:e())}} returns {{Code|1}}.|} <b>Rules</b> </td> ==math:log10== <td>If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is {| width='100%'|-| width='120' | '''Signatures'''|{{Func|math:log10|$arg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the arc tangent base 10 logarithm of <code>{{Code|$arg}}.<br/code>, If {{Code|$arg}} is the empty sequence, the empty sequence is returned as an angle in radians in the range -π/2 to +π/2.<br /> Otherwise the result is the base 10 logarithm of {{Code|$arg}}.|- </td> </tr> </table> | '''Examples''' |<h2>* {{Code|math:atan2</h2> log(100)}} returns {{Code|2}}.<table> |} <tr> <td width="90"> Additional Functions= <b>Signatures</b> </td> ==math:e== <td> {| width='100%' <code> |- <b>| width='120' | '''Signatures'''|{{Func|math:atan2</b>($arg1 as e||xs:double?, $arg2 as xs:double?) as }}|-| '''Summary'''|Returns the {{Code|xs:double?}} value of the mathematical constant </codei> e<br /i> whose lexical representation is 2.718281828459045. </td> |- </tr> | '''Examples''' <tr> | <td> * {{Code|5*math:e()}} returns {{Code|13.591409142295225}}. <b>Summary</b> |} </td> <td>Returns the arc tangent of the first argument divided by the second argument, the result being in the range ==math:sinh=={| width='100%'|-π/2 to +π/2 radians.</td> </tr> | width='120' | '''Signatures'''|{{Func|math:sinh|$arg as xs:double?|xs:double?}} <tr> |- <td> | '''Summary''' <b>Rules</b> |Returns the hyperbolic sine of {{Code|$arg}}.<br/td> <td>If <code>{{Code|$arg1</code> arg}} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the arc tangent hyperbolic sine 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:sinh(0)}} returns {{Code|0}}.</table> |} <h2>==math:pow</h2> cosh==<table> {| width='100%' <tr> |- <td | width="90"> <b>'120' | '''Signatures</b> ''' </td> <td> <code> <b>math:pow</b>(|{{Func|math:cosh|$arg1 arg as xs:double?, $arg2 as |xs:double?) as xs:double?</code> }}|- <br /> | '''Summary''' |Returns the hyperbolic cosine 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 first argument raised to the power hyperbolic cosine of the second argument{{Code|$arg}}.</td> </tr> |- <tr> | '''Examples'''| <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</codearg as xs:double?|xs:double?}}|-| '''Summary'''|Returns the hyperbolic tangent of {{Code|$arg}}.<br/> If {{Code|$arg}} is the empty sequence, the function returns the empty sequenceis returned.<br />Otherwise the result is the <code>$arg1</code> raised to the power hyperbolic tangent of <code>{{Code|$arg2</code>arg}}.<br /> </td> |- </tr> <tr> | '''Examples''' <td> | <b>Examples</b> </td> <td>The expression <code>* {{Code|math:powtanh(2, 3100)</code> }} returns <code>8</code>.<br /> {{Code|1}}. </td> |} </tr> </table> <h2>==math:exp</h2> crc32==<table> <tr> {| width='100%'|- <td | width="90"> <b>'120' | '''Signatures</b> ''' |{{Func|math:crc32|$string as xs:string?|xs:hexBinary?}}<br /td> <td> |- <code> | '''Summary''' <b>math:exp</b>(|Calculates the CRC32 check sum of the given {{Code|$arg as xs:double?) as xs:double?string}}.<br/code> If an empty sequence is supplied, the empty sequence is returned. <br /> |- </td> | '''Examples''' </tr> |* {{Code|math:crc32("")}} returns {{Code|'00000000'}}.* {{Code|math:crc32("BaseX")}} returns {{Code|'4C06FC7F'}}.|} <tr> <td> <b>Summary</b> =Changelog= </td> <td>Returns <i>e</i> raised to the power of the argument; Version 9.</td> 1 </tr> * Updated: [[#math:crc32|math:crc32]] can be called with empty sequence. <tr> <td> ; Version 7.5* Moved: [[Random Module#random:integer|math:random]] and [[Random Module#random:uuid|math:uuid]] have been moved to [[Random Module]]. <b>Rules</b> </td> ; Version 7.3 <td>If <code>$arg</code> is the empty sequence, the function returns the empty sequence.<br />Otherwise the result is * Added: [[#math:crc32|math:crc32]] and [[Random Module#random:uuid|math:uuid]] have been adopted from 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