1
0
mirror of https://github.com/apache/commons-math.git synced 2025-03-04 23:49:14 +00:00
Unit test (showing that the report is invalid).


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1365963 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2012-07-26 12:25:06 +00:00
parent 31c3a82d4c
commit 0062503cf9

@ -26,6 +26,7 @@ import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.optimization.GoalType;
import org.apache.commons.math3.optimization.ConvergenceChecker;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@ -157,4 +158,27 @@ public final class BrentOptimizerTest {
result = optimizer.optimize(50, f, GoalType.MINIMIZE, 4, 3 * Math.PI / 2).getPoint();
Assert.assertEquals(3 * Math.PI / 2, result, 1e-6);
}
@Test
public void testMath832() {
final UnivariateFunction f = new UnivariateFunction() {
public double value(double x) {
final double sqrtX = FastMath.sqrt(x);
final double a = 1e2 * sqrtX;
final double b = 1e6 / x;
final double c = 1e4 / sqrtX;
return a + b + c;
}
};
UnivariateOptimizer optimizer = new BrentOptimizer(1e-10, 1e-8);
final double result = optimizer.optimize(1483,
f,
GoalType.MINIMIZE,
Double.MIN_VALUE,
Double.MAX_VALUE).getPoint();
Assert.assertEquals(804.9355825, result, 1e-6);
}
}