Average Error: 43.9 → 10.2
Time: 4.3s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\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.1266206296132032 \cdot 10^{-10}:\\ \;\;\;\;\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 -4.1266206296132032 \cdot 10^{-10}:\\
\;\;\;\;\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 r82455 = b;
        double r82456 = -r82455;
        double r82457 = r82455 * r82455;
        double r82458 = 3.0;
        double r82459 = a;
        double r82460 = r82458 * r82459;
        double r82461 = c;
        double r82462 = r82460 * r82461;
        double r82463 = r82457 - r82462;
        double r82464 = sqrt(r82463);
        double r82465 = r82456 + r82464;
        double r82466 = r82465 / r82460;
        return r82466;
}

double f(double a, double b, double c) {
        double r82467 = b;
        double r82468 = -r82467;
        double r82469 = r82467 * r82467;
        double r82470 = 3.0;
        double r82471 = a;
        double r82472 = r82470 * r82471;
        double r82473 = c;
        double r82474 = r82472 * r82473;
        double r82475 = r82469 - r82474;
        double r82476 = sqrt(r82475);
        double r82477 = r82468 + r82476;
        double r82478 = r82477 / r82472;
        double r82479 = -4.126620629613203e-10;
        bool r82480 = r82478 <= r82479;
        double r82481 = -r82475;
        double r82482 = fma(r82467, r82467, r82481);
        double r82483 = r82468 - r82476;
        double r82484 = r82482 / r82483;
        double r82485 = r82484 / r82472;
        double r82486 = -0.5;
        double r82487 = r82473 / r82467;
        double r82488 = r82486 * r82487;
        double r82489 = r82480 ? r82485 : r82488;
        return r82489;
}

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.126620629613203e-10

    1. Initial program 22.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-+22.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. Simplified22.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 -4.126620629613203e-10 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 55.9

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

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

    \[\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.1266206296132032 \cdot 10^{-10}:\\ \;\;\;\;\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 2020003 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))