@approx(x:numeric, y:numeric)    ; listable

The function call can also be written with the special syntax

       (x ~ y)

note that the parenthesis are mandatory.

This predicate returns true if

       abs((x - y)/max(x, y)) <  $APPROX_RATIO

The predefined variable $APPROX_RATIO is initalized to 0.1 so (x ~ y) means x and y differ by less than 10%. By changing the value of the variable , one changes the level of approximation for the following calls to @approx.

Notice that using this function to check if a number is near zero is a bad idea: (x ~ 0) results in the comparaison of 1 or -1 (as a result of abs(x)/x) even if x is zero.

If one argument is a tab and the other is a scalar u, the scalar argument is extended to tab if (all elements of the extension are equal to u) and the predicate returns true if it hold pointwise for all elements of the tabs. For example

       (tab[1, 2] ~ 1.02)

returns false because we don’t have (2 ~ 1.02).