Average Error: 33.1 → 10.9
Time: 22.1s
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 -9.348931433494438 \cdot 10^{+39}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b}, \frac{1}{2}, \frac{b \cdot \frac{-2}{3}}{a}\right)\\ \mathbf{elif}\;b \le 1.3353078790738604 \cdot 10^{-121}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right) \cdot \frac{1}{3}}{a}\\ \mathbf{elif}\;b \le 1.6168702840263923 \cdot 10^{-79}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \mathbf{elif}\;b \le 1.546013236023957 \cdot 10^{-67}:\\ \;\;\;\;\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right)}{a \cdot \sqrt[3]{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \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 -9.348931433494438 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b}, \frac{1}{2}, \frac{b \cdot \frac{-2}{3}}{a}\right)\\

\mathbf{elif}\;b \le 1.3353078790738604 \cdot 10^{-121}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right) \cdot \frac{1}{3}}{a}\\

\mathbf{elif}\;b \le 1.6168702840263923 \cdot 10^{-79}:\\
\;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\

\end{array}
double f(double a, double b, double c) {
        double r5327153 = b;
        double r5327154 = -r5327153;
        double r5327155 = r5327153 * r5327153;
        double r5327156 = 3.0;
        double r5327157 = a;
        double r5327158 = r5327156 * r5327157;
        double r5327159 = c;
        double r5327160 = r5327158 * r5327159;
        double r5327161 = r5327155 - r5327160;
        double r5327162 = sqrt(r5327161);
        double r5327163 = r5327154 + r5327162;
        double r5327164 = r5327163 / r5327158;
        return r5327164;
}

double f(double a, double b, double c) {
        double r5327165 = b;
        double r5327166 = -9.348931433494438e+39;
        bool r5327167 = r5327165 <= r5327166;
        double r5327168 = c;
        double r5327169 = r5327168 / r5327165;
        double r5327170 = 0.5;
        double r5327171 = -0.6666666666666666;
        double r5327172 = r5327165 * r5327171;
        double r5327173 = a;
        double r5327174 = r5327172 / r5327173;
        double r5327175 = fma(r5327169, r5327170, r5327174);
        double r5327176 = 1.3353078790738604e-121;
        bool r5327177 = r5327165 <= r5327176;
        double r5327178 = -1.0;
        double r5327179 = -3.0;
        double r5327180 = r5327179 * r5327173;
        double r5327181 = r5327165 * r5327165;
        double r5327182 = fma(r5327180, r5327168, r5327181);
        double r5327183 = sqrt(r5327182);
        double r5327184 = fma(r5327165, r5327178, r5327183);
        double r5327185 = 0.3333333333333333;
        double r5327186 = r5327184 * r5327185;
        double r5327187 = r5327186 / r5327173;
        double r5327188 = 1.6168702840263923e-79;
        bool r5327189 = r5327165 <= r5327188;
        double r5327190 = -0.5;
        double r5327191 = r5327169 * r5327190;
        double r5327192 = 1.546013236023957e-67;
        bool r5327193 = r5327165 <= r5327192;
        double r5327194 = 1.0;
        double r5327195 = 3.0;
        double r5327196 = cbrt(r5327195);
        double r5327197 = r5327196 * r5327196;
        double r5327198 = r5327194 / r5327197;
        double r5327199 = r5327173 * r5327196;
        double r5327200 = r5327184 / r5327199;
        double r5327201 = r5327198 * r5327200;
        double r5327202 = r5327193 ? r5327201 : r5327191;
        double r5327203 = r5327189 ? r5327191 : r5327202;
        double r5327204 = r5327177 ? r5327187 : r5327203;
        double r5327205 = r5327167 ? r5327175 : r5327204;
        return r5327205;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -9.348931433494438e+39

    1. Initial program 34.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*34.1

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

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right)}{3}}}{a}\]
    5. Using strategy rm
    6. Applied div-inv34.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right) \cdot \frac{1}{3}}}{a}\]
    7. Simplified34.1

      \[\leadsto \frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right) \cdot \color{blue}{\frac{1}{3}}}{a}\]
    8. Taylor expanded around -inf 6.5

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b} - \frac{2}{3} \cdot \frac{b}{a}}\]
    9. Simplified6.5

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

    if -9.348931433494438e+39 < b < 1.3353078790738604e-121

    1. Initial program 12.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 associate-/r*12.3

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

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right)}{3}}}{a}\]
    5. Using strategy rm
    6. Applied div-inv12.4

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right) \cdot \frac{1}{3}}}{a}\]
    7. Simplified12.4

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

    if 1.3353078790738604e-121 < b < 1.6168702840263923e-79 or 1.546013236023957e-67 < b

    1. Initial program 50.8

      \[\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 \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}}\]

    if 1.6168702840263923e-79 < b < 1.546013236023957e-67

    1. Initial program 35.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-cbrt35.9

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot a\right)}}\]
    5. Applied *-un-lft-identity35.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot a\right)}\]
    6. Applied times-frac35.9

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\sqrt[3]{3} \cdot a}}\]
    7. Simplified35.8

      \[\leadsto \frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \color{blue}{\frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right)}{a \cdot \sqrt[3]{3}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification10.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -9.348931433494438 \cdot 10^{+39}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b}, \frac{1}{2}, \frac{b \cdot \frac{-2}{3}}{a}\right)\\ \mathbf{elif}\;b \le 1.3353078790738604 \cdot 10^{-121}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right) \cdot \frac{1}{3}}{a}\\ \mathbf{elif}\;b \le 1.6168702840263923 \cdot 10^{-79}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \mathbf{elif}\;b \le 1.546013236023957 \cdot 10^{-67}:\\ \;\;\;\;\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\mathsf{fma}\left(b, -1, \sqrt{\mathsf{fma}\left(-3 \cdot a, c, b \cdot b\right)}\right)}{a \cdot \sqrt[3]{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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