Average Error: 33.4 → 10.6
Time: 43.7s
Precision: 64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -3.6727086316196992 \cdot 10^{+65}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 7.643168247577731 \cdot 10^{-56}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]
double f(double a, double b_2, double c) {
        double r1533634 = b_2;
        double r1533635 = -r1533634;
        double r1533636 = r1533634 * r1533634;
        double r1533637 = a;
        double r1533638 = c;
        double r1533639 = r1533637 * r1533638;
        double r1533640 = r1533636 - r1533639;
        double r1533641 = sqrt(r1533640);
        double r1533642 = r1533635 + r1533641;
        double r1533643 = r1533642 / r1533637;
        return r1533643;
}

double f(double a, double b_2, double c) {
        double r1533644 = b_2;
        double r1533645 = -3.6727086316196992e+65;
        bool r1533646 = r1533644 <= r1533645;
        double r1533647 = 0.5;
        double r1533648 = c;
        double r1533649 = r1533648 / r1533644;
        double r1533650 = r1533647 * r1533649;
        double r1533651 = a;
        double r1533652 = r1533644 / r1533651;
        double r1533653 = 2.0;
        double r1533654 = r1533652 * r1533653;
        double r1533655 = r1533650 - r1533654;
        double r1533656 = 7.643168247577731e-56;
        bool r1533657 = r1533644 <= r1533656;
        double r1533658 = 1.0;
        double r1533659 = r1533644 * r1533644;
        double r1533660 = r1533648 * r1533651;
        double r1533661 = r1533659 - r1533660;
        double r1533662 = sqrt(r1533661);
        double r1533663 = r1533662 - r1533644;
        double r1533664 = r1533651 / r1533663;
        double r1533665 = r1533658 / r1533664;
        double r1533666 = -0.5;
        double r1533667 = r1533666 * r1533649;
        double r1533668 = r1533657 ? r1533665 : r1533667;
        double r1533669 = r1533646 ? r1533655 : r1533668;
        return r1533669;
}

\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -3.6727086316196992 \cdot 10^{+65}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 7.643168247577731 \cdot 10^{-56}:\\
\;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\end{array}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -3.6727086316196992e+65

    1. Initial program 38.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified38.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv38.1

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around -inf 5.2

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]

    if -3.6727086316196992e+65 < b_2 < 7.643168247577731e-56

    1. Initial program 14.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified14.6

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity14.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}{a}\]
    5. Applied associate-/l*14.7

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]

    if 7.643168247577731e-56 < b_2

    1. Initial program 53.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified53.3

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv53.3

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around inf 8.5

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.6727086316196992 \cdot 10^{+65}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 7.643168247577731 \cdot 10^{-56}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019101 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))