Average Error: 33.2 → 10.4
Time: 30.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 -1.6158258643550695 \cdot 10^{+153}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c \cdot \frac{a}{b}, \frac{3}{2}, b \cdot -2\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.821014310434392 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{a} \cdot \frac{\sqrt{\mathsf{fma}\left(-3, c \cdot a, b \cdot b\right)} - b}{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 -1.6158258643550695 \cdot 10^{+153}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c \cdot \frac{a}{b}, \frac{3}{2}, b \cdot -2\right)}{3 \cdot a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r3898315 = b;
        double r3898316 = -r3898315;
        double r3898317 = r3898315 * r3898315;
        double r3898318 = 3.0;
        double r3898319 = a;
        double r3898320 = r3898318 * r3898319;
        double r3898321 = c;
        double r3898322 = r3898320 * r3898321;
        double r3898323 = r3898317 - r3898322;
        double r3898324 = sqrt(r3898323);
        double r3898325 = r3898316 + r3898324;
        double r3898326 = r3898325 / r3898320;
        return r3898326;
}

double f(double a, double b, double c) {
        double r3898327 = b;
        double r3898328 = -1.6158258643550695e+153;
        bool r3898329 = r3898327 <= r3898328;
        double r3898330 = c;
        double r3898331 = a;
        double r3898332 = r3898331 / r3898327;
        double r3898333 = r3898330 * r3898332;
        double r3898334 = 1.5;
        double r3898335 = -2.0;
        double r3898336 = r3898327 * r3898335;
        double r3898337 = fma(r3898333, r3898334, r3898336);
        double r3898338 = 3.0;
        double r3898339 = r3898338 * r3898331;
        double r3898340 = r3898337 / r3898339;
        double r3898341 = 3.821014310434392e-21;
        bool r3898342 = r3898327 <= r3898341;
        double r3898343 = 1.0;
        double r3898344 = r3898343 / r3898331;
        double r3898345 = -3.0;
        double r3898346 = r3898330 * r3898331;
        double r3898347 = r3898327 * r3898327;
        double r3898348 = fma(r3898345, r3898346, r3898347);
        double r3898349 = sqrt(r3898348);
        double r3898350 = r3898349 - r3898327;
        double r3898351 = r3898350 / r3898338;
        double r3898352 = r3898344 * r3898351;
        double r3898353 = r3898330 / r3898327;
        double r3898354 = -0.5;
        double r3898355 = r3898353 * r3898354;
        double r3898356 = r3898342 ? r3898352 : r3898355;
        double r3898357 = r3898329 ? r3898340 : r3898356;
        return r3898357;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.6158258643550695e+153

    1. Initial program 60.6

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

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

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

    if -1.6158258643550695e+153 < b < 3.821014310434392e-21

    1. Initial program 14.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*14.1

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

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

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

    if 3.821014310434392e-21 < b

    1. Initial program 54.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.6158258643550695 \cdot 10^{+153}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c \cdot \frac{a}{b}, \frac{3}{2}, b \cdot -2\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.821014310434392 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{a} \cdot \frac{\sqrt{\mathsf{fma}\left(-3, c \cdot a, b \cdot b\right)} - b}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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