XPath/XQuery tan function


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


as xs:double?
) as xs:double?


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


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 specification of the tan function applied to 64-bit binary floating point values.


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.

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

The expression 1 div math:tan(math:pi() div 2) returns 0.0e0.

The expression 1 div math:tan(-math:pi() div 2) returns -0.0e0.

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

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').


The treatment of the invalidOperation and underflow exceptions is defined in .

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