Math Functions
Math Functions
Functions in the math namespace (http://www.w3.org/2005/xpath-functions/math), prefix math:.
All math functions accept xs:double arguments and return xs:double.
Constants
| Function | Description |
|---|---|
math:pi() |
Returns π (3.141592653589793) |
Exponential and Logarithmic
| Function | Description |
|---|---|
math:exp($x) |
Returns e^x |
math:exp10($x) |
Returns 10^x |
math:log($x) |
Returns natural logarithm ln(x) |
math:log10($x) |
Returns base-10 logarithm log₁₀(x) |
math:pow($base, $exp) |
Returns base^exp |
math:sqrt($x) |
Returns square root √x |
Trigonometric
| Function | Description |
|---|---|
math:sin($θ) |
Sine (radians) |
math:cos($θ) |
Cosine (radians) |
math:tan($θ) |
Tangent (radians) |
math:asin($x) |
Arc sine → radians |
math:acos($x) |
Arc cosine → radians |
math:atan($x) |
Arc tangent → radians |
math:atan2($y, $x) |
Two-argument arc tangent → radians |
Examples
math:sqrt(2) (: 1.4142135623730951 :)
math:pi() * 2 (: 6.283185307179586 :)
math:pow(2, 10) (: 1024 :)
math:sin(math:pi() div 2) (: 1 :)
math:log(math:exp(1)) (: 1 :)