commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [math] MATH-1333
Date Wed, 09 Mar 2016 22:18:29 GMT
Repository: commons-math
Updated Branches:
  refs/heads/feature-MATH-1333 160696e7f -> 4247a6975


MATH-1333

Unit test that makes "MullerSolver2" fail.  Thanks to Connor Petty.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/4247a697
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/4247a697
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/4247a697

Branch: refs/heads/feature-MATH-1333
Commit: 4247a69755e16cc409d6c7ab39d77bfc39ae641c
Parents: 160696e
Author: Gilles <erans@apache.org>
Authored: Wed Mar 9 23:14:31 2016 +0100
Committer: Gilles <erans@apache.org>
Committed: Wed Mar 9 23:14:31 2016 +0100

----------------------------------------------------------------------
 .../analysis/solvers/MullerSolver2Test.java     | 31 ++++++++++++++++++++
 .../analysis/solvers/MullerSolverTest.java      |  3 +-
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/4247a697/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolver2Test.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolver2Test.java
b/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolver2Test.java
index b11fefc..6bf5784 100644
--- a/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolver2Test.java
+++ b/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolver2Test.java
@@ -144,4 +144,35 @@ public final class MullerSolver2Test {
             // expected
         }
     }
+
+    @Test
+    public void testMath1333() {
+        final UnivariateFunction logFunction = new UnivariateFunction() {
+                private double log1pe(double x) {
+                    if (x > 0) {
+                        return x + FastMath.log1p(FastMath.exp(-x));
+                    } else {
+                        return FastMath.log1p(FastMath.exp(x));
+                    }
+                }
+
+                @Override
+                public double value(double x) {
+                    final double a = 14.084938888325166;
+                    final double b = 0.795268254092313;
+                    final double c = -67.83667640994328;
+                    final double d = -4.63152721314618E-7;
+                    //aa*log(1+e^(bbx+c))+d - 0.01 * x - 20 * 0.01
+                    return a * a * log1pe(b * b * x + c) + d - 0.01 * x - 20 * 0.01;
+                }
+            };
+        final UnivariateSolver solver = new MullerSolver2(0.25);
+        final double min = 20;
+        final double max = 107.27001423177079;
+        final double start = 100d / 3;
+        final double result = solver.solve(1000, logFunction, min, max, start);
+
+        Assert.assertTrue(result + " < " + min, result >= min);
+        Assert.assertTrue(result + " > " + max, result <= max);
+    }
 }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/4247a697/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolverTest.java
b/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolverTest.java
index 2bb0b1b..163aa86 100644
--- a/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolverTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/solvers/MullerSolverTest.java
@@ -173,7 +173,8 @@ public final class MullerSolverTest {
         final UnivariateSolver solver = new MullerSolver(0.25);
         final double min = 20;
         final double max = 100.04173804515072;
-        final double result = solver.solve(1000, logFunction, min, max, 100 / (double) 3);
+        final double start = 100d / 3;
+        final double result = solver.solve(1000, logFunction, min, max, start);
 
         Assert.assertTrue(result + " < " + min, result >= min);
         Assert.assertTrue(result + " > " + max, result <= max);


Mime
View raw message