Average Error: 34.4 → 8.8
Time: 12.5s
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 -5.10985616674947893 \cdot 10^{57}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.57120366754749 \cdot 10^{-295}:\\ \;\;\;\;\frac{\frac{a \cdot c}{a}}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 2.09453346119227227 \cdot 10^{90}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{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 -5.10985616674947893 \cdot 10^{57}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.57120366754749 \cdot 10^{-295}:\\
\;\;\;\;\frac{\frac{a \cdot c}{a}}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r19966 = b_2;
        double r19967 = -r19966;
        double r19968 = r19966 * r19966;
        double r19969 = a;
        double r19970 = c;
        double r19971 = r19969 * r19970;
        double r19972 = r19968 - r19971;
        double r19973 = sqrt(r19972);
        double r19974 = r19967 - r19973;
        double r19975 = r19974 / r19969;
        return r19975;
}

double f(double a, double b_2, double c) {
        double r19976 = b_2;
        double r19977 = -5.109856166749479e+57;
        bool r19978 = r19976 <= r19977;
        double r19979 = -0.5;
        double r19980 = c;
        double r19981 = r19980 / r19976;
        double r19982 = r19979 * r19981;
        double r19983 = -2.57120366754749e-295;
        bool r19984 = r19976 <= r19983;
        double r19985 = a;
        double r19986 = r19985 * r19980;
        double r19987 = r19986 / r19985;
        double r19988 = r19980 * r19985;
        double r19989 = -r19988;
        double r19990 = fma(r19976, r19976, r19989);
        double r19991 = sqrt(r19990);
        double r19992 = r19991 - r19976;
        double r19993 = r19987 / r19992;
        double r19994 = 2.0945334611922723e+90;
        bool r19995 = r19976 <= r19994;
        double r19996 = -r19976;
        double r19997 = r19976 * r19976;
        double r19998 = r19997 - r19986;
        double r19999 = sqrt(r19998);
        double r20000 = r19996 - r19999;
        double r20001 = 1.0;
        double r20002 = r20001 / r19985;
        double r20003 = r20000 * r20002;
        double r20004 = 0.5;
        double r20005 = r19976 / r19985;
        double r20006 = -2.0;
        double r20007 = r20005 * r20006;
        double r20008 = fma(r19981, r20004, r20007);
        double r20009 = r19995 ? r20003 : r20008;
        double r20010 = r19984 ? r19993 : r20009;
        double r20011 = r19978 ? r19982 : r20010;
        return r20011;
}

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 < -5.109856166749479e+57

    1. Initial program 58.1

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

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

    if -5.109856166749479e+57 < b_2 < -2.57120366754749e-295

    1. Initial program 30.9

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified17.1

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

      \[\leadsto \frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv17.1

      \[\leadsto \frac{\color{blue}{\left(b_2 \cdot \left(b_2 - b_2\right) + a \cdot c\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    8. Applied associate-/l*22.4

      \[\leadsto \color{blue}{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\frac{a}{\frac{1}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}}\]
    9. Simplified22.4

      \[\leadsto \frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{a \cdot \left(\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2\right)}}\]
    10. Using strategy rm
    11. Applied associate-/r*16.7

      \[\leadsto \color{blue}{\frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{a}}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}\]
    12. Simplified16.7

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

    if -2.57120366754749e-295 < b_2 < 2.0945334611922723e+90

    1. Initial program 9.2

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

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

    if 2.0945334611922723e+90 < b_2

    1. Initial program 45.6

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified61.8

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

      \[\leadsto \frac{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv61.8

      \[\leadsto \frac{\color{blue}{\left(b_2 \cdot \left(b_2 - b_2\right) + a \cdot c\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    8. Applied associate-/l*62.2

      \[\leadsto \color{blue}{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\frac{a}{\frac{1}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}}\]
    9. Simplified62.2

      \[\leadsto \frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\color{blue}{a \cdot \left(\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2\right)}}\]
    10. Taylor expanded around inf 4.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.10985616674947893 \cdot 10^{57}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.57120366754749 \cdot 10^{-295}:\\ \;\;\;\;\frac{\frac{a \cdot c}{a}}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 2.09453346119227227 \cdot 10^{90}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020042 +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))