Average Error: 33.1 → 9.4
Time: 1.5m
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 -1.7678040264959333 \cdot 10^{+146}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(-2 \cdot b_2\right)\right)}\\ \mathbf{elif}\;b_2 \le 5.524249207244028 \cdot 10^{-127}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.890069572265506 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{a \cdot c}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{c}{b_2}\right), \frac{1}{2}, \left(\frac{-2}{a} \cdot b_2\right)\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 -1.7678040264959333 \cdot 10^{+146}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(-2 \cdot b_2\right)\right)}\\

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

\mathbf{elif}\;b_2 \le 5.890069572265506 \cdot 10^{-16}:\\
\;\;\;\;\frac{\frac{a \cdot c}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r3867347 = b_2;
        double r3867348 = -r3867347;
        double r3867349 = r3867347 * r3867347;
        double r3867350 = a;
        double r3867351 = c;
        double r3867352 = r3867350 * r3867351;
        double r3867353 = r3867349 - r3867352;
        double r3867354 = sqrt(r3867353);
        double r3867355 = r3867348 - r3867354;
        double r3867356 = r3867355 / r3867350;
        return r3867356;
}

double f(double a, double b_2, double c) {
        double r3867357 = b_2;
        double r3867358 = -1.7678040264959333e+146;
        bool r3867359 = r3867357 <= r3867358;
        double r3867360 = c;
        double r3867361 = 0.5;
        double r3867362 = a;
        double r3867363 = r3867357 / r3867360;
        double r3867364 = r3867362 / r3867363;
        double r3867365 = -2.0;
        double r3867366 = r3867365 * r3867357;
        double r3867367 = fma(r3867361, r3867364, r3867366);
        double r3867368 = r3867360 / r3867367;
        double r3867369 = 5.524249207244028e-127;
        bool r3867370 = r3867357 <= r3867369;
        double r3867371 = r3867357 * r3867357;
        double r3867372 = r3867362 * r3867360;
        double r3867373 = r3867371 - r3867372;
        double r3867374 = sqrt(r3867373);
        double r3867375 = r3867374 - r3867357;
        double r3867376 = r3867360 / r3867375;
        double r3867377 = 5.890069572265506e-16;
        bool r3867378 = r3867357 <= r3867377;
        double r3867379 = r3867357 + r3867374;
        double r3867380 = r3867372 / r3867379;
        double r3867381 = -r3867380;
        double r3867382 = r3867372 / r3867381;
        double r3867383 = r3867382 / r3867362;
        double r3867384 = r3867360 / r3867357;
        double r3867385 = r3867365 / r3867362;
        double r3867386 = r3867385 * r3867357;
        double r3867387 = fma(r3867384, r3867361, r3867386);
        double r3867388 = r3867378 ? r3867383 : r3867387;
        double r3867389 = r3867370 ? r3867376 : r3867388;
        double r3867390 = r3867359 ? r3867368 : r3867389;
        return r3867390;
}

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 < -1.7678040264959333e+146

    1. Initial program 61.9

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--62.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. Simplified36.8

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

      \[\leadsto \frac{\frac{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-identity36.8

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity36.8

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac36.8

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    12. Taylor expanded around -inf 7.3

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

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

    if -1.7678040264959333e+146 < b_2 < 5.524249207244028e-127

    1. Initial program 29.1

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

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

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

      \[\leadsto \frac{\frac{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-identity16.2

      \[\leadsto \frac{\frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac16.2

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

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

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

    if 5.524249207244028e-127 < b_2 < 5.890069572265506e-16

    1. Initial program 6.4

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

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

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied flip--36.2

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}}{a}\]
    8. Simplified19.3

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

    if 5.890069572265506e-16 < b_2

    1. Initial program 28.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.7678040264959333 \cdot 10^{+146}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(-2 \cdot b_2\right)\right)}\\ \mathbf{elif}\;b_2 \le 5.524249207244028 \cdot 10^{-127}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.890069572265506 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{a \cdot c}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{c}{b_2}\right), \frac{1}{2}, \left(\frac{-2}{a} \cdot b_2\right)\right)\\ \end{array}\]

Reproduce

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