Average Error: 28.7 → 16.3
Time: 14.1s
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 3491.917439368316536274505779147148132324:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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 3491.917439368316536274505779147148132324:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, -\left(3 \cdot a\right) \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r66542 = b;
        double r66543 = -r66542;
        double r66544 = r66542 * r66542;
        double r66545 = 3.0;
        double r66546 = a;
        double r66547 = r66545 * r66546;
        double r66548 = c;
        double r66549 = r66547 * r66548;
        double r66550 = r66544 - r66549;
        double r66551 = sqrt(r66550);
        double r66552 = r66543 + r66551;
        double r66553 = r66552 / r66547;
        return r66553;
}

double f(double a, double b, double c) {
        double r66554 = b;
        double r66555 = 3491.9174393683165;
        bool r66556 = r66554 <= r66555;
        double r66557 = r66554 * r66554;
        double r66558 = 3.0;
        double r66559 = a;
        double r66560 = r66558 * r66559;
        double r66561 = c;
        double r66562 = r66560 * r66561;
        double r66563 = -r66562;
        double r66564 = fma(r66554, r66554, r66563);
        double r66565 = r66557 - r66564;
        double r66566 = -r66554;
        double r66567 = r66557 - r66562;
        double r66568 = sqrt(r66567);
        double r66569 = r66566 - r66568;
        double r66570 = r66565 / r66569;
        double r66571 = r66570 / r66560;
        double r66572 = -0.5;
        double r66573 = r66561 / r66554;
        double r66574 = r66572 * r66573;
        double r66575 = r66556 ? r66571 : r66574;
        return r66575;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.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 flip-+18.2

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

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

    if 3491.9174393683165 < b

    1. Initial program 37.4

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

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

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

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.05367121277235087e-8 a 94906265.6242515594) (< 1.05367121277235087e-8 b 94906265.6242515594) (< 1.05367121277235087e-8 c 94906265.6242515594))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))