Average Error: 28.4 → 16.7
Time: 18.4s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 60.51244836482759836826517130248248577118:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}, b \cdot b - 3 \cdot \left(c \cdot a\right)\right) + b \cdot b}}{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 60.51244836482759836826517130248248577118:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}, b \cdot b - 3 \cdot \left(c \cdot a\right)\right) + b \cdot b}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3439432 = b;
        double r3439433 = -r3439432;
        double r3439434 = r3439432 * r3439432;
        double r3439435 = 3.0;
        double r3439436 = a;
        double r3439437 = r3439435 * r3439436;
        double r3439438 = c;
        double r3439439 = r3439437 * r3439438;
        double r3439440 = r3439434 - r3439439;
        double r3439441 = sqrt(r3439440);
        double r3439442 = r3439433 + r3439441;
        double r3439443 = r3439442 / r3439437;
        return r3439443;
}

double f(double a, double b, double c) {
        double r3439444 = b;
        double r3439445 = 60.5124483648276;
        bool r3439446 = r3439444 <= r3439445;
        double r3439447 = r3439444 * r3439444;
        double r3439448 = 3.0;
        double r3439449 = c;
        double r3439450 = a;
        double r3439451 = r3439449 * r3439450;
        double r3439452 = r3439448 * r3439451;
        double r3439453 = r3439447 - r3439452;
        double r3439454 = sqrt(r3439453);
        double r3439455 = r3439453 * r3439454;
        double r3439456 = r3439447 * r3439444;
        double r3439457 = r3439455 - r3439456;
        double r3439458 = fma(r3439444, r3439454, r3439453);
        double r3439459 = r3439458 + r3439447;
        double r3439460 = r3439457 / r3439459;
        double r3439461 = r3439448 * r3439450;
        double r3439462 = r3439460 / r3439461;
        double r3439463 = -0.5;
        double r3439464 = r3439449 / r3439444;
        double r3439465 = r3439463 * r3439464;
        double r3439466 = r3439446 ? r3439462 : r3439465;
        return r3439466;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 60.5124483648276

    1. Initial program 14.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip3-+14.6

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

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

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

    if 60.5124483648276 < b

    1. Initial program 34.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 60.51244836482759836826517130248248577118:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 3 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\mathsf{fma}\left(b, \sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)}, b \cdot b - 3 \cdot \left(c \cdot a\right)\right) + b \cdot b}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))