Average Error: 34.5 → 10.1
Time: 6.8s
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.3645547041066157 \cdot 10^{-80}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.1199128263687574 \cdot 10^{46}:\\ \;\;\;\;\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}, -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 -8.3645547041066157 \cdot 10^{-80}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 4.1199128263687574 \cdot 10^{46}:\\
\;\;\;\;\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}, -2 \cdot \frac{b_2}{a}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r12534 = b_2;
        double r12535 = -r12534;
        double r12536 = r12534 * r12534;
        double r12537 = a;
        double r12538 = c;
        double r12539 = r12537 * r12538;
        double r12540 = r12536 - r12539;
        double r12541 = sqrt(r12540);
        double r12542 = r12535 - r12541;
        double r12543 = r12542 / r12537;
        return r12543;
}

double f(double a, double b_2, double c) {
        double r12544 = b_2;
        double r12545 = -8.364554704106616e-80;
        bool r12546 = r12544 <= r12545;
        double r12547 = -0.5;
        double r12548 = c;
        double r12549 = r12548 / r12544;
        double r12550 = r12547 * r12549;
        double r12551 = 4.1199128263687574e+46;
        bool r12552 = r12544 <= r12551;
        double r12553 = r12544 * r12544;
        double r12554 = a;
        double r12555 = r12554 * r12548;
        double r12556 = r12553 - r12555;
        double r12557 = sqrt(r12556);
        double r12558 = r12544 + r12557;
        double r12559 = -r12558;
        double r12560 = r12559 / r12554;
        double r12561 = 0.5;
        double r12562 = -2.0;
        double r12563 = r12544 / r12554;
        double r12564 = r12562 * r12563;
        double r12565 = fma(r12549, r12561, r12564);
        double r12566 = r12552 ? r12560 : r12565;
        double r12567 = r12546 ? r12550 : r12566;
        return r12567;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -8.364554704106616e-80

    1. Initial program 53.8

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

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

    if -8.364554704106616e-80 < b_2 < 4.1199128263687574e+46

    1. Initial program 13.7

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity13.8

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}\]
    6. Applied *-un-lft-identity13.8

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied times-frac13.8

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    8. Applied add-cube-cbrt13.8

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Applied times-frac13.8

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

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

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

    if 4.1199128263687574e+46 < b_2

    1. Initial program 36.8

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity37.0

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}\]
    6. Applied *-un-lft-identity37.0

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied times-frac37.0

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    8. Applied add-cube-cbrt37.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Applied times-frac37.0

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}\]
    13. Simplified5.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -8.3645547041066157 \cdot 10^{-80}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.1199128263687574 \cdot 10^{46}:\\ \;\;\;\;\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}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]

Reproduce

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