[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking for tiny inequalities (was: Re: puzzling Octave behaviour)

From: Bill Denney
Subject: Re: checking for tiny inequalities (was: Re: puzzling Octave behaviour)
Date: Mon, 24 Jul 2006 08:41:42 -0400 (EDT)

On Mon, 24 Jul 2006, Joan Picanyol i Puig wrote:

I need some clarification on the significance and use of eps. According to octave,

   `eps' is the largest relative spacing between any two adjacent
   numbers in the machine's floating point system

Which I understand as "any number smaller than eps is undistinguishable from 0". However, AFAIK, 64-bit double precision floating point permits representing something as small as 10^-323 or so, and although I've done comparisons to some multiple of eps as a threshold to check for 0s, I'm unsure on how would that work if I really needed to work with values around 10^-20.

If you need to work with values around 10^-20, then according to machine precision

a = 10e-20
b = a + a*eps/10

a could equal b

to test if they should equal each other, you would want to do something like

abs(a/b) - 1 < 10*eps

instead of just

a == b

This is because depending on the exact operations used to get from one number to another rounding may have occurred slightly differently.

A slightly different example is that when you compute b and c as follows

b = a + (a*eps)/10
c = a + a*(eps/10)

The following may or may not be true

b == c

because it depends on how machine rounding occurred along the way to the final result. This test returns true on my copy of octave, but the principle is that different methods of getting to the same number may give different results.

Hopefully I made things clearer.


"There is no cure for birth and death other than to enjoy the interval."
  -- George Santayana

reply via email to

[Prev in Thread] Current Thread [Next in Thread]