Average Error: 34.7 → 12.2
Time: 5.3s
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 -3.24871045842543306174489604165780381049 \cdot 10^{105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1.5 \cdot \frac{a}{b}, c, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.206156884192515644391499516147333317583 \cdot 10^{-138}:\\ \;\;\;\;\frac{\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}\\ \mathbf{elif}\;b \le 8.327899021808038017686023791133232588729 \cdot 10^{148}:\\ \;\;\;\;\frac{\frac{3 \cdot \left(a \cdot c\right) + 0}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{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 -3.24871045842543306174489604165780381049 \cdot 10^{105}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1.5 \cdot \frac{a}{b}, c, -2 \cdot b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 1.206156884192515644391499516147333317583 \cdot 10^{-138}:\\
\;\;\;\;\frac{\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}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r104468 = b;
        double r104469 = -r104468;
        double r104470 = r104468 * r104468;
        double r104471 = 3.0;
        double r104472 = a;
        double r104473 = r104471 * r104472;
        double r104474 = c;
        double r104475 = r104473 * r104474;
        double r104476 = r104470 - r104475;
        double r104477 = sqrt(r104476);
        double r104478 = r104469 + r104477;
        double r104479 = r104478 / r104473;
        return r104479;
}

double f(double a, double b, double c) {
        double r104480 = b;
        double r104481 = -3.248710458425433e+105;
        bool r104482 = r104480 <= r104481;
        double r104483 = 1.5;
        double r104484 = a;
        double r104485 = r104484 / r104480;
        double r104486 = r104483 * r104485;
        double r104487 = c;
        double r104488 = -2.0;
        double r104489 = r104488 * r104480;
        double r104490 = fma(r104486, r104487, r104489);
        double r104491 = 3.0;
        double r104492 = r104491 * r104484;
        double r104493 = r104490 / r104492;
        double r104494 = 1.2061568841925156e-138;
        bool r104495 = r104480 <= r104494;
        double r104496 = cbrt(r104480);
        double r104497 = r104496 * r104496;
        double r104498 = -r104496;
        double r104499 = r104480 * r104480;
        double r104500 = r104492 * r104487;
        double r104501 = r104499 - r104500;
        double r104502 = sqrt(r104501);
        double r104503 = fma(r104497, r104498, r104502);
        double r104504 = r104503 / r104492;
        double r104505 = 8.327899021808038e+148;
        bool r104506 = r104480 <= r104505;
        double r104507 = r104484 * r104487;
        double r104508 = r104491 * r104507;
        double r104509 = 0.0;
        double r104510 = r104508 + r104509;
        double r104511 = -r104480;
        double r104512 = r104511 - r104502;
        double r104513 = r104510 / r104512;
        double r104514 = r104513 / r104492;
        double r104515 = -1.5;
        double r104516 = r104507 / r104480;
        double r104517 = r104515 * r104516;
        double r104518 = r104517 / r104492;
        double r104519 = r104506 ? r104514 : r104518;
        double r104520 = r104495 ? r104504 : r104519;
        double r104521 = r104482 ? r104493 : r104520;
        return r104521;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 48.6

      \[\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-cbrt48.7

      \[\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-rgt-neg-in48.7

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

      \[\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 11.1

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

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

    if -3.248710458425433e+105 < b < 1.2061568841925156e-138

    1. Initial program 11.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-cbrt12.1

      \[\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-rgt-neg-in12.1

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

      \[\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}\]

    if 1.2061568841925156e-138 < b < 8.327899021808038e+148

    1. Initial program 41.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-exp-log42.6

      \[\leadsto \frac{\color{blue}{e^{\log \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied flip-+42.6

      \[\leadsto \frac{e^{\log \color{blue}{\left(\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}}\right)}}}{3 \cdot a}\]
    6. Applied log-div64.0

      \[\leadsto \frac{e^{\color{blue}{\log \left(\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}\right) - \log \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    7. Applied exp-diff64.0

      \[\leadsto \frac{\color{blue}{\frac{e^{\log \left(\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}\right)}}{e^{\log \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}}{3 \cdot a}\]
    8. Simplified64.0

      \[\leadsto \frac{\frac{\color{blue}{3 \cdot \left(a \cdot c\right) + 0}}{e^{\log \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    9. Simplified15.7

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

    if 8.327899021808038e+148 < b

    1. Initial program 63.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.24871045842543306174489604165780381049 \cdot 10^{105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1.5 \cdot \frac{a}{b}, c, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.206156884192515644391499516147333317583 \cdot 10^{-138}:\\ \;\;\;\;\frac{\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}\\ \mathbf{elif}\;b \le 8.327899021808038017686023791133232588729 \cdot 10^{148}:\\ \;\;\;\;\frac{\frac{3 \cdot \left(a \cdot c\right) + 0}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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