Re: Fuzzy comparison



On Thu, 6 Jul 2006, Abstract Dissonance wrote:

I'm trying to come up with a simple function that will allow me to compare
two real numbers in a "fuzzy" way. That is, I don't if a < b or b < a as

What do you mean when you say
I don't if .. or .. as ...

long as they are within some tolerance but I also want the function to "act"
like the normal comparison in most respects(i.e., g(x) = x).

Actually, for my purposes I want a function f(x) to have the properties for
two real numbers a and b,

if |b - a| < e then 0 <= f(b - a)

If |x| < e =~ 2.718..., then 0 <= f(x).

if a <(>) b then f(a-b) <=(>=) f(b-a)

Bah, the <(>) is redundant
if a < b, then f(a-b) <= f(b-a)
if 0 < x, then f(-x) <= f(x)
if 0 > x, then 0 < -x, f(--x) <= f(-x)
f(-x) >= f(x), same as the (>).

if a > b, then f(a-b) >= f(b-a)
if 0 > x, then f(-x) >= f(x)

f'(x) >= 0 for all x
f(x) ~= x for large x.
I'd also like to have f'(0) = 0 or ~= 0.

f(x) = x if e <= |x|
f(x) = 0 if |x| < e

.