Average Error: 28.5 → 14.6
Time: 4.5s
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 -4.22600719708206439 \cdot 10^{-6}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{-1.5}{\frac{\left(3 \cdot a\right) \cdot b}{a \cdot c}}\\ \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 -4.22600719708206439 \cdot 10^{-6}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{-1.5}{\frac{\left(3 \cdot a\right) \cdot b}{a \cdot c}}\\

\end{array}
double f(double a, double b, double c) {
        double r79591 = b;
        double r79592 = -r79591;
        double r79593 = r79591 * r79591;
        double r79594 = 3.0;
        double r79595 = a;
        double r79596 = r79594 * r79595;
        double r79597 = c;
        double r79598 = r79596 * r79597;
        double r79599 = r79593 - r79598;
        double r79600 = sqrt(r79599);
        double r79601 = r79592 + r79600;
        double r79602 = r79601 / r79596;
        return r79602;
}

double f(double a, double b, double c) {
        double r79603 = b;
        double r79604 = -r79603;
        double r79605 = r79603 * r79603;
        double r79606 = 3.0;
        double r79607 = a;
        double r79608 = r79606 * r79607;
        double r79609 = c;
        double r79610 = r79608 * r79609;
        double r79611 = r79605 - r79610;
        double r79612 = sqrt(r79611);
        double r79613 = r79604 + r79612;
        double r79614 = r79613 / r79608;
        double r79615 = -4.226007197082064e-06;
        bool r79616 = r79614 <= r79615;
        double r79617 = -r79611;
        double r79618 = fma(r79603, r79603, r79617);
        double r79619 = r79604 - r79612;
        double r79620 = r79618 / r79619;
        double r79621 = r79620 / r79608;
        double r79622 = -1.5;
        double r79623 = r79608 * r79603;
        double r79624 = r79607 * r79609;
        double r79625 = r79623 / r79624;
        double r79626 = r79622 / r79625;
        double r79627 = r79616 ? r79621 : r79626;
        return r79627;
}

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)) < -4.226007197082064e-06

    1. Initial program 17.2

      \[\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-+17.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. Simplified16.5

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

    1. Initial program 41.4

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied associate-*r/12.5

      \[\leadsto \frac{\color{blue}{\frac{-1.5 \cdot \left(a \cdot c\right)}{b}}}{3 \cdot a}\]
    5. Applied associate-/l/12.5

      \[\leadsto \color{blue}{\frac{-1.5 \cdot \left(a \cdot c\right)}{\left(3 \cdot a\right) \cdot b}}\]
    6. Using strategy rm
    7. Applied associate-/l*12.5

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

    \[\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 -4.22600719708206439 \cdot 10^{-6}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{-1.5}{\frac{\left(3 \cdot a\right) \cdot b}{a \cdot c}}\\ \end{array}\]

Reproduce

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