1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.math4.legacy.analysis.solvers;
19
20 import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
21 import org.apache.commons.math4.legacy.exception.ConvergenceException;
22 import org.apache.commons.math4.core.jdkmath.JdkMath;
23 import org.junit.Test;
24 import org.junit.Assert;
25
26
27
28
29
30 public final class RegulaFalsiSolverTest extends BaseSecantSolverAbstractTest {
31
32 @Override
33 protected UnivariateSolver getSolver() {
34 return new RegulaFalsiSolver();
35 }
36
37
38 @Override
39 protected int[] getQuinticEvalCounts() {
40
41
42
43 return new int[] {3, 7, 8, 19, 18, 11, 67, 55, 288, 151, -1};
44 }
45
46 @Test(expected=ConvergenceException.class)
47 public void testIssue631() {
48 final UnivariateFunction f = new UnivariateFunction() {
49
50 @Override
51 public double value(double x) {
52 return JdkMath.exp(x) - JdkMath.pow(Math.PI, 3.0);
53 }
54 };
55
56 final UnivariateSolver solver = new RegulaFalsiSolver();
57 final double root = solver.solve(3624, f, 1, 10);
58 Assert.assertEquals(3.4341896575482003, root, 1e-15);
59 }
60 }