Skip to content

Commit 4a252b2

Browse files
committed
Increasing the MAX_ITERATIONS limits in sbisect and regula_falsa.
Even with recent updates found in practice sbisect sometimes needs nearly 60 iterations and regula_falsa just over 100. Previously used identical limits of 50. Now 65 and 130 respectively
1 parent 89e661c commit 4a252b2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

source/core/math/polynomialsolver.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const DBL TWO_M_PI_3 = 2.0943951023931954923084;
9393
const DBL FOUR_M_PI_3 = 4.1887902047863909846168;
9494

9595
/* Max number of iterations. */
96-
const int MAX_ITERATIONS = 50;
96+
const int MAX_ITERATIONS = 65;
9797

9898
// NOTE: max_value - min_value threshold below which regula_falsa function is
9999
// tried when there is a single root. Single roots happen often. Rays continued
@@ -685,7 +685,13 @@ static bool regula_falsa(const int order, const DBL *coef, DBL a, DBL b, DBL *va
685685

686686
mid = (a + b) / 2;
687687

688-
for (its = 0; its < MAX_ITERATIONS; its++)
688+
// NOTE: 2x MAX_ITERATIONS multiplier over sturm bisection requirement found to
689+
// happen in practice. Necessary if you want regula_falsa to find the root
690+
// where the algorithm converges very slowly. Later look to tune setting with
691+
// respect to performance as this method vs sturm bisection run at different
692+
// speeds.
693+
694+
for (its = 0; its < (MAX_ITERATIONS * 2); its++)
689695
{
690696
x = (fb * a - fa * b) / (fb - fa);
691697

0 commit comments

Comments
 (0)