Average Error: 33.6 → 10.6
Time: 20.1s
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 -7.363255598823911 \cdot 10^{-15}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.823572975982288 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 - c \cdot a\right)}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{elif}\;b_2 \le -2.3344326820285623 \cdot 10^{-123}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.6691257204922504 \cdot 10^{+85}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2 \cdot -2}{a}\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 -7.363255598823911 \cdot 10^{-15}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le -2.3344326820285623 \cdot 10^{-123}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r794141 = b_2;
        double r794142 = -r794141;
        double r794143 = r794141 * r794141;
        double r794144 = a;
        double r794145 = c;
        double r794146 = r794144 * r794145;
        double r794147 = r794143 - r794146;
        double r794148 = sqrt(r794147);
        double r794149 = r794142 - r794148;
        double r794150 = r794149 / r794144;
        return r794150;
}

double f(double a, double b_2, double c) {
        double r794151 = b_2;
        double r794152 = -7.363255598823911e-15;
        bool r794153 = r794151 <= r794152;
        double r794154 = -0.5;
        double r794155 = c;
        double r794156 = r794155 / r794151;
        double r794157 = r794154 * r794156;
        double r794158 = -1.823572975982288e-27;
        bool r794159 = r794151 <= r794158;
        double r794160 = r794151 * r794151;
        double r794161 = a;
        double r794162 = r794155 * r794161;
        double r794163 = r794160 - r794162;
        double r794164 = r794160 - r794163;
        double r794165 = r794164 / r794161;
        double r794166 = -r794151;
        double r794167 = sqrt(r794163);
        double r794168 = r794166 + r794167;
        double r794169 = r794165 / r794168;
        double r794170 = -2.3344326820285623e-123;
        bool r794171 = r794151 <= r794170;
        double r794172 = 1.6691257204922504e+85;
        bool r794173 = r794151 <= r794172;
        double r794174 = r794166 - r794167;
        double r794175 = r794174 / r794161;
        double r794176 = 0.5;
        double r794177 = -2.0;
        double r794178 = r794151 * r794177;
        double r794179 = r794178 / r794161;
        double r794180 = fma(r794176, r794156, r794179);
        double r794181 = r794173 ? r794175 : r794180;
        double r794182 = r794171 ? r794157 : r794181;
        double r794183 = r794159 ? r794169 : r794182;
        double r794184 = r794153 ? r794157 : r794183;
        return r794184;
}

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 < -7.363255598823911e-15 or -1.823572975982288e-27 < b_2 < -2.3344326820285623e-123

    1. Initial program 50.8

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

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

    if -7.363255598823911e-15 < b_2 < -1.823572975982288e-27

    1. Initial program 36.1

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

      \[\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--36.2

      \[\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/36.2

      \[\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*36.2

      \[\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. Simplified36.1

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

    if -2.3344326820285623e-123 < b_2 < 1.6691257204922504e+85

    1. Initial program 12.6

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

      \[\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 div-inv12.8

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    6. Applied add-cube-cbrt12.8

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Applied times-frac12.8

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

      \[\leadsto \color{blue}{\frac{1}{a}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Simplified12.7

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    10. Using strategy rm
    11. Applied associate-*l/12.6

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}}\]
    12. Simplified12.6

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

    if 1.6691257204922504e+85 < b_2

    1. Initial program 42.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.363255598823911 \cdot 10^{-15}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.823572975982288 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 - c \cdot a\right)}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{elif}\;b_2 \le -2.3344326820285623 \cdot 10^{-123}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.6691257204922504 \cdot 10^{+85}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2 \cdot -2}{a}\right)\\ \end{array}\]

Reproduce

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