Average Error: 32.5 → 7.0
Time: 29.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 -2.4629151126589693 \cdot 10^{+107}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -9.739621771792007 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.3869004057037945 \cdot 10^{+35}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_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 -2.4629151126589693 \cdot 10^{+107}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -9.739621771792007 \cdot 10^{-284}:\\
\;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r913297 = b_2;
        double r913298 = -r913297;
        double r913299 = r913297 * r913297;
        double r913300 = a;
        double r913301 = c;
        double r913302 = r913300 * r913301;
        double r913303 = r913299 - r913302;
        double r913304 = sqrt(r913303);
        double r913305 = r913298 - r913304;
        double r913306 = r913305 / r913300;
        return r913306;
}

double f(double a, double b_2, double c) {
        double r913307 = b_2;
        double r913308 = -2.4629151126589693e+107;
        bool r913309 = r913307 <= r913308;
        double r913310 = -0.5;
        double r913311 = c;
        double r913312 = r913311 / r913307;
        double r913313 = r913310 * r913312;
        double r913314 = -9.739621771792007e-284;
        bool r913315 = r913307 <= r913314;
        double r913316 = r913307 * r913307;
        double r913317 = a;
        double r913318 = r913317 * r913311;
        double r913319 = r913316 - r913318;
        double r913320 = sqrt(r913319);
        double r913321 = r913320 - r913307;
        double r913322 = r913311 / r913321;
        double r913323 = 5.3869004057037945e+35;
        bool r913324 = r913307 <= r913323;
        double r913325 = -r913307;
        double r913326 = r913325 - r913320;
        double r913327 = r913326 / r913317;
        double r913328 = 0.5;
        double r913329 = -2.0;
        double r913330 = r913307 / r913317;
        double r913331 = r913329 * r913330;
        double r913332 = fma(r913328, r913312, r913331);
        double r913333 = r913324 ? r913327 : r913332;
        double r913334 = r913315 ? r913322 : r913333;
        double r913335 = r913309 ? r913313 : r913334;
        return r913335;
}

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 < -2.4629151126589693e+107

    1. Initial program 59.0

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

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

    if -2.4629151126589693e+107 < b_2 < -9.739621771792007e-284

    1. Initial program 31.2

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

      \[\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. Simplified14.3

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

      \[\leadsto \frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity14.3

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{a}{a \cdot c}}}\]
    10. Using strategy rm
    11. Applied div-inv13.8

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

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

    if -9.739621771792007e-284 < b_2 < 5.3869004057037945e+35

    1. Initial program 10.3

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified10.3

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

    if 5.3869004057037945e+35 < b_2

    1. Initial program 32.9

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

      \[\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. Simplified59.5

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

      \[\leadsto \frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity59.5

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{a}{a \cdot c}}}\]
    10. Taylor expanded around inf 6.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.4629151126589693 \cdot 10^{+107}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -9.739621771792007 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.3869004057037945 \cdot 10^{+35}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]

Reproduce

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