title: Java: Trouble in computing the root of a given polynomial
body: <p>I'm trying to enter a for-loop over a subinterval that forms a partition of another within a specified range in order to calculate the roots of a given polynomial.  My problem is that my "if" and "if-else" are not executed, even when conditions should ensure their execution.  I've tested my "poly" function in other parts of the program and found no issues.  Here is my troublesome for-loop.</p>
  
  <pre><code>for (int i = L; i &lt; R; i += resolution) {
         double a = i, b = resolution+i;
         { if (poly(C, a)*poly(C, b) &lt; 0) {
            double mid = findRoot(C, a, b, tolerance);
            System.out.println(mid);
            if (Math.abs(poly(C, mid)) &lt; threshold){
              System.out.println("Root found at: "+mid);
              numCount = 1;
            }
         } else if (poly(D, a)*poly(D, b) &lt; 0) {
            double mid = findRoot(D, a, b, tolerance);
            if(Math.abs(poly(C, mid)) &lt; threshold) {
              System.out.println("Root found at: "+mid);
              numCount = 2;
  
         } else {
           numCount = 3;
           System.out.println("No roots were found in the specified range.");
         } System.out.println("numCount is "+numCount); break;
       }
    }
  </code></pre>