Average Error: 33.3 → 13.1
Time: 18.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 -2.6777729652842867 \cdot 10^{+110}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-2, b, \frac{a \cdot \frac{3}{2}}{\frac{b}{c}}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 4.989300060318096 \cdot 10^{-57}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\left(\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \left(-\sqrt[3]{b}\right), \sqrt[3]{b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-3}{2} \cdot a}{\frac{b}{c}}}{3 \cdot a}\\ \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 -2.6777729652842867 \cdot 10^{+110}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, b, \frac{a \cdot \frac{3}{2}}{\frac{b}{c}}\right)}{3 \cdot a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-3}{2} \cdot a}{\frac{b}{c}}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r1890511 = b;
        double r1890512 = -r1890511;
        double r1890513 = r1890511 * r1890511;
        double r1890514 = 3.0;
        double r1890515 = a;
        double r1890516 = r1890514 * r1890515;
        double r1890517 = c;
        double r1890518 = r1890516 * r1890517;
        double r1890519 = r1890513 - r1890518;
        double r1890520 = sqrt(r1890519);
        double r1890521 = r1890512 + r1890520;
        double r1890522 = r1890521 / r1890516;
        return r1890522;
}

double f(double a, double b, double c) {
        double r1890523 = b;
        double r1890524 = -2.6777729652842867e+110;
        bool r1890525 = r1890523 <= r1890524;
        double r1890526 = -2.0;
        double r1890527 = a;
        double r1890528 = 1.5;
        double r1890529 = r1890527 * r1890528;
        double r1890530 = c;
        double r1890531 = r1890523 / r1890530;
        double r1890532 = r1890529 / r1890531;
        double r1890533 = fma(r1890526, r1890523, r1890532);
        double r1890534 = 3.0;
        double r1890535 = r1890534 * r1890527;
        double r1890536 = r1890533 / r1890535;
        double r1890537 = 4.989300060318096e-57;
        bool r1890538 = r1890523 <= r1890537;
        double r1890539 = cbrt(r1890523);
        double r1890540 = cbrt(r1890539);
        double r1890541 = r1890540 * r1890540;
        double r1890542 = r1890541 * r1890540;
        double r1890543 = -r1890539;
        double r1890544 = r1890542 * r1890543;
        double r1890545 = r1890523 * r1890523;
        double r1890546 = r1890535 * r1890530;
        double r1890547 = r1890545 - r1890546;
        double r1890548 = sqrt(r1890547);
        double r1890549 = fma(r1890544, r1890539, r1890548);
        double r1890550 = r1890549 / r1890535;
        double r1890551 = -1.5;
        double r1890552 = r1890551 * r1890527;
        double r1890553 = r1890552 / r1890531;
        double r1890554 = r1890553 / r1890535;
        double r1890555 = r1890538 ? r1890550 : r1890554;
        double r1890556 = r1890525 ? r1890536 : r1890555;
        return r1890556;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.6777729652842867e+110

    1. Initial program 47.0

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

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

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

    if -2.6777729652842867e+110 < b < 4.989300060318096e-57

    1. Initial program 13.2

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

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

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

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

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

    if 4.989300060318096e-57 < b

    1. Initial program 52.9

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

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

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

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

      \[\leadsto \frac{\color{blue}{-\frac{3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    7. Simplified16.3

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

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

Reproduce

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