Difference between revisions of "Math Module"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | =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 | <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 | ||
[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.</p> | ||
− | + | ==math:pi== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 36: | Line 38: | ||
</table> | </table> | ||
− | + | ==math:e== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 70: | Line 72: | ||
</table> | </table> | ||
− | + | ==math:sqrt== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 97: | Line 99: | ||
</table> | </table> | ||
− | + | ==math:sin== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 124: | Line 126: | ||
</table> | </table> | ||
− | + | ==math:cos== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 151: | Line 153: | ||
</table> | </table> | ||
− | + | ==math:tan== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 178: | Line 180: | ||
</table> | </table> | ||
− | + | ==math:asin== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 205: | Line 207: | ||
</table> | </table> | ||
− | + | ==math:acos== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 232: | Line 234: | ||
</table> | </table> | ||
− | + | ==math:atan== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 259: | Line 261: | ||
</table> | </table> | ||
− | + | ==math:atan2== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 286: | Line 288: | ||
</table> | </table> | ||
− | + | ==math:pow== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 320: | Line 322: | ||
</table> | </table> | ||
− | + | ==math:exp== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 354: | Line 356: | ||
</table> | </table> | ||
− | + | ==math:log== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 388: | Line 390: | ||
</table> | </table> | ||
− | + | ==math:log10== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 422: | Line 424: | ||
</table> | </table> | ||
− | + | ==math:random== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 449: | Line 451: | ||
</table> | </table> | ||
− | + | ==math:sinh== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 483: | Line 485: | ||
</table> | </table> | ||
− | + | ==math:cosh== | |
<table> | <table> | ||
<tr> | <tr> | ||
Line 517: | Line 519: | ||
</table> | </table> | ||
− | + | ==math:tanh== | |
<table> | <table> | ||
<tr> | <tr> |
Revision as of 16:33, 3 December 2010
Contents
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
Summary |
Returns a random value. |
Rules |
This function returns a random xs:double value between 0.0 and 1.0 . |
math:sinh
Signatures |
|
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 |
|
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 |
|
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 . |