Average Error: 29.0 → 17.5
Time: 7.7s
Precision: 64
\[1.05367121277235087 \cdot 10^{-8} \lt a \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt b \lt 94906265.6242515594 \land 1.05367121277235087 \cdot 10^{-8} \lt c \lt 94906265.6242515594\]
\[\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 20.327229482009734 \lor \neg \left(b \le 520.871493226619691\right) \land b \le 5060.8354328326695:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + 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 20.327229482009734 \lor \neg \left(b \le 520.871493226619691\right) \land b \le 5060.8354328326695:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r103360 = b;
        double r103361 = -r103360;
        double r103362 = r103360 * r103360;
        double r103363 = 3.0;
        double r103364 = a;
        double r103365 = r103363 * r103364;
        double r103366 = c;
        double r103367 = r103365 * r103366;
        double r103368 = r103362 - r103367;
        double r103369 = sqrt(r103368);
        double r103370 = r103361 + r103369;
        double r103371 = r103370 / r103365;
        return r103371;
}

double f(double a, double b, double c) {
        double r103372 = b;
        double r103373 = 20.327229482009734;
        bool r103374 = r103372 <= r103373;
        double r103375 = 520.8714932266197;
        bool r103376 = r103372 <= r103375;
        double r103377 = !r103376;
        double r103378 = 5060.8354328326695;
        bool r103379 = r103372 <= r103378;
        bool r103380 = r103377 && r103379;
        bool r103381 = r103374 || r103380;
        double r103382 = r103372 * r103372;
        double r103383 = 3.0;
        double r103384 = a;
        double r103385 = r103383 * r103384;
        double r103386 = c;
        double r103387 = r103385 * r103386;
        double r103388 = fma(r103372, r103372, r103387);
        double r103389 = r103382 - r103388;
        double r103390 = r103382 - r103387;
        double r103391 = sqrt(r103390);
        double r103392 = r103391 + r103372;
        double r103393 = r103389 / r103392;
        double r103394 = r103393 / r103385;
        double r103395 = -0.5;
        double r103396 = r103386 / r103372;
        double r103397 = r103395 * r103396;
        double r103398 = r103381 ? r103394 : r103397;
        return r103398;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 20.327229482009734 or 520.8714932266197 < b < 5060.8354328326695

    1. Initial program 18.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified18.2

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--18.2

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

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

    if 20.327229482009734 < b < 520.8714932266197 or 5060.8354328326695 < b

    1. Initial program 34.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified34.7

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Taylor expanded around inf 17.5

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

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

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :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)))