Difference between revisions of "Math Module"

From BaseX Documentation
Jump to navigation Jump to search
m (wikified... phew!)
Line 1: Line 1:
 
=Math Module=
 
=Math Module=
  
<p>The math module defines extension functions to perform mathematical operations, such as <code>pi</code>, <code>asin</code> and <code>acos</code>. All functions are preceded by the <code>math:</code> prefix. Some of the functions have also been specified in the
+
The math module defines extension functions to perform mathematical operations, such as <code>pi</code>, <code>asin</code> and <code>acos</code>. All functions are preceded by the <code>math:</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>
+
[http://www.w3.org/TR/xpath-functions-11/ Functions and Operators Specification] of the upcoming XQuery 1.1 Recommendation.  
 
   
 
   
 
==math:pi==  
 
==math:pi==  
<table>
+
{|
  <tr>
+
| '''Signatures'''
    <td width="90">
+
| <code> '''math:pi'''() as xs:double</code>
      <b>Signatures</b>
+
|-
    </td>
+
| '''Summary'''
    <td>
+
|Returns the value of the mathematical constant π.
      <code>  
+
|-
        <b>math:pi</b>() as xs:double</code>  
+
| '''Rules'''
      <br />
+
|This function returns the <code>xs:double</code> value whose lexical representation is 3.141592653589793.  
    </td>
+
|-
  </tr>
+
| '''Examples'''
  <tr>
+
|The expression <code>2*math:pi()</code> returns <code>6.283185307179586e0</code>.The expression <code>60 * (math:pi() div 180)</code> converts an angle of 60 degrees to radians.  
    <td>
+
|}
      <b>Summary</b>
 
    </td>
 
    <td>Returns the value of the mathematical constant π.</td>
 
  </tr>
 
  <tr>
 
    <td>
 
      <b>Rules</b>
 
    </td>
 
    <td>This function returns the <code>xs:double</code> value whose lexical representation is 3.141592653589793.<br />
 
    </td>
 
  </tr>
 
  <tr>
 
    <td>
 
      <b>Examples</b>
 
    </td>
 
    <td>The expression <code>2*math:pi()</code> returns <code>6.283185307179586e0</code>.<br />The expression <code>60 * (math:pi() div 180)</code> converts an angle of 60 degrees to radians.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:e==  
 
==math:e==  
<table>
+
{|
  <tr>
+
| '''Signatures'''
    <td width="90">
+
| <code> '''math:e'''() as xs:double</code>  
      <b>Signatures</b>
+
|-
    </td>
+
| '''Summary'''
    <td>
+
|Returns the value of the mathematical constant <i>e</i>.
      <code>  
+
|-
        <b>math:e</b>() as xs:double</code>  
+
| '''Rules'''
      <br />
+
|This function returns the <code>xs:double</code> value whose lexical representation is 2.718281828459045.  
    </td>
+
|-
  </tr>
+
| '''Examples'''
  <tr>
+
|The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>.  
    <td>
+
|}
      <b>Summary</b>
 
    </td>
 
    <td>Returns the value of the mathematical constant <i>e</i>.</td>
 
  </tr>
 
  <tr>
 
    <td>
 
      <b>Rules</b>
 
    </td>
 
    <td>This function returns the <code>xs:double</code> value whose lexical representation is 2.718281828459045.<br />
 
    </td>
 
  </tr>
 
  <tr>
 
    <td>
 
      <b>Examples</b>
 
    </td>
 
    <td>The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:sqrt==  
 
==math:sqrt==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:sqrt'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:sqrt</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the square root of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|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>.  
  <tr>
+
|}
    <td>
 
      <b>Summary</b>
 
    </td>
 
    <td>Returns the square root 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 <code>xs:double</code> value of the mathematical square root of <code>$arg</code>.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:sin==  
 
==math:sin==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:sin'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:sin</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the sine of the argument, expressed in radians.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|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.  
  <tr>
+
|}
    <td>
 
      <b>Summary</b>
 
    </td>
 
    <td>Returns the sine of the argument, expressed in radians.</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 sine of <code>$arg</code>, treated as an angle in radians.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:cos==  
 
==math:cos==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:cos'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:cos</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the cosine of the argument, expressed in radians.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|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.  
  <tr>
+
|}
    <td>
 
      <b>Summary</b>
 
    </td>
 
    <td>Returns the cosine of the argument, expressed in radians.</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 cosine of <code>$arg</code>, treated as an angle in radians.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:tan==  
 
==math:tan==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:tan'''($ as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:tan</b>($ as xs:double?) as xs:double?</code>  
+
|Returns the tangent of the argument, expressed in radians.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|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.  
  <tr>
+
|}
    <td>
 
      <b>Summary</b>
 
    </td>
 
    <td>Returns the tangent of the argument, expressed in radians.</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 tangent of <code>$arg</code>, treated as an angle in radians.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:asin==  
 
==math:asin==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:asin'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:asin</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the arc sine of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|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.  
  <tr>
+
|}
    <td>
 
      <b>Summary</b>
 
    </td>
 
    <td>Returns the arc 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 arc sine of <code>$arg</code>, returned as an angle in radians in the range -π/2 to +π/2.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:acos==  
 
==math:acos==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:acos'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:acos</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the arc cosine of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc cosine of <code>$arg</code>, returned as an angle in radians in the range 0 to +π.  
  <tr>
+
|}
    <td>
 
      <b>Summary</b>
 
    </td>
 
    <td>Returns the arc 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 arc cosine of <code>$arg</code>, returned as an angle in radians in the range 0 to +π.<br />
 
    </td>
 
  </tr>
 
</table>
 
 
   
 
   
 
==math:atan==  
 
==math:atan==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:atan'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:atan</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the arc tangent of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc tangent of <code>$arg</code>, returned as an angle in radians in the range -π/2 to +π/2.  
  <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==  
 
==math:atan2==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:atan2'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:atan2</b>($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
+
|Returns the arc tangent of the first argument divided by the second argument, the result being in the range -π/2 to +π/2 radians.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|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 +π.  
  <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==  
 
==math:pow==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:pow'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:pow</b>($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
+
|Returns the first argument raised to the power of the second argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg1</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the <code>$arg1</code> raised to the power of <code>$arg2</code>.  
  <tr>
+
|-
    <td>
+
|'''Examples'''
      <b>Summary</b>
+
|The expression <code>math:pow(2, 3)</code> returns <code>8</code>.  
    </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==  
 
==math:exp==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:exp'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:exp</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns <i>e</i> raised to the power of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the value of <i>e</i> raised to the power of <code>$arg</code>.  
  <tr>
+
|-
    <td>
+
|'''Examples'''
      <b>Summary</b>
+
|The expression <code>math:exp(1)</code> returns <i>e</i>.  
    </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==  
 
==math:log==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:log'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
|-
    <td>
+
|'''Summary'''
      <code>  
+
|Returns the natural logarithm of the argument.
        <b>math:log</b>($arg as xs:double?) as xs:double?</code>  
+
|-
      <br />
+
|'''Rules'''
    </td>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the natural logarithm (base <i>e</i>) of <code>$arg</code>.  
  </tr>
+
|-
  <tr>
+
|'''Examples'''
    <td>
+
|The expression <code>math:log(math:e())</code> returns <code>1</code>.  
      <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==  
 
==math:log10==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:log10'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:log10</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the base 10 logarithm of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the base 10 logarithm of <code>$arg</code>.  
  <tr>
+
|-
    <td>
+
|'''Examples'''
      <b>Summary</b>
+
|The expression <code>math:log(100)</code> returns <code>2</code>.  
    </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==  
 
==math:random==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:random'''() as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:random</b>() as xs:double?</code>  
+
|Returns a random value.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|This function returns a random <code>xs:double</code> value between <code>0.0</code> and <code>1.0</code>.  
  <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==  
 
==math:sinh==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:sinh'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:sinh</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the hyperbolic sine of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic sine of <code>$arg</code>.  
  <tr>
+
|-
    <td>
+
|'''Examples'''
      <b>Summary</b>
+
|The expression <code>math:sinh(0)</code> returns <code>0</code>.  
    </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==  
 
==math:cosh==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
| <code> '''math:cosh'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
     
    <td>
+
|-
      <code>  
+
|'''Summary'''
        <b>math:cosh</b>($arg as xs:double?) as xs:double?</code>  
+
|Returns the hyperbolic cosine of the argument.
      <br />
+
|-
    </td>
+
|'''Rules'''
  </tr>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic cosine of <code>$arg</code>.  
  <tr>
+
|-
    <td>
+
|'''Examples'''
      <b>Summary</b>
+
|The expression <code>math:cosh(0)</code> returns <code>1</code>.  
    </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==  
 
==math:tanh==  
<table>
+
{|
   <tr>
+
   |-
    <td width="90">
+
|'''Signatures'''
      <b>Signatures</b>
+
|      <code> '''math:tanh'''($arg as xs:double?) as xs:double?</code>  
    </td>
+
|-
    <td>
+
|'''Summary'''
      <code>  
+
|Returns the hyperbolic tangent of the argument.
        <b>math:tanh</b>($arg as xs:double?) as xs:double?</code>  
+
|-
      <br />
+
|'''Rules'''
    </td>
+
|If <code>$arg</code> is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic tangent of <code>$arg</code>.  
  </tr>
+
|-
  <tr>
+
|'''Examples'''
    <td>
+
|The expression <code>math:tanh(100)</code> returns <code>1</code>.  
      <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]]
 
[[Category:XQuery]]
[[Category:Wikify]]
 

Revision as of 22:53, 9 December 2010

Math Module

The math module defines extension functions to perform mathematical operations, such as pi, asin and acos. All functions are preceded by the math: prefix. Some of the functions have also been specified in the Functions and Operators Specification of the upcoming XQuery 1.1 Recommendation.

math:pi

Signatures math:pi() as xs:double
Summary Returns the value of the mathematical constant π.
Rules This function returns the xs:double value whose lexical representation is 3.141592653589793.
Examples The expression 2*math:pi() returns 6.283185307179586e0.The expression 60 * (math:pi() div 180) converts an angle of 60 degrees to radians.

math:e

Signatures math:e() as xs:double
Summary Returns the value of the mathematical constant e.
Rules This function returns the xs:double value whose lexical representation is 2.718281828459045.
Examples The expression 5*math:e() returns 13.591409142295225.

math:sqrt

Signatures math:sqrt($arg as xs:double?) as xs:double?
Summary Returns the square root of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the xs:double value of the mathematical square root of $arg.

math:sin

Signatures math:sin($arg as xs:double?) as xs:double?
Summary Returns the sine of the argument, expressed in radians.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the sine of $arg, treated as an angle in radians.

math:cos

Signatures math:cos($arg as xs:double?) as xs:double?
Summary Returns the cosine of the argument, expressed in radians.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the cosine of $arg, treated as an angle in radians.

math:tan

Signatures math:tan($ as xs:double?) as xs:double?
Summary Returns the tangent of the argument, expressed in radians.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the tangent of $arg, treated as an angle in radians.

math:asin

Signatures math:asin($arg as xs:double?) as xs:double?
Summary Returns the arc sine of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc sine of $arg, returned as an angle in radians in the range -π/2 to +π/2.

math:acos

Signatures math:acos($arg as xs:double?) as xs:double?
Summary Returns the arc cosine of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc cosine of $arg, returned as an angle in radians in the range 0 to +π.

math:atan

Signatures math:atan($arg as xs:double?) as xs:double?
Summary Returns the arc tangent of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc tangent of $arg, returned as an angle in radians in the range -π/2 to +π/2.

math:atan2

Signatures math:atan2($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?
Summary Returns the arc tangent of the first argument divided by the second argument, the result being in the range -π/2 to +π/2 radians.
Rules If $arg1 is the empty sequence, the function returns the empty sequence.Otherwise the result is the arc tangent of $arg1 divided by $arg2, returned as an angle in radians in the range -π to +π.

math:pow

Signatures math:pow($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?
Summary Returns the first argument raised to the power of the second argument.
Rules If $arg1 is the empty sequence, the function returns the empty sequence.Otherwise the result is the $arg1 raised to the power of $arg2.
Examples The expression math:pow(2, 3) returns 8.

math:exp

Signatures math:exp($arg as xs:double?) as xs:double?
Summary Returns e raised to the power of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the value of e raised to the power of $arg.
Examples The expression math:exp(1) returns e.

math:log

Signatures math:log($arg as xs:double?) as xs:double?
Summary Returns the natural logarithm of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the natural logarithm (base e) of $arg.
Examples The expression math:log(math:e()) returns 1.

math:log10

Signatures math:log10($arg as xs:double?) as xs:double?
Summary Returns the base 10 logarithm of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the base 10 logarithm of $arg.
Examples The expression math:log(100) returns 2.

math:random

Signatures math:random() as xs:double?
Summary Returns a random value.
Rules This function returns a random xs:double value between 0.0 and 1.0.

math:sinh

Signatures math:sinh($arg as xs:double?) as xs:double?
Summary Returns the hyperbolic sine of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic sine of $arg.
Examples The expression math:sinh(0) returns 0.

math:cosh

Signatures math:cosh($arg as xs:double?) as xs:double?
Summary Returns the hyperbolic cosine of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic cosine of $arg.
Examples The expression math:cosh(0) returns 1.

math:tanh

Signatures math:tanh($arg as xs:double?) as xs:double?
Summary Returns the hyperbolic tangent of the argument.
Rules If $arg is the empty sequence, the function returns the empty sequence.Otherwise the result is the hyperbolic tangent of $arg.
Examples The expression math:tanh(100) returns 1.