Average Error: 33.7 → 6.8
Time: 11.0s
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.98276540088900058 \cdot 10^{134}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2 \cdot -2}{a}\right)\\ \mathbf{elif}\;b_2 \le 2.302359130067309 \cdot 10^{-184}:\\ \;\;\;\;\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 2.83168293908294112 \cdot 10^{110}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) - \left|\sqrt[3]{b_2 \cdot b_2 - a \cdot c}\right| \cdot \sqrt{\sqrt[3]{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.98276540088900058 \cdot 10^{134}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2 \cdot -2}{a}\right)\\

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

\mathbf{elif}\;b_2 \le 2.83168293908294112 \cdot 10^{110}:\\
\;\;\;\;\frac{c}{\left(-b_2\right) - \left|\sqrt[3]{b_2 \cdot b_2 - a \cdot c}\right| \cdot \sqrt{\sqrt[3]{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 r15476 = b_2;
        double r15477 = -r15476;
        double r15478 = r15476 * r15476;
        double r15479 = a;
        double r15480 = c;
        double r15481 = r15479 * r15480;
        double r15482 = r15478 - r15481;
        double r15483 = sqrt(r15482);
        double r15484 = r15477 + r15483;
        double r15485 = r15484 / r15479;
        return r15485;
}

double f(double a, double b_2, double c) {
        double r15486 = b_2;
        double r15487 = -1.9827654008890006e+134;
        bool r15488 = r15486 <= r15487;
        double r15489 = 0.5;
        double r15490 = c;
        double r15491 = r15490 / r15486;
        double r15492 = -2.0;
        double r15493 = r15486 * r15492;
        double r15494 = a;
        double r15495 = r15493 / r15494;
        double r15496 = fma(r15489, r15491, r15495);
        double r15497 = 2.302359130067309e-184;
        bool r15498 = r15486 <= r15497;
        double r15499 = -r15486;
        double r15500 = r15486 * r15486;
        double r15501 = r15494 * r15490;
        double r15502 = r15500 - r15501;
        double r15503 = sqrt(r15502);
        double r15504 = r15499 + r15503;
        double r15505 = 1.0;
        double r15506 = r15505 / r15494;
        double r15507 = r15504 * r15506;
        double r15508 = 2.831682939082941e+110;
        bool r15509 = r15486 <= r15508;
        double r15510 = cbrt(r15502);
        double r15511 = fabs(r15510);
        double r15512 = sqrt(r15510);
        double r15513 = r15511 * r15512;
        double r15514 = r15499 - r15513;
        double r15515 = r15490 / r15514;
        double r15516 = -0.5;
        double r15517 = r15516 * r15491;
        double r15518 = r15509 ? r15515 : r15517;
        double r15519 = r15498 ? r15507 : r15518;
        double r15520 = r15488 ? r15496 : r15519;
        return r15520;
}

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.9827654008890006e+134

    1. Initial program 56.8

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

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

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

    if -1.9827654008890006e+134 < b_2 < 2.302359130067309e-184

    1. Initial program 10.0

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

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

    if 2.302359130067309e-184 < b_2 < 2.831682939082941e+110

    1. Initial program 37.8

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

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

      \[\leadsto \frac{\color{blue}{c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt7.1

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

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

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

    if 2.831682939082941e+110 < b_2

    1. Initial program 60.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.98276540088900058 \cdot 10^{134}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2 \cdot -2}{a}\right)\\ \mathbf{elif}\;b_2 \le 2.302359130067309 \cdot 10^{-184}:\\ \;\;\;\;\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 2.83168293908294112 \cdot 10^{110}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) - \left|\sqrt[3]{b_2 \cdot b_2 - a \cdot c}\right| \cdot \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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