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

Phil Steitz updated MATH-464:
-----------------------------

    Fix Version/s: 2.2

Thanks for reporting this.

The problem here is not with the iteration count.  In the example above, only 
26 iterations are executed and the method returns the correct value.  What is 
causing the number of function evaluations to be so large is that each 
iteration involves multiple function evaluations.   I need to dig more deeply 
into the algorithm to determine what (if anything) the problem is, but what is 
causing the high number of function evaluations is the following
{code}
// prepare next iteration
double ratio = FastMath.min(4, FastMath.pow(delta / limit, 0.5 / 
abscissas.length));
n = FastMath.max((int) (ratio * n), n + 1);
{code}

In the example, delta / limit becomes large, causing n to increase rapidly.  As 
n increases, the number of function evaluations increases.

> LegendreGaussIntegrator ignores defaultMaximalIterationCount and does 38 
> million iterations
> -------------------------------------------------------------------------------------------
>
>                 Key: MATH-464
>                 URL: https://issues.apache.org/jira/browse/MATH-464
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.1
>            Reporter: Michael Borcherds
>            Priority: Critical
>             Fix For: 2.2
>
>   Original Estimate: 3h
>  Remaining Estimate: 3h
>
> The following code results in count = 37801710 which is effectively an 
> infinite loop for typical functions we are using
> (in GeoGebra)
> The argument defaultMaximalIterationCount = 100 is being ignored
> This is the version we are using:
> http://www.geogebra.org/trac/browser/trunk/geogebra/org/apache/commons/math/analysis/integration/LegendreGaussIntegrator.java
>       LegendreGaussIntegrator gauss = new LegendreGaussIntegrator(5, 100);
>     
>       try {
>               double result = gauss.integrate(new testFun(), -10, 
> 0.32462367623786328);
>       } catch (Exception ee) {
>               ee.printStackTrace();
>       }
> class testFun implements UnivariateRealFunction {
>     public double value(double x) throws FunctionEvaluationException {
>       count ++;
>         if (x>=0 && x<=5) return 0.2; else return 0;
>     }
> }

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

Reply via email to