[jira] [Created] (MATH-843) Precision.EPSILON: wrong documentation

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
Dominik Gruntz created MATH-843:
-----------------------------------

             Summary: Precision.EPSILON: wrong documentation
                 Key: MATH-843
                 URL: https://issues.apache.org/jira/browse/MATH-843
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.0
            Reporter: Dominik Gruntz
            Priority: Minor


The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.

However, this is NOT the smallest positive number with this property.

Consider the following program:
{code}
public class Eps {
  public static void main(String[] args) {
    double e = Double.longBitsToDouble(0x3c90000000000001L);
        double e1 = 1-e;
        System.out.println(e);
        System.out.println(1-e);
        System.out.println(1-e != 1);
  }
}
{code}
The output is:
{code}
% java Eps
5.551115123125784E-17
0.9999999999999999
true
{code}

This proves, that there are smaller positive numbers with the property that 1-eps != 1.

I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
an upper bound on the relative error which occurs when a real number is
rounded to its nearest Double floating-point number. I propose to update
the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13430648#comment-13430648 ]

Gilles commented on MATH-843:
-----------------------------

Thanks for the report.

I've updated the documentation in revision 1370547. Do you agree with the new version?

               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13430699#comment-13430699 ]

Dominik Gruntz commented on MATH-843:
-------------------------------------

yes, the new documentation in rev 1370547 is correct; 2^(-53) has that property (i.e. it is the largest double eps such that 1+eps = 1):
{code}
scala> math.pow(2, -53)
res1: Double = 1.1102230246251565E-16

scala> 1+res1 == 1
res2: Boolean = true

scala> java.lang.Double.longBitsToDouble(java.lang.Double.doubleToLongBits(res1)+1)
res3: Double = 1.1102230246251568E-16

scala> 1+res3
res4: Double = 1.0000000000000002
{code}

So I agree, but I do not like it. I would not define this constant over 1+eps == 1 (as if executed in extended precision the result may be different), but I would define it as upper bound on the relative error due to rounding real numbers to {{double}} floating-point numbers.
               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13430988#comment-13430988 ]

Gilles commented on MATH-843:
-----------------------------

bq. [...] but I do not like it.

I like it because it is more straightforward to understand while I must admit that I don't fully understand your definition...
I've added a trivial unit test ("testMath841") that verifies the claim made in the documentation.

Please provide a unit test that makes your point clear, and I'll see no problem adding your proposed comment in the Javadoc.

bq. [...] if executed in extended precision the result may be different [...]

I don't understand: The Javadoc now explicitly states "double-precision".
Let me know whether it can be made clearer.

               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13431197#comment-13431197 ]

Dominik Gruntz commented on MATH-843:
-------------------------------------

{quote}
I don't understand: The Javadoc now explicitly states "double-precision".
Let me know whether it can be made clearer.
{quote}
The computation may be done in the registers of your processor and these registers may provide more accuracy (typically 80bits). In Java this extended precision can be prevented by using the {{strictfp}} keyword.

The same holds for your test. It should be marked with {{strictfp}} as well. On some machines, the expression {{1 + Precision.EPSILON}} in the test {{1 + Precision.EPSILON == 1}} might be hold in a register with extended precision and thus may be greater than {{1}}. The expression then returns false.

Regarding the other definition: This is the one which can be found in [Wikipedia|http://en.wikipedia.org/wiki/Machine_epsilon] and in the [Computing Surveys article by Goldberg|http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html]. The machine epsilon is defined as upper bound of the relative error which may occur when a real number is rounded to its closest floating-point approximation. This upper bound is {{B^(-(p-1))/2}} where {{B}} is the base and {{p}} is the precision or length of the mantissa. For IEEE754 64-bit numbers (e.g. for {{double}}) this value is {{2^(-53)}}.
               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13431763#comment-13431763 ]

Gilles commented on MATH-843:
-----------------------------

bq. On some machines, the expression 1 + Precision.EPSILON in the test 1 + Precision.EPSILON == 1 might be hold in a register with extended precision and thus may be greater than 1. The expression then returns false.

Did you actually see that?
I would (maybe naively) think that "1 + ESPILON" would be cast to a 64-bit double before the comparison. If so, wouldn't the equality still hold?

bq. Regarding the other definition: [...]

No problem to add this comment if you provide it here in a "noformat" block with all the references as HTML links ("<a href="...">...</a>") which I can copy/paste into the code.
Thanks.

               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

     [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gilles updated MATH-843:
------------------------

    Fix Version/s: 3.1
   

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>             Fix For: 3.1
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13436962#comment-13436962 ]

Sébastien Brisard commented on MATH-843:
----------------------------------------

Dominik,
could you please review {{r1374395}} before we resolve this issue?
Thanks
               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>             Fix For: 3.1
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437716#comment-13437716 ]

Dominik Gruntz commented on MATH-843:
-------------------------------------

looks good to me, thanks. Or is there another place for reviewing?
Dominik

               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>             Fix For: 3.1
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

     [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sébastien Brisard resolved MATH-843.
------------------------------------

    Resolution: Fixed
   

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>             Fix For: 3.1
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (MATH-843) Precision.EPSILON: wrong documentation

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/MATH-843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437719#comment-13437719 ]

Sébastien Brisard commented on MATH-843:
----------------------------------------

Thanks, Dominik, that will do!
I'm resolving this issue right now.
               

> Precision.EPSILON: wrong documentation
> --------------------------------------
>
>                 Key: MATH-843
>                 URL: https://issues.apache.org/jira/browse/MATH-843
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dominik Gruntz
>            Priority: Minor
>              Labels: documentation
>             Fix For: 3.1
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The documentation of the Field {{EPSILON}} in class {{org.apache.commons.math3.util.Precision}} states, that {{EPSILON}} is the smallest positive number such that {{1 - EPSILON}} is not numerically equal to 1, and its value is defined as 1.1102230246251565E-16.
> However, this is NOT the smallest positive number with this property.
> Consider the following program:
> {code}
> public class Eps {
>   public static void main(String[] args) {
>     double e = Double.longBitsToDouble(0x3c90000000000001L);
> double e1 = 1-e;
> System.out.println(e);
> System.out.println(1-e);
> System.out.println(1-e != 1);
>   }
> }
> {code}
> The output is:
> {code}
> % java Eps
> 5.551115123125784E-17
> 0.9999999999999999
> true
> {code}
> This proves, that there are smaller positive numbers with the property that 1-eps != 1.
> I propose not to change the constant value, but to update the documentation. The value {{Precision.EPSILON}} is
> an upper bound on the relative error which occurs when a real number is
> rounded to its nearest Double floating-point number. I propose to update
> the api docs in this sense.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira