On Tue, 13 Sep 2016 09:42:28 +1200, Juan Rada-Vilela wrote:
Hello,

First of all, thanks for such a great library.

I have been looking at the source code of the MidPointIntegrator (and
others), and there is something in particular that got my attention. In MidPointIntegrator (and others), the first parameter of the method stage (namely final int n) defines the resolution of the integrator as a power of two (2^{n-1}), and the documentation states that it does so "*because
this configuration can best utilize the already computed values*". An
extract of the source code is preseted below and can be found [here]

<https://git-wip-us.apache.org/repos/asf?p=commons-math.git;a=blob;f=src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java;h=edcb3007c2936a913419e2cd7e058cc97a3bf443;hb=refs/heads/develop#l98>

Could you please elaborate on how does the setting of the resolution to powers of two best utilize the already computed values? Could you please
provide some references supporting such a claim?

I's think that it's related to the implementation (see the "stage"
method). Using twice as many points at each refinement stage allows
to evaluate the function at only half of those points, the other half
having contributed to the previous estimation of the integral (that
estimation being added to the sum computed in the current stage).

You are most welcome to check that it is indeed how the implementation
works (e.g. you could write a "straightforward" implementation of the
algorithm that allows for any subdivision of the integration interval
and ensure that it provides the same numerical result as CM when the
subdivision is a power of two.


HTH,
Gilles


 /**
     * Compute the n-th stage integral of midpoint rule.
     * This function should only be called by API
<code>integrate()</code> in the package.
     * To save time it does not verify arguments - caller does.
     * <p>
* The interval is divided equally into 2^n sections rather than an * arbitrary m sections because this configuration can best utilize the
     * already computed values.</p>
     *
     * @param n the stage of 1/2 refinement. Must be larger than 0.
* @param previousStageResult Result from the previous call to the
     * {@code stage} method.
     * @param min Lower bound of the integration interval.
* @param diffMaxMin Difference between the lower bound and upper bound
     * of the integration interval.
     * @return the value of n-th stage integral
     * @throws TooManyEvaluationsException if the maximal number of
evaluations
     * is exceeded.
     */
    private double stage(final int n,
                         double previousStageResult,
                         double min,
                         double diffMaxMin)
        throws TooManyEvaluationsException {


Many thanks,

<http://www.fuzzylite.com/> Juan Rada-Vilela, Ph.D.
jcr...@fuzzylite.com
http://www.fuzzylite.com/jcrada


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to