Method on @infsup: sdist (X, Y)

Compute the signed distance between two intervals as sets.

The signed distance for closed real intervals is the minimum distance between each pair of numbers, where the result’s sign indicates whether x precedes y (negative), y precedes x (positive), or x intersects y (zero). That is, the signed distance equals zero if a number can be found in both intervals. Otherwise the signed distance is the positive or negative size of the gap between both intervals on the real number lane.

If any interval is empty, the result is NaN. For interval arrays the result is computed entry-wise.

Accuracy: The result is correctly-rounded (away from zero).

sdist (infsup (0, 6), infsup (7, 20))
  ⇒ ans =  -1
sdist (infsup (3, 5), infsup (0, 1))
  ⇒ ans =  2

See also: @infsup/idist, @infsup/hdist.

Package: interval