For further distribution to my comment and clarification, the documentation gives you the key.
Math.cos (double)
The calculated result must be within 1 ulp of the exact result. The results should be semi-monotonous.
. ulp is the difference between a coded floating-point number and the next number that can be encoded in a data type, in this case double.
If the result should be within 1 ulp, this means that the result can be one of at most two floating point values.
It follows that the only way that the calculation does not stop is that the input of one of these numbers will give you another number. But since the function is half-monotonous, this means that this cannot be. Otherwise, you will have a higher value of the two as input, giving you a lower value as the output, and a lower value will give you a higher result as the output. Half-monotonous means that it moves in only one direction (this is done very simply and somewhat inaccurately).
source share