Average Error: 34.7 → 13.3
Time: 5.2s
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{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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 r104589 = b;
        double r104590 = -r104589;
        double r104591 = r104589 * r104589;
        double r104592 = 3.0;
        double r104593 = a;
        double r104594 = r104592 * r104593;
        double r104595 = c;
        double r104596 = r104594 * r104595;
        double r104597 = r104591 - r104596;
        double r104598 = sqrt(r104597);
        double r104599 = r104590 + r104598;
        double r104600 = r104599 / r104594;
        return r104600;
}

double f(double a, double b, double c) {
        double r104601 = b;
        double r104602 = -3.248710458425433e+105;
        bool r104603 = r104601 <= r104602;
        double r104604 = 1.5;
        double r104605 = a;
        double r104606 = c;
        double r104607 = r104605 * r104606;
        double r104608 = r104607 / r104601;
        double r104609 = r104604 * r104608;
        double r104610 = 2.0;
        double r104611 = r104610 * r104601;
        double r104612 = r104609 - r104611;
        double r104613 = 3.0;
        double r104614 = r104613 * r104605;
        double r104615 = r104612 / r104614;
        double r104616 = 1.2061568841925156e-138;
        bool r104617 = r104601 <= r104616;
        double r104618 = -r104601;
        double r104619 = cbrt(r104618);
        double r104620 = r104619 * r104619;
        double r104621 = r104601 * r104601;
        double r104622 = r104614 * r104606;
        double r104623 = r104621 - r104622;
        double r104624 = sqrt(r104623);
        double r104625 = fma(r104620, r104619, r104624);
        double r104626 = r104625 / r104614;
        double r104627 = 8.327899021808038e+148;
        bool r104628 = r104601 <= r104627;
        double r104629 = r104613 * r104607;
        double r104630 = 0.0;
        double r104631 = r104629 + r104630;
        double r104632 = r104618 - r104624;
        double r104633 = r104631 / r104632;
        double r104634 = r104633 / r104614;
        double r104635 = -1.5;
        double r104636 = r104635 * r104608;
        double r104637 = r104636 / r104614;
        double r104638 = r104628 ? r104634 : r104637;
        double r104639 = r104617 ? r104626 : r104638;
        double r104640 = r104603 ? r104615 : r104639;
        return r104640;
}

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{\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}\]
    4. 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}\]
    5. Taylor expanded around -inf 11.1

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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{\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}\]
    4. 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. Using strategy rm
    3. Applied add-exp-log63.3

      \[\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. 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 simplification13.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.24871045842543306174489604165780381049 \cdot 10^{105}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{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)))