I am trying to use the min function on numbers.
The min() function works on sequences, not on numbers directly. Instead of:
min($a, $b)
try:
min(($a, $b))
Otherwise the function expects $b to be the optional collation argument (which needs to be a string).