You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex (JIRA)" <ji...@apache.org> on 2012/07/24 22:58:35 UTC

[jira] [Created] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Alex created MATH-832:
-------------------------

             Summary: Brent solver calculates incorrect root (namley Double.MAX_VALUE)
                 Key: MATH-832
                 URL: https://issues.apache.org/jira/browse/MATH-832
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.0
         Environment: Netbeans 7.1.2
            Reporter: Alex


Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0


Java-Input:{code:title=Test.java|borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}


Java-Output:{code:title=Test.java|borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:30 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

# [http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
);{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

# [http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println((new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2));{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Commented] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex commented on MATH-832:
---------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:
[http://www.wolframalpha.com/input/?i=Plot[100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000}]]
[http://www.wolframalpha.com/input/?i=Plot[d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000}]]
[http://www.wolframalpha.com/input/?i=Plot[d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100}]]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:33 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, 1.0e10, startValue2)
);{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, 1.0e10, startValue2)
);{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Commented] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13423061#comment-13423061 ] 

Gilles commented on MATH-832:
-----------------------------

"BrentSolver" (on the derivative of "uf") and "Brentoptimizer" (on "uf") both return the same value.

What you encountered is probably a limitation of finite precision: large values (on the right of the search interval) caused the solver to stop iterating too early: You might want to try with other values of the tolerances (arguments to the constructor).

                
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

Java-Input:{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

Java-Output:{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0


Java-Input:{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}


Java-Output:{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> Wolfram-Alpha-Solution:
> http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> Java-Input:{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> Java-Output:{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:27 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
asd
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
asd
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:
[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
 startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;
UnivariateFunction uf = new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
};

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);
System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
>  startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:28 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})

[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println((new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2));{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
asd
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
asd
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Commented] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421841#comment-13421841 ] 

Gilles commented on MATH-832:
-----------------------------

bq. min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}

Are you using the right class?
Optimizing (a.k.a. finding the minimum) and solving (a.k.a. finding the root) are not the same thing.

Please try this:
{code}
public void testMath832() {
    final UnivariateFunction f = new UnivariateFunction() {
            public double value(double x) {
                final double sqrtX = FastMath.sqrt(x);
                final double a = 1e2 * sqrtX;
                final double b = 1e6 / x;
                final double c = 1e4 / sqrtX;

                return a + b + c;
            }
        };

    UnivariateOptimizer optimizer = new BrentOptimizer(1e-10, 1e-8);
    final double result = optimizer.optimize(1483,
                                             f,
                                             GoalType.MINIMIZE,
                                             Double.MIN_VALUE,
                                             Double.MAX_VALUE).getPoint();

    Assert.assertEquals(804.935582, result, 1e-6);
}
{code}

                
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;
UnivariateFunction uf = new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
};

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);
System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
 startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;
UnivariateFunction uf = new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
};

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);
System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Remaining Estimate:     (was: 0.75h)
     Original Estimate:     (was: 0.75h)
    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

UnivariateFunction uf = new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
};

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);
System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;
UnivariateFunction uf = new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
};

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);
System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:31 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
);{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

# [http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
);{code}


# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
*Wolfram-Alpha-Solution:*
[http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
*Wolfram-Alpha-Solution:*
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:27 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:
[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:
[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:29 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

# [http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println((new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2));{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})

[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println((new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2));{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
*Wolfram-Alpha-Solution:*
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*Java-Input:*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*Java-Output:*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
*strong*Wolfram-Alpha-Solution:*strong*
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*strong*Java-Input:*strong*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*strong*Java-Output:*strong*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> *Wolfram-Alpha-Solution:*
> http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:32 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, 1.0e10, startValue2)
);{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})
http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
);{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:26 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:
[http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
[http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:
[http://www.wolframalpha.com/input/?i=Plot[100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000}]]
[http://www.wolframalpha.com/input/?i=Plot[d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000}]]
[http://www.wolframalpha.com/input/?i=Plot[d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100}]]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
            (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
        );{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
*strong*Wolfram-Alpha-Solution:*strong*
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

*strong*Java-Input:*strong*{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

*strong*Java-Output:*strong*{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
{code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}

Java-Input:{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}

Java-Output:{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> *strong*Wolfram-Alpha-Solution:*strong*
> http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *strong*Java-Input:*strong*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *strong*Java-Output:*strong*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0


Java-Input:{code:borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}


Java-Output:{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0


Java-Input:{code:title=Test.java|borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}


Java-Output:{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    Environment: 
Netbeans 7.1.2


  was:Netbeans 7.1.2

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> Wolfram-Alpha-Solution:
> http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
> Java-Input:{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> Java-Output:{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Updated] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Alex updated MATH-832:
----------------------

    Description: 
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0


Java-Input:{code:title=Test.java|borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}


Java-Output:{code:borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

  was:
Wolfram-Alpha-Solution:
http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0


Java-Input:{code:title=Test.java|borderStyle=solid}
int startValue1 = 100 + 1000000 + 10000;
int startValue2 = 100;

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
);

System.out.println(
    (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
    @Override
    public double value(double x) {
        return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
    }
}, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
);{code}


Java-Output:{code:title=Test.java|borderStyle=solid}
804.9355821866686
1.7976931348623157E308 (= Double.MAX_VALUE){code} 

    
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>   Original Estimate: 0.75h
>  Remaining Estimate: 0.75h
>
> Wolfram-Alpha-Solution:
> http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0
> Java-Input:{code:title=Test.java|borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> }, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> Java-Output:{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Commented] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Gilles (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13423012#comment-13423012 ] 

Gilles commented on MATH-832:
-----------------------------

bq. [...] But now i think i know where the problem is [...]

I do not. Is there a problem in Commons Math?

bq. An upper bound for the interval sufficiently smaller than infinity causes no problems

The initial report seems to indicate that you wanted to obtain the minimum of "uf". Then, in your last comment, you still use "BrentSolver" which will search for the root (of that same "uf").
Which is it?

Also, please correct the links in your previous comment; they seem broken (parts not being interpreted as links). Even better would be to upload files (either figures, or source code to reproduce the problem) to this page, instead of those unreadable links!
Thanks.

                
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Resolved] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

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

Gilles resolved MATH-832.
-------------------------

    Resolution: Invalid

If you still consider that there is a problem, please file another report, with a more precise description of the issue.

                
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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

        

[jira] [Comment Edited] (MATH-832) Brent solver calculates incorrect root (namley Double.MAX_VALUE)

Posted by "Alex (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422980#comment-13422980 ] 

Alex edited comment on MATH-832 at 7/26/12 9:30 AM:
----------------------------------------------------

I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

# [http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
);{code}


# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]
# [http://www.wolframalpha.com/input/?i=Plot(d%2Fdx+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+10^10%2C+10^100})]
                
      was (Author: alex87):
    I tried testMath832() and there was no error (although i'm not sure if i did it right - i never worked with JUnit before). But now i think i know where the problem is: It isn't the difference between optimizing and solving (minimizing a function (that derivative has only one root) => finding the root of the derivative) but a numerical issue:

# [http://www.wolframalpha.com/input/?i=Plot(100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29%2C+{x%2C+0%2C+1000})]

An upper bound for the interval sufficiently smaller than infinity causes no problems:{code:borderStyle=solid}
System.out.println(
        (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, *1.0e10*, startValue2)
);{code}
                  
> Brent solver calculates incorrect root (namley Double.MAX_VALUE)
> ----------------------------------------------------------------
>
>                 Key: MATH-832
>                 URL: https://issues.apache.org/jira/browse/MATH-832
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.0
>         Environment: Netbeans 7.1.2
>            Reporter: Alex
>
> *Wolfram-Alpha-Solution:*
> [http://www.wolframalpha.com/input/?i=min+100*sqrt%28x%29%2B1000000%2Fx%2B10000%2Fsqrt%28x%29+with+x%3E0]
> {code:borderStyle=solid}min{100 sqrt(x)+1000000/x+10000/sqrt(x)|x>0}~~4431.94 at x~~804.936{code}
> *Java-Input:*{code:borderStyle=solid}
> int startValue1 = 100 + 1000000 + 10000;
> int startValue2 = 100;
> UnivariateFunction uf = new UnivariateFunction() {
>     @Override
>     public double value(double x) {
>         return 100/(2*Math.sqrt(x)) - 1000000/Math.pow(x,2) - 10000/(2*Math.pow(x,(double) 3/2));
>     }
> };
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue1)
> );
> System.out.println(
>     (new BrentSolver()).solve(Integer.MAX_VALUE, uf, 1/Double.MAX_VALUE, Double.MAX_VALUE, startValue2)
> );{code}
> *Java-Output:*{code:borderStyle=solid}
> 804.9355821866686
> 1.7976931348623157E308 (= Double.MAX_VALUE){code} 

--
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