1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.hipparchus.analysis.solvers;
24
25 import org.hipparchus.analysis.UnivariateFunction;
26 import org.hipparchus.exception.MathIllegalStateException;
27 import org.hipparchus.util.FastMath;
28 import org.junit.jupiter.api.Test;
29
30 import static org.junit.jupiter.api.Assertions.assertEquals;
31 import static org.junit.jupiter.api.Assertions.assertThrows;
32
33
34
35
36
37 final class RegulaFalsiSolverTest extends BaseSecantSolverAbstractTest {
38
39 @Override
40 protected UnivariateSolver getSolver() {
41 UnivariateSolver solver = new RegulaFalsiSolver();
42 checktype(solver, BaseSecantSolver.Method.REGULA_FALSI);
43 return solver;
44 }
45
46
47 @Override
48 protected int[] getQuinticEvalCounts() {
49
50
51
52 return new int[] {3, 7, 8, 19, 18, 11, 67, 55, 288, 151, -1};
53 }
54
55 @Test
56 void testIssue631() {
57 assertThrows(MathIllegalStateException.class, () -> {
58 final UnivariateFunction f = new UnivariateFunction() {
59
60 public double value(double x) {
61 return FastMath.exp(x) - FastMath.pow(Math.PI, 3.0);
62 }
63 };
64
65 final UnivariateSolver solver = new RegulaFalsiSolver();
66 final double root = solver.solve(3624, f, 1, 10);
67 assertEquals(3.4341896575482003, root, 1e-15);
68 });
69 }
70 }