Average Error: 34.0 → 8.0
Time: 17.7s
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.951254764388741219368659145895391722321 \cdot 10^{95}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.739506439947909364444676366873273107151 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}{a} \cdot a}\\ \mathbf{elif}\;b_2 \le 2098867031.934578418731689453125:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 -1.951254764388741219368659145895391722321 \cdot 10^{95}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le 2098867031.934578418731689453125:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 r34596 = b_2;
        double r34597 = -r34596;
        double r34598 = r34596 * r34596;
        double r34599 = a;
        double r34600 = c;
        double r34601 = r34599 * r34600;
        double r34602 = r34598 - r34601;
        double r34603 = sqrt(r34602);
        double r34604 = r34597 - r34603;
        double r34605 = r34604 / r34599;
        return r34605;
}

double f(double a, double b_2, double c) {
        double r34606 = b_2;
        double r34607 = -1.9512547643887412e+95;
        bool r34608 = r34606 <= r34607;
        double r34609 = -0.5;
        double r34610 = c;
        double r34611 = r34610 / r34606;
        double r34612 = r34609 * r34611;
        double r34613 = 1.7395064399479094e-284;
        bool r34614 = r34606 <= r34613;
        double r34615 = -r34610;
        double r34616 = a;
        double r34617 = r34606 * r34606;
        double r34618 = fma(r34615, r34616, r34617);
        double r34619 = sqrt(r34618);
        double r34620 = r34619 - r34606;
        double r34621 = r34620 / r34616;
        double r34622 = r34621 * r34616;
        double r34623 = r34610 / r34622;
        double r34624 = 2098867031.9345784;
        bool r34625 = r34606 <= r34624;
        double r34626 = 1.0;
        double r34627 = -r34606;
        double r34628 = r34610 * r34616;
        double r34629 = r34617 - r34628;
        double r34630 = sqrt(r34629);
        double r34631 = r34627 - r34630;
        double r34632 = r34616 / r34631;
        double r34633 = r34626 / r34632;
        double r34634 = 0.5;
        double r34635 = -2.0;
        double r34636 = r34606 / r34616;
        double r34637 = r34635 * r34636;
        double r34638 = fma(r34634, r34611, r34637);
        double r34639 = r34625 ? r34633 : r34638;
        double r34640 = r34614 ? r34623 : r34639;
        double r34641 = r34608 ? r34612 : r34640;
        return r34641;
}

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.9512547643887412e+95

    1. Initial program 58.9

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

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

    if -1.9512547643887412e+95 < b_2 < 1.7395064399479094e-284

    1. Initial program 32.7

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

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

      \[\leadsto \frac{\frac{0 + c \cdot a}{\color{blue}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt17.2

      \[\leadsto \frac{\frac{0 + c \cdot a}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - \color{blue}{\left(\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}\right) \cdot \sqrt[3]{b_2}}}}{a}\]
    8. Applied add-sqr-sqrt17.2

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

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

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

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

      \[\leadsto \frac{\frac{0 + c \cdot a}{\left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right) + \color{blue}{\left(b_2 + \left(-b_2\right)\right)}}}{a}\]
    13. Using strategy rm
    14. Applied *-un-lft-identity17.0

      \[\leadsto \frac{\frac{0 + c \cdot a}{\color{blue}{1 \cdot \left(\left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right) + \left(b_2 + \left(-b_2\right)\right)\right)}}}{a}\]
    15. Applied *-un-lft-identity17.0

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

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

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

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{c}{\frac{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - \left(b_2 - 0\right)}{a}}}}{a}\]
    19. Using strategy rm
    20. Applied associate-*r/15.4

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

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

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

    if 1.7395064399479094e-284 < b_2 < 2098867031.9345784

    1. Initial program 10.5

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

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

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

    if 2098867031.9345784 < b_2

    1. Initial program 32.2

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

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

      \[\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 simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.951254764388741219368659145895391722321 \cdot 10^{95}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.739506439947909364444676366873273107151 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{\frac{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}{a} \cdot a}\\ \mathbf{elif}\;b_2 \le 2098867031.934578418731689453125:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 2019209 +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))