Average Error: 34.4 → 10.8
Time: 6.4s
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.96851200589285808 \cdot 10^{66}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.70136217446186 \cdot 10^{-118}:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \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.96851200589285808 \cdot 10^{66}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 2.70136217446186 \cdot 10^{-118}:\\
\;\;\;\;\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}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r112080 = b;
        double r112081 = -r112080;
        double r112082 = r112080 * r112080;
        double r112083 = 3.0;
        double r112084 = a;
        double r112085 = r112083 * r112084;
        double r112086 = c;
        double r112087 = r112085 * r112086;
        double r112088 = r112082 - r112087;
        double r112089 = sqrt(r112088);
        double r112090 = r112081 + r112089;
        double r112091 = r112090 / r112085;
        return r112091;
}

double f(double a, double b, double c) {
        double r112092 = b;
        double r112093 = -2.968512005892858e+66;
        bool r112094 = r112092 <= r112093;
        double r112095 = 0.5;
        double r112096 = c;
        double r112097 = r112096 / r112092;
        double r112098 = r112095 * r112097;
        double r112099 = 0.6666666666666666;
        double r112100 = a;
        double r112101 = r112092 / r112100;
        double r112102 = r112099 * r112101;
        double r112103 = r112098 - r112102;
        double r112104 = 2.70136217446186e-118;
        bool r112105 = r112092 <= r112104;
        double r112106 = cbrt(r112092);
        double r112107 = r112106 * r112106;
        double r112108 = -r112106;
        double r112109 = r112092 * r112092;
        double r112110 = 3.0;
        double r112111 = r112110 * r112100;
        double r112112 = r112111 * r112096;
        double r112113 = r112109 - r112112;
        double r112114 = sqrt(r112113);
        double r112115 = fma(r112107, r112108, r112114);
        double r112116 = r112115 / r112111;
        double r112117 = -0.5;
        double r112118 = r112117 * r112097;
        double r112119 = r112105 ? r112116 : r112118;
        double r112120 = r112094 ? r112103 : r112119;
        return r112120;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.968512005892858e+66

    1. Initial program 41.5

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}}\]

    if -2.968512005892858e+66 < b < 2.70136217446186e-118

    1. Initial program 13.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-cbrt13.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-in13.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-def13.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 2.70136217446186e-118 < b

    1. Initial program 51.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.96851200589285808 \cdot 10^{66}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.70136217446186 \cdot 10^{-118}:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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