[Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Jonathan Taylor
Hi, When solving a quadratic equation I get that alpha = -3.78336776728e-31 which I believe to be far below machine precision: finfo(float).eps 2.2204460492503131e-16 But an if statement like: if alpha == 0: ... does not catch this. Is there a better way to check for things that are

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Robert Kern
On Mon, Jan 19, 2009 at 14:43, Jonathan Taylor jonathan.tay...@utoronto.ca wrote: Hi, When solving a quadratic equation I get that alpha = -3.78336776728e-31 which I believe to be far below machine precision: finfo(float).eps 2.2204460492503131e-16 But an if statement like: if alpha ==

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Jonathan Taylor
Interesting. That makes sense and I suppose that also explains why there is no function to do this sort of thing for you. Jon. On Mon, Jan 19, 2009 at 3:55 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 14:43, Jonathan Taylor jonathan.tay...@utoronto.ca wrote: Hi,

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Charles R Harris
On Mon, Jan 19, 2009 at 7:23 PM, Jonathan Taylor jonathan.tay...@utoronto.ca wrote: Interesting. That makes sense and I suppose that also explains why there is no function to do this sort of thing for you. A combination of relative and absolute errors is another common solution, i.e., test

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Robert Kern
On Mon, Jan 19, 2009 at 22:09, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 7:23 PM, Jonathan Taylor jonathan.tay...@utoronto.ca wrote: Interesting. That makes sense and I suppose that also explains why there is no function to do this sort of thing for you. A

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Charles R Harris
On Mon, Jan 19, 2009 at 9:17 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 22:09, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 7:23 PM, Jonathan Taylor jonathan.tay...@utoronto.ca wrote: Interesting. That makes sense and I suppose

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Robert Kern
On Mon, Jan 19, 2009 at 23:36, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 9:17 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 22:09, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 7:23 PM, Jonathan Taylor

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Charles R Harris
On Mon, Jan 19, 2009 at 10:48 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 23:36, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 9:17 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 22:09, Charles R Harris

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Robert Kern
On Tue, Jan 20, 2009 at 00:21, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 10:48 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 23:36, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 9:17 PM, Robert Kern

Re: [Numpy-discussion] Testing for close to zero?

2009-01-19 Thread Charles R Harris
On Mon, Jan 19, 2009 at 11:26 PM, Robert Kern robert.k...@gmail.com wrote: On Tue, Jan 20, 2009 at 00:21, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jan 19, 2009 at 10:48 PM, Robert Kern robert.k...@gmail.com wrote: On Mon, Jan 19, 2009 at 23:36, Charles R Harris