commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Axion004 (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (MATH-1238) NoBracketingException send with valid brackets
Date Thu, 10 Sep 2015 18:23:45 GMT

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

Axion004 edited comment on MATH-1238 at 9/10/15 6:22 PM:
---------------------------------------------------------

I have the same issue through the following test program

import java.util.TreeSet;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.solvers.*;

public class TestBrent {

    public static void main(String[] args) {
        BrentSolver test2 = new BrentSolver(1E-10);
        UnivariateFunction function = (double x) -> Math.sin(x);

        double EPSILON = 1e-6;
        TreeSet<Double> set = new TreeSet<>();
        for (int i = 1; i <= 500; i++) {
            set.add(test2.solve(1000, function, i, i+1));
        }

        for (Double s : set) {
            if (s > 0) {
                System.out.println(s);
            }
        }
    }
}






run:
Exception in thread "main" org.apache.commons.math3.exception.NoBracketingException: function
values at endpoints do not have different signs, endpoints: [1, 2], values: [0.841, 0.909]
	at org.apache.commons.math3.analysis.solvers.BrentSolver.doSolve(BrentSolver.java:133)
	at org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.solve(BaseAbstractUnivariateSolver.java:199)
	at org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.solve(BaseAbstractUnivariateSolver.java:204)
	at TestBrent.main(TestBrent.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)



was (Author: axion004):
I have the same issue through the following test program

import java.util.TreeSet;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.solvers.*;

public class TestBrent {

    public static void main(String[] args) {
        BrentSolver test2 = new BrentSolver(1E-10);
        UnivariateFunction function = (double x) -> Math.sin(x);

        double EPSILON = 1e-6;
        TreeSet<Double> set = new TreeSet<>();
        for (int i = 1; i <= 500; i++) {
            set.add(test2.solve(1000, function, i, i+1));
        }

        for (Double s : set) {
            if (s > 0) {
                System.out.println(s);
            }
        }
    }
}

Exception in thread "main" org.apache.commons.math3.exception.NoBracketingException: function
values at endpoints do not have different signs, endpoints: [1, 2], values: [0.841, 0.909]
	at org.apache.commons.math3.analysis.solvers.BrentSolver.doSolve(BrentSolver.java:133)
	at org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.solve(BaseAbstractUnivariateSolver.java:199)
	at org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver.solve(BaseAbstractUnivariateSolver.java:204)
	at TestBrent.main(TestBrent.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time:



> NoBracketingException send with valid brackets
> ----------------------------------------------
>
>                 Key: MATH-1238
>                 URL: https://issues.apache.org/jira/browse/MATH-1238
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: charles sitbon
>            Priority: Minor
>
> The brent solver sometimes send a NoBracketingException with valid brackets : example
for a beta distribution with large Beta (285) and alpha around 15
> Exception in thread "main" org.apache.commons.math3.exception.NoBracketingException:
function values at endpoints do not have different signs, endpoints: [0, 1], values: [-0.15,
0.85]
> the exception is actually caused by the yinitial which is Nan



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message