Available in all subroutines.

Computes the cosine of its argument x, measured in radians.


x - Floating point value representing an angle in radians.

Return Value

Upon successful completion, this function returns the cosine of x.

If x is math.NAN, a NaN will be returned.

If x is ±0, the value 1.0 will be returned.

If x is math.POS_INFINITY or math.NEG_INFINITY, a domain error occurs and a NaN will be returned.


If the x argument is math.POS_INFINITY or math.NEG_INFINITY, then fastly.error will be set to EDOM.


declare local FLOAT;
set = math.cos(math.PI_2);

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.