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 r86542 = b;
        double r86543 = -r86542;
        double r86544 = r86542 * r86542;
        double r86545 = 3.0;
        double r86546 = a;
        double r86547 = r86545 * r86546;
        double r86548 = c;
        double r86549 = r86547 * r86548;
        double r86550 = r86544 - r86549;
        double r86551 = sqrt(r86550);
        double r86552 = r86543 + r86551;
        double r86553 = r86552 / r86547;
        return r86553;
}

double f(double a, double b, double c) {
        double r86554 = b;
        double r86555 = -r86554;
        double r86556 = r86554 * r86554;
        double r86557 = 3.0;
        double r86558 = a;
        double r86559 = r86557 * r86558;
        double r86560 = c;
        double r86561 = r86559 * r86560;
        double r86562 = r86556 - r86561;
        double r86563 = sqrt(r86562);
        double r86564 = r86555 + r86563;
        double r86565 = r86564 / r86559;
        double r86566 = -2.2304930357882482e-07;
        bool r86567 = r86565 <= r86566;
        double r86568 = -r86562;
        double r86569 = fma(r86554, r86554, r86568);
        double r86570 = r86555 - r86563;
        double r86571 = r86569 / r86570;
        double r86572 = r86571 / r86559;
        double r86573 = -1.5;
        double r86574 = r86558 * r86573;
        double r86575 = r86560 / r86554;
        double r86576 = r86574 * r86575;
        double r86577 = 1.0;
        double r86578 = r86577 / r86559;
        double r86579 = r86576 * r86578;
        double r86580 = r86567 ? r86572 : r86579;
        return r86580;
}

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)))