math:cos

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

Signature

math:cos( 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.

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

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

Notes

The treatment of the invalidOperation exception is defined in Arithmetic operators on numeric values.

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

Examples

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

The expression math:cos(0) returns 1.0e0.

The expression math:cos(-0.0e0) returns 1.0e0.

The expression math:cos(math:pi() div 2) returns 0.0e0 (approximately).

The expression math:cos(-math:pi() div 2) returns 0.0e0 (approximately).

The expression math:cos(math:pi()) returns -1.0e0 (approximately).

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

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

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