title: Find the lowest quadratic root in a specific interval
body: <p>I want to create a Java method which returns the lowest root of a quadratic equation in the interval <code>(0, 1)</code>. If there are no solutions in the interval, return <code>1</code>. I need some help making this an efficient algorithm.</p>
  
  <p>This is my current method:</p>
  
  <pre><code>public static float getLowestRoot(float A, float B, float C) {
      float D = B*B - 4*A*C;
      if(D &lt; 0) return 1;
  
      float sD = (float) Math.sqrt(D);
  
      float x1 = (-B + sD) / (2*A);
      float x2 = (-B - sD) / (2*A);
  
      if(x2 &lt; x1) {
          float tmp = x2;
          x2 = x1;
          x1 = tmp;
      }
  
      if(x1 &gt; 0 &amp;&amp; x1 &lt; 1) return x1;
      if(x2 &gt; 0 &amp;&amp; x2 &lt; 1) return x2;
  
      return 1;
  }
  </code></pre>
  
  <p>This method does the job but I was wondering if there is a way to compress the algorithm, because right now it feels bloated.</p>