Average Error: 33.5 → 8.0
Time: 6.6s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -5.571370019832872361238263891019444684316 \cdot 10^{135}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 7.350002554571356146229538851751536262884 \cdot 10^{-304}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 1.118702370458101710062112245551516930432 \cdot 10^{72}:\\ \;\;\;\;\frac{1 \cdot \frac{3}{\frac{1}{a} \cdot \frac{\mathsf{fma}\left(-1, b, -\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right|\right)}{c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -5.571370019832872361238263891019444684316 \cdot 10^{135}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 7.350002554571356146229538851751536262884 \cdot 10^{-304}:\\
\;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\

\mathbf{elif}\;b \le 1.118702370458101710062112245551516930432 \cdot 10^{72}:\\
\;\;\;\;\frac{1 \cdot \frac{3}{\frac{1}{a} \cdot \frac{\mathsf{fma}\left(-1, b, -\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right|\right)}{c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r121363 = b;
        double r121364 = -r121363;
        double r121365 = r121363 * r121363;
        double r121366 = 3.0;
        double r121367 = a;
        double r121368 = r121366 * r121367;
        double r121369 = c;
        double r121370 = r121368 * r121369;
        double r121371 = r121365 - r121370;
        double r121372 = sqrt(r121371);
        double r121373 = r121364 + r121372;
        double r121374 = r121373 / r121368;
        return r121374;
}

double f(double a, double b, double c) {
        double r121375 = b;
        double r121376 = -5.5713700198328724e+135;
        bool r121377 = r121375 <= r121376;
        double r121378 = 0.5;
        double r121379 = c;
        double r121380 = r121379 / r121375;
        double r121381 = r121378 * r121380;
        double r121382 = 0.6666666666666666;
        double r121383 = a;
        double r121384 = r121375 / r121383;
        double r121385 = r121382 * r121384;
        double r121386 = r121381 - r121385;
        double r121387 = 7.350002554571356e-304;
        bool r121388 = r121375 <= r121387;
        double r121389 = -r121375;
        double r121390 = r121375 * r121375;
        double r121391 = 3.0;
        double r121392 = r121391 * r121383;
        double r121393 = r121392 * r121379;
        double r121394 = r121390 - r121393;
        double r121395 = sqrt(r121394);
        double r121396 = r121389 + r121395;
        double r121397 = r121396 / r121391;
        double r121398 = r121397 / r121383;
        double r121399 = 1.1187023704581017e+72;
        bool r121400 = r121375 <= r121399;
        double r121401 = 1.0;
        double r121402 = r121401 / r121383;
        double r121403 = -1.0;
        double r121404 = cbrt(r121394);
        double r121405 = sqrt(r121404);
        double r121406 = fabs(r121404);
        double r121407 = r121405 * r121406;
        double r121408 = -r121407;
        double r121409 = fma(r121403, r121375, r121408);
        double r121410 = r121409 / r121379;
        double r121411 = r121402 * r121410;
        double r121412 = r121391 / r121411;
        double r121413 = r121401 * r121412;
        double r121414 = r121413 / r121392;
        double r121415 = -0.5;
        double r121416 = r121415 * r121380;
        double r121417 = r121400 ? r121414 : r121416;
        double r121418 = r121388 ? r121398 : r121417;
        double r121419 = r121377 ? r121386 : r121418;
        return r121419;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -5.5713700198328724e+135

    1. Initial program 56.8

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}}\]

    if -5.5713700198328724e+135 < b < 7.350002554571356e-304

    1. Initial program 8.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*8.5

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

    if 7.350002554571356e-304 < b < 1.1187023704581017e+72

    1. Initial program 30.4

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Simplified16.0

      \[\leadsto \frac{\frac{\color{blue}{0 + 3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt16.2

      \[\leadsto \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}{3 \cdot a}\]
    7. Applied sqrt-prod16.2

      \[\leadsto \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}{3 \cdot a}\]
    8. Simplified16.2

      \[\leadsto \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \color{blue}{\left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right|} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right)}}}{3 \cdot a}\]
    11. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(0 + 3 \cdot \left(a \cdot c\right)\right)}}{1 \cdot \left(\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}\right)}}{3 \cdot a}\]
    12. Applied times-frac16.2

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}}{3 \cdot a}\]
    13. Simplified16.2

      \[\leadsto \frac{\color{blue}{1} \cdot \frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    14. Simplified16.3

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{3}{\frac{\mathsf{fma}\left(-1, b, -\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right|\right)}{a \cdot c}}}}{3 \cdot a}\]
    15. Using strategy rm
    16. Applied *-un-lft-identity16.3

      \[\leadsto \frac{1 \cdot \frac{3}{\frac{\color{blue}{1 \cdot \mathsf{fma}\left(-1, b, -\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right|\right)}}{a \cdot c}}}{3 \cdot a}\]
    17. Applied times-frac14.2

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

    if 1.1187023704581017e+72 < b

    1. Initial program 58.0

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.571370019832872361238263891019444684316 \cdot 10^{135}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 7.350002554571356146229538851751536262884 \cdot 10^{-304}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 1.118702370458101710062112245551516930432 \cdot 10^{72}:\\ \;\;\;\;\frac{1 \cdot \frac{3}{\frac{1}{a} \cdot \frac{\mathsf{fma}\left(-1, b, -\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \left|\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}\right|\right)}{c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019356 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))