Average Error: 28.6 → 15.1
Time: 4.4s
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}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -3.6373948679911628 \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}:\\ \;\;\;\;-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}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -3.6373948679911628 \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}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r104540 = b;
        double r104541 = -r104540;
        double r104542 = r104540 * r104540;
        double r104543 = 3.0;
        double r104544 = a;
        double r104545 = r104543 * r104544;
        double r104546 = c;
        double r104547 = r104545 * r104546;
        double r104548 = r104542 - r104547;
        double r104549 = sqrt(r104548);
        double r104550 = r104541 + r104549;
        double r104551 = r104550 / r104545;
        return r104551;
}

double f(double a, double b, double c) {
        double r104552 = b;
        double r104553 = -r104552;
        double r104554 = r104552 * r104552;
        double r104555 = 3.0;
        double r104556 = a;
        double r104557 = r104555 * r104556;
        double r104558 = c;
        double r104559 = r104557 * r104558;
        double r104560 = r104554 - r104559;
        double r104561 = sqrt(r104560);
        double r104562 = r104553 + r104561;
        double r104563 = r104562 / r104557;
        double r104564 = -3.637394867991163e-07;
        bool r104565 = r104563 <= r104564;
        double r104566 = -r104560;
        double r104567 = fma(r104552, r104552, r104566);
        double r104568 = r104553 - r104561;
        double r104569 = r104567 / r104568;
        double r104570 = r104569 / r104557;
        double r104571 = -0.5;
        double r104572 = r104558 / r104552;
        double r104573 = r104571 * r104572;
        double r104574 = r104565 ? r104570 : r104573;
        return r104574;
}

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)) < -3.637394867991163e-07

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

      \[\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 -3.637394867991163e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 43.7

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

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

    \[\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 -3.6373948679911628 \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}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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