This module contains all the functions part of the
W3C XPath and XQuery Functions and Operators 3.0
section "4.7 Trigonometric and exponential functions".

```
acos
($arg as xs:double?) as xs:double? external
```
Returns the arc cosine of the argument, the result being in the range zero to + π radians. |

```
asin
($arg as xs:double?) as xs:double? external
```
Returns the arc sine of the argument, the result being in the range - π /2 to + π /2 radians. |

```
atan
($arg as xs:double?) as xs:double? external
```
Returns the arc tangent of the argument, the result being in the range - π /2 to + π /2 radians. |

```
atan2
($y as xs:double, $x as xs:double) as xs:double external
```
Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis, the result being in the range - π to + π . |

```
cos
($theta as xs:double?) as xs:double? external
```
Returns the cosine of the argument, expressed in radians. |

```
exp
($arg as xs:double?) as xs:double? external
```
Returns the value of e x . |

```
exp10
($arg as xs:double?) as xs:double? external
```
Returns the value of 10 x . |

```
log
($arg as xs:double?) as xs:double? external
```
Returns the natural logarithm of the argument. |

```
log10
($arg as xs:double?) as xs:double? external
```
Returns the base-ten logarithm of the argument. |

```
pi
() as xs:double external
```
Returns an approximation to the mathematical constant π . |

```
pow
($x as xs:double?, $y as numeric) as xs:double? external
```
Returns the result of raising the first argument to the power of the second. |

```
sin
($theta as xs:double?) as xs:double? external
```
Returns the sine of the argument, expressed in radians. |

```
sqrt
($arg as xs:double?) as xs:double? external
```
Returns the non-negative square root of the argument. |

```
tan
($theta as xs:double?) as xs:double? external
```
Returns the tangent of the argument, expressed in radians. |

declare function math:acos($arg as xs:double?) as xs:double? external

Returns the arc cosine of the argument, the result being in the range zero to
+`π` radians.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the arc cosine of `$`

`θ`,
treated as an angle in radians, as defined in the `acos`

function applied to 64-bit binary floating point
values.

The treatment of the `invalidOperation`

exception is defined in

If `$arg`

is `NaN`

, or if its absolute value is greater than one,
then the result is `NaN`

.

In other cases the result is an `xs:double`

value representing an angle
`θ` in radians in the range `0 <= $`

`θ````
<=
+
```

`π`.

- arg as xs:double

- xs:double?

declare function math:asin($arg as xs:double?) as xs:double? external

Returns the arc sine of the argument, the result being in the range
-`π`/2 to +`π`/2 radians.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the arc sine of `$`

`θ`,
treated as an angle in radians, as defined in the `asin`

function applied to 64-bit binary floating point
values.

The treatment of the `invalidOperation`

and `underflow`

exceptions
is defined in

If `$arg`

is positive or negative zero, the result is `$arg`

.

If `$arg`

is `NaN`

, or if its absolute value is greater than one,
then the result is `NaN`

.

In other cases the result is an `xs:double`

value representing an angle
`θ` in radians in the range -`π````
/2 <=
$
```

`θ`` <= +`

`π``/2`

.

- arg as xs:double

- xs:double?

declare function math:atan($arg as xs:double?) as xs:double? external

Returns the arc tangent of the argument, the result being in the range
-`π`/2 to +`π`/2 radians.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the arc tangent of `$`

`θ`,
treated as an angle in radians, as defined in the `atan`

function applied to 64-bit binary floating point
values.

The treatment of the `underflow`

exception is defined in

If `$arg`

is positive or negative zero, the result is `$arg`

.

If `$arg`

is `NaN`

then the result is `NaN`

.

In other cases the result is an `xs:double`

value representing an angle
`θ` in radians in the range -`π````
/2 <=
$
```

`θ`` <= +`

`π``/2`

.

- arg as xs:double

- xs:double?

declare function math:atan2($y as xs:double, $x as xs:double) as xs:double external

Returns the angle in radians subtended at the origin by the point on a plane
with coordinates (x, y) and the positive x-axis, the result being in the range
-`π` to +`π`.

This function is

The result is the value of `atan2(y, x)`

as defined in the
`atan2`

function applied
to 64-bit binary floating point values.

The treatment of the `underflow`

exception is defined in

If `NaN`

then the result is `NaN`

.

If `$y`

is positive and `$x`

is positive and finite, then
(subject to rules for overflow, underflow and approximation)
the value of `atan2($y, $x)`

is `atan($y div $x)`

.

If `$y`

is positive and `$x`

is negative and finite, then
(subject to the same caveats)
the value of `atan2($y, $x)`

is `π` `- atan($y div $x)`

.

Some results for special values of the arguments are shown in the examples below.

- y as xs:double

- x as xs:double

- xs:double

declare function math:cos($theta as xs:double?) as xs:double? external

Returns the cosine of the argument, expressed in radians.

This function is

If `$`

`θ` is the empty sequence, the function returns the empty
sequence.

If `$`

`θ` is positive or negative infinity, or `NaN`

,
then the result is `NaN`

.

Otherwise the result is the cosine of `$`

`θ`,
treated as an angle in radians, as defined in the `cos`

function applied to 64-bit binary floating point
values.

The treatment of the `invalidOperation`

exception is defined in

If `$`

`θ` is positive or negative zero, the result is
`$`

`θ`.

If `$`

`θ` is positive or negative infinity, or `NaN`

,
then the result is `NaN`

.

Otherwise the result is always in the range -1.0e0 to +1.0e0

- theta as xs:double

- xs:double?

declare function math:exp($arg as xs:double?) as xs:double? external

Returns the value of `e`^{x}.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the mathematical constant `e`
raised to the power of `$arg`

, as defined in the `exp`

function applied to 64-bit binary floating point
values.

The treatment of overflow and underflow is defined in

- arg as xs:double

- xs:double?

declare function math:exp10($arg as xs:double?) as xs:double? external

Returns the value of `10`

^{x}.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is ten raised to the power of `$arg`

,
as defined in the `exp10`

function applied to 64-bit binary floating point values.

The treatment of overflow and underflow is defined in

- arg as xs:double

- xs:double?

declare function math:log($arg as xs:double?) as xs:double? external

Returns the natural logarithm of the argument.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the natural logarithm of `$arg`

, as
defined in the `log`

function applied to 64-bit binary floating point values.

The treatment of `divideByZero`

and `invalidOperation`

exceptions
is defined in `NaN`

.

- arg as xs:double

- xs:double?

declare function math:log10($arg as xs:double?) as xs:double? external

Returns the base-ten logarithm of the argument.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the base-10 logarithm of `$arg`

, as
defined in the `log10`

function applied to 64-bit binary floating point values.

The treatment of `divideByZero`

and `invalidOperation`

exceptions
is defined in `NaN`

.

- arg as xs:double

- xs:double?

declare function math:pi() as xs:double external

Returns an approximation to the mathematical constant `π`.

This function is

This function returns the `xs:double`

value whose lexical representation is
3.141592653589793e0

The expression `2*math:pi()`

returns `6.283185307179586e0`

.

The expression `60 * (math:pi() div 180)`

converts an angle of 60 degrees
to radians.

- xs:double

declare function math:pow($x as xs:double?, $y as numeric) as xs:double? external

Returns the result of raising the first argument to the power of the second.

This function is

If `$x`

is the empty sequence, the function returns the empty sequence.

If `$y`

is an instance of `xs:integer`

, the result is
`$x`

raised to the power of `$y`

as defined in the `pown`

function applied to a
64-bit binary floating point value and an integer.

Otherwise `$y`

is converted to an `xs:double`

by numeric
promotion, and the result is the value of `$x`

raised to the power of
`$y`

as defined in the `pow`

function applied to two 64-bit binary floating point values.

The treatment of the `divideByZero`

and `invalidOperation`

exceptions is defined in

- x as xs:double

- y as numeric

- xs:double?

declare function math:sin($theta as xs:double?) as xs:double? external

Returns the sine of the argument, expressed in radians.

This function is

If `$`

`θ` is the empty sequence, the function returns the empty
sequence.

Otherwise the result is the sine of `$`

`θ`,
treated as an angle in radians, as defined in the `sin`

function applied to 64-bit binary floating point
values.

The treatment of the `invalidOperation`

and `underflow`

exceptions
is defined in

If `$`

`θ` is positive or negative zero, the result is
`$`

`θ`.

If `$`

`θ` is positive or negative infinity, or `NaN`

,
then the result is `NaN`

.

Otherwise the result is always in the range -1.0e0 to +1.0e0

- theta as xs:double

- xs:double?

declare function math:sqrt($arg as xs:double?) as xs:double? external

Returns the non-negative square root of the argument.

This function is

If `$arg`

is the empty sequence, the function returns the empty sequence.

Otherwise the result is the mathematical non-negative square root of
`$arg`

as defined in the `squareRoot`

function applied to 64-bit binary floating point values.

The treatment of the `invalidOperation`

exception is defined in `NaN`

.

If `$arg`

is positive or negative zero, positive infinity, or
`NaN`

, then the result is `$arg`

. (Negative zero is the only
case where the result can have negative sign)

- arg as xs:double

- xs:double?

declare function math:tan($theta as xs:double?) as xs:double? external

Returns the tangent of the argument, expressed in radians.

This function is

If `$`

`θ` is the empty sequence, the function returns the empty
sequence.

Otherwise the result is the tangent of `$`

`θ`,
treated as an angle in radians, as defined in the `tan`

function applied to 64-bit binary floating point
values.

The treatment of the `invalidOperation`

and `underflow`

exceptions
is defined in

If `$`

`θ` is positive or negative infinity, or `NaN`

,
then the result is `NaN`

.

- theta as xs:double

- xs:double?