*/
public double integrate(double a, double b) throws NumericException {
TrapezoidalIntegrator.IterativeState state = new TrapezoidalIntegrator.IterativeState(
function, a, b);
DoubleArray r0 = new DoubleArray();
DoubleArray r1 = new DoubleArray();
double error = Double.MAX_VALUE;
int n;
r0.add(state.getResult());
do {
state.iterate();
n = state.getIterations();
r1.clear();
r1.add(state.getResult());
double d = 4.0;
for (int i = 0; i < n; ++i) {
r1.add(r1.get(i) + (r1.get(i) - r0.get(i)) / (d - 1.0));
d *= 4.0;
}
error = Math.abs(r1.get(n) / r0.get(n - 1) - 1.0);
r0 = r1;
r1 = new DoubleArray();
} while (n < getMaximumIterations()
&& error > getMaximumRelativeError());
if (n >= getMaximumIterations()) {
throw new ConvergenceException(