Difference between revisions of "Math Module"

From BaseX Documentation
Jump to navigation Jump to search
Line 7: Line 7:
 
{|  
 
{|  
 
  | width="90" | <b>Signatures</b>  
 
  | width="90" | <b>Signatures</b>  
  | <code> <b>math:pi'''() as xs:double</code>   
+
  | <code> <b>math:pi</b>() as xs:double</code>   
 
  |-
 
  |-
 
  | <b>Summary</b>  
 
  | <b>Summary</b>  
Line 22: Line 22:
 
{|  
 
{|  
 
| width="90" | <b>Signatures</b>  
 
| width="90" | <b>Signatures</b>  
| <code> <b>math:e'''() as xs:double</code>  
+
| <code> <b>math:e</b>() as xs:double</code>  
 
|-
 
|-
 
| <b>Summary</b>  
 
| <b>Summary</b>  
Line 38: Line 38:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:sqrt'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:sqrt</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 52: Line 52:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:sin'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:sin</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 66: Line 66:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:cos'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:cos</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 80: Line 80:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:tan'''($ as xs:double?) as xs:double?</code>  
+
| <code> <b>math:tan</b>($ as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 94: Line 94:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:asin'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:asin</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 108: Line 108:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:acos'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:acos</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 122: Line 122:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:atan'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:atan</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 136: Line 136:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:atan2'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
+
| <code> <b>math:atan2</b>($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 150: Line 150:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:pow'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
+
| <code> <b>math:pow</b>($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 167: Line 167:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:exp'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:exp</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 184: Line 184:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:log'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:log</b>($arg as xs:double?) as xs:double?</code>  
 
|-
 
|-
 
|<b>Summary</b>  
 
|<b>Summary</b>  
Line 200: Line 200:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:log10'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:log10</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 217: Line 217:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:random'''() as xs:double?</code>  
+
| <code> <b>math:random</b>() as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 231: Line 231:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:sinh'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:sinh</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 248: Line 248:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
| <code> <b>math:cosh'''($arg as xs:double?) as xs:double?</code>  
+
| <code> <b>math:cosh</b>($arg as xs:double?) as xs:double?</code>  
 
        
 
        
 
|-
 
|-
Line 265: Line 265:
 
   |-
 
   |-
 
|width="90" | <b>Signatures</b>  
 
|width="90" | <b>Signatures</b>  
|      <code> <b>math:tanh'''($arg as xs:double?) as xs:double?</code>  
+
|      <code> <b>math:tanh</b>($arg as xs:double?) as xs:double?</code>  
 
|-
 
|-
 
|<b>Summary</b>  
 
|<b>Summary</b>  

Revision as of 16:26, 12 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.