Average Error: 34.0 → 9.2
Time: 26.0s
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.260570947330360464594776218624123716053 \cdot 10^{-14}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.607074818869120297163406991470356321958 \cdot 10^{-204}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{fma}\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}}{a}\\ \mathbf{elif}\;b_2 \le 1.673851663574979563728921105654267462341 \cdot 10^{107}:\\ \;\;\;\;\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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.260570947330360464594776218624123716053 \cdot 10^{-14}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le 1.673851663574979563728921105654267462341 \cdot 10^{107}:\\
\;\;\;\;\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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 r5167987 = b_2;
        double r5167988 = -r5167987;
        double r5167989 = r5167987 * r5167987;
        double r5167990 = a;
        double r5167991 = c;
        double r5167992 = r5167990 * r5167991;
        double r5167993 = r5167989 - r5167992;
        double r5167994 = sqrt(r5167993);
        double r5167995 = r5167988 - r5167994;
        double r5167996 = r5167995 / r5167990;
        return r5167996;
}

double f(double a, double b_2, double c) {
        double r5167997 = b_2;
        double r5167998 = -5.2605709473303605e-14;
        bool r5167999 = r5167997 <= r5167998;
        double r5168000 = -0.5;
        double r5168001 = c;
        double r5168002 = r5168001 / r5167997;
        double r5168003 = r5168000 * r5168002;
        double r5168004 = -1.6070748188691203e-204;
        bool r5168005 = r5167997 <= r5168004;
        double r5168006 = a;
        double r5168007 = r5168001 * r5168006;
        double r5168008 = r5167997 * r5167997;
        double r5168009 = r5168006 * r5168001;
        double r5168010 = r5168008 - r5168009;
        double r5168011 = sqrt(r5168010);
        double r5168012 = sqrt(r5168011);
        double r5168013 = -r5167997;
        double r5168014 = fma(r5168012, r5168012, r5168013);
        double r5168015 = r5168007 / r5168014;
        double r5168016 = r5168015 / r5168006;
        double r5168017 = 1.6738516635749796e+107;
        bool r5168018 = r5167997 <= r5168017;
        double r5168019 = r5167997 + r5168011;
        double r5168020 = -r5168019;
        double r5168021 = r5168020 / r5168006;
        double r5168022 = 0.5;
        double r5168023 = r5167997 / r5168006;
        double r5168024 = -2.0;
        double r5168025 = r5168023 * r5168024;
        double r5168026 = fma(r5168002, r5168022, r5168025);
        double r5168027 = r5168018 ? r5168021 : r5168026;
        double r5168028 = r5168005 ? r5168016 : r5168027;
        double r5168029 = r5167999 ? r5168003 : r5168028;
        return r5168029;
}

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.2605709473303605e-14

    1. Initial program 55.9

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

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

    if -5.2605709473303605e-14 < b_2 < -1.6070748188691203e-204

    1. Initial program 30.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt30.0

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied sqrt-prod30.3

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

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

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt18.7

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}}{a}\]
    11. Applied sqrt-prod18.9

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}}{a}\]
    12. Applied fma-neg18.9

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

    if -1.6070748188691203e-204 < b_2 < 1.6738516635749796e+107

    1. Initial program 10.7

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied sqrt-prod10.9

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    5. Using strategy rm
    6. Applied neg-sub010.9

      \[\leadsto \frac{\color{blue}{\left(0 - b_2\right)} - \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    7. Applied associate--l-10.9

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

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

    if 1.6738516635749796e+107 < b_2

    1. Initial program 48.4

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

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

      \[\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 simplification9.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.260570947330360464594776218624123716053 \cdot 10^{-14}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.607074818869120297163406991470356321958 \cdot 10^{-204}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{fma}\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}}{a}\\ \mathbf{elif}\;b_2 \le 1.673851663574979563728921105654267462341 \cdot 10^{107}:\\ \;\;\;\;\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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 2019173 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))