Average Error: 33.6 → 10.6
Time: 19.3s
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 r797915 = b_2;
        double r797916 = -r797915;
        double r797917 = r797915 * r797915;
        double r797918 = a;
        double r797919 = c;
        double r797920 = r797918 * r797919;
        double r797921 = r797917 - r797920;
        double r797922 = sqrt(r797921);
        double r797923 = r797916 - r797922;
        double r797924 = r797923 / r797918;
        return r797924;
}

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

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))