Average Error: 34.5 → 14.8
Time: 19.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 -63362873442066488610789523456:\\ \;\;\;\;\frac{\mathsf{fma}\left(-2, b, \frac{1.5 \cdot a}{\frac{b}{c}}\right)}{a \cdot 3}\\ \mathbf{elif}\;b \le 3.394285259336288061672372155189834062038 \cdot 10^{-72}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{b} \cdot \sqrt[3]{b}, -\sqrt[3]{b}, \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot a}{b} \cdot -1.5}{a \cdot 3}\\ \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 -63362873442066488610789523456:\\
\;\;\;\;\frac{\mathsf{fma}\left(-2, b, \frac{1.5 \cdot a}{\frac{b}{c}}\right)}{a \cdot 3}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4617624 = b;
        double r4617625 = -r4617624;
        double r4617626 = r4617624 * r4617624;
        double r4617627 = 3.0;
        double r4617628 = a;
        double r4617629 = r4617627 * r4617628;
        double r4617630 = c;
        double r4617631 = r4617629 * r4617630;
        double r4617632 = r4617626 - r4617631;
        double r4617633 = sqrt(r4617632);
        double r4617634 = r4617625 + r4617633;
        double r4617635 = r4617634 / r4617629;
        return r4617635;
}

double f(double a, double b, double c) {
        double r4617636 = b;
        double r4617637 = -6.336287344206649e+28;
        bool r4617638 = r4617636 <= r4617637;
        double r4617639 = -2.0;
        double r4617640 = 1.5;
        double r4617641 = a;
        double r4617642 = r4617640 * r4617641;
        double r4617643 = c;
        double r4617644 = r4617636 / r4617643;
        double r4617645 = r4617642 / r4617644;
        double r4617646 = fma(r4617639, r4617636, r4617645);
        double r4617647 = 3.0;
        double r4617648 = r4617641 * r4617647;
        double r4617649 = r4617646 / r4617648;
        double r4617650 = 3.394285259336288e-72;
        bool r4617651 = r4617636 <= r4617650;
        double r4617652 = cbrt(r4617636);
        double r4617653 = r4617652 * r4617652;
        double r4617654 = -r4617652;
        double r4617655 = r4617636 * r4617636;
        double r4617656 = r4617648 * r4617643;
        double r4617657 = r4617655 - r4617656;
        double r4617658 = sqrt(r4617657);
        double r4617659 = fma(r4617653, r4617654, r4617658);
        double r4617660 = r4617659 / r4617648;
        double r4617661 = r4617643 * r4617641;
        double r4617662 = r4617661 / r4617636;
        double r4617663 = -1.5;
        double r4617664 = r4617662 * r4617663;
        double r4617665 = r4617664 / r4617648;
        double r4617666 = r4617651 ? r4617660 : r4617665;
        double r4617667 = r4617638 ? r4617649 : r4617666;
        return r4617667;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -6.336287344206649e+28

    1. Initial program 34.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-cbrt34.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}\right)}}}{3 \cdot a}\]
    4. Applied associate-*r*34.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(\left(3 \cdot a\right) \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right) \cdot \sqrt[3]{c}}}}{3 \cdot a}\]
    5. Taylor expanded around -inf 11.8

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    6. Simplified7.5

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

    if -6.336287344206649e+28 < b < 3.394285259336288e-72

    1. Initial program 14.0

      \[\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-cbrt14.2

      \[\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-in14.2

      \[\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-def14.2

      \[\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 3.394285259336288e-72 < b

    1. Initial program 53.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -63362873442066488610789523456:\\ \;\;\;\;\frac{\mathsf{fma}\left(-2, b, \frac{1.5 \cdot a}{\frac{b}{c}}\right)}{a \cdot 3}\\ \mathbf{elif}\;b \le 3.394285259336288061672372155189834062038 \cdot 10^{-72}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{b} \cdot \sqrt[3]{b}, -\sqrt[3]{b}, \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot a}{b} \cdot -1.5}{a \cdot 3}\\ \end{array}\]

Reproduce

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