# Changes

,  16:29, 3 December 2010
Created page with "<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..."
<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 <a href="http://www.w3.org/TR/xpath-functions-11/">Functions and Operators Specification</a> of the upcoming XQuery 1.1 Recommendation.</p>

<h2>math:pi</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:pi</b>() as xs:double</code>
<br />
</td>
</tr>
<tr>
<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>

<h2>math:e</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:e</b>() as xs:double</code>
<br />
</td>
</tr>
<tr>
<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>

<h2>math:sqrt</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:sqrt</b>(\$arg as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<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>

<h2>math:sin</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:sin</b>(\$arg as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<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>

<h2>math:cos</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:cos</b>(\$arg as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<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>

<h2>math:tan</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:tan</b>(\$ as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<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>

<h2>math:asin</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:asin</b>(\$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.</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>

<h2>math:acos</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:acos</b>(\$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.</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>

<h2>math:atan</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:atan</b>(\$arg as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<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>

<h2>math:atan2</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:atan2</b>(\$arg1 as xs:double?, \$arg2 as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<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>

<h2>math:pow</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:pow</b>(\$arg1 as xs:double?, \$arg2 as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</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>

<h2>math:exp</h2>
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>math:exp</b>(\$arg as xs:double?) as xs:double?</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</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>

<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]))); -->