Average Error: 33.6 → 10.6
Time: 18.2s
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{b_2}{a}, -2, \frac{\frac{c}{b_2}}{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 -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{b_2}{a}, -2, \frac{\frac{c}{b_2}}{2}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r797918 = b_2;
        double r797919 = -r797918;
        double r797920 = r797918 * r797918;
        double r797921 = a;
        double r797922 = c;
        double r797923 = r797921 * r797922;
        double r797924 = r797920 - r797923;
        double r797925 = sqrt(r797924);
        double r797926 = r797919 - r797925;
        double r797927 = r797926 / r797921;
        return r797927;
}

double f(double a, double b_2, double c) {
        double r797928 = b_2;
        double r797929 = -7.363255598823911e-15;
        bool r797930 = r797928 <= r797929;
        double r797931 = -0.5;
        double r797932 = c;
        double r797933 = r797932 / r797928;
        double r797934 = r797931 * r797933;
        double r797935 = -1.823572975982288e-27;
        bool r797936 = r797928 <= r797935;
        double r797937 = r797928 * r797928;
        double r797938 = a;
        double r797939 = r797932 * r797938;
        double r797940 = r797937 - r797939;
        double r797941 = r797937 - r797940;
        double r797942 = r797941 / r797938;
        double r797943 = -r797928;
        double r797944 = sqrt(r797940);
        double r797945 = r797943 + r797944;
        double r797946 = r797942 / r797945;
        double r797947 = -2.3344326820285623e-123;
        bool r797948 = r797928 <= r797947;
        double r797949 = 1.6691257204922504e+85;
        bool r797950 = r797928 <= r797949;
        double r797951 = r797943 - r797944;
        double r797952 = r797951 / r797938;
        double r797953 = r797928 / r797938;
        double r797954 = -2.0;
        double r797955 = 2.0;
        double r797956 = r797933 / r797955;
        double r797957 = fma(r797953, r797954, r797956);
        double r797958 = r797950 ? r797952 : r797957;
        double r797959 = r797948 ? r797934 : r797958;
        double r797960 = r797936 ? r797946 : r797959;
        double r797961 = r797930 ? r797934 : r797960;
        return r797961;
}

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 div-inv12.7

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

      \[\leadsto \color{blue}{\frac{\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.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{c}{b_2}}{2}\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{b_2}{a}, -2, \frac{\frac{c}{b_2}}{2}\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))