
Hi, Is there a built-in constant in Haskell (or, if it is compiler-specific, in ghc) that gives the smallest positive floating point number x such that 1+x /= x? Some languages refer to that as double.eps or similar. I need it for numeric algorithms. Thanks, Tamas

Hi, Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp:
the smallest positive floating point number x such that 1+x /= x? That would be the smallest positive number, woudn't it?
Do you mean the smalles postive number x with 1+x /= 1? Greetings, Joachim -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189

On Sat, Sep 30, 2006 at 12:20:16AM +0000, Joachim Breitner wrote:
Hi,
Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp:
the smallest positive floating point number x such that 1+x /= x? That would be the smallest positive number, woudn't it?
Do you mean the smalles postive number x with 1+x /= 1?
Hi Joachim, Specifically, I would be happy with the smallest Double that makes the statement true. I need it as a convergence bound for an iterative algorithm. Anyhow, thanks for the clarification, but I would be happier with an answer. Tamas

Haskell doesn't provide such a value, but you could easily compute it from from the values given in the RealFloat class. It tells you the base, number of digits in mantissa, etc. As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration doesn't make the value bounce back and forth with more than eps? -- Lennart On Sep 29, 2006, at 20:26 , Tamas K Papp wrote:
On Sat, Sep 30, 2006 at 12:20:16AM +0000, Joachim Breitner wrote:
Hi,
Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp:
the smallest positive floating point number x such that 1+x /= x? That would be the smallest positive number, woudn't it?
Do you mean the smalles postive number x with 1+x /= 1?
Hi Joachim,
Specifically, I would be happy with the smallest Double that makes the statement true. I need it as a convergence bound for an iterative algorithm. Anyhow, thanks for the clarification, but I would be happier with an answer.
Tamas _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Fri, Sep 29, 2006 at 09:26:27PM -0400, Lennart Augustsson wrote:
As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration doesn't make the value bounce back and forth with more than eps?
Hi Lennart, Thanks for the answer, I will try it. I am not using eps, but rather a value derived from eps by analyzing the algorithm (eg eps^0.25). Your answer will help me calculate that directly. Thanks, Tamas
participants (3)
-
Joachim Breitner
-
Lennart Augustsson
-
Tamas K Papp