Average Error: 43.2 → 10.1
Time: 18.1s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 -3.125067702281917015824392463985148538086 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{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{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -3.125067702281917015824392463985148538086 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r3909458 = b;
        double r3909459 = -r3909458;
        double r3909460 = r3909458 * r3909458;
        double r3909461 = 3.0;
        double r3909462 = a;
        double r3909463 = r3909461 * r3909462;
        double r3909464 = c;
        double r3909465 = r3909463 * r3909464;
        double r3909466 = r3909460 - r3909465;
        double r3909467 = sqrt(r3909466);
        double r3909468 = r3909459 + r3909467;
        double r3909469 = r3909468 / r3909463;
        return r3909469;
}

double f(double a, double b, double c) {
        double r3909470 = b;
        double r3909471 = r3909470 * r3909470;
        double r3909472 = 3.0;
        double r3909473 = a;
        double r3909474 = r3909472 * r3909473;
        double r3909475 = c;
        double r3909476 = r3909474 * r3909475;
        double r3909477 = r3909471 - r3909476;
        double r3909478 = sqrt(r3909477);
        double r3909479 = -r3909470;
        double r3909480 = r3909478 + r3909479;
        double r3909481 = r3909480 / r3909474;
        double r3909482 = -3.125067702281917e-07;
        bool r3909483 = r3909481 <= r3909482;
        double r3909484 = r3909475 * r3909473;
        double r3909485 = r3909484 * r3909472;
        double r3909486 = r3909471 - r3909485;
        double r3909487 = sqrt(r3909486);
        double r3909488 = r3909486 * r3909487;
        double r3909489 = r3909470 * r3909471;
        double r3909490 = r3909488 - r3909489;
        double r3909491 = r3909487 + r3909470;
        double r3909492 = fma(r3909487, r3909491, r3909471);
        double r3909493 = r3909490 / r3909492;
        double r3909494 = r3909493 / r3909474;
        double r3909495 = -0.5;
        double r3909496 = r3909475 / r3909470;
        double r3909497 = r3909495 * r3909496;
        double r3909498 = r3909483 ? r3909494 : r3909497;
        return r3909498;
}

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.125067702281917e-07

    1. Initial program 21.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 flip3-+21.3

      \[\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. Simplified20.6

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

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

    if -3.125067702281917e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))

    1. Initial program 53.1

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

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

    \[\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 -3.125067702281917015824392463985148538086 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(c \cdot a\right) \cdot 3\right) \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}, \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} + b, b \cdot b\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))