Average Error: 34.4 → 6.4
Time: 20.3s
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.857238265713216596268581045781308602833 \cdot 10^{109}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 1.134509230518344573571097694463152126109 \cdot 10^{-265}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}, \sqrt[3]{b_2}, \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\ \mathbf{elif}\;b_2 \le 6.634949600836956616333645071253138645384 \cdot 10^{139}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \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.857238265713216596268581045781308602833 \cdot 10^{109}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\

\mathbf{elif}\;b_2 \le 1.134509230518344573571097694463152126109 \cdot 10^{-265}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}, \sqrt[3]{b_2}, \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\end{array}
double f(double a, double b_2, double c) {
        double r25610 = b_2;
        double r25611 = -r25610;
        double r25612 = r25610 * r25610;
        double r25613 = a;
        double r25614 = c;
        double r25615 = r25613 * r25614;
        double r25616 = r25612 - r25615;
        double r25617 = sqrt(r25616);
        double r25618 = r25611 + r25617;
        double r25619 = r25618 / r25613;
        return r25619;
}

double f(double a, double b_2, double c) {
        double r25620 = b_2;
        double r25621 = -1.8572382657132166e+109;
        bool r25622 = r25620 <= r25621;
        double r25623 = c;
        double r25624 = r25623 / r25620;
        double r25625 = 0.5;
        double r25626 = -2.0;
        double r25627 = a;
        double r25628 = r25620 / r25627;
        double r25629 = r25626 * r25628;
        double r25630 = fma(r25624, r25625, r25629);
        double r25631 = 1.1345092305183446e-265;
        bool r25632 = r25620 <= r25631;
        double r25633 = cbrt(r25620);
        double r25634 = r25633 * r25633;
        double r25635 = -r25634;
        double r25636 = r25620 * r25620;
        double r25637 = r25627 * r25623;
        double r25638 = r25636 - r25637;
        double r25639 = sqrt(r25638);
        double r25640 = fma(r25635, r25633, r25639);
        double r25641 = r25640 / r25627;
        double r25642 = 6.634949600836957e+139;
        bool r25643 = r25620 <= r25642;
        double r25644 = -r25620;
        double r25645 = r25644 - r25639;
        double r25646 = r25623 / r25645;
        double r25647 = -0.5;
        double r25648 = r25647 * r25624;
        double r25649 = r25643 ? r25646 : r25648;
        double r25650 = r25632 ? r25641 : r25649;
        double r25651 = r25622 ? r25630 : r25650;
        return r25651;
}

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.8572382657132166e+109

    1. Initial program 50.1

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

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

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

    if -1.8572382657132166e+109 < b_2 < 1.1345092305183446e-265

    1. Initial program 9.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt9.7

      \[\leadsto \frac{\left(-\color{blue}{\left(\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}\right) \cdot \sqrt[3]{b_2}}\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    4. Applied distribute-lft-neg-in9.7

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

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

    if 1.1345092305183446e-265 < b_2 < 6.634949600836957e+139

    1. Initial program 35.9

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

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

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

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

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

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

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

    if 6.634949600836957e+139 < b_2

    1. Initial program 62.6

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.857238265713216596268581045781308602833 \cdot 10^{109}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 1.134509230518344573571097694463152126109 \cdot 10^{-265}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}, \sqrt[3]{b_2}, \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\ \mathbf{elif}\;b_2 \le 6.634949600836956616333645071253138645384 \cdot 10^{139}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019347 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))