math:tan

Returns the tangent of the argument. The argument is an angle in radians.

Signature

math:tan( as xs:double?) as xs:double?

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

If $θ is the empty sequence, the function returns the empty sequence.

Otherwise the result is the tangent of $θ (which is treated as an angle in radians) as defined in the [IEEE 754-2008] specification of the tan function applied to 64-bit binary floating point values.

Notes

The treatment of the invalidOperation and underflow exceptions is defined in Arithmetic operators on numeric values.

If $θ is positive or negative infinity, or NaN, then the result is NaN.

Examples

The expression math:tan(()) returns ().

The expression math:tan(0) returns 0.0e0.

The expression math:tan(-0.0e0) returns -0.0e0.

The expression math:tan(math:pi() div 4) returns 1.0e0 (approximately).

The expression math:tan(-math:pi() div 4) returns -1.0e0 (approximately).

The expression 1 div math:tan(math:pi() div 2) returns 0.0e0 (approximately). (Mathematically, tan(π/2) is positive infinity. But because math:pi() div 2 returns an approximation, the result of math:tan(math:pi() div 2) will be a large but finite number.)

The expression 1 div math:tan(-math:pi() div 2) returns -0.0e0 (approximately). (Mathematically, tan(-π/2) is negative infinity. But because -math:pi() div 2 returns an approximation, the result of math:tan(-math:pi() div 2) will be a large but finite negative number.)

The expression math:tan(math:pi()) returns 0.0e0 (approximately).

The expression math:tan(xs:double('NaN')) returns xs:double('NaN').

The expression math:tan(xs:double('INF')) returns xs:double('NaN').

The expression math:tan(xs:double('-INF')) returns xs:double('NaN').