[SciPy-user] numerical accuracy

Robert Kern robert.kern at gmail.com
Wed Dec 21 06:29:36 CST 2005

Steve Schmerler wrote:

> If a and c are "equal" regarding the numerical accury (a - c < 1e-16), 
> aren't they supposed to be considered equal when comparing them?

No, for floating point numbers there are several possible ways to define
"equality". Python uses "the bit patterns are equal". You also probably want to
use a relative tolerance (roughly, (a-c)/a < eps) rather than the absolute
tolerance that you describe. Use scipy.allclose() for full control.

Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the SciPy-user mailing list