45 double threshold_dist_root;
47 int last_threshold_sign = 0;
52 double threshold_dist_a_k = node.threshold_distance( a_k );
53 double threshold_dist_b_k = node.threshold_distance( b_k );
55 if ( threshold_dist_a_k * threshold_dist_b_k > 0 )
60 const int MAX_ITER = 500;
61 const double TERMINATION_CRITERION = 1e-14;
63 for (
int iter = 0; iter < MAX_ITER; ++iter )
65 assert( threshold_dist_b_k != threshold_dist_a_k );
67 root = ( a_k * threshold_dist_b_k - b_k * threshold_dist_a_k ) / ( threshold_dist_b_k - threshold_dist_a_k );
68 threshold_dist_root = node.threshold_distance( root );
70 if ( std::abs( threshold_dist_root ) < TERMINATION_CRITERION )
75 if ( threshold_dist_a_k * threshold_dist_root > 0.0 )
79 threshold_dist_a_k = threshold_dist_root;
81 if ( last_threshold_sign == 1 )
87 threshold_dist_b_k /= 2;
89 last_threshold_sign = 1;
91 else if ( threshold_dist_b_k * threshold_dist_root > 0.0 )
95 threshold_dist_b_k = threshold_dist_root;
97 if ( last_threshold_sign == -1 )
99 threshold_dist_a_k /= 2;
101 last_threshold_sign = -1;
108 throw NumericalInstability(
"regula_falsi: Regula falsi method did not converge during set number of iterations" );
double regula_falsi(const CN &node, const double dt)
Localize threshold crossing by using Illinois algorithm of regula falsi method.
Definition regula_falsi.h:42