Average Error: 28.9 → 14.8
Time: 4.5s
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}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -2.230493035788248233472128283921831481962 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot -1.5\right) \cdot \frac{c}{b}\right) \cdot \frac{1}{3 \cdot a}\\ \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{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -2.230493035788248233472128283921831481962 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, b, -\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot -1.5\right) \cdot \frac{c}{b}\right) \cdot \frac{1}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r86384 = b;
        double r86385 = -r86384;
        double r86386 = r86384 * r86384;
        double r86387 = 3.0;
        double r86388 = a;
        double r86389 = r86387 * r86388;
        double r86390 = c;
        double r86391 = r86389 * r86390;
        double r86392 = r86386 - r86391;
        double r86393 = sqrt(r86392);
        double r86394 = r86385 + r86393;
        double r86395 = r86394 / r86389;
        return r86395;
}

double f(double a, double b, double c) {
        double r86396 = b;
        double r86397 = -r86396;
        double r86398 = r86396 * r86396;
        double r86399 = 3.0;
        double r86400 = a;
        double r86401 = r86399 * r86400;
        double r86402 = c;
        double r86403 = r86401 * r86402;
        double r86404 = r86398 - r86403;
        double r86405 = sqrt(r86404);
        double r86406 = r86397 + r86405;
        double r86407 = r86406 / r86401;
        double r86408 = -2.2304930357882482e-07;
        bool r86409 = r86407 <= r86408;
        double r86410 = -r86404;
        double r86411 = fma(r86396, r86396, r86410);
        double r86412 = r86397 - r86405;
        double r86413 = r86411 / r86412;
        double r86414 = r86413 / r86401;
        double r86415 = -1.5;
        double r86416 = r86400 * r86415;
        double r86417 = r86402 / r86396;
        double r86418 = r86416 * r86417;
        double r86419 = 1.0;
        double r86420 = r86419 / r86401;
        double r86421 = r86418 * r86420;
        double r86422 = r86409 ? r86414 : r86421;
        return r86422;
}

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.0 a) c)))) (* 3.0 a)) < -2.2304930357882482e-07

    1. Initial program 18.7

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

      \[\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. Simplified18.0

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

    if -2.2304930357882482e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 44.6

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity10.1

      \[\leadsto \frac{-1.5 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3 \cdot a}\]
    5. Applied times-frac10.0

      \[\leadsto \frac{-1.5 \cdot \color{blue}{\left(\frac{a}{1} \cdot \frac{c}{b}\right)}}{3 \cdot a}\]
    6. Applied associate-*r*9.9

      \[\leadsto \frac{\color{blue}{\left(-1.5 \cdot \frac{a}{1}\right) \cdot \frac{c}{b}}}{3 \cdot a}\]
    7. Simplified9.9

      \[\leadsto \frac{\color{blue}{\left(a \cdot -1.5\right)} \cdot \frac{c}{b}}{3 \cdot a}\]
    8. Using strategy rm
    9. Applied div-inv10.0

      \[\leadsto \color{blue}{\left(\left(a \cdot -1.5\right) \cdot \frac{c}{b}\right) \cdot \frac{1}{3 \cdot a}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.8

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

Reproduce

herbie shell --seed 2019353 +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)))