Average Error: 52.5 → 5.7
Time: 16.2s
Precision: 64
\[4.930380657631324 \cdot 10^{-32} \lt a \lt 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} \lt b \lt 2.028240960365167 \cdot 10^{+31} \land 4.930380657631324 \cdot 10^{-32} \lt c \lt 2.028240960365167 \cdot 10^{+31}\]
\[\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 -0.00701116563119958:\\ \;\;\;\;\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(b, b, \left(\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\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 -0.00701116563119958:\\
\;\;\;\;\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(b, b, \left(\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\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 r2586527 = b;
        double r2586528 = -r2586527;
        double r2586529 = r2586527 * r2586527;
        double r2586530 = 3.0;
        double r2586531 = a;
        double r2586532 = r2586530 * r2586531;
        double r2586533 = c;
        double r2586534 = r2586532 * r2586533;
        double r2586535 = r2586529 - r2586534;
        double r2586536 = sqrt(r2586535);
        double r2586537 = r2586528 + r2586536;
        double r2586538 = r2586537 / r2586532;
        return r2586538;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2586539 = b;
        double r2586540 = r2586539 * r2586539;
        double r2586541 = 3.0;
        double r2586542 = a;
        double r2586543 = r2586541 * r2586542;
        double r2586544 = c;
        double r2586545 = r2586543 * r2586544;
        double r2586546 = r2586540 - r2586545;
        double r2586547 = sqrt(r2586546);
        double r2586548 = -r2586539;
        double r2586549 = r2586547 + r2586548;
        double r2586550 = r2586549 / r2586543;
        double r2586551 = -0.00701116563119958;
        bool r2586552 = r2586550 <= r2586551;
        double r2586553 = r2586544 * r2586542;
        double r2586554 = r2586553 * r2586541;
        double r2586555 = r2586540 - r2586554;
        double r2586556 = sqrt(r2586555);
        double r2586557 = r2586555 * r2586556;
        double r2586558 = r2586539 * r2586540;
        double r2586559 = r2586557 - r2586558;
        double r2586560 = -3.0;
        double r2586561 = r2586553 * r2586560;
        double r2586562 = fma(r2586539, r2586539, r2586561);
        double r2586563 = fma(r2586539, r2586539, r2586562);
        double r2586564 = sqrt(r2586562);
        double r2586565 = r2586539 * r2586564;
        double r2586566 = r2586563 + r2586565;
        double r2586567 = r2586559 / r2586566;
        double r2586568 = r2586567 / r2586543;
        double r2586569 = -0.5;
        double r2586570 = r2586544 / r2586539;
        double r2586571 = r2586569 * r2586570;
        double r2586572 = r2586552 ? r2586568 : r2586571;
        return r2586572;
}

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)) < -0.00701116563119958

    1. Initial program 22.6

      \[\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-+22.7

      \[\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. Simplified22.0

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

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

    if -0.00701116563119958 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 56.2

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.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 -0.00701116563119958:\\ \;\;\;\;\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(b, b, \left(\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(\left(c \cdot a\right) \cdot -3\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019132 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical, wide range"
  :pre (and (< 4.930380657631324e-32 a 2.028240960365167e+31) (< 4.930380657631324e-32 b 2.028240960365167e+31) (< 4.930380657631324e-32 c 2.028240960365167e+31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))