You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2011/01/14 13:07:47 UTC

[jira] Commented: (MATH-464) LegendreGaussIntegrator ignores defaultMaximalIterationCount and does 38 million iterations

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

Phil Steitz commented on MATH-464:
----------------------------------

I am now thinking that this is not a bug, but a consequence of the fact that the integrand in the example is not at all well-approximated by a polynomial.  With a small-enough stepsize, the algorithm does converge, but requiring the large number of function evaluations above.  Here are some stepsize values for the example and the associated absolute error:

n 8 error 0.05738431110184819
n 28 error 0.027423287634332688
n 100 error 8.62162720248888E-5
n 249 error 5.308122631570711E-4
n 650 error 4.3582615516528367E-4
n 1641 error 2.519984967931377E-4
n 3829 error 5.838605030586419E-5
...
 n 1102593 error 6.71416523906343E-8

The last entry is from the last (26th) iteration.  I haven't verified the rationale for the updating formula for n above, but it does appear warranted in this case to increase n quickly as large n (= small stepsize) is required to get a decent estimate of the integral using Gaussian quadrature.


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