Average Error: 33.8 → 28.7
Time: 45.1s
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 -1.3439079675895927 \cdot 10^{+154}:\\ \;\;\;\;\frac{-1}{3} \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 3.7959291444004856 \cdot 10^{+110}:\\ \;\;\;\;\frac{\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)} - b}}}{\sqrt[3]{3}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \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 -1.3439079675895927 \cdot 10^{+154}:\\
\;\;\;\;\frac{-1}{3} \cdot \frac{b}{a}\\

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

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r4162521 = b;
        double r4162522 = -r4162521;
        double r4162523 = r4162521 * r4162521;
        double r4162524 = 3.0;
        double r4162525 = a;
        double r4162526 = r4162524 * r4162525;
        double r4162527 = c;
        double r4162528 = r4162526 * r4162527;
        double r4162529 = r4162523 - r4162528;
        double r4162530 = sqrt(r4162529);
        double r4162531 = r4162522 + r4162530;
        double r4162532 = r4162531 / r4162526;
        return r4162532;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r4162533 = b;
        double r4162534 = -1.3439079675895927e+154;
        bool r4162535 = r4162533 <= r4162534;
        double r4162536 = -0.3333333333333333;
        double r4162537 = a;
        double r4162538 = r4162533 / r4162537;
        double r4162539 = r4162536 * r4162538;
        double r4162540 = 3.7959291444004856e+110;
        bool r4162541 = r4162533 <= r4162540;
        double r4162542 = 1.0;
        double r4162543 = 3.0;
        double r4162544 = cbrt(r4162543);
        double r4162545 = r4162544 * r4162544;
        double r4162546 = r4162542 / r4162545;
        double r4162547 = c;
        double r4162548 = -3.0;
        double r4162549 = r4162537 * r4162548;
        double r4162550 = r4162533 * r4162533;
        double r4162551 = fma(r4162547, r4162549, r4162550);
        double r4162552 = sqrt(r4162551);
        double r4162553 = r4162552 - r4162533;
        double r4162554 = r4162537 / r4162553;
        double r4162555 = r4162546 / r4162554;
        double r4162556 = r4162555 / r4162544;
        double r4162557 = 0.0;
        double r4162558 = r4162541 ? r4162556 : r4162557;
        double r4162559 = r4162535 ? r4162539 : r4162558;
        return r4162559;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 3 regimes
  2. if b < -1.3439079675895927e+154

    1. Initial program 60.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified60.7

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-/r*60.7

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3}}{a}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt60.7

      \[\leadsto \frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}}{a}\]
    7. Applied *-un-lft-identity60.7

      \[\leadsto \frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    8. Applied *-un-lft-identity60.7

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    9. Applied distribute-lft-out--60.7

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    10. Applied times-frac60.7

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{\sqrt[3]{3}}}}{a}\]
    11. Applied associate-/l*60.7

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{\sqrt[3]{3}}}}}\]
    12. Taylor expanded around -inf 52.2

      \[\leadsto \color{blue}{\frac{-1}{3} \cdot \frac{b}{a}}\]

    if -1.3439079675895927e+154 < b < 3.7959291444004856e+110

    1. Initial program 20.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified20.7

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-/r*20.7

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3}}{a}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt20.7

      \[\leadsto \frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}}{a}\]
    7. Applied *-un-lft-identity20.7

      \[\leadsto \frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    8. Applied *-un-lft-identity20.7

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    9. Applied distribute-lft-out--20.7

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}}{a}\]
    10. Applied times-frac20.8

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{\sqrt[3]{3}}}}{a}\]
    11. Applied associate-/l*20.8

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{\sqrt[3]{3}}}}}\]
    12. Using strategy rm
    13. Applied associate-/r/20.8

      \[\leadsto \frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\color{blue}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b} \cdot \sqrt[3]{3}}}\]
    14. Applied associate-/r*20.8

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

    if 3.7959291444004856e+110 < b

    1. Initial program 59.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified59.6

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-/r*59.6

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3}}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity59.6

      \[\leadsto \frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3}}{\color{blue}{1 \cdot a}}\]
    7. Applied div-inv59.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right) \cdot \frac{1}{3}}}{1 \cdot a}\]
    8. Applied times-frac59.6

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

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

      \[\leadsto \left(\sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)} - b\right) \cdot \color{blue}{\frac{\frac{1}{3}}{a}}\]
    11. Taylor expanded around 0 40.3

      \[\leadsto \color{blue}{0}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification28.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3439079675895927 \cdot 10^{+154}:\\ \;\;\;\;\frac{-1}{3} \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 3.7959291444004856 \cdot 10^{+110}:\\ \;\;\;\;\frac{\frac{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(a \cdot -3\right), \left(b \cdot b\right)\right)} - b}}}{\sqrt[3]{3}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

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