Average Error: 33.9 → 6.8
Time: 19.4s
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.359953003549156817553996908233908949771 \cdot 10^{103}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.094358742794727790656239317142702500789 \cdot 10^{-239}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le 5.099089738165329086098741767888130630655 \cdot 10^{67}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 2.094358742794727790656239317142702500789 \cdot 10^{-239}:\\
\;\;\;\;\frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\

\mathbf{elif}\;b_2 \le 5.099089738165329086098741767888130630655 \cdot 10^{67}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r23774 = b_2;
        double r23775 = -r23774;
        double r23776 = r23774 * r23774;
        double r23777 = a;
        double r23778 = c;
        double r23779 = r23777 * r23778;
        double r23780 = r23776 - r23779;
        double r23781 = sqrt(r23780);
        double r23782 = r23775 - r23781;
        double r23783 = r23782 / r23777;
        return r23783;
}

double f(double a, double b_2, double c) {
        double r23784 = b_2;
        double r23785 = -3.359953003549157e+103;
        bool r23786 = r23784 <= r23785;
        double r23787 = -0.5;
        double r23788 = c;
        double r23789 = r23788 / r23784;
        double r23790 = r23787 * r23789;
        double r23791 = 2.094358742794728e-239;
        bool r23792 = r23784 <= r23791;
        double r23793 = -r23784;
        double r23794 = r23784 * r23784;
        double r23795 = a;
        double r23796 = r23795 * r23788;
        double r23797 = r23794 - r23796;
        double r23798 = sqrt(r23797);
        double r23799 = r23793 + r23798;
        double r23800 = r23788 / r23799;
        double r23801 = 5.099089738165329e+67;
        bool r23802 = r23784 <= r23801;
        double r23803 = r23793 - r23798;
        double r23804 = r23803 / r23795;
        double r23805 = 0.5;
        double r23806 = r23784 / r23795;
        double r23807 = -2.0;
        double r23808 = r23806 * r23807;
        double r23809 = fma(r23805, r23789, r23808);
        double r23810 = r23802 ? r23804 : r23809;
        double r23811 = r23792 ? r23800 : r23810;
        double r23812 = r23786 ? r23790 : r23811;
        return r23812;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -3.359953003549157e+103

    1. Initial program 59.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 2.5

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

    if -3.359953003549157e+103 < b_2 < 2.094358742794728e-239

    1. Initial program 30.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num30.6

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied flip--30.7

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}}\]
    6. Applied associate-/r/30.8

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied associate-/r*30.8

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{a}{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    8. Simplified15.4

      \[\leadsto \frac{\color{blue}{\frac{0 + a \cdot c}{a}}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    9. Taylor expanded around 0 9.5

      \[\leadsto \frac{\color{blue}{c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]

    if 2.094358742794728e-239 < b_2 < 5.099089738165329e+67

    1. Initial program 8.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]

    if 5.099089738165329e+67 < b_2

    1. Initial program 40.4

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 5.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.094358742794727790656239317142702500789 \cdot 10^{-239}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le 5.099089738165329086098741767888130630655 \cdot 10^{67}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))