Average Error: 33.2 → 6.6
Time: 1.1m
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 -8.130457313724135 \cdot 10^{+141}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.0456115258101208 \cdot 10^{-269}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 1.5249859025699474 \cdot 10^{+99}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \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 -8.130457313724135 \cdot 10^{+141}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\

\end{array}
double f(double a, double b_2, double c) {
        double r2028312 = b_2;
        double r2028313 = -r2028312;
        double r2028314 = r2028312 * r2028312;
        double r2028315 = a;
        double r2028316 = c;
        double r2028317 = r2028315 * r2028316;
        double r2028318 = r2028314 - r2028317;
        double r2028319 = sqrt(r2028318);
        double r2028320 = r2028313 - r2028319;
        double r2028321 = r2028320 / r2028315;
        return r2028321;
}

double f(double a, double b_2, double c) {
        double r2028322 = b_2;
        double r2028323 = -8.130457313724135e+141;
        bool r2028324 = r2028322 <= r2028323;
        double r2028325 = -0.5;
        double r2028326 = c;
        double r2028327 = r2028326 / r2028322;
        double r2028328 = r2028325 * r2028327;
        double r2028329 = 1.0456115258101208e-269;
        bool r2028330 = r2028322 <= r2028329;
        double r2028331 = r2028322 * r2028322;
        double r2028332 = a;
        double r2028333 = r2028332 * r2028326;
        double r2028334 = r2028331 - r2028333;
        double r2028335 = sqrt(r2028334);
        double r2028336 = -r2028322;
        double r2028337 = r2028335 + r2028336;
        double r2028338 = r2028326 / r2028337;
        double r2028339 = 1.5249859025699474e+99;
        bool r2028340 = r2028322 <= r2028339;
        double r2028341 = 1.0;
        double r2028342 = r2028341 / r2028332;
        double r2028343 = r2028336 - r2028335;
        double r2028344 = r2028342 * r2028343;
        double r2028345 = 0.5;
        double r2028346 = r2028322 / r2028326;
        double r2028347 = r2028332 / r2028346;
        double r2028348 = -2.0;
        double r2028349 = r2028322 * r2028348;
        double r2028350 = fma(r2028345, r2028347, r2028349);
        double r2028351 = r2028350 / r2028332;
        double r2028352 = r2028340 ? r2028344 : r2028351;
        double r2028353 = r2028330 ? r2028338 : r2028352;
        double r2028354 = r2028324 ? r2028328 : r2028353;
        return r2028354;
}

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 < -8.130457313724135e+141

    1. Initial program 61.6

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

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

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

    if -8.130457313724135e+141 < b_2 < 1.0456115258101208e-269

    1. Initial program 32.8

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

      \[\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 flip--32.9

      \[\leadsto \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}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/32.9

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified14.4

      \[\leadsto \frac{\color{blue}{\frac{a \cdot c}{a}}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    8. Taylor expanded around 0 8.6

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

    if 1.0456115258101208e-269 < b_2 < 1.5249859025699474e+99

    1. Initial program 8.9

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

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

    if 1.5249859025699474e+99 < b_2

    1. Initial program 44.3

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

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

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

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

      \[\leadsto \frac{\color{blue}{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(-2 \cdot b_2\right))_*}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -8.130457313724135 \cdot 10^{+141}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.0456115258101208 \cdot 10^{-269}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 1.5249859025699474 \cdot 10^{+99}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \end{array}\]

Reproduce

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