private void bisectionRoot ( double l , double u , int index ) { // use bisection until there is an estimate within tolerance int iter = 0 ; while ( u - l > boundTolerance * Math . abs ( l ) && iter ++ < maxBoundIterations ) { double m = ( l + u ) / 2.0 ; int numRoots = sturm . countRealRoots ( m , u ) ; if ( numRoots == 1 ) { l = m ; } else { // In systems where some coefficients are close to zero the Sturm sequence starts to yield erratic results. // In this case, certain basic assumptions are broken and a garbage solution is returned. The EVD method // still seems to yield a solution in these cases. Maybe a different formulation would improve its numerical // stability? The problem seems to lie with polynomial division by very small coefficients // if( sturm.countRealRoots(l,m) != 1 ) { // throw new RuntimeException("Oh Crap"); // } u = m ; } } // assign the root to the mid point between the bounds roots [ index ] = ( l + u ) / 2.0 ; }
Searches for a single real root inside the range . Only one root is assumed to be inside