Average Error: 34.2 → 16.5
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 -6.2188582860194007 \cdot 10^{53}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3272050005915425310000:\\ \;\;\;\;\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{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 -6.2188582860194007 \cdot 10^{53}:\\
\;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 3272050005915425310000:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r110916 = b;
        double r110917 = -r110916;
        double r110918 = r110916 * r110916;
        double r110919 = 3.0;
        double r110920 = a;
        double r110921 = r110919 * r110920;
        double r110922 = c;
        double r110923 = r110921 * r110922;
        double r110924 = r110918 - r110923;
        double r110925 = sqrt(r110924);
        double r110926 = r110917 + r110925;
        double r110927 = r110926 / r110921;
        return r110927;
}

double f(double a, double b, double c) {
        double r110928 = b;
        double r110929 = -6.218858286019401e+53;
        bool r110930 = r110928 <= r110929;
        double r110931 = -r110928;
        double r110932 = 1.5;
        double r110933 = a;
        double r110934 = c;
        double r110935 = r110933 * r110934;
        double r110936 = r110935 / r110928;
        double r110937 = r110932 * r110936;
        double r110938 = r110937 - r110928;
        double r110939 = r110931 + r110938;
        double r110940 = 3.0;
        double r110941 = r110940 * r110933;
        double r110942 = r110939 / r110941;
        double r110943 = 3.2720500059154253e+21;
        bool r110944 = r110928 <= r110943;
        double r110945 = cbrt(r110928);
        double r110946 = r110945 * r110945;
        double r110947 = -r110945;
        double r110948 = r110928 * r110928;
        double r110949 = r110941 * r110934;
        double r110950 = r110948 - r110949;
        double r110951 = sqrt(r110950);
        double r110952 = fma(r110946, r110947, r110951);
        double r110953 = r110952 / r110941;
        double r110954 = -1.5;
        double r110955 = r110954 * r110936;
        double r110956 = r110955 / r110941;
        double r110957 = r110944 ? r110953 : r110956;
        double r110958 = r110930 ? r110942 : r110957;
        return r110958;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -6.218858286019401e+53

    1. Initial program 37.7

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

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

    if -6.218858286019401e+53 < b < 3.2720500059154253e+21

    1. Initial program 18.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-cube-cbrt18.5

      \[\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-in18.5

      \[\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-def18.5

      \[\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.2720500059154253e+21 < b

    1. Initial program 56.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.2188582860194007 \cdot 10^{53}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3272050005915425310000:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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