Difference between revisions of "Math Module"

From BaseX Documentation
Jump to navigation Jump to search
(42 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Math Module=
+
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 [http://www.w3.org/TR/xpath-functions-30/ Functions and Operators Specification] of the upcoming XQuery 3.0 Recommendation, and some additional ones have been added in this module.
  
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
+
=Conventions=
[http://www.w3.org/TR/xpath-functions-11/ Functions and Operators Specification] of the upcoming XQuery 1.1 Recommendation.  
+
 
+
All functions in this module are assigned to the <code><nowiki>http://www.w3.org/2005/xpath-functions/math</nowiki></code> namespace, which is statically bound to the {{Code|math}} prefix.<br/>
==math:pi==  
+
 
{|  
+
=W3 Functions=
| width="90" | <b>Signatures</b>
+
 
| <code> <b>math:pi'''() as xs:double</code> 
+
==math:pi==
|-
+
{| width='100%'
| <b>Summary</b>
+
|-
|Returns the value of the mathematical constant π.
+
| width='120' | '''Signatures'''
|-
+
|{{Func|math:pi||xs:double}}
| <b>Rules</b>
+
|-
|This function returns the <code>xs:double</code> value whose lexical representation is 3.141592653589793.  
+
| '''Summary'''
|-
+
|Returns the {{Code|xs:double}} value of the mathematical constant π whose lexical representation is 3.141592653589793.
| <b>Examples</b>
+
|-
|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.  
+
| '''Examples'''
 +
|
 +
* {{Code|2*math:pi()}} returns {{Code|6.283185307179586e0}}.
 +
* {{Code|60 * (math:pi() div 180)}} converts an angle of 60 degrees to radians.
 
|}
 
|}
+
 
==math:e==  
+
==math:sqrt==
{|
+
{| width='100%'
| width="90" | <b>Signatures</b>
 
| <code> <b>math:e'''() as xs:double</code>
 
 
|-
 
|-
| <b>Summary</b>
+
| width='120' | '''Signatures'''
|Returns the value of the mathematical constant <i>e</i>.
+
|{{Func|math:sqrt|$arg as xs:double?|xs:double?}}
 
|-
 
|-
| <b>Rules</b>  
+
| '''Summary'''
|This function returns the <code>xs:double</code> value whose lexical representation is 2.718281828459045.  
+
|Returns the square root of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the {{Code|xs:double}} value of the mathematical square root of {{Code|$arg}}.
 +
|}
 +
 
 +
==math:sin==
 +
{| width='100%'
 
|-
 
|-
| <b>Examples</b>
+
| width='120' | '''Signatures'''
|The expression <code>5*math:e()</code> returns <code>13.591409142295225</code>.
+
|{{Func|math:sin|$arg as xs:double?|xs:double?}}
|}
 
 
==math:sqrt==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:sqrt'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the square root of the argument.
+
|Returns the sine of the {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the sine of {{Code|$arg}}, treated as an angle in radians.
 +
|}
 +
 
 +
==math:cos==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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>.
+
|{{Func|math:cos|$arg as xs:double?|xs:double?}}
|}
 
 
==math:sin==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:sin'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the sine of the argument, expressed in radians.
+
|Returns the cosine of {{Code|$arg}}, expressed in radians.<br/>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.
 +
|}
 +
 
 +
==math:tan==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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.
+
|{{Func|math:tan|$arg as xs:double?|xs:double?}}
|}
 
 
==math:cos==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:cos'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the cosine of the argument, expressed in radians.
+
|Returns the tangent of {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the tangent of {{Code|$arg}}, treated as an angle in radians.
 +
|}
 +
 
 +
==math:asin==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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.
+
|{{Func|math:asin|$arg as xs:double?|xs:double?}}
|}
 
 
==math:tan==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:tan'''($ as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the tangent of the argument, expressed in radians.
+
|Returns the arc sine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc sine of {{Code|$arg}}, returned as an angle in radians in the range -π/2 to +π/2.
 +
|}
 +
 
 +
==math:acos==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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.
+
|{{Func|math:acos|$arg as xs:double?|xs:double?}}
|}
 
 
==math:asin==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:asin'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the arc sine of the argument.
+
|Returns the arc cosine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc cosine of {{Code|$arg}}, returned as an angle in radians in the range 0 to +π.
 +
|}
 +
 
 +
==math:atan==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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.
+
|{{Func|math:atan|$arg as xs:double?|xs:double?}}
|}
 
 
==math:acos==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:acos'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the arc cosine of the argument.
+
|Returns the arc tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of {{Code|$arg}}, returned as an angle in radians in the range -π/2 to +π/2.
 +
|}
 +
 
 +
==math:atan2==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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 +π.
+
|{{Func|math:atan2|$arg1 as xs:double?, $arg2 as xs:double|xs:double?}}
|}
 
 
==math:atan==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:atan'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>  
+
| '''Summary'''
|Returns the arc tangent of the argument.
+
|Returns the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, the result being in the range -π/2 to +π/2 radians.<br/>If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, returned as an angle in radians in the range -π to +π.
 +
|}
 +
 
 +
==math:pow==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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.
+
|{{Func|math:pow|$arg1 as xs:double?, $arg2 as xs:double|xs:double?}}
|}
 
 
==math:atan2==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:atan2'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>
+
| '''Summary'''
|Returns the arc tangent of the first argument divided by the second argument, the result being in the range -π/2 to +π/2 radians.
+
|Returns {{Code|$arg1}} raised to the power of {{Code|$arg2}}.<br/>If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the {{Code|$arg1}} raised to the power of {{Code|$arg2}}.
 
|-
 
|-
|<b>Rules</b>
+
| '''Examples'''
|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 +π.  
+
|
|}  
+
* {{Code|math:pow(2, 3)}} returns {{Code|8}}.
+
|}
==math:pow==  
+
 
{|
+
==math:exp==
  |-
+
{| width='100%'
|width="90" | <b>Signatures</b>
 
| <code> <b>math:pow'''($arg1 as xs:double?, $arg2 as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>
+
| width='120' | '''Signatures'''
|Returns the first argument raised to the power of the second argument.
+
|{{Func|math:exp|$arg as xs:double?|xs:double?}}
 
|-
 
|-
|<b>Rules</b>  
+
| '''Summary'''
|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>.  
+
|Returns <i>e</i> raised to the power of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the value of <i>e</i> raised to the power of {{Code|$arg}}.
 
|-
 
|-
|<b>Examples</b>
+
| '''Examples'''
|The expression <code>math:pow(2, 3)</code> returns <code>8</code>.  
+
|
|}  
+
* {{Code|math:exp(1)}} returns <i>e</i>.
+
|}
==math:exp==  
+
 
{|
+
==math:log==
  |-
+
{| width='100%'
|width="90" | <b>Signatures</b>
 
| <code> <b>math:exp'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>
+
| width='120' | '''Signatures'''
|Returns <i>e</i> raised to the power of the argument.
+
|{{Func|math:log|$arg as xs:double?|xs:double?}}
 
|-
 
|-
|<b>Rules</b>
+
| '''Summary'''
|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>.  
+
|Returns the natural logarithm of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the natural logarithm (base <i>e</i>) of {{Code|$arg}}.
 
|-
 
|-
|<b>Examples</b>
+
| '''Examples'''
|The expression <code>math:exp(1)</code> returns <i>e</i>.  
+
|
|}  
+
* {{Code|math:log(math:e())}} returns {{Code|1}}.
+
|}
==math:log==  
+
 
{|
+
==math:log10==
  |-
+
{| width='100%'
|width="90" | <b>Signatures</b>
 
| <code> <b>math:log'''($arg as xs:double?) as xs:double?</code>
 
 
|-
 
|-
|<b>Summary</b>
+
| width='120' | '''Signatures'''
|Returns the natural logarithm of the argument.
+
|{{Func|math:log10|$arg as xs:double?|xs:double?}}
 
|-
 
|-
|<b>Rules</b>
+
| '''Summary'''
|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>.  
+
|Returns the base 10 logarithm of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the base 10 logarithm of {{Code|$arg}}.
 
|-
 
|-
|<b>Examples</b>
+
| '''Examples'''
|The expression <code>math:log(math:e())</code> returns <code>1</code>.  
+
|
|}  
+
* {{Code|math:log(100)}} returns {{Code|2}}.
+
|}
==math:log10==  
+
 
{|
+
=Additional Functions=
  |-
+
 
|width="90" | <b>Signatures</b>
+
==math:e==
| <code> <b>math:log10'''($arg as xs:double?) as xs:double?</code>
+
{| width='100%'
     
 
 
|-
 
|-
|<b>Summary</b>
+
| width='120' | '''Signatures'''
|Returns the base 10 logarithm of the argument.
+
|{{Func|math:e||xs:double}}
 
|-
 
|-
|<b>Rules</b>
+
| '''Summary'''
|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>.  
+
|Returns the {{Code|xs:double}} value of the mathematical constant <i>e</i> whose lexical representation is 2.718281828459045.
 
|-
 
|-
|<b>Examples</b>
+
| '''Examples'''
|The expression <code>math:log(100)</code> returns <code>2</code>.  
+
|
|}  
+
* {{Code|5*math:e()}} returns {{Code|13.591409142295225}}.
+
|}
==math:random==  
+
 
{|
+
==math:sinh==
  |-
+
{| width='100%'
|width="90" | <b>Signatures</b>
 
| <code> <b>math:random'''() as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>
+
| width='120' | '''Signatures'''
|Returns a random value.
+
|{{Func|math:sinh|$arg as xs:double?|xs:double?}}
 
|-
 
|-
|<b>Rules</b>
+
| '''Summary'''
|This function returns a random <code>xs:double</code> value between <code>0.0</code> and <code>1.0</code>.
+
|Returns the hyperbolic sine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic sine of {{Code|$arg}}.
|}
 
 
==math:sinh==
 
{|  
 
  |-
 
|width="90" | <b>Signatures</b>
 
| <code> <b>math:sinh'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>
+
| '''Examples'''
|Returns the hyperbolic sine of the argument.
+
|
 +
* {{Code|math:sinh(0)}} returns {{Code|0}}.
 +
|}
 +
 
 +
==math:cosh==
 +
{| width='100%'
 
|-
 
|-
|<b>Rules</b>
+
| width='120' | '''Signatures'''
|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>.
+
|{{Func|math:cosh|$arg as xs:double?|xs:double?}}
 
|-
 
|-
|<b>Examples</b>
+
| '''Summary'''
|The expression <code>math:sinh(0)</code> returns <code>0</code>.
+
|Returns the hyperbolic cosine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic cosine of {{Code|$arg}}.
|}  
 
 
==math:cosh==
 
{|
 
  |-
 
|width="90" | <b>Signatures</b>  
 
| <code> <b>math:cosh'''($arg as xs:double?) as xs:double?</code>
 
     
 
 
|-
 
|-
|<b>Summary</b>
+
| '''Examples'''
|Returns the hyperbolic cosine of the argument.
+
|
 +
* {{Code|math:cosh(0)}} returns {{Code|1}}.
 +
|}
 +
 
 +
==math:tanh==
 +
{| width='100%'
 +
|-
 +
| width='120' | '''Signatures'''
 +
|{{Func|math:tanh|$arg as xs:double?|xs:double?}}
 
|-
 
|-
|<b>Rules</b>
+
| '''Summary'''
|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>.  
+
|Returns the hyperbolic tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic tangent of {{Code|$arg}}.
 
|-
 
|-
|<b>Examples</b>
+
| '''Examples'''
|The expression <code>math:cosh(0)</code> returns <code>1</code>.  
+
|
|}  
+
* {{Code|math:tanh(100)}} returns {{Code|1}}.
+
|}
==math:tanh==  
+
 
{|
+
==math:crc32==
  |-
+
 
|width="90" | <b>Signatures</b>
+
{| width='100%'
|      <code> <b>math:tanh'''($arg as xs:double?) as xs:double?</code>
 
 
|-
 
|-
|<b>Summary</b>  
+
| width='120' | '''Signatures'''
|Returns the hyperbolic tangent of the argument.
+
|{{Func|math:crc32|$string as xs:string?|xs:hexBinary?}}<br />
 
|-
 
|-
|<b>Rules</b>
+
| '''Summary'''
|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>.  
+
|Calculates the CRC32 check sum of the given {{Code|$string}}.<br/>If an empty sequence is supplied, the empty sequence is returned.
 
|-
 
|-
|<b>Examples</b>
+
| '''Examples'''
|The expression <code>math:tanh(100)</code> returns <code>1</code>.  
+
|
|}
+
* {{Code|math:crc32("")}} returns {{Code|'00000000'}}.
[[Category:XQuery]]
+
* {{Code|math:crc32("BaseX")}} returns {{Code|'4C06FC7F'}}.
 +
|}
 +
 
 +
=Changelog=
 +
 
 +
; Version 9.1
 +
* Updated: [[#math:crc32|math:crc32]] can be called with empty sequence.
 +
 
 +
; Version 7.5
 +
* Moved: [[Random Module#random:integer|math:random]] and [[Random Module#random:uuid|math:uuid]] have been moved to [[Random Module]].
 +
 
 +
; Version 7.3
 +
* Added: [[#math:crc32|math:crc32]] and [[Random Module#random:uuid|math:uuid]] have been adopted from the obsolete Utility Module.

Revision as of 13:39, 16 April 2019

The math XQuery Module defines functions to perform mathematical operations, such as pi, asin and acos. Most functions are specified in the Functions and Operators Specification of the upcoming XQuery 3.0 Recommendation, and some additional ones have been added in this module.

Conventions

All functions in this module are assigned to the http://www.w3.org/2005/xpath-functions/math namespace, which is statically bound to the math prefix.

W3 Functions

math:pi

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

math:sqrt

Signatures math:sqrt($arg as xs:double?) as xs:double?
Summary Returns the square root of $arg.
If $arg is the empty sequence, the empty sequence is returned.
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 $arg, expressed in radians.
If $arg is the empty sequence, the empty sequence is returned.
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 $arg, expressed in radians.
If $arg is the empty sequence, the empty sequence is returned.
Otherwise the result is the cosine of $arg, treated as an angle in radians.

math:tan

Signatures math:tan($arg as xs:double?) as xs:double?
Summary Returns the tangent of $arg, expressed in radians.
If $arg is the empty sequence, the empty sequence is returned.
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 $arg.
If $arg is the empty sequence, the empty sequence is returned.
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 $arg.
If $arg is the empty sequence, the empty sequence is returned.
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 $arg.
If $arg is the empty sequence, the empty sequence is returned.
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 $arg1 divided by $arg2, the result being in the range -π/2 to +π/2 radians.
If $arg1 is the empty sequence, the empty sequence is returned.
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 $arg1 raised to the power of $arg2.
If $arg1 is the empty sequence, the empty sequence is returned.
Otherwise the result is the $arg1 raised to the power of $arg2.
Examples
  • 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 $arg.
If $arg is the empty sequence, the empty sequence is returned.
Otherwise the result is the value of e raised to the power of $arg.
Examples
  • math:exp(1) returns e.

math:log

Signatures math:log($arg as xs:double?) as xs:double?
Summary Returns the natural logarithm of $arg.
If $arg is the empty sequence, the empty sequence is returned.
Otherwise the result is the natural logarithm (base e) of $arg.
Examples
  • 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 $arg.
If $arg is the empty sequence, the empty sequence is returned.
Otherwise the result is the base 10 logarithm of $arg.
Examples
  • math:log(100) returns 2.

Additional Functions

math:e

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

math:sinh

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

math:cosh

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

math:tanh

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

math:crc32

Signatures math:crc32($string as xs:string?) as xs:hexBinary?
Summary Calculates the CRC32 check sum of the given $string.
If an empty sequence is supplied, the empty sequence is returned.
Examples
  • math:crc32("") returns '00000000'.
  • math:crc32("BaseX") returns '4C06FC7F'.

Changelog

Version 9.1
  • Updated: math:crc32 can be called with empty sequence.
Version 7.5
Version 7.3