You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Christian Semrau (JIRA)" <ji...@apache.org> on 2009/01/16 23:43:59 UTC

[jira] Created: (MATH-240) MathUtils.factorial(n) fails for n >= 17

MathUtils.factorial(n) fails for n >= 17
----------------------------------------

                 Key: MATH-240
                 URL: https://issues.apache.org/jira/browse/MATH-240
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 2.0
            Reporter: Christian Semrau
            Priority: Minor


The result of MathUtils.factorial(n) for n = 17...20 is wrong, probably because of rounding errors in the double calculations.

Replace the first line of MathUtilsTest.testFactorial() by

        for (int i = 1; i <= 20; i++) {

to check all valid arguments for the long result and see the failure.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MATH-240) MathUtils.factorial(n) fails for n >= 17

Posted by "Christian Semrau (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Semrau updated MATH-240:
----------------------------------

    Description: 
The result of MathUtils.factorial( n ) for n = 17, 18, 19 is wrong, probably because of rounding errors in the double calculations.

Replace the first line of MathUtilsTest.testFactorial() by

        for (int i = 1; i <= 20; i++) {

to check all valid arguments for the long result and see the failure.

I suggest implementing a simple loop to multiply the long result - or even using a precomputed long[] - instead of adding logarithms.

  was:
The result of MathUtils.factorial( n ) for n = 17...20 is wrong, probably because of rounding errors in the double calculations.

Replace the first line of MathUtilsTest.testFactorial() by

        for (int i = 1; i <= 20; i++) {

to check all valid arguments for the long result and see the failure.


> MathUtils.factorial(n) fails for n >= 17
> ----------------------------------------
>
>                 Key: MATH-240
>                 URL: https://issues.apache.org/jira/browse/MATH-240
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Christian Semrau
>            Priority: Minor
>
> The result of MathUtils.factorial( n ) for n = 17, 18, 19 is wrong, probably because of rounding errors in the double calculations.
> Replace the first line of MathUtilsTest.testFactorial() by
>         for (int i = 1; i <= 20; i++) {
> to check all valid arguments for the long result and see the failure.
> I suggest implementing a simple loop to multiply the long result - or even using a precomputed long[] - instead of adding logarithms.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MATH-240) MathUtils.factorial(n) fails for n >= 17

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz resolved MATH-240.
------------------------------

    Resolution: Fixed

Thanks for reporting this.  Fixed in r735781.

> MathUtils.factorial(n) fails for n >= 17
> ----------------------------------------
>
>                 Key: MATH-240
>                 URL: https://issues.apache.org/jira/browse/MATH-240
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Christian Semrau
>            Assignee: Phil Steitz
>            Priority: Minor
>             Fix For: 2.0
>
>
> The result of MathUtils.factorial( n ) for n = 17, 18, 19 is wrong, probably because of rounding errors in the double calculations.
> Replace the first line of MathUtilsTest.testFactorial() by
>         for (int i = 1; i <= 20; i++) {
> to check all valid arguments for the long result and see the failure.
> I suggest implementing a simple loop to multiply the long result - or even using a precomputed long[] - instead of adding logarithms.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MATH-240) MathUtils.factorial(n) fails for n >= 17

Posted by "Christian Semrau (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Semrau updated MATH-240:
----------------------------------

    Description: 
The result of MathUtils.factorial( n ) for n = 17...20 is wrong, probably because of rounding errors in the double calculations.

Replace the first line of MathUtilsTest.testFactorial() by

        for (int i = 1; i <= 20; i++) {

to check all valid arguments for the long result and see the failure.

  was:
The result of MathUtils.factorial(n) for n = 17...20 is wrong, probably because of rounding errors in the double calculations.

Replace the first line of MathUtilsTest.testFactorial() by

        for (int i = 1; i <= 20; i++) {

to check all valid arguments for the long result and see the failure.


> MathUtils.factorial(n) fails for n >= 17
> ----------------------------------------
>
>                 Key: MATH-240
>                 URL: https://issues.apache.org/jira/browse/MATH-240
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Christian Semrau
>            Priority: Minor
>
> The result of MathUtils.factorial( n ) for n = 17...20 is wrong, probably because of rounding errors in the double calculations.
> Replace the first line of MathUtilsTest.testFactorial() by
>         for (int i = 1; i <= 20; i++) {
> to check all valid arguments for the long result and see the failure.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MATH-240) MathUtils.factorial(n) fails for n >= 17

Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz updated MATH-240:
-----------------------------

    Fix Version/s: 2.0
         Assignee: Phil Steitz

> MathUtils.factorial(n) fails for n >= 17
> ----------------------------------------
>
>                 Key: MATH-240
>                 URL: https://issues.apache.org/jira/browse/MATH-240
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>            Reporter: Christian Semrau
>            Assignee: Phil Steitz
>            Priority: Minor
>             Fix For: 2.0
>
>
> The result of MathUtils.factorial( n ) for n = 17, 18, 19 is wrong, probably because of rounding errors in the double calculations.
> Replace the first line of MathUtilsTest.testFactorial() by
>         for (int i = 1; i <= 20; i++) {
> to check all valid arguments for the long result and see the failure.
> I suggest implementing a simple loop to multiply the long result - or even using a precomputed long[] - instead of adding logarithms.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.