Average Error: 29.0 → 14.5
Time: 52.0s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.358185588111044 \cdot 10^{-06}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)} \cdot \mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.358185588111044 \cdot 10^{-06}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)} \cdot \mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3289436 = b;
        double r3289437 = -r3289436;
        double r3289438 = r3289436 * r3289436;
        double r3289439 = 3.0;
        double r3289440 = a;
        double r3289441 = r3289439 * r3289440;
        double r3289442 = c;
        double r3289443 = r3289441 * r3289442;
        double r3289444 = r3289438 - r3289443;
        double r3289445 = sqrt(r3289444);
        double r3289446 = r3289437 + r3289445;
        double r3289447 = r3289446 / r3289441;
        return r3289447;
}

double f(double a, double b, double c) {
        double r3289448 = b;
        double r3289449 = r3289448 * r3289448;
        double r3289450 = 3.0;
        double r3289451 = a;
        double r3289452 = r3289450 * r3289451;
        double r3289453 = c;
        double r3289454 = r3289452 * r3289453;
        double r3289455 = r3289449 - r3289454;
        double r3289456 = sqrt(r3289455);
        double r3289457 = -r3289448;
        double r3289458 = r3289456 + r3289457;
        double r3289459 = r3289458 / r3289452;
        double r3289460 = -1.358185588111044e-06;
        bool r3289461 = r3289459 <= r3289460;
        double r3289462 = -3.0;
        double r3289463 = r3289462 * r3289453;
        double r3289464 = r3289451 * r3289463;
        double r3289465 = fma(r3289448, r3289448, r3289464);
        double r3289466 = sqrt(r3289465);
        double r3289467 = r3289466 * r3289465;
        double r3289468 = r3289448 * r3289449;
        double r3289469 = r3289467 - r3289468;
        double r3289470 = fma(r3289448, r3289448, r3289465);
        double r3289471 = r3289448 * r3289466;
        double r3289472 = r3289470 + r3289471;
        double r3289473 = r3289469 / r3289472;
        double r3289474 = r3289473 / r3289452;
        double r3289475 = -0.5;
        double r3289476 = r3289453 / r3289448;
        double r3289477 = r3289475 * r3289476;
        double r3289478 = r3289461 ? r3289474 : r3289477;
        return r3289478;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -1.358185588111044e-06

    1. Initial program 17.8

      \[\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-+17.9

      \[\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. Simplified17.3

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} \cdot \mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right) - \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. Simplified17.3

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

    if -1.358185588111044e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 42.9

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

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

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

Reproduce

herbie shell --seed 2019141 +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 a) c)))) (* 3 a)))