Average Error: 28.8 → 14.7
Time: 20.1s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.2869062720138724 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b, b \cdot b\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.2869062720138724 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b, b \cdot b\right)}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2739538 = b;
        double r2739539 = -r2739538;
        double r2739540 = r2739538 * r2739538;
        double r2739541 = 3.0;
        double r2739542 = a;
        double r2739543 = r2739541 * r2739542;
        double r2739544 = c;
        double r2739545 = r2739543 * r2739544;
        double r2739546 = r2739540 - r2739545;
        double r2739547 = sqrt(r2739546);
        double r2739548 = r2739539 + r2739547;
        double r2739549 = r2739548 / r2739543;
        return r2739549;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2739550 = b;
        double r2739551 = r2739550 * r2739550;
        double r2739552 = 3.0;
        double r2739553 = a;
        double r2739554 = r2739552 * r2739553;
        double r2739555 = c;
        double r2739556 = r2739554 * r2739555;
        double r2739557 = r2739551 - r2739556;
        double r2739558 = sqrt(r2739557);
        double r2739559 = -r2739550;
        double r2739560 = r2739558 + r2739559;
        double r2739561 = r2739560 / r2739554;
        double r2739562 = -1.2869062720138724e-05;
        bool r2739563 = r2739561 <= r2739562;
        double r2739564 = r2739557 * r2739558;
        double r2739565 = r2739550 * r2739551;
        double r2739566 = r2739564 - r2739565;
        double r2739567 = r2739558 + r2739550;
        double r2739568 = fma(r2739558, r2739567, r2739551);
        double r2739569 = r2739566 / r2739568;
        double r2739570 = r2739569 / r2739554;
        double r2739571 = -0.5;
        double r2739572 = r2739555 / r2739550;
        double r2739573 = r2739571 * r2739572;
        double r2739574 = r2739563 ? r2739570 : r2739573;
        return r2739574;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -1.2869062720138724e-05

    1. Initial program 17.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip3-+17.1

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{3} + {\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}^{3}}{\left(-b\right) \cdot \left(-b\right) + \left(\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) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    4. Simplified16.3

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} \cdot \left(b \cdot b - c \cdot \left(3 \cdot a\right)\right) - \left(b \cdot b\right) \cdot b}}{\left(-b\right) \cdot \left(-b\right) + \left(\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) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]
    5. Simplified16.3

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

    if -1.2869062720138724e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 40.1

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

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

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

Reproduce

herbie shell --seed 2019134 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical, narrow range"
  :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)))