Average Error: 33.8 → 6.7
Time: 19.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 -5.062954969806706230304038666801404238404 \cdot 10^{105}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, 0.6666666666666666296592325124947819858789 \cdot \left(-\frac{b}{a}\right)\right)\\ \mathbf{elif}\;b \le -3.20329872101204323810903584035987239206 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot \left(-c\right)\right)\right)}}{a}}{3} - \frac{\frac{b}{3}}{a}\\ \mathbf{elif}\;b \le 6.945505805945457026290428958234187572732 \cdot 10^{133}:\\ \;\;\;\;\frac{\frac{c \cdot \left(-3\right)}{3}}{b + \sqrt{\mathsf{fma}\left(a \cdot \left(-c\right), 3, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \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.062954969806706230304038666801404238404 \cdot 10^{105}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, 0.6666666666666666296592325124947819858789 \cdot \left(-\frac{b}{a}\right)\right)\\

\mathbf{elif}\;b \le -3.20329872101204323810903584035987239206 \cdot 10^{-299}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot \left(-c\right)\right)\right)}}{a}}{3} - \frac{\frac{b}{3}}{a}\\

\mathbf{elif}\;b \le 6.945505805945457026290428958234187572732 \cdot 10^{133}:\\
\;\;\;\;\frac{\frac{c \cdot \left(-3\right)}{3}}{b + \sqrt{\mathsf{fma}\left(a \cdot \left(-c\right), 3, b \cdot b\right)}}\\

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

\end{array}
double f(double a, double b, double c) {
        double r98436 = b;
        double r98437 = -r98436;
        double r98438 = r98436 * r98436;
        double r98439 = 3.0;
        double r98440 = a;
        double r98441 = r98439 * r98440;
        double r98442 = c;
        double r98443 = r98441 * r98442;
        double r98444 = r98438 - r98443;
        double r98445 = sqrt(r98444);
        double r98446 = r98437 + r98445;
        double r98447 = r98446 / r98441;
        return r98447;
}

double f(double a, double b, double c) {
        double r98448 = b;
        double r98449 = -5.062954969806706e+105;
        bool r98450 = r98448 <= r98449;
        double r98451 = 0.5;
        double r98452 = c;
        double r98453 = r98452 / r98448;
        double r98454 = 0.6666666666666666;
        double r98455 = a;
        double r98456 = r98448 / r98455;
        double r98457 = -r98456;
        double r98458 = r98454 * r98457;
        double r98459 = fma(r98451, r98453, r98458);
        double r98460 = -3.203298721012043e-299;
        bool r98461 = r98448 <= r98460;
        double r98462 = 3.0;
        double r98463 = -r98452;
        double r98464 = r98455 * r98463;
        double r98465 = r98462 * r98464;
        double r98466 = fma(r98448, r98448, r98465);
        double r98467 = sqrt(r98466);
        double r98468 = r98467 / r98455;
        double r98469 = r98468 / r98462;
        double r98470 = r98448 / r98462;
        double r98471 = r98470 / r98455;
        double r98472 = r98469 - r98471;
        double r98473 = 6.945505805945457e+133;
        bool r98474 = r98448 <= r98473;
        double r98475 = -r98462;
        double r98476 = r98452 * r98475;
        double r98477 = r98476 / r98462;
        double r98478 = r98448 * r98448;
        double r98479 = fma(r98464, r98462, r98478);
        double r98480 = sqrt(r98479);
        double r98481 = r98448 + r98480;
        double r98482 = r98477 / r98481;
        double r98483 = -0.5;
        double r98484 = r98453 * r98483;
        double r98485 = r98474 ? r98482 : r98484;
        double r98486 = r98461 ? r98472 : r98485;
        double r98487 = r98450 ? r98459 : r98486;
        return r98487;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -5.062954969806706e+105

    1. Initial program 49.2

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(c \cdot a, -3, 0\right)}}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} + b}}{3 \cdot a}\]
    6. Simplified62.5

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

      \[\leadsto \frac{\frac{\mathsf{fma}\left(c \cdot a, -3, 0\right)}{\color{blue}{1 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(c \cdot a\right)\right)}\right)}}}{3 \cdot a}\]
    9. Applied *-un-lft-identity62.5

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

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{\mathsf{fma}\left(c \cdot a, -3, 0\right)}{b + \sqrt{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(c \cdot a\right)\right)}}}}{3 \cdot a}\]
    11. Applied times-frac62.5

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

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

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

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

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

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

    if -5.062954969806706e+105 < b < -3.203298721012043e-299

    1. Initial program 9.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-sub9.0

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

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

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

    if -3.203298721012043e-299 < b < 6.945505805945457e+133

    1. Initial program 33.1

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

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

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

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

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

      \[\leadsto \frac{\frac{\mathsf{fma}\left(c \cdot a, -3, 0\right)}{\color{blue}{1 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(c \cdot a\right)\right)}\right)}}}{3 \cdot a}\]
    9. Applied *-un-lft-identity16.6

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

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

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

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

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

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

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

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

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

    if 6.945505805945457e+133 < b

    1. Initial program 61.9

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(c \cdot a, -3, 0\right)}}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} + b}}{3 \cdot a}\]
    6. Simplified35.5

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

      \[\leadsto \frac{\frac{\mathsf{fma}\left(c \cdot a, -3, 0\right)}{\color{blue}{1 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(c \cdot a\right)\right)}\right)}}}{3 \cdot a}\]
    9. Applied *-un-lft-identity35.5

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

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{\mathsf{fma}\left(c \cdot a, -3, 0\right)}{b + \sqrt{\mathsf{fma}\left(b, b, \left(-3\right) \cdot \left(c \cdot a\right)\right)}}}}{3 \cdot a}\]
    11. Applied times-frac35.5

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

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

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
    16. Simplified1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.062954969806706230304038666801404238404 \cdot 10^{105}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, 0.6666666666666666296592325124947819858789 \cdot \left(-\frac{b}{a}\right)\right)\\ \mathbf{elif}\;b \le -3.20329872101204323810903584035987239206 \cdot 10^{-299}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot \left(-c\right)\right)\right)}}{a}}{3} - \frac{\frac{b}{3}}{a}\\ \mathbf{elif}\;b \le 6.945505805945457026290428958234187572732 \cdot 10^{133}:\\ \;\;\;\;\frac{\frac{c \cdot \left(-3\right)}{3}}{b + \sqrt{\mathsf{fma}\left(a \cdot \left(-c\right), 3, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

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